Skip to content

Conversation

@fdemiramon
Copy link

@fdemiramon fdemiramon commented Feb 18, 2025

Draft / Proposal. See doc https://docs.google.com/document/d/1VJPArKUcVyc5kqtiDIMWshQOqicKx4M-jxu721BWbL4/

Description

Resolves #

Checklist

  • I have updated the documentation to account for the changes in the code.
  • If I added new functionality, I added tests covering it.
  • If I fixed a bug, I added a test preventing this bug from silently reappearing again.
  • My contribution follows Venus contribution guidelines.

@fdemiramon fdemiramon marked this pull request as draft February 18, 2025 08:57
@fdemiramon fdemiramon changed the title [DRAFT] Keyring Network integration [DRAFT] Proposal for Keyring Network integration Mar 13, 2025
/// @param _keyringChecker The address of the keyring checker.
/// @param _keyringPolicyId The policy id of the keyring.
function setKeyringConfiguration(address _keyringChecker, uint32 _keyringPolicyId) public {
ensureAdmin(msg.sender);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ensureAdmin(msg.sender);
ensureAdmin();

/// @notice Sets the keyring configuration.
/// @param _keyringChecker The address of the keyring checker.
/// @param _keyringPolicyId The policy id of the keyring.
function setKeyringConfiguration(address _keyringChecker, uint32 _keyringPolicyId) public {
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually add the setter functions in the SetterFacet facet

/// @notice Enables or disables the keyring guard.
/// @param _enabled Whether to enable or disable the keyring guard.
function enableKeyringGuard(bool _enabled) public {
ensureAdmin(msg.sender);
Copy link
Contributor

Choose a reason for hiding this comment

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

We could check this permission in the ACM contract:

Suggested change
ensureAdmin(msg.sender);
ensureAllowed("enableKeyringGuard(bool)");

/// @param _keyringPolicyId The policy id of the keyring.
function setKeyringConfiguration(address _keyringChecker, uint32 _keyringPolicyId) public {
ensureAdmin(msg.sender);
if (address(_keyringChecker) == address(0) || _keyringPolicyId == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We use require instead of revert in these contracts. Moreover, we could reuse ensureNonzeroAddress:

Suggested change
if (address(_keyringChecker) == address(0) || _keyringPolicyId == 0) {
ensureNonzeroAddress(_keyringChecker);
require(_keyringPolicyId != 0, "can't be zero");

}
keyringChecker = IKeyringChecker(_keyringChecker);
keyringPolicyId = _keyringPolicyId;
emit KeyringConfigurationUpdated(address(_keyringChecker), _keyringPolicyId);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need the cast to address, because _keyringChecker is already an address

uint256 actualRepayAmount, // solhint-disable-line no-unused-vars
uint256 borrowerIndex // solhint-disable-line no-unused-vars
) external {
ensureUserAllowed(payer);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not needed, because we are already checking the permission for repaying in the repayBorrowAllowed check (the "pre-hook")

address borrower,
uint256 repayAmount // solhint-disable-line no-unused-vars
) external returns (uint256) {
ensureUserAllowed(payer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ensureUserAllowed(payer);
ensureUserAllowed(payer);
ensureUserAllowed(borrower);

Copy link
Contributor

Choose a reason for hiding this comment

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

We could check both wallets, but theoretically borrower will be allowed, because we checked it in the borrow flow. So, maybe it's not needed

uint256 actualRepayAmount, // solhint-disable-line no-unused-vars
uint256 seizeTokens // solhint-disable-line no-unused-vars
) external {
ensureUserAllowed(liquidator);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not needed, because we are already checking the permission for liquidating in the liquidateBorrowAllowed check (the "pre-hook")

address borrower,
uint256 seizeTokens // solhint-disable-line no-unused-vars
) external {
ensureUserAllowed(liquidator);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not needed, because we are already checking the permission for seizing in the seizeAllowed check (the "pre-hook")

*/
// solhint-disable-next-line no-unused-vars
function transferVerify(address vToken, address src, address dst, uint256 transferTokens) external {
ensureUserAllowed(dst);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not needed, because we are already checking the permission for transferring in the transferAllowed check (the "pre-hook")

@fred-venus fred-venus force-pushed the develop branch 6 times, most recently from f8786ac to d1378e1 Compare December 12, 2025 09:03
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