Skip to content

Commit 71fd906

Browse files
authored
feat: bring back superstate & maple; remove centrifuge crosschain transfers (#16)
* feat: bring back superstate & maple; remove centrifuge crosschain transfers * remove unused key
1 parent 87e20c4 commit 71fd906

File tree

12 files changed

+1065
-765
lines changed

12 files changed

+1065
-765
lines changed

script/staging/FullStagingDeploy.s.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ contract FullStagingDeploy is Script {
7171
address constant FLUID_SUSDS_VAULT = 0x2BBE31d63E6813E3AC858C04dae43FB2a72B0D11;
7272
address constant FLUID_SUSDS_VAULT_BASE = 0xf62e339f21d8018940f188F6987Bcdf02A849619;
7373

74-
// address constant SYRUP_USDC = 0x80ac24aA929eaF5013f6436cdA2a7ba190f5Cc0b;
74+
address constant SYRUP_USDC = 0x80ac24aA929eaF5013f6436cdA2a7ba190f5Cc0b;
7575

7676
address constant AUSDC_BASE = 0x4e65fE4DbA92790696d040ac24Aa414708F5c0AB;
7777
address constant MORPHO_BASE = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;
@@ -401,8 +401,8 @@ contract FullStagingDeploy is Script {
401401

402402
bytes32 susdeDepositKey = RateLimitHelpers.makeAssetKey(controller.LIMIT_4626_DEPOSIT(), address(controller.susde()));
403403

404-
// bytes32 syrupUsdcDepositKey = RateLimitHelpers.makeAssetKey(controller.LIMIT_4626_DEPOSIT(), SYRUP_USDC);
405-
// bytes32 syrupUsdcWithdrawKey = RateLimitHelpers.makeAssetKey(controller.LIMIT_MAPLE_REDEEM(), SYRUP_USDC);
404+
bytes32 syrupUsdcDepositKey = RateLimitHelpers.makeAssetKey(controller.LIMIT_4626_DEPOSIT(), SYRUP_USDC);
405+
bytes32 syrupUsdcWithdrawKey = RateLimitHelpers.makeAssetKey(controller.LIMIT_MAPLE_REDEEM(), SYRUP_USDC);
406406

407407
bytes32 domainKeyArbitrum = RateLimitHelpers.makeDomainKey(controller.LIMIT_USDC_TO_DOMAIN(), CCTPForwarder.DOMAIN_ID_CIRCLE_ARBITRUM_ONE);
408408
bytes32 domainKeyBase = RateLimitHelpers.makeDomainKey(controller.LIMIT_USDC_TO_DOMAIN(), CCTPForwarder.DOMAIN_ID_CIRCLE_BASE);
@@ -422,9 +422,9 @@ contract FullStagingDeploy is Script {
422422
rateLimits.setRateLimitData(susdeDepositKey, maxAmount18, slope18);
423423

424424
// Maple-specific deposit/withdraw rate limits
425-
// rateLimits.setRateLimitData(syrupUsdcDepositKey, maxAmount6, slope6);
425+
rateLimits.setRateLimitData(syrupUsdcDepositKey, maxAmount6, slope6);
426426

427-
// rateLimits.setUnlimitedRateLimitData(syrupUsdcWithdrawKey);
427+
rateLimits.setUnlimitedRateLimitData(syrupUsdcWithdrawKey);
428428

429429
vm.stopBroadcast();
430430
}
@@ -454,7 +454,7 @@ contract FullStagingDeploy is Script {
454454
rateLimits.setRateLimitData(RateLimitHelpers.makeAssetKey(psmWithdrawKey, usdc), maxAmount6, slope6);
455455
rateLimits.setRateLimitData(RateLimitHelpers.makeAssetKey(psmDepositKey, usds), maxAmount18, slope18);
456456
rateLimits.setRateLimitData(RateLimitHelpers.makeAssetKey(psmDepositKey, susds), maxAmount18, slope18);
457-
457+
458458
rateLimits.setUnlimitedRateLimitData(RateLimitHelpers.makeAssetKey(psmWithdrawKey, usds));
459459
rateLimits.setUnlimitedRateLimitData(RateLimitHelpers.makeAssetKey(psmWithdrawKey, susds));
460460

script/staging/test/FullStagingDeployment.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ interface IVatLike {
4343
function can(address, address) external view returns (uint256);
4444
}
4545

46-
// interface IMapleTokenExtended is IERC4626 {
47-
// function manager() external view returns (address);
48-
// }
46+
interface IMapleTokenExtended is IERC4626 {
47+
function manager() external view returns (address);
48+
}
4949

5050
interface IWithdrawalManagerLike {
5151
function processRedemptions(uint256 maxSharesToProcess) external;

src/ForeignController.sol

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import { IALMProxy } from "./interfaces/IALMProxy.sol";
2020
import { ICCTPLike } from "./interfaces/CCTPInterfaces.sol";
2121
import { IRateLimits } from "./interfaces/IRateLimits.sol";
2222

23-
import "./interfaces/CentrifugeInterfaces.sol";
24-
import "./interfaces/ILayerZero.sol";
23+
import "./interfaces/ILayerZero.sol";
2524

2625
import { OptionsBuilder } from "layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol";
2726

@@ -31,6 +30,15 @@ interface IATokenWithPool is IAToken {
3130
function POOL() external view returns(address);
3231
}
3332

33+
interface ICentrifugeToken is IERC7540 {
34+
function cancelDepositRequest(uint256 requestId, address controller) external;
35+
function cancelRedeemRequest(uint256 requestId, address controller) external;
36+
function claimCancelDepositRequest(uint256 requestId, address receiver, address controller)
37+
external returns (uint256 assets);
38+
function claimCancelRedeemRequest(uint256 requestId, address receiver, address controller)
39+
external returns (uint256 shares);
40+
}
41+
3442
contract ForeignController is AccessControl {
3543

3644
using OptionsBuilder for bytes;
@@ -47,8 +55,6 @@ contract ForeignController is AccessControl {
4755
uint256 usdcAmount
4856
);
4957

50-
event CentrifugeRecipientSet(uint16 indexed centrifugeId, bytes32 recipient);
51-
5258
event LayerZeroRecipientSet(uint32 indexed destinationEndpointId, bytes32 layerZeroRecipient);
5359

5460
event MintRecipientSet(uint32 indexed destinationDomain, bytes32 mintRecipient);
@@ -62,19 +68,17 @@ contract ForeignController is AccessControl {
6268
bytes32 public constant FREEZER = keccak256("FREEZER");
6369
bytes32 public constant RELAYER = keccak256("RELAYER");
6470

65-
bytes32 public constant LIMIT_4626_DEPOSIT = keccak256("LIMIT_4626_DEPOSIT");
66-
bytes32 public constant LIMIT_4626_WITHDRAW = keccak256("LIMIT_4626_WITHDRAW");
67-
bytes32 public constant LIMIT_7540_DEPOSIT = keccak256("LIMIT_7540_DEPOSIT");
68-
bytes32 public constant LIMIT_7540_REDEEM = keccak256("LIMIT_7540_REDEEM");
69-
bytes32 public constant LIMIT_AAVE_DEPOSIT = keccak256("LIMIT_AAVE_DEPOSIT");
70-
bytes32 public constant LIMIT_AAVE_WITHDRAW = keccak256("LIMIT_AAVE_WITHDRAW");
71-
bytes32 public constant LIMIT_ASSET_TRANSFER = keccak256("LIMIT_ASSET_TRANSFER");
72-
bytes32 public constant LIMIT_CENTRIFUGE_TRANSFER = keccak256("LIMIT_CENTRIFUGE_TRANSFER");
73-
bytes32 public constant LIMIT_LAYERZERO_TRANSFER = keccak256("LIMIT_LAYERZERO_TRANSFER");
74-
bytes32 public constant LIMIT_PSM_DEPOSIT = keccak256("LIMIT_PSM_DEPOSIT");
75-
bytes32 public constant LIMIT_PSM_WITHDRAW = keccak256("LIMIT_PSM_WITHDRAW");
76-
bytes32 public constant LIMIT_USDC_TO_CCTP = keccak256("LIMIT_USDC_TO_CCTP");
77-
bytes32 public constant LIMIT_USDC_TO_DOMAIN = keccak256("LIMIT_USDC_TO_DOMAIN");
71+
bytes32 public constant LIMIT_4626_DEPOSIT = keccak256("LIMIT_4626_DEPOSIT");
72+
bytes32 public constant LIMIT_4626_WITHDRAW = keccak256("LIMIT_4626_WITHDRAW");
73+
bytes32 public constant LIMIT_7540_DEPOSIT = keccak256("LIMIT_7540_DEPOSIT");
74+
bytes32 public constant LIMIT_7540_REDEEM = keccak256("LIMIT_7540_REDEEM");
75+
bytes32 public constant LIMIT_AAVE_DEPOSIT = keccak256("LIMIT_AAVE_DEPOSIT");
76+
bytes32 public constant LIMIT_AAVE_WITHDRAW = keccak256("LIMIT_AAVE_WITHDRAW");
77+
bytes32 public constant LIMIT_LAYERZERO_TRANSFER = keccak256("LIMIT_LAYERZERO_TRANSFER");
78+
bytes32 public constant LIMIT_PSM_DEPOSIT = keccak256("LIMIT_PSM_DEPOSIT");
79+
bytes32 public constant LIMIT_PSM_WITHDRAW = keccak256("LIMIT_PSM_WITHDRAW");
80+
bytes32 public constant LIMIT_USDC_TO_CCTP = keccak256("LIMIT_USDC_TO_CCTP");
81+
bytes32 public constant LIMIT_USDC_TO_DOMAIN = keccak256("LIMIT_USDC_TO_DOMAIN");
7882

7983
uint256 internal constant CENTRIFUGE_REQUEST_ID = 0;
8084

@@ -87,7 +91,6 @@ contract ForeignController is AccessControl {
8791

8892
mapping(uint32 destinationDomain => bytes32 mintRecipient) public mintRecipients;
8993
mapping(uint32 destinationEndpointId => bytes32 layerZeroRecipient) public layerZeroRecipients;
90-
mapping(uint16 centrifugeId => bytes32 recipient) public centrifugeRecipients;
9194

9295
/**********************************************************************************************/
9396
/*** Initialization ***/
@@ -152,14 +155,6 @@ contract ForeignController is AccessControl {
152155
emit LayerZeroRecipientSet(destinationEndpointId, layerZeroRecipient);
153156
}
154157

155-
function setCentrifugeRecipient(uint16 centrifugeId, bytes32 recipient)
156-
external
157-
onlyRole(DEFAULT_ADMIN_ROLE)
158-
{
159-
centrifugeRecipients[centrifugeId] = recipient;
160-
emit CentrifugeRecipientSet(centrifugeId, recipient);
161-
}
162-
163158
/**********************************************************************************************/
164159
/*** Freezer functions ***/
165160
/**********************************************************************************************/
@@ -497,45 +492,6 @@ contract ForeignController is AccessControl {
497492
);
498493
}
499494

500-
function transferSharesCentrifuge(
501-
address token,
502-
uint128 amount,
503-
uint16 destinationCentrifugeId,
504-
uint128 remoteExtraGasLimit
505-
)
506-
external payable
507-
{
508-
_checkRole(RELAYER);
509-
_rateLimited(
510-
keccak256(abi.encode(LIMIT_CENTRIFUGE_TRANSFER, token, destinationCentrifugeId)),
511-
amount
512-
);
513-
514-
bytes32 recipient = centrifugeRecipients[destinationCentrifugeId];
515-
require(recipient != 0, "MainnetController/centrifuge-id-not-configured");
516-
517-
ICentrifugeV3VaultLike centrifugeVault = ICentrifugeV3VaultLike(token);
518-
519-
address spoke = IAsyncRedeemManagerLike(centrifugeVault.manager()).spoke();
520-
521-
// Initiate cross-chain transfer via the specific spoke address
522-
proxy.doCallWithValue{value: msg.value}(
523-
spoke,
524-
abi.encodeCall(
525-
ISpokeLike(spoke).crosschainTransferShares,
526-
(
527-
destinationCentrifugeId,
528-
centrifugeVault.poolId(),
529-
centrifugeVault.scId(),
530-
recipient,
531-
amount,
532-
remoteExtraGasLimit
533-
)
534-
),
535-
msg.value
536-
);
537-
}
538-
539495
/**********************************************************************************************/
540496
/*** Relayer Aave functions ***/
541497
/**********************************************************************************************/

0 commit comments

Comments
 (0)