Skip to content
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

contracts: Convert Troves to ERC721 NFTs #81

Merged
merged 5 commits into from
Apr 4, 2024
Merged

contracts: Convert Troves to ERC721 NFTs #81

merged 5 commits into from
Apr 4, 2024

Conversation

bingen
Copy link
Collaborator

@bingen bingen commented Mar 13, 2024

Closes #12
Closes #64

@bingen bingen self-assigned this Mar 13, 2024
@danielattilasimon
Copy link
Collaborator

Yikes, the merge conflicts with #76 are pretty substantial already 😬

I recommend we do something about it ASAP.

@bingen bingen force-pushed the trove_ERC721 branch 3 times, most recently from d51d023 to 0381401 Compare March 25, 2024 20:27
@bingen bingen marked this pull request as ready for review March 26, 2024 07:11
@bingen bingen requested a review from RickGriff March 26, 2024 07:52
@bingen bingen mentioned this pull request Mar 27, 2024
Copy link
Collaborator

@RickGriff RickGriff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, epic PR with a huge number of changes to core and tests, thanks. Looks good!!

* Otherwise, only the address in this mapping (and the trove owner) will be allowed.
* To restrict this permission to no one, trove owner should be set in this mapping.
*/
mapping (uint256 => address) public TroveAddManagers;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we're only having one "AddManager" and one "RemoveManager" per NFT right? I guess we could also do a whitelist of multiple, but I prefer the simplicity of only one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is what I understood when we discussed during a dev call. I thought a little bit about this. As you mention, I like the simplicity and gas efficiency of doing it this way. And more complex solutions can be built on top. For instance, setting as manager a 1/n multisig would allow n addresses to effectively be the manager. But I don’t expect that to be most common use case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, sounds good then.

Copy link
Collaborator

@RickGriff RickGriff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, epic PR with a huge number of changes to core and tests, thanks. Looks good!!

}

function adjustTroveInterestRate(uint _newAnnualInterestRate, address _upperHint, address _lowerHint) external {
function adjustTroveInterestRate(uint256 _troveId, uint _newAnnualInterestRate, uint256 _upperHint, uint256 _lowerHint) external {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, where's the access control now for this? Previously it was implicit in _requireTroveIsActive right? So I guess now we should explicitly check that the caller owns the Trove ID (and we're missing a test that checks for the revert)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixing and adding test.

// Save the uint256 of the Trove preceding the current one, before potentially modifying the list
uint256 nextUserToCheck = contractsCache.sortedTroves.getPrev(currentTroveId);
// TODO: check ICR?
//getCurrentICR(currentTroveId, _price) < MCR
Copy link
Collaborator

@RickGriff RickGriff Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the loop could sometimes find Troves with ICR < MCR, which didn't happen in v1 since we started at >= 110%. I guess we can just skip them if and when the loop finds them.

I suppose then this system will still has the property that redemptions can reduce the TCR when there is underwater debt (Troves with CR < MCR). Though if we do remove Recovery Mode the attack potential should be even smaller than v1.

Maybe we'd only skip at ICR < 100%, which would mean that redemptions still always improve the CR of Troves they hit, and it makes it less likely that redemptions reduce the TCR (since some of the underwater debt would be redeemed from)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I’ll do that.

@bingen bingen changed the base branch from ERC20_ETH to main April 2, 2024 14:35
Copy link
Collaborator

@RickGriff RickGriff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks good!

@bingen bingen merged commit 5c9f2f6 into main Apr 4, 2024
5 of 6 checks passed
@danielattilasimon danielattilasimon deleted the trove_ERC721 branch April 12, 2024 06:15
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.

Trove management “on behalf” Trove ownership transfers
3 participants