-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support migrating from Maker CDPs #44
base: main
Are you sure you want to change the base?
Conversation
…l to Comet if amount is 0
Pushed up two more changes:
|
- **REVERT** `UnauthorizedCDP(cdpId)` | ||
- **WHEN** `borrowAmount == type(uint256).max`: | ||
- **BIND READ** `repayAmount = getVaultDebt(vat, ilk, urn)` | ||
- **BIND READ** `(, dart) = -vat.urns(ilk, urn)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is vat.urns
guaranteed to be <= 0?
withdrawAmount = position.collateralAmount; | ||
|
||
// **BIND** `withdrawAmount18 = collateralAmount * (10 ** (18 - gemJoin.dec()))` | ||
withdrawAmount18 = position.collateralAmount * (10 ** (18 - position.gemJoin.dec())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda tricky, some more commentary on why these decimal conversions are correct might be useful for posterity
dart = signed256(amount * RAY / rate); | ||
// Checks the calculated dart is not higher than urn.art (total debt), otherwise uses its value | ||
dart = uint256(dart) <= art ? -dart : -signed256(art); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the verge of wondering if it would make sense to separate 'modules' into contracts e.g. w/ the Maker structs / helpers defined separately?
CometMigratorV2.CDPPosition[] memory cdpPosition = new CometMigratorV2.CDPPosition[](1); | ||
cdpPosition[0] = CometMigratorV2.CDPPosition({ | ||
cdpId: cdpIds[0], | ||
collateralAmount: 100e18, // XXX withdrawing all without max doesn't work due to dust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So can't exit the CDP with dust remaining?
@@ -7,6 +7,9 @@ import "forge-std/Test.sol"; | |||
import "./MainnetConstantsV2.t.sol"; | |||
|
|||
contract Positor is Test, MainnetConstants { | |||
// Units used in Maker contracts | |||
uint256 internal constant RAY = 10**27; | |||
|
|||
// XXX change name to `PositCompoundV2`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but a lot of complexity added here that I can't say I fully understand so I wouldn't mind taking a deeper dive if that's useful
This PR adds support to Migrator 2.0 for migrating from Maker CDPs. I've also updated the spec to be up-to-date with the implementation.