Skip to content

Commit

Permalink
Merge pull request #35 from sense-finance/feat/perm-allow-susde-yts
Browse files Browse the repository at this point in the history
feat: perm allow susde yts
  • Loading branch information
stevenvaleri authored Jan 29, 2025
2 parents c011ae5 + 3ff45ab commit 2327508
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 2 deletions.
45 changes: 45 additions & 0 deletions safe-batches/perm-allow-march-may-2025-susde-yts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"version": "1.0",
"chainId": "1",
"createdAt": 1738100309628,
"meta": {
"name": "Transactions Batch",
"description": "perm-allow-march-may-2025-susde-yts",
"txBuilderVersion": "1.10.0",
"createdFromSafeAddress": "0x9D89745fD63Af482ce93a9AdB8B0BbDbb98D3e06",
"createdFromOwnerAddress": "",
"checksum": "0xadf9bc35830cfd511df3c300674e200cd666db73623a499feb5cc093399cd866"
},
"transactions": [
{
"to": "0x9000fef2846a5253fd2c6ed5241de0fddb404302",
"value": "0x0",
"data": "0x5534fa0c00000000000000000000000096512230bf0fa4e20cf02c3e8a7d983132cd2b9fa9059cbb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"
},
{
"to": "0x9000fef2846a5253fd2c6ed5241de0fddb404302",
"value": "0x0",
"data": "0x5534fa0c0000000000000000000000001de6ff19fda7496ddc12f2161f6ad6427c52abbea9059cbb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002"
},
{
"to": "0x28c3498b4956f4ad8d4549aca8f66260975d361a",
"value": "0x0",
"data": "0x60d0825a00000000000000000000000096512230bf0fa4e20cf02c3e8a7d983132cd2b9fa9059cbb00000000000000000000000000000000000000000000000000000000"
},
{
"to": "0x28c3498b4956f4ad8d4549aca8f66260975d361a",
"value": "0x0",
"data": "0x60d0825a00000000000000000000000096512230bf0fa4e20cf02c3e8a7d983132cd2b9f095ea7b300000000000000000000000000000000000000000000000000000000"
},
{
"to": "0x28c3498b4956f4ad8d4549aca8f66260975d361a",
"value": "0x0",
"data": "0x60d0825a0000000000000000000000001de6ff19fda7496ddc12f2161f6ad6427c52abbea9059cbb00000000000000000000000000000000000000000000000000000000"
},
{
"to": "0x28c3498b4956f4ad8d4549aca8f66260975d361a",
"value": "0x0",
"data": "0x60d0825a0000000000000000000000001de6ff19fda7496ddc12f2161f6ad6427c52abbe095ea7b300000000000000000000000000000000000000000000000000000000"
}
]
}
64 changes: 62 additions & 2 deletions script/RumpelConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ library RumpelConfig {
RumpelGuard.AllowListState desiredState = config.selectorStates[j].state;
RumpelGuard.AllowListState currentState = rumpelGuard.allowedCalls(target, selector);

if (
currentState == RumpelGuard.AllowListState.OFF
&& desiredState == RumpelGuard.AllowListState.PERMANENTLY_ON
) {
revert("cannot go from OFF to PERMANENTLY_ON");
}

if (currentState == desiredState) {
console.log("Selector already set");
} else {
Expand All @@ -133,10 +140,28 @@ library RumpelConfig {
TokenGuardConfig[] memory tokens = getGuardTokenConfigs(tag);
for (uint256 i = 0; i < tokens.length; i++) {
TokenGuardConfig memory config = tokens[i];
if (config.transferAllowState != rumpelGuard.allowedCalls(config.token, ERC20.transfer.selector)) {
RumpelGuard.AllowListState currentTransferAllowState =
rumpelGuard.allowedCalls(config.token, ERC20.transfer.selector);
RumpelGuard.AllowListState currentApproveAllowState =
rumpelGuard.allowedCalls(config.token, ERC20.approve.selector);

if (
currentTransferAllowState == RumpelGuard.AllowListState.OFF
&& config.transferAllowState == RumpelGuard.AllowListState.PERMANENTLY_ON
) {
revert("cannot go from OFF to PERMANENTLY_ON");
}
if (
currentApproveAllowState == RumpelGuard.AllowListState.OFF
&& config.approveAllowState == RumpelGuard.AllowListState.PERMANENTLY_ON
) {
revert("cannot go from OFF to PERMANENTLY_ON");
}

if (config.transferAllowState != currentTransferAllowState) {
rumpelGuard.setCallAllowed(config.token, ERC20.transfer.selector, config.transferAllowState);
}
if (config.approveAllowState != rumpelGuard.allowedCalls(config.token, ERC20.approve.selector)) {
if (config.approveAllowState != currentApproveAllowState) {
rumpelGuard.setCallAllowed(config.token, ERC20.approve.selector, config.approveAllowState);
}
}
Expand Down Expand Up @@ -223,6 +248,8 @@ library RumpelConfig {
return new ProtocolGuardConfig[](0);
} else if (tagHash == keccak256(bytes("remove-lrt2-claiming"))) {
return getRemoveLRT2ProtocolGuardConfigs();
} else if (tagHash == keccak256(bytes("perm-allow-march-may-2025-susde-yts"))) {
return new ProtocolGuardConfig[](0);
}

revert("Unsupported tag");
Expand Down Expand Up @@ -273,6 +300,8 @@ library RumpelConfig {
return getAddKsusdeTransferTokenGuardConfigs();
} else if (tagHash == keccak256(bytes("remove-lrt2-claiming"))) {
return getRemoveLRT2AssetTokenGuardConfigs();
} else if (tagHash == keccak256(bytes("perm-allow-march-may-2025-susde-yts"))) {
return getPermAllowMarchAndMay2025SusdeYTsTokenGuardConfigs();
}

revert("Unsupported tag");
Expand Down Expand Up @@ -320,6 +349,8 @@ library RumpelConfig {
return new TokenModuleConfig[](0);
} else if (tagHash == keccak256(bytes("remove-lrt2-claiming"))) {
return new TokenModuleConfig[](0);
} else if (tagHash == keccak256(bytes("perm-allow-march-may-2025-susde-yts"))) {
return getMarchAndMay20252025SusdeYTsTokenModuleConfigs();
}

revert("Unsupported tag");
Expand Down Expand Up @@ -364,6 +395,8 @@ library RumpelConfig {
return new ProtocolModuleConfig[](0);
} else if (tagHash == keccak256(bytes("remove-lrt2-claiming"))) {
return new ProtocolModuleConfig[](0);
} else if (tagHash == keccak256(bytes("perm-allow-march-may-2025-susde-yts"))) {
return new ProtocolModuleConfig[](0);
}

revert("Unsupported tag");
Expand Down Expand Up @@ -1164,6 +1197,33 @@ library RumpelConfig {

return configs;
}

function getPermAllowMarchAndMay2025SusdeYTsTokenGuardConfigs() internal pure returns (TokenGuardConfig[] memory) {
TokenGuardConfig[] memory configs = new TokenGuardConfig[](2);

configs[0] = TokenGuardConfig({
token: MAINNET_YT_SUSDE_27MAR2025,
transferAllowState: RumpelGuard.AllowListState.PERMANENTLY_ON,
approveAllowState: RumpelGuard.AllowListState.OFF
});

configs[1] = TokenGuardConfig({
token: MAINNET_YT_SUSDE_29MAY2025,
transferAllowState: RumpelGuard.AllowListState.PERMANENTLY_ON,
approveAllowState: RumpelGuard.AllowListState.OFF
});

return configs;
}

function getMarchAndMay20252025SusdeYTsTokenModuleConfigs() internal pure returns (TokenModuleConfig[] memory) {
TokenModuleConfig[] memory configs = new TokenModuleConfig[](3);

configs[0] = TokenModuleConfig({token: MAINNET_YT_SUSDE_27MAR2025, blockTransfer: true, blockApprove: true});
configs[1] = TokenModuleConfig({token: MAINNET_YT_SUSDE_29MAY2025, blockTransfer: true, blockApprove: true});

return configs;
}
}

interface IMorphoBundler {
Expand Down

0 comments on commit 2327508

Please sign in to comment.