Skip to content

Conversation

@adamocallaghan
Copy link

Hi Shafu,

I've added some tests for the MicroStable repo. All four are passing. I can add more another time if you'd like to get the coverage up.

Two changes were made to the Manager.sol file...

  • line 51-52: moved the mint function require statement above the balance update as it was causing an issue with the collatRatio (address2minted was updated by the amount before collatRatio was retrieved, meaning that "minted == 0" was never true).
  • line 73: I think latestAnswer (on the Chainlink eth-usd price feed) returns 8 decimals of precision, so I've multiplied it by 1e10 to get the precision up to 18 decimals. Let me know if you think this is correct or not.

I made one change to the ShUSD.sol file...

  • line 20: transferManager function added; I'm sure there's a way in Foundry to precompile the contract address, but I'm not sure how to do it just yet (will keep looking), and as both the ShUSD and Manager contracts rely upon the others address being passed into the constructor I just thought it would be easier to called transferManager on the token and transfer it to the Manager contract once both were deployed in the tests/on testnets.

I've also added an .example.env as the fork tests rely upon having an RPC URL set in .env.

Regards,
Adam

@shafu0x
Copy link
Owner

shafu0x commented Nov 25, 2024

This is great! Will definitely merge this

But could you keep the formatting I use. I don't like auto formatters.

@shafu0x
Copy link
Owner

shafu0x commented Nov 25, 2024

Regarding Line 51: You have to update the mapping first before you check the collatRatio. Because collatRatio needs the updated mapping.

Line 73: You are correct and your fix is correct

Line 20: Don't want to add that there tbh

@adamocallaghan
Copy link
Author

Ok, good stuff Shafu! Just on your comments...

Line 51: let me know if I'm just getting confused here, but if we update the address2minted mapping first in the mint function is there every a situation where the "if(minted == 0)" code can be triggered in the collatRatio function...
uint256 minted = address2minted[user];
if (minted == 0) return type(uint256).max;
...?

So minted here will always have a value > 0?

Line 73: ok, thanks.

Line 20: I have removed this in my local repo and am passing the managerContractAddress into the ShUSD contract instantiation. I'm still digging through the Foundry docs to figure out how to correctly use vm.computeCreateAddress.

Re: the formatting... apologies, I tried to fix it, I must have a couple of linters installed, because disabling Prettier hasn't worked.

@shafu0x
Copy link
Owner

shafu0x commented Nov 26, 2024

Line 51: Yeah if you try to liquidate someone with 0 shUSD minted

@shafu0x
Copy link
Owner

shafu0x commented Nov 26, 2024

I fixed the liquidation btw. I could not wait on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants