Skip to content

Commit 377da63

Browse files
committed
chore: add interface
1 parent 3e2497c commit 377da63

File tree

2 files changed

+155
-23
lines changed

2 files changed

+155
-23
lines changed

.gas-snapshot

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ CrossRatePriceFeedTest:test_latestRoundData_invalidDenominatorPrice(int256) (run
4040
CrossRatePriceFeedTest:test_latestRoundData_invalidNumeratorPrice(int256) (runs: 256, μ: 907390, ~: 907952)
4141
CrossRatePriceFeedTest:test_latestRoundData_realValuesFork() (gas: 70243)
4242
CrossRatePriceFeedTest:test_latestRoundData_realValuesFuzz18(int256,int256) (runs: 256, μ: 1301519, ~: 1301597)
43-
CrossRatePriceFeedTest:test_latestRoundData_realValuesFuzz8(int256,int256) (runs: 256, μ: 1301321, ~: 1301621)
44-
CrossRatePriceFeedTest:test_latestRoundData_revertsOnOverflow(int256) (runs: 257, μ: 935241, ~: 935235)
43+
CrossRatePriceFeedTest:test_latestRoundData_realValuesFuzz8(int256,int256) (runs: 256, μ: 1301315, ~: 1301621)
44+
CrossRatePriceFeedTest:test_latestRoundData_revertsOnOverflow(int256) (runs: 256, μ: 935243, ~: 935235)
4545
CrossRatePriceFeedTest:test_latestRoundData_roundIdOne() (gas: 60318)
46-
CrossRatePriceFeedTest:test_latestRoundData_staleDenominatorPrice(uint256) (runs: 256, μ: 906768, ~: 907044)
47-
CrossRatePriceFeedTest:test_latestRoundData_staleNumeratorPrice(uint256) (runs: 256, μ: 906770, ~: 907046)
46+
CrossRatePriceFeedTest:test_latestRoundData_staleDenominatorPrice(uint256) (runs: 256, μ: 906854, ~: 907132)
47+
CrossRatePriceFeedTest:test_latestRoundData_staleNumeratorPrice(uint256) (runs: 256, μ: 906768, ~: 907046)
4848
CrossRatePriceFeedTest:test_latestRoundData_startedAtZero() (gas: 60332)
4949
CrossRatePriceFeedTest:test_latestRoundData_usesEarlierUpdatedAt() (gas: 68898)
5050
DeactivateInstruction:test_deactivateInstruction_alreadyDeactivated() (gas: 20424)
@@ -74,33 +74,33 @@ DeploymentAddressesTest:test_transferOnceERC20Action_deployedAddress() (gas: 650
7474
DeploymentAddressesTest:test_treasury_deployedAddress() (gas: 389464)
7575
DeploymentAddressesTest:test_uniswapV3ExactInputAction_deployedAddress() (gas: 1826284)
7676
DeploymentAddressesTest:test_withdrawERC4626Action_deployedAddress() (gas: 864746)
77-
DepositERC4626Test:test_depositERC4626_happyPath() (gas: 419978)
78-
DepositERC4626Test:test_depositERC4626_insufficientBalance() (gas: 216555)
77+
DepositERC4626Test:test_depositERC4626_happyPath() (gas: 481909)
78+
DepositERC4626Test:test_depositERC4626_insufficientBalance() (gas: 258567)
7979
DepositERC4626Test:test_depositERC4626_maxDepositReached() (gas: 150609)
8080
DepositERC4626Test:test_depositERC4626_maxDepositTooLow() (gas: 38646)
8181
DepositERC4626Test:test_depositERC4626_minTotalSharesZero() (gas: 36832)
8282
DepositERC4626Test:test_depositERC4626_recipientZero() (gas: 36769)
8383
DepositERC4626Test:test_depositERC4626_totalSharesTooLow() (gas: 39187)
8484
DepositERC4626Test:test_depositERC4626_valueZero() (gas: 36815)
8585
DepositERC4626Test:test_depositERC4626_vaultZero() (gas: 36798)
86-
EstimateCallOnceGasConstant:testFuzz_callOnce_gasConstant(uint256,(address,bool,uint256,uint256,uint16,bytes4,bytes,(address,uint256,uint256,uint256))) (runs: 256, μ: 4128, ~: 3894)
86+
EstimateCallOnceGasConstant:testFuzz_callOnce_gasConstant(uint256,(address,bool,uint256,uint256,uint16,bytes4,bytes,(address,uint256,uint256,uint256))) (runs: 256, μ: 4127, ~: 3876)
8787
EstimateDeactivateInstructionGasConstant:testFuzz_deactivateInstruction_gasConstant(uint256,(bytes32,(address,uint256,uint256,uint256))) (runs: 256, μ: 1960, ~: 1914)
88-
EstimateDepositERC4626GasConstant:testFuzz_depositERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4489, ~: 4416)
89-
EstimateRefuelERC20GasConstant:testFuzz_refuelERC20_gasConstant(uint256,uint256,(address,address,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3026, ~: 3024)
90-
EstimateRefuelGasConstant:testFuzz_refuel_gasConstant(uint256,uint256,(address,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 2887, ~: 2826)
91-
EstimateSweepCCTPGasConstant:testFuzz_sweepCCTP_gasConstant(uint256,uint256,(address,uint32,bytes32,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3364, ~: 3342)
92-
EstimateSweepDepositERC4626GasConstant:testFuzz_sweepDepositERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3576, ~: 3534)
93-
EstimateSweepERC20GasConstant:testFuzz_sweepERC20_gasConstant(uint256,uint256,(address,address,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3013, ~: 3024)
88+
EstimateDepositERC4626GasConstant:testFuzz_depositERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4486, ~: 4434)
89+
EstimateRefuelERC20GasConstant:testFuzz_refuelERC20_gasConstant(uint256,uint256,(address,address,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3014, ~: 3006)
90+
EstimateRefuelGasConstant:testFuzz_refuel_gasConstant(uint256,uint256,(address,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 2897, ~: 2835)
91+
EstimateSweepCCTPGasConstant:testFuzz_sweepCCTP_gasConstant(uint256,uint256,(address,uint32,bytes32,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3356, ~: 3333)
92+
EstimateSweepDepositERC4626GasConstant:testFuzz_sweepDepositERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3523, ~: 3516)
93+
EstimateSweepERC20GasConstant:testFuzz_sweepERC20_gasConstant(uint256,uint256,(address,address,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3026, ~: 3042)
9494
EstimateSweepGasConstant:testFuzz_sweep_gasConstant(uint256,uint256,(address,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 2871, ~: 2808)
95-
EstimateSweepUniswapV3GasConstant:testFuzz_sweepUniswapV3_gasConstant(uint256,uint256,(address,address,address,uint24,uint256,uint256,uint256,uint32,uint32,(address,uint256,uint256,uint256))) (runs: 256, μ: 4426, ~: 4407)
96-
EstimateSweepWithdrawERC4626GasConstant:testFuzz_sweepWithdrawERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3284, ~: 3270)
97-
EstimateTransferCCTPGasConstant:testFuzz_transferCCTP_gasConstant(uint256,uint256,(address,uint256,uint32,bytes32,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4239, ~: 4188)
98-
EstimateTransferERC20GasConstant:testFuzz_transferERC20_gasConstant(uint256,uint256,(address,address,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4000, ~: 3960)
95+
EstimateSweepUniswapV3GasConstant:testFuzz_sweepUniswapV3_gasConstant(uint256,uint256,(address,address,address,uint24,uint256,uint256,uint256,uint32,uint32,(address,uint256,uint256,uint256))) (runs: 256, μ: 4424, ~: 4398)
96+
EstimateSweepWithdrawERC4626GasConstant:testFuzz_sweepWithdrawERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 3297, ~: 3297)
97+
EstimateTransferCCTPGasConstant:testFuzz_transferCCTP_gasConstant(uint256,uint256,(address,uint256,uint32,bytes32,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4224, ~: 4206)
98+
EstimateTransferERC20GasConstant:testFuzz_transferERC20_gasConstant(uint256,uint256,(address,address,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4009, ~: 3969)
9999
EstimateTransferGasConstant:testFuzz_transfer_gasConstant(uint256,uint256,(address,uint256,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 3766, ~: 3762)
100-
EstimateTransferOnceERC20GasConstant:testFuzz_transferERC20Once_gasConstant(uint256,(address,address,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 2562, ~: 2586)
100+
EstimateTransferOnceERC20GasConstant:testFuzz_transferERC20Once_gasConstant(uint256,(address,address,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 2575, ~: 2586)
101101
EstimateTransferOnceGasConstant:testFuzz_transferOnce_gasConstant(uint256,(address,uint256,uint256,(address,uint256,uint256,uint256))) (runs: 256, μ: 2322, ~: 2298)
102-
EstimateUniswapV3ExactInputGasConstant:testFuzz_uniswapV3ExactInput_gasConstant(uint256,uint256,(address,address,address,uint24,uint256,uint256,uint32,uint32,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 5314, ~: 5298)
103-
EstimateWithdrawERC4626GasConstant:testFuzz_withdrawERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4243, ~: 4206)
102+
EstimateUniswapV3ExactInputGasConstant:testFuzz_uniswapV3ExactInput_gasConstant(uint256,uint256,(address,address,address,uint24,uint256,uint256,uint32,uint32,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 5332, ~: 5316)
103+
EstimateWithdrawERC4626GasConstant:testFuzz_withdrawERC4626_gasConstant(uint256,uint256,(address,address,uint256,uint256,(uint256,uint256,uint256,uint256),(address,uint256,uint256,uint256))) (runs: 256, μ: 4177, ~: 4170)
104104
FeeTokenRegistryTest:test_addFeeToken_alreadyRegistered() (gas: 1898)
105105
FeeTokenRegistryTest:test_addFeeToken_happyPath() (gas: 37590)
106106
FeeTokenRegistryTest:test_addFeeToken_roundIdZero() (gas: 12004)
@@ -213,7 +213,7 @@ SweepCCTPTest:test_sweepCCTP_tokenNotSupported() (gas: 36792)
213213
SweepCCTPTest:test_sweepCCTP_tokenZero() (gas: 34886)
214214
SweepDepositERC4626Test:test_sweepDepositERC4626_balanceUnderThreshold() (gas: 38503)
215215
SweepDepositERC4626Test:test_sweepDepositERC4626_endBalanceOverThreshold() (gas: 35287)
216-
SweepDepositERC4626Test:test_sweepDepositERC4626_happyPath() (gas: 398547)
216+
SweepDepositERC4626Test:test_sweepDepositERC4626_happyPath() (gas: 460478)
217217
SweepDepositERC4626Test:test_sweepDepositERC4626_maxDepositReached() (gas: 149430)
218218
SweepDepositERC4626Test:test_sweepDepositERC4626_maxDepositTooLow() (gas: 36753)
219219
SweepDepositERC4626Test:test_sweepDepositERC4626_minTotalSharesZero() (gas: 35304)
@@ -253,7 +253,7 @@ SweepUniswapV3Test:test_sweepUniswapV3_tokenToEth() (gas: 3042)
253253
SweepUniswapV3Test:test_sweepUniswapV3_tokenToToken() (gas: 3086)
254254
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_balanceUnderThreshold() (gas: 56923)
255255
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_endBalanceOverThreshold() (gas: 34904)
256-
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_happyPath() (gas: 320160)
256+
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_happyPath() (gas: 373047)
257257
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_maxWithdrawReached() (gas: 100002)
258258
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_maxWithdrawTooLow() (gas: 38358)
259259
SweepWithdrawERC4626Test:test_sweepWithdrawERC4626_recipientZero() (gas: 34875)
@@ -312,7 +312,7 @@ UniswapV3ExactInputTest:test_uniswapV3ExactInput_recipientZero() (gas: 38513)
312312
UniswapV3ExactInputTest:test_uniswapV3ExactInput_sameToken() (gas: 38484)
313313
UniswapV3ExactInputTest:test_uniswapV3ExactInput_tokenToEth() (gas: 3042)
314314
UniswapV3ExactInputTest:test_uniswapV3ExactInput_tokenToToken() (gas: 3064)
315-
WithdrawERC4626Test:test_withdrawERC4626_happyPath() (gas: 267185)
315+
WithdrawERC4626Test:test_withdrawERC4626_happyPath() (gas: 302453)
316316
WithdrawERC4626Test:test_withdrawERC4626_maxWithdrawReached() (gas: 96775)
317317
WithdrawERC4626Test:test_withdrawERC4626_maxWithdrawTooLow() (gas: 37566)
318318
WithdrawERC4626Test:test_withdrawERC4626_recipientZero() (gas: 36481)

src/actions/external/IERC7540.sol

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// SPDX-License-Identifier: AGPL-3.0-only
2+
pragma solidity >=0.5.0;
3+
4+
interface IERC7540Operator {
5+
/**
6+
* @dev The event emitted when an operator is set.
7+
*
8+
* @param controller The address of the controller.
9+
* @param operator The address of the operator.
10+
* @param approved The approval status.
11+
*/
12+
event OperatorSet(address indexed controller, address indexed operator, bool approved);
13+
14+
/**
15+
* @dev Sets or removes an operator for the caller.
16+
*
17+
* @param operator The address of the operator.
18+
* @param approved The approval status.
19+
* @return Whether the call was executed successfully or not
20+
*/
21+
function setOperator(address operator, bool approved) external returns (bool);
22+
23+
/**
24+
* @dev Returns `true` if the `operator` is approved as an operator for an `controller`.
25+
*
26+
* @param controller The address of the controller.
27+
* @param operator The address of the operator.
28+
* @return status The approval status
29+
*/
30+
function isOperator(address controller, address operator) external view returns (bool status);
31+
}
32+
33+
interface IERC7540Deposit {
34+
event DepositRequest(
35+
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
36+
);
37+
/**
38+
* @dev Transfers assets from sender into the Vault and submits a Request for asynchronous deposit.
39+
*
40+
* - MUST support ERC-20 approve / transferFrom on asset as a deposit Request flow.
41+
* - MUST revert if all of assets cannot be requested for deposit.
42+
* - owner MUST be msg.sender unless some unspecified explicit approval is given by the caller,
43+
* approval of ERC-20 tokens from owner to sender is NOT enough.
44+
*
45+
* @param assets the amount of deposit assets to transfer from owner
46+
* @param controller the controller of the request who will be able to operate the request
47+
* @param owner the source of the deposit assets
48+
*
49+
* NOTE: most implementations will require pre-approval of the Vault with the Vault's underlying asset token.
50+
*/
51+
52+
function requestDeposit(uint256 assets, address controller, address owner) external returns (uint256 requestId);
53+
54+
/**
55+
* @dev Returns the amount of requested assets in Pending state.
56+
*
57+
* - MUST NOT include any assets in Claimable state for deposit or mint.
58+
* - MUST NOT show any variations depending on the caller.
59+
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
60+
*/
61+
function pendingDepositRequest(uint256 requestId, address controller) external view returns (uint256 pendingAssets);
62+
63+
/**
64+
* @dev Returns the amount of requested assets in Claimable state for the controller to deposit or mint.
65+
*
66+
* - MUST NOT include any assets in Pending state.
67+
* - MUST NOT show any variations depending on the caller.
68+
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
69+
*/
70+
function claimableDepositRequest(uint256 requestId, address controller)
71+
external
72+
view
73+
returns (uint256 claimableAssets);
74+
75+
/**
76+
* @dev Mints shares Vault shares to receiver by claiming the Request of the controller.
77+
*
78+
* - MUST emit the Deposit event.
79+
* - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.
80+
*/
81+
function deposit(uint256 assets, address receiver, address controller) external returns (uint256 shares);
82+
83+
/**
84+
* @dev Mints exactly shares Vault shares to receiver by claiming the Request of the controller.
85+
*
86+
* - MUST emit the Deposit event.
87+
* - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.
88+
*/
89+
function mint(uint256 shares, address receiver, address controller) external returns (uint256 assets);
90+
}
91+
92+
interface IERC7540Redeem {
93+
event RedeemRequest(
94+
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
95+
);
96+
97+
/**
98+
* @dev Assumes control of shares from sender into the Vault and submits a Request for asynchronous redeem.
99+
*
100+
* - MUST support a redeem Request flow where the control of shares is taken from sender directly
101+
* where msg.sender has ERC-20 approval over the shares of owner.
102+
* - MUST revert if all of shares cannot be requested for redeem.
103+
*
104+
* @param shares the amount of shares to be redeemed to transfer from owner
105+
* @param controller the controller of the request who will be able to operate the request
106+
* @param owner the source of the shares to be redeemed
107+
*
108+
* NOTE: most implementations will require pre-approval of the Vault with the Vault's share token.
109+
*/
110+
function requestRedeem(uint256 shares, address controller, address owner) external returns (uint256 requestId);
111+
112+
/**
113+
* @dev Returns the amount of requested shares in Pending state.
114+
*
115+
* - MUST NOT include any shares in Claimable state for redeem or withdraw.
116+
* - MUST NOT show any variations depending on the caller.
117+
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
118+
*/
119+
function pendingRedeemRequest(uint256 requestId, address controller) external view returns (uint256 pendingShares);
120+
121+
/**
122+
* @dev Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw.
123+
*
124+
* - MUST NOT include any shares in Pending state for redeem or withdraw.
125+
* - MUST NOT show any variations depending on the caller.
126+
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
127+
*/
128+
function claimableRedeemRequest(uint256 requestId, address controller)
129+
external
130+
view
131+
returns (uint256 claimableShares);
132+
}

0 commit comments

Comments
 (0)