@gauntlet-xyz/sdk 2.5.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -7
- package/dist/api/activity.d.ts +4 -2
- package/dist/api/activity.d.ts.map +1 -1
- package/dist/api/activityRows.d.ts +11 -0
- package/dist/api/activityRows.d.ts.map +1 -0
- package/dist/api/caip.d.ts +1 -1
- package/dist/api/caip.d.ts.map +1 -1
- package/dist/api/client.d.ts +43 -5
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/decimal.d.ts.map +1 -1
- package/dist/api/errors.d.ts +1 -1
- package/dist/api/errors.d.ts.map +1 -1
- package/dist/api/generated.d.ts +570 -7
- package/dist/api/generated.d.ts.map +1 -1
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/index.d.ts +13 -13
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +47 -8
- package/dist/api/index.js.map +7 -1
- package/dist/api/positionHistory.d.ts +1 -1
- package/dist/api/positionHistory.d.ts.map +1 -1
- package/dist/attribution/index.d.ts +8 -5
- package/dist/attribution/index.d.ts.map +1 -1
- package/dist/chunk-JJOLVL5V.js +546 -0
- package/dist/chunk-JJOLVL5V.js.map +7 -0
- package/dist/chunk-JRSNLXFY.js +2009 -0
- package/dist/chunk-JRSNLXFY.js.map +7 -0
- package/dist/chunk-MEKISE2T.js +367 -0
- package/dist/chunk-MEKISE2T.js.map +7 -0
- package/dist/chunk-YQXTLIJA.js +4477 -0
- package/dist/chunk-YQXTLIJA.js.map +7 -0
- package/dist/cjs/api/activity.d.ts +72 -0
- package/dist/cjs/api/activity.d.ts.map +1 -0
- package/dist/cjs/api/activity.js +138 -0
- package/dist/cjs/api/activity.js.map +7 -0
- package/dist/cjs/api/activityRows.d.ts +11 -0
- package/dist/cjs/api/activityRows.d.ts.map +1 -0
- package/dist/cjs/api/activityRows.js +139 -0
- package/dist/cjs/api/activityRows.js.map +7 -0
- package/dist/cjs/api/caip.d.ts +29 -0
- package/dist/cjs/api/caip.d.ts.map +1 -0
- package/dist/cjs/api/caip.js +61 -0
- package/dist/cjs/api/caip.js.map +7 -0
- package/dist/cjs/api/client.d.ts +173 -0
- package/dist/cjs/api/client.d.ts.map +1 -0
- package/dist/cjs/api/client.js +199 -0
- package/dist/cjs/api/client.js.map +7 -0
- package/dist/cjs/api/decimal.d.ts +21 -0
- package/dist/cjs/api/decimal.d.ts.map +1 -0
- package/dist/cjs/api/decimal.js +61 -0
- package/dist/cjs/api/decimal.js.map +7 -0
- package/dist/cjs/api/errors.d.ts +32 -0
- package/dist/cjs/api/errors.d.ts.map +1 -0
- package/dist/cjs/api/errors.js +80 -0
- package/dist/cjs/api/errors.js.map +7 -0
- package/dist/cjs/api/generated.d.ts +2068 -0
- package/dist/cjs/api/generated.d.ts.map +1 -0
- package/dist/cjs/api/generated.js +17 -0
- package/dist/cjs/api/generated.js.map +7 -0
- package/dist/cjs/api/http.d.ts +16 -0
- package/dist/cjs/api/http.d.ts.map +1 -0
- package/dist/cjs/api/http.js +65 -0
- package/dist/cjs/api/http.js.map +7 -0
- package/dist/cjs/api/index.d.ts +14 -0
- package/dist/cjs/api/index.d.ts.map +1 -0
- package/dist/cjs/api/index.js +73 -0
- package/dist/cjs/api/index.js.map +7 -0
- package/dist/cjs/api/positionHistory.d.ts +44 -0
- package/dist/cjs/api/positionHistory.d.ts.map +1 -0
- package/dist/cjs/api/positionHistory.js +144 -0
- package/dist/cjs/api/positionHistory.js.map +7 -0
- package/dist/cjs/attribution/erc8021.d.ts +9 -0
- package/dist/cjs/attribution/erc8021.d.ts.map +1 -0
- package/dist/cjs/attribution/erc8021.js +37 -0
- package/dist/cjs/attribution/erc8021.js.map +7 -0
- package/dist/cjs/attribution/index.d.ts +28 -0
- package/dist/cjs/attribution/index.d.ts.map +1 -0
- package/dist/cjs/attribution/index.js +70 -0
- package/dist/cjs/attribution/index.js.map +7 -0
- package/dist/cjs/client.d.ts +72 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +80 -0
- package/dist/cjs/client.js.map +7 -0
- package/dist/cjs/constants.d.ts +16 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +83 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/errors.d.ts +85 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +210 -0
- package/dist/cjs/errors.js.map +7 -0
- package/dist/cjs/evm/abis/erc20.d.ts +41 -0
- package/dist/cjs/evm/abis/erc20.d.ts.map +1 -0
- package/dist/cjs/evm/abis/erc20.js +57 -0
- package/dist/cjs/evm/abis/erc20.js.map +7 -0
- package/dist/cjs/evm/abis/erc4626.d.ts +105 -0
- package/dist/cjs/evm/abis/erc4626.d.ts.map +1 -0
- package/dist/cjs/evm/abis/erc4626.js +97 -0
- package/dist/cjs/evm/abis/erc4626.js.map +7 -0
- package/dist/cjs/evm/abis/multiDepositorVault.d.ts +1048 -0
- package/dist/cjs/evm/abis/multiDepositorVault.d.ts.map +1 -0
- package/dist/cjs/evm/abis/multiDepositorVault.js +614 -0
- package/dist/cjs/evm/abis/multiDepositorVault.js.map +7 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculator.d.ts +910 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculator.d.ts.map +1 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculator.js +517 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculator.js.map +7 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.d.ts +277 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.d.ts.map +1 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.js +166 -0
- package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.js.map +7 -0
- package/dist/cjs/evm/abis/provisioner.d.ts +4984 -0
- package/dist/cjs/evm/abis/provisioner.d.ts.map +1 -0
- package/dist/cjs/evm/abis/provisioner.js +2785 -0
- package/dist/cjs/evm/abis/provisioner.js.map +7 -0
- package/dist/cjs/evm/abis/provisionerV2.d.ts +740 -0
- package/dist/cjs/evm/abis/provisionerV2.d.ts.map +1 -0
- package/dist/cjs/evm/abis/provisionerV2.js +320 -0
- package/dist/cjs/evm/abis/provisionerV2.js.map +7 -0
- package/dist/cjs/evm/adapters/aera.d.ts +6 -0
- package/dist/cjs/evm/adapters/aera.d.ts.map +1 -0
- package/dist/cjs/evm/adapters/aera.js +500 -0
- package/dist/cjs/evm/adapters/aera.js.map +7 -0
- package/dist/cjs/evm/adapters/index.d.ts +3 -0
- package/dist/cjs/evm/adapters/index.d.ts.map +1 -0
- package/dist/cjs/evm/adapters/index.js +41 -0
- package/dist/cjs/evm/adapters/index.js.map +7 -0
- package/dist/cjs/evm/adapters/morpho.d.ts +3 -0
- package/dist/cjs/evm/adapters/morpho.d.ts.map +1 -0
- package/dist/cjs/evm/adapters/morpho.js +103 -0
- package/dist/cjs/evm/adapters/morpho.js.map +7 -0
- package/dist/cjs/evm/adapters/types.d.ts +85 -0
- package/dist/cjs/evm/adapters/types.d.ts.map +1 -0
- package/dist/cjs/evm/adapters/types.js +17 -0
- package/dist/cjs/evm/adapters/types.js.map +7 -0
- package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.d.ts +46 -0
- package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.d.ts.map +1 -0
- package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.js +223 -0
- package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.js.map +7 -0
- package/dist/cjs/evm/aeraContracts/readOptions.d.ts +8 -0
- package/dist/cjs/evm/aeraContracts/readOptions.d.ts.map +1 -0
- package/dist/cjs/evm/aeraContracts/readOptions.js +31 -0
- package/dist/cjs/evm/aeraContracts/readOptions.js.map +7 -0
- package/dist/cjs/evm/aeraContracts/v1.d.ts +2317 -0
- package/dist/cjs/evm/aeraContracts/v1.d.ts.map +1 -0
- package/dist/cjs/evm/aeraContracts/v1.js +120 -0
- package/dist/cjs/evm/aeraContracts/v1.js.map +7 -0
- package/dist/cjs/evm/aeraContracts/v2.d.ts +4538 -0
- package/dist/cjs/evm/aeraContracts/v2.d.ts.map +1 -0
- package/dist/cjs/evm/aeraContracts/v2.js +449 -0
- package/dist/cjs/evm/aeraContracts/v2.js.map +7 -0
- package/dist/cjs/evm/aeraContracts.d.ts +33 -0
- package/dist/cjs/evm/aeraContracts.d.ts.map +1 -0
- package/dist/cjs/evm/aeraContracts.js +234 -0
- package/dist/cjs/evm/aeraContracts.js.map +7 -0
- package/dist/cjs/evm/deposit.d.ts +51 -0
- package/dist/cjs/evm/deposit.d.ts.map +1 -0
- package/dist/cjs/evm/deposit.js +142 -0
- package/dist/cjs/evm/deposit.js.map +7 -0
- package/dist/cjs/evm/depositQuote.d.ts +32 -0
- package/dist/cjs/evm/depositQuote.d.ts.map +1 -0
- package/dist/cjs/evm/depositQuote.js +97 -0
- package/dist/cjs/evm/depositQuote.js.map +7 -0
- package/dist/cjs/evm/depositReceiverApproval.d.ts +17 -0
- package/dist/cjs/evm/depositReceiverApproval.d.ts.map +1 -0
- package/dist/cjs/evm/depositReceiverApproval.js +71 -0
- package/dist/cjs/evm/depositReceiverApproval.js.map +7 -0
- package/dist/cjs/evm/index.d.ts +28 -0
- package/dist/cjs/evm/index.d.ts.map +1 -0
- package/dist/cjs/evm/index.js +116 -0
- package/dist/cjs/evm/index.js.map +7 -0
- package/dist/cjs/evm/operationMode.d.ts +9 -0
- package/dist/cjs/evm/operationMode.d.ts.map +1 -0
- package/dist/cjs/evm/operationMode.js +65 -0
- package/dist/cjs/evm/operationMode.js.map +7 -0
- package/dist/cjs/evm/tokenModes.d.ts +22 -0
- package/dist/cjs/evm/tokenModes.d.ts.map +1 -0
- package/dist/cjs/evm/tokenModes.js +47 -0
- package/dist/cjs/evm/tokenModes.js.map +7 -0
- package/dist/cjs/evm/types.d.ts +34 -0
- package/dist/cjs/evm/types.d.ts.map +1 -0
- package/dist/cjs/evm/types.js +32 -0
- package/dist/cjs/evm/types.js.map +7 -0
- package/dist/cjs/evm/userCurrentBalance.d.ts +69 -0
- package/dist/cjs/evm/userCurrentBalance.d.ts.map +1 -0
- package/dist/cjs/evm/userCurrentBalance.js +268 -0
- package/dist/cjs/evm/userCurrentBalance.js.map +7 -0
- package/dist/cjs/evm/vaults.d.ts +44 -0
- package/dist/cjs/evm/vaults.d.ts.map +1 -0
- package/dist/cjs/evm/vaults.js +78 -0
- package/dist/cjs/evm/vaults.js.map +7 -0
- package/dist/cjs/evm/withdraw.d.ts +75 -0
- package/dist/cjs/evm/withdraw.d.ts.map +1 -0
- package/dist/cjs/evm/withdraw.js +174 -0
- package/dist/cjs/evm/withdraw.js.map +7 -0
- package/dist/cjs/evm/withdrawQuote.d.ts +135 -0
- package/dist/cjs/evm/withdrawQuote.d.ts.map +1 -0
- package/dist/cjs/evm/withdrawQuote.js +257 -0
- package/dist/cjs/evm/withdrawQuote.js.map +7 -0
- package/dist/cjs/index.d.ts +31 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +128 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/privy/index.d.ts +52 -0
- package/dist/cjs/privy/index.d.ts.map +1 -0
- package/dist/cjs/privy/index.js +57 -0
- package/dist/cjs/privy/index.js.map +7 -0
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/errors.d.ts +4 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/evm/adapters/aera.d.ts +1 -1
- package/dist/evm/adapters/aera.d.ts.map +1 -1
- package/dist/evm/adapters/index.d.ts +1 -1
- package/dist/evm/adapters/index.d.ts.map +1 -1
- package/dist/evm/adapters/morpho.d.ts +1 -1
- package/dist/evm/adapters/morpho.d.ts.map +1 -1
- package/dist/evm/adapters/types.d.ts +6 -3
- package/dist/evm/adapters/types.d.ts.map +1 -1
- package/dist/evm/aeraContracts/priceAndFeeCalculator.d.ts +1 -1
- package/dist/evm/aeraContracts/priceAndFeeCalculator.d.ts.map +1 -1
- package/dist/evm/aeraContracts/v1.d.ts +2 -2
- package/dist/evm/aeraContracts/v1.d.ts.map +1 -1
- package/dist/evm/aeraContracts/v2.d.ts +25 -4
- package/dist/evm/aeraContracts/v2.d.ts.map +1 -1
- package/dist/evm/aeraContracts.d.ts +2 -2
- package/dist/evm/aeraContracts.d.ts.map +1 -1
- package/dist/evm/deposit.d.ts +7 -4
- package/dist/evm/deposit.d.ts.map +1 -1
- package/dist/evm/depositQuote.d.ts +32 -0
- package/dist/evm/depositQuote.d.ts.map +1 -0
- package/dist/evm/depositReceiverApproval.d.ts +2 -2
- package/dist/evm/depositReceiverApproval.d.ts.map +1 -1
- package/dist/evm/index.d.ts +27 -25
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +86 -12
- package/dist/evm/index.js.map +7 -1
- package/dist/evm/tokenModes.d.ts +2 -2
- package/dist/evm/tokenModes.d.ts.map +1 -1
- package/dist/evm/userCurrentBalance.d.ts +21 -3
- package/dist/evm/userCurrentBalance.d.ts.map +1 -1
- package/dist/evm/vaults.d.ts +2 -9
- package/dist/evm/vaults.d.ts.map +1 -1
- package/dist/evm/withdraw.d.ts +5 -3
- package/dist/evm/withdraw.d.ts.map +1 -1
- package/dist/evm/withdrawQuote.d.ts +14 -6
- package/dist/evm/withdrawQuote.d.ts.map +1 -1
- package/dist/index.d.ts +30 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +137 -14
- package/dist/index.js.map +7 -1
- package/dist/manifest/vaults.json +1958 -0
- package/dist/privy/index.d.ts +1 -1
- package/dist/privy/index.d.ts.map +1 -1
- package/dist/privy/index.js +39 -48
- package/dist/privy/index.js.map +7 -1
- package/manifest/vaults.json +22 -395
- package/package.json +43 -9
- package/src/api/activity.ts +18 -15
- package/src/api/activityRows.ts +143 -0
- package/src/api/caip.ts +3 -1
- package/src/api/client.ts +105 -6
- package/src/api/decimal.ts +1 -0
- package/src/api/generated.ts +570 -7
- package/src/api/http.ts +1 -0
- package/src/api/index.ts +8 -0
- package/src/api/positionHistory.ts +20 -5
- package/src/attribution/index.ts +6 -2
- package/src/client.ts +4 -1
- package/src/constants.ts +2 -0
- package/src/errors.ts +7 -0
- package/src/evm/adapters/aera.ts +40 -19
- package/src/evm/adapters/types.ts +3 -0
- package/src/evm/aeraContracts/v2.ts +124 -16
- package/src/evm/aeraContracts.ts +29 -14
- package/src/evm/deposit.ts +61 -18
- package/src/evm/depositQuote.ts +138 -0
- package/src/evm/depositReceiverApproval.ts +14 -9
- package/src/evm/index.ts +10 -1
- package/src/evm/userCurrentBalance.ts +155 -60
- package/src/evm/vaults.ts +0 -7
- package/src/evm/withdraw.ts +20 -1
- package/src/evm/withdrawQuote.ts +126 -51
- package/src/index.ts +11 -2
- package/dist/api/activity.js +0 -154
- package/dist/api/activity.js.map +0 -1
- package/dist/api/caip.js +0 -38
- package/dist/api/caip.js.map +0 -1
- package/dist/api/client.js +0 -119
- package/dist/api/client.js.map +0 -1
- package/dist/api/decimal.js +0 -44
- package/dist/api/decimal.js.map +0 -1
- package/dist/api/errors.js +0 -41
- package/dist/api/errors.js.map +0 -1
- package/dist/api/generated.js +0 -6
- package/dist/api/generated.js.map +0 -1
- package/dist/api/http.js +0 -39
- package/dist/api/http.js.map +0 -1
- package/dist/api/positionHistory.js +0 -126
- package/dist/api/positionHistory.js.map +0 -1
- package/dist/attribution/erc8021.js +0 -17
- package/dist/attribution/erc8021.js.map +0 -1
- package/dist/attribution/index.js +0 -45
- package/dist/attribution/index.js.map +0 -1
- package/dist/client.js +0 -72
- package/dist/client.js.map +0 -1
- package/dist/constants.js +0 -28
- package/dist/constants.js.map +0 -1
- package/dist/errors.js +0 -134
- package/dist/errors.js.map +0 -1
- package/dist/evm/abis/erc20.js +0 -30
- package/dist/evm/abis/erc20.js.map +0 -1
- package/dist/evm/abis/erc4626.js +0 -70
- package/dist/evm/abis/erc4626.js.map +0 -1
- package/dist/evm/abis/multiDepositorVault.js +0 -587
- package/dist/evm/abis/multiDepositorVault.js.map +0 -1
- package/dist/evm/abis/priceAndFeeCalculator.js +0 -490
- package/dist/evm/abis/priceAndFeeCalculator.js.map +0 -1
- package/dist/evm/abis/priceAndFeeCalculatorV2.js +0 -141
- package/dist/evm/abis/priceAndFeeCalculatorV2.js.map +0 -1
- package/dist/evm/abis/provisioner.js +0 -2768
- package/dist/evm/abis/provisioner.js.map +0 -1
- package/dist/evm/abis/provisionerV2.js +0 -295
- package/dist/evm/abis/provisionerV2.js.map +0 -1
- package/dist/evm/adapters/aera.js +0 -280
- package/dist/evm/adapters/aera.js.map +0 -1
- package/dist/evm/adapters/index.js +0 -14
- package/dist/evm/adapters/index.js.map +0 -1
- package/dist/evm/adapters/morpho.js +0 -79
- package/dist/evm/adapters/morpho.js.map +0 -1
- package/dist/evm/adapters/types.js +0 -2
- package/dist/evm/adapters/types.js.map +0 -1
- package/dist/evm/aeraContracts/priceAndFeeCalculator.js +0 -174
- package/dist/evm/aeraContracts/priceAndFeeCalculator.js.map +0 -1
- package/dist/evm/aeraContracts/readOptions.js +0 -4
- package/dist/evm/aeraContracts/readOptions.js.map +0 -1
- package/dist/evm/aeraContracts/v1.js +0 -59
- package/dist/evm/aeraContracts/v1.js.map +0 -1
- package/dist/evm/aeraContracts/v2.js +0 -273
- package/dist/evm/aeraContracts/v2.js.map +0 -1
- package/dist/evm/aeraContracts.js +0 -195
- package/dist/evm/aeraContracts.js.map +0 -1
- package/dist/evm/deposit.js +0 -109
- package/dist/evm/deposit.js.map +0 -1
- package/dist/evm/depositReceiverApproval.js +0 -32
- package/dist/evm/depositReceiverApproval.js.map +0 -1
- package/dist/evm/operationMode.js +0 -41
- package/dist/evm/operationMode.js.map +0 -1
- package/dist/evm/tokenModes.js +0 -34
- package/dist/evm/tokenModes.js.map +0 -1
- package/dist/evm/types.js +0 -5
- package/dist/evm/types.js.map +0 -1
- package/dist/evm/userCurrentBalance.js +0 -211
- package/dist/evm/userCurrentBalance.js.map +0 -1
- package/dist/evm/vaults.js +0 -75
- package/dist/evm/vaults.js.map +0 -1
- package/dist/evm/withdraw.js +0 -177
- package/dist/evm/withdraw.js.map +0 -1
- package/dist/evm/withdrawQuote.js +0 -164
- package/dist/evm/withdrawQuote.js.map +0 -1
|
@@ -0,0 +1,4477 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountMismatchError,
|
|
3
|
+
AccountRequiredError,
|
|
4
|
+
BLOCKS_3_DAYS,
|
|
5
|
+
CHAIN_NAMES,
|
|
6
|
+
ChainMismatchError,
|
|
7
|
+
DAY,
|
|
8
|
+
DEFAULT_BLOCKS_3_DAYS,
|
|
9
|
+
DEFAULT_BPS,
|
|
10
|
+
DEFAULT_MAX_PRICE_AGE,
|
|
11
|
+
DEFAULT_REQUEST_DEADLINE_BUFFER,
|
|
12
|
+
DEFAULT_SOLVER_TIP,
|
|
13
|
+
GauntletSDKError,
|
|
14
|
+
InvalidSlippageBPSError,
|
|
15
|
+
InvalidSolverTipError,
|
|
16
|
+
InvalidSyncDepositBoundError,
|
|
17
|
+
InvalidWithdrawParamsError,
|
|
18
|
+
LOG_PAGE_SIZE,
|
|
19
|
+
MAX_BPS,
|
|
20
|
+
StalePriceError,
|
|
21
|
+
UnimplementedFeatureError,
|
|
22
|
+
UnsupportedAssetError,
|
|
23
|
+
UnsupportedDepositModeError,
|
|
24
|
+
UnsupportedFeatureError,
|
|
25
|
+
UnsupportedProtocolError,
|
|
26
|
+
VaultNotFoundError,
|
|
27
|
+
requireNonZeroSyncWithdrawBound,
|
|
28
|
+
resolveVault
|
|
29
|
+
} from "./chunk-JJOLVL5V.js";
|
|
30
|
+
|
|
31
|
+
// src/evm/types.ts
|
|
32
|
+
var ContractVersion = {
|
|
33
|
+
V1: "v1",
|
|
34
|
+
V2: "v2"
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/evm/aeraContracts.ts
|
|
38
|
+
import {
|
|
39
|
+
ContractFunctionExecutionError,
|
|
40
|
+
ContractFunctionRevertedError,
|
|
41
|
+
ContractFunctionZeroDataError,
|
|
42
|
+
getContract,
|
|
43
|
+
zeroAddress
|
|
44
|
+
} from "viem";
|
|
45
|
+
|
|
46
|
+
// src/evm/abis/multiDepositorVault.ts
|
|
47
|
+
var multiDepositorVaultAbi = [
|
|
48
|
+
{ type: "constructor", inputs: [], stateMutability: "nonpayable" },
|
|
49
|
+
{ type: "fallback", stateMutability: "nonpayable" },
|
|
50
|
+
{ type: "receive", stateMutability: "payable" },
|
|
51
|
+
{
|
|
52
|
+
type: "function",
|
|
53
|
+
inputs: [],
|
|
54
|
+
name: "FEE_TOKEN",
|
|
55
|
+
outputs: [{ name: "", internalType: "contract IERC20", type: "address" }],
|
|
56
|
+
stateMutability: "view"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "function",
|
|
60
|
+
inputs: [],
|
|
61
|
+
name: "WHITELIST",
|
|
62
|
+
outputs: [{ name: "", internalType: "contract IWhitelist", type: "address" }],
|
|
63
|
+
stateMutability: "view"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "function",
|
|
67
|
+
inputs: [],
|
|
68
|
+
name: "acceptOwnership",
|
|
69
|
+
outputs: [],
|
|
70
|
+
stateMutability: "nonpayable"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "function",
|
|
74
|
+
inputs: [
|
|
75
|
+
{ name: "owner", internalType: "address", type: "address" },
|
|
76
|
+
{ name: "spender", internalType: "address", type: "address" }
|
|
77
|
+
],
|
|
78
|
+
name: "allowance",
|
|
79
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
80
|
+
stateMutability: "view"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "function",
|
|
84
|
+
inputs: [
|
|
85
|
+
{ name: "spender", internalType: "address", type: "address" },
|
|
86
|
+
{ name: "value", internalType: "uint256", type: "uint256" }
|
|
87
|
+
],
|
|
88
|
+
name: "approve",
|
|
89
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
90
|
+
stateMutability: "nonpayable"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "function",
|
|
94
|
+
inputs: [],
|
|
95
|
+
name: "authority",
|
|
96
|
+
outputs: [{ name: "", internalType: "contract Authority", type: "address" }],
|
|
97
|
+
stateMutability: "view"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "function",
|
|
101
|
+
inputs: [{ name: "account", internalType: "address", type: "address" }],
|
|
102
|
+
name: "balanceOf",
|
|
103
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
104
|
+
stateMutability: "view"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: "function",
|
|
108
|
+
inputs: [],
|
|
109
|
+
name: "beforeTransferHook",
|
|
110
|
+
outputs: [{ name: "", internalType: "contract IBeforeTransferHook", type: "address" }],
|
|
111
|
+
stateMutability: "view"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "function",
|
|
115
|
+
inputs: [{ name: "guardian", internalType: "address", type: "address" }],
|
|
116
|
+
name: "checkGuardianWhitelist",
|
|
117
|
+
outputs: [{ name: "isRemoved", internalType: "bool", type: "bool" }],
|
|
118
|
+
stateMutability: "nonpayable"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
type: "function",
|
|
122
|
+
inputs: [],
|
|
123
|
+
name: "claimFees",
|
|
124
|
+
outputs: [
|
|
125
|
+
{ name: "feeRecipientFees", internalType: "uint256", type: "uint256" },
|
|
126
|
+
{ name: "protocolFees", internalType: "uint256", type: "uint256" }
|
|
127
|
+
],
|
|
128
|
+
stateMutability: "nonpayable"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: "function",
|
|
132
|
+
inputs: [],
|
|
133
|
+
name: "claimProtocolFees",
|
|
134
|
+
outputs: [{ name: "protocolFees", internalType: "uint256", type: "uint256" }],
|
|
135
|
+
stateMutability: "nonpayable"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: "function",
|
|
139
|
+
inputs: [],
|
|
140
|
+
name: "decimals",
|
|
141
|
+
outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
|
|
142
|
+
stateMutability: "view"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
type: "function",
|
|
146
|
+
inputs: [
|
|
147
|
+
{ name: "sender", internalType: "address", type: "address" },
|
|
148
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
149
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" },
|
|
150
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" },
|
|
151
|
+
{ name: "recipient", internalType: "address", type: "address" }
|
|
152
|
+
],
|
|
153
|
+
name: "enter",
|
|
154
|
+
outputs: [],
|
|
155
|
+
stateMutability: "nonpayable"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: "function",
|
|
159
|
+
inputs: [
|
|
160
|
+
{ name: "sender", internalType: "address", type: "address" },
|
|
161
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
162
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" },
|
|
163
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" },
|
|
164
|
+
{ name: "recipient", internalType: "address", type: "address" }
|
|
165
|
+
],
|
|
166
|
+
name: "exit",
|
|
167
|
+
outputs: [],
|
|
168
|
+
stateMutability: "nonpayable"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
type: "function",
|
|
172
|
+
inputs: [],
|
|
173
|
+
name: "feeCalculator",
|
|
174
|
+
outputs: [{ name: "", internalType: "contract IFeeCalculator", type: "address" }],
|
|
175
|
+
stateMutability: "view"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
type: "function",
|
|
179
|
+
inputs: [],
|
|
180
|
+
name: "feeRecipient",
|
|
181
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
182
|
+
stateMutability: "view"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: "function",
|
|
186
|
+
inputs: [],
|
|
187
|
+
name: "getActiveGuardians",
|
|
188
|
+
outputs: [{ name: "", internalType: "address[]", type: "address[]" }],
|
|
189
|
+
stateMutability: "view"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: "function",
|
|
193
|
+
inputs: [],
|
|
194
|
+
name: "getCurrentHookCallType",
|
|
195
|
+
outputs: [{ name: "", internalType: "enum HookCallType", type: "uint8" }],
|
|
196
|
+
stateMutability: "view"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
type: "function",
|
|
200
|
+
inputs: [{ name: "guardian", internalType: "address", type: "address" }],
|
|
201
|
+
name: "getGuardianRoot",
|
|
202
|
+
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
|
|
203
|
+
stateMutability: "view"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
type: "function",
|
|
207
|
+
inputs: [],
|
|
208
|
+
name: "name",
|
|
209
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
210
|
+
stateMutability: "view"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
type: "function",
|
|
214
|
+
inputs: [
|
|
215
|
+
{ name: "", internalType: "address", type: "address" },
|
|
216
|
+
{ name: "", internalType: "address", type: "address" },
|
|
217
|
+
{ name: "", internalType: "uint256", type: "uint256" },
|
|
218
|
+
{ name: "", internalType: "bytes", type: "bytes" }
|
|
219
|
+
],
|
|
220
|
+
name: "onERC721Received",
|
|
221
|
+
outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }],
|
|
222
|
+
stateMutability: "pure"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "function",
|
|
226
|
+
inputs: [],
|
|
227
|
+
name: "owner",
|
|
228
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
229
|
+
stateMutability: "view"
|
|
230
|
+
},
|
|
231
|
+
{ type: "function", inputs: [], name: "pause", outputs: [], stateMutability: "nonpayable" },
|
|
232
|
+
{
|
|
233
|
+
type: "function",
|
|
234
|
+
inputs: [],
|
|
235
|
+
name: "paused",
|
|
236
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
237
|
+
stateMutability: "view"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
type: "function",
|
|
241
|
+
inputs: [],
|
|
242
|
+
name: "pendingOwner",
|
|
243
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
244
|
+
stateMutability: "view"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
type: "function",
|
|
248
|
+
inputs: [],
|
|
249
|
+
name: "provisioner",
|
|
250
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
251
|
+
stateMutability: "view"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
type: "function",
|
|
255
|
+
inputs: [{ name: "guardian", internalType: "address", type: "address" }],
|
|
256
|
+
name: "removeGuardian",
|
|
257
|
+
outputs: [],
|
|
258
|
+
stateMutability: "nonpayable"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
type: "function",
|
|
262
|
+
inputs: [{ name: "newAuthority", internalType: "contract Authority", type: "address" }],
|
|
263
|
+
name: "setAuthority",
|
|
264
|
+
outputs: [],
|
|
265
|
+
stateMutability: "nonpayable"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
type: "function",
|
|
269
|
+
inputs: [{ name: "hook", internalType: "contract IBeforeTransferHook", type: "address" }],
|
|
270
|
+
name: "setBeforeTransferHook",
|
|
271
|
+
outputs: [],
|
|
272
|
+
stateMutability: "nonpayable"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: "function",
|
|
276
|
+
inputs: [
|
|
277
|
+
{ name: "newFeeCalculator", internalType: "contract IFeeCalculator", type: "address" }
|
|
278
|
+
],
|
|
279
|
+
name: "setFeeCalculator",
|
|
280
|
+
outputs: [],
|
|
281
|
+
stateMutability: "nonpayable"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
type: "function",
|
|
285
|
+
inputs: [{ name: "newFeeRecipient", internalType: "address", type: "address" }],
|
|
286
|
+
name: "setFeeRecipient",
|
|
287
|
+
outputs: [],
|
|
288
|
+
stateMutability: "nonpayable"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
type: "function",
|
|
292
|
+
inputs: [
|
|
293
|
+
{ name: "guardian", internalType: "address", type: "address" },
|
|
294
|
+
{ name: "root", internalType: "bytes32", type: "bytes32" }
|
|
295
|
+
],
|
|
296
|
+
name: "setGuardianRoot",
|
|
297
|
+
outputs: [],
|
|
298
|
+
stateMutability: "nonpayable"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
type: "function",
|
|
302
|
+
inputs: [{ name: "provisioner_", internalType: "address", type: "address" }],
|
|
303
|
+
name: "setProvisioner",
|
|
304
|
+
outputs: [],
|
|
305
|
+
stateMutability: "nonpayable"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
type: "function",
|
|
309
|
+
inputs: [{ name: "newSubmitHooks", internalType: "contract ISubmitHooks", type: "address" }],
|
|
310
|
+
name: "setSubmitHooks",
|
|
311
|
+
outputs: [],
|
|
312
|
+
stateMutability: "nonpayable"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: "function",
|
|
316
|
+
inputs: [{ name: "data", internalType: "bytes", type: "bytes" }],
|
|
317
|
+
name: "submit",
|
|
318
|
+
outputs: [],
|
|
319
|
+
stateMutability: "nonpayable"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
type: "function",
|
|
323
|
+
inputs: [],
|
|
324
|
+
name: "submitHooks",
|
|
325
|
+
outputs: [{ name: "", internalType: "contract ISubmitHooks", type: "address" }],
|
|
326
|
+
stateMutability: "view"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
type: "function",
|
|
330
|
+
inputs: [],
|
|
331
|
+
name: "symbol",
|
|
332
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
333
|
+
stateMutability: "view"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
type: "function",
|
|
337
|
+
inputs: [],
|
|
338
|
+
name: "totalSupply",
|
|
339
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
340
|
+
stateMutability: "view"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
type: "function",
|
|
344
|
+
inputs: [
|
|
345
|
+
{ name: "to", internalType: "address", type: "address" },
|
|
346
|
+
{ name: "value", internalType: "uint256", type: "uint256" }
|
|
347
|
+
],
|
|
348
|
+
name: "transfer",
|
|
349
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
350
|
+
stateMutability: "nonpayable"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
type: "function",
|
|
354
|
+
inputs: [
|
|
355
|
+
{ name: "from", internalType: "address", type: "address" },
|
|
356
|
+
{ name: "to", internalType: "address", type: "address" },
|
|
357
|
+
{ name: "value", internalType: "uint256", type: "uint256" }
|
|
358
|
+
],
|
|
359
|
+
name: "transferFrom",
|
|
360
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
361
|
+
stateMutability: "nonpayable"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
type: "function",
|
|
365
|
+
inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
|
|
366
|
+
name: "transferOwnership",
|
|
367
|
+
outputs: [],
|
|
368
|
+
stateMutability: "nonpayable"
|
|
369
|
+
},
|
|
370
|
+
{ type: "function", inputs: [], name: "unpause", outputs: [], stateMutability: "nonpayable" },
|
|
371
|
+
{
|
|
372
|
+
type: "event",
|
|
373
|
+
anonymous: false,
|
|
374
|
+
inputs: [
|
|
375
|
+
{ name: "owner", internalType: "address", type: "address", indexed: true },
|
|
376
|
+
{ name: "spender", internalType: "address", type: "address", indexed: true },
|
|
377
|
+
{ name: "value", internalType: "uint256", type: "uint256", indexed: false }
|
|
378
|
+
],
|
|
379
|
+
name: "Approval"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
type: "event",
|
|
383
|
+
anonymous: false,
|
|
384
|
+
inputs: [
|
|
385
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
386
|
+
{ name: "newAuthority", internalType: "contract Authority", type: "address", indexed: true }
|
|
387
|
+
],
|
|
388
|
+
name: "AuthorityUpdated"
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
type: "event",
|
|
392
|
+
anonymous: false,
|
|
393
|
+
inputs: [
|
|
394
|
+
{ name: "beforeTransferHook", internalType: "address", type: "address", indexed: true }
|
|
395
|
+
],
|
|
396
|
+
name: "BeforeTransferHookSet"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
type: "event",
|
|
400
|
+
anonymous: false,
|
|
401
|
+
inputs: [
|
|
402
|
+
{ name: "sender", internalType: "address", type: "address", indexed: true },
|
|
403
|
+
{ name: "recipient", internalType: "address", type: "address", indexed: true },
|
|
404
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
405
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256", indexed: false },
|
|
406
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256", indexed: false }
|
|
407
|
+
],
|
|
408
|
+
name: "Enter"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
type: "event",
|
|
412
|
+
anonymous: false,
|
|
413
|
+
inputs: [
|
|
414
|
+
{ name: "sender", internalType: "address", type: "address", indexed: true },
|
|
415
|
+
{ name: "recipient", internalType: "address", type: "address", indexed: true },
|
|
416
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
417
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256", indexed: false },
|
|
418
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256", indexed: false }
|
|
419
|
+
],
|
|
420
|
+
name: "Exit"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
type: "event",
|
|
424
|
+
anonymous: false,
|
|
425
|
+
inputs: [{ name: "newFeeCalculator", internalType: "address", type: "address", indexed: true }],
|
|
426
|
+
name: "FeeCalculatorUpdated"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
type: "event",
|
|
430
|
+
anonymous: false,
|
|
431
|
+
inputs: [{ name: "newFeeRecipient", internalType: "address", type: "address", indexed: true }],
|
|
432
|
+
name: "FeeRecipientUpdated"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
type: "event",
|
|
436
|
+
anonymous: false,
|
|
437
|
+
inputs: [
|
|
438
|
+
{ name: "feeRecipient", internalType: "address", type: "address", indexed: true },
|
|
439
|
+
{ name: "fees", internalType: "uint256", type: "uint256", indexed: false }
|
|
440
|
+
],
|
|
441
|
+
name: "FeesClaimed"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
type: "event",
|
|
445
|
+
anonymous: false,
|
|
446
|
+
inputs: [
|
|
447
|
+
{ name: "guardian", internalType: "address", type: "address", indexed: true },
|
|
448
|
+
{ name: "root", internalType: "bytes32", type: "bytes32", indexed: true }
|
|
449
|
+
],
|
|
450
|
+
name: "GuardianRootSet"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
type: "event",
|
|
454
|
+
anonymous: false,
|
|
455
|
+
inputs: [
|
|
456
|
+
{ name: "previousOwner", internalType: "address", type: "address", indexed: true },
|
|
457
|
+
{ name: "newOwner", internalType: "address", type: "address", indexed: true }
|
|
458
|
+
],
|
|
459
|
+
name: "OwnershipTransferStarted"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
type: "event",
|
|
463
|
+
anonymous: false,
|
|
464
|
+
inputs: [
|
|
465
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
466
|
+
{ name: "newOwner", internalType: "address", type: "address", indexed: true }
|
|
467
|
+
],
|
|
468
|
+
name: "OwnershipTransferred"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
type: "event",
|
|
472
|
+
anonymous: false,
|
|
473
|
+
inputs: [{ name: "account", internalType: "address", type: "address", indexed: false }],
|
|
474
|
+
name: "Paused"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
type: "event",
|
|
478
|
+
anonymous: false,
|
|
479
|
+
inputs: [
|
|
480
|
+
{ name: "protocolFeeRecipient", internalType: "address", type: "address", indexed: true },
|
|
481
|
+
{ name: "protocolEarnedFees", internalType: "uint256", type: "uint256", indexed: false }
|
|
482
|
+
],
|
|
483
|
+
name: "ProtocolFeesClaimed"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
type: "event",
|
|
487
|
+
anonymous: false,
|
|
488
|
+
inputs: [{ name: "provisioner", internalType: "address", type: "address", indexed: true }],
|
|
489
|
+
name: "ProvisionerSet"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
type: "event",
|
|
493
|
+
anonymous: false,
|
|
494
|
+
inputs: [
|
|
495
|
+
{ name: "submitHooksAddress", internalType: "address", type: "address", indexed: true }
|
|
496
|
+
],
|
|
497
|
+
name: "SubmitHooksSet"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
type: "event",
|
|
501
|
+
anonymous: false,
|
|
502
|
+
inputs: [
|
|
503
|
+
{ name: "from", internalType: "address", type: "address", indexed: true },
|
|
504
|
+
{ name: "to", internalType: "address", type: "address", indexed: true },
|
|
505
|
+
{ name: "value", internalType: "uint256", type: "uint256", indexed: false }
|
|
506
|
+
],
|
|
507
|
+
name: "Transfer"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
type: "event",
|
|
511
|
+
anonymous: false,
|
|
512
|
+
inputs: [{ name: "account", internalType: "address", type: "address", indexed: false }],
|
|
513
|
+
name: "Unpaused"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
type: "error",
|
|
517
|
+
inputs: [
|
|
518
|
+
{ name: "index", internalType: "uint256", type: "uint256" },
|
|
519
|
+
{ name: "result", internalType: "bytes", type: "bytes" }
|
|
520
|
+
],
|
|
521
|
+
name: "Aera__AfterOperationHooksFailed"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
type: "error",
|
|
525
|
+
inputs: [{ name: "result", internalType: "bytes", type: "bytes" }],
|
|
526
|
+
name: "Aera__AfterSubmitHooksFailed"
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
type: "error",
|
|
530
|
+
inputs: [
|
|
531
|
+
{ name: "token", internalType: "address", type: "address" },
|
|
532
|
+
{ name: "spender", internalType: "address", type: "address" }
|
|
533
|
+
],
|
|
534
|
+
name: "Aera__AllowanceIsNotZero"
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
type: "error",
|
|
538
|
+
inputs: [
|
|
539
|
+
{ name: "index", internalType: "uint256", type: "uint256" },
|
|
540
|
+
{ name: "result", internalType: "bytes", type: "bytes" }
|
|
541
|
+
],
|
|
542
|
+
name: "Aera__BeforeOperationHooksFailed"
|
|
543
|
+
},
|
|
544
|
+
{ type: "error", inputs: [], name: "Aera__BeforeOperationHooksWithConfigurableHooks" },
|
|
545
|
+
{
|
|
546
|
+
type: "error",
|
|
547
|
+
inputs: [{ name: "result", internalType: "bytes", type: "bytes" }],
|
|
548
|
+
name: "Aera__BeforeSubmitHooksFailed"
|
|
549
|
+
},
|
|
550
|
+
{ type: "error", inputs: [], name: "Aera__CalldataTooShort" },
|
|
551
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotAuthOrGuardian" },
|
|
552
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotFeeRecipient" },
|
|
553
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotGuardian" },
|
|
554
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotProtocolFeeRecipient" },
|
|
555
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotProvisioner" },
|
|
556
|
+
{ type: "error", inputs: [], name: "Aera__CopyOffsetOutOfBounds" },
|
|
557
|
+
{ type: "error", inputs: [], name: "Aera__ExpectedCallbackNotReceived" },
|
|
558
|
+
{ type: "error", inputs: [], name: "Aera__ExtractionNumberTooLarge" },
|
|
559
|
+
{ type: "error", inputs: [], name: "Aera__GuardianNotWhitelisted" },
|
|
560
|
+
{ type: "error", inputs: [], name: "Aera__InvalidBeforeOperationHooksReturnDataLength" },
|
|
561
|
+
{ type: "error", inputs: [], name: "Aera__NoFeesToClaim" },
|
|
562
|
+
{ type: "error", inputs: [], name: "Aera__NoResults" },
|
|
563
|
+
{ type: "error", inputs: [], name: "Aera__OffsetOutOfBounds" },
|
|
564
|
+
{ type: "error", inputs: [], name: "Aera__PasteOffsetOutOfBounds" },
|
|
565
|
+
{ type: "error", inputs: [], name: "Aera__ProofVerificationFailed" },
|
|
566
|
+
{
|
|
567
|
+
type: "error",
|
|
568
|
+
inputs: [
|
|
569
|
+
{ name: "index", internalType: "uint256", type: "uint256" },
|
|
570
|
+
{ name: "result", internalType: "bytes", type: "bytes" }
|
|
571
|
+
],
|
|
572
|
+
name: "Aera__SubmissionFailed"
|
|
573
|
+
},
|
|
574
|
+
{ type: "error", inputs: [], name: "Aera__Unauthorized" },
|
|
575
|
+
{ type: "error", inputs: [], name: "Aera__UnauthorizedCallback" },
|
|
576
|
+
{ type: "error", inputs: [], name: "Aera__UnitsLocked" },
|
|
577
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
|
|
578
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressFeeCalculator" },
|
|
579
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressFeeRecipient" },
|
|
580
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressFeeToken" },
|
|
581
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressGuardian" },
|
|
582
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressMerkleRoot" },
|
|
583
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressOwner" },
|
|
584
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressProvisioner" },
|
|
585
|
+
{
|
|
586
|
+
type: "error",
|
|
587
|
+
inputs: [
|
|
588
|
+
{ name: "spender", internalType: "address", type: "address" },
|
|
589
|
+
{ name: "allowance", internalType: "uint256", type: "uint256" },
|
|
590
|
+
{ name: "needed", internalType: "uint256", type: "uint256" }
|
|
591
|
+
],
|
|
592
|
+
name: "ERC20InsufficientAllowance"
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
type: "error",
|
|
596
|
+
inputs: [
|
|
597
|
+
{ name: "sender", internalType: "address", type: "address" },
|
|
598
|
+
{ name: "balance", internalType: "uint256", type: "uint256" },
|
|
599
|
+
{ name: "needed", internalType: "uint256", type: "uint256" }
|
|
600
|
+
],
|
|
601
|
+
name: "ERC20InsufficientBalance"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
type: "error",
|
|
605
|
+
inputs: [{ name: "approver", internalType: "address", type: "address" }],
|
|
606
|
+
name: "ERC20InvalidApprover"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
type: "error",
|
|
610
|
+
inputs: [{ name: "receiver", internalType: "address", type: "address" }],
|
|
611
|
+
name: "ERC20InvalidReceiver"
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
type: "error",
|
|
615
|
+
inputs: [{ name: "sender", internalType: "address", type: "address" }],
|
|
616
|
+
name: "ERC20InvalidSender"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
type: "error",
|
|
620
|
+
inputs: [{ name: "spender", internalType: "address", type: "address" }],
|
|
621
|
+
name: "ERC20InvalidSpender"
|
|
622
|
+
},
|
|
623
|
+
{ type: "error", inputs: [], name: "EnforcedPause" },
|
|
624
|
+
{ type: "error", inputs: [], name: "ExpectedPause" },
|
|
625
|
+
{ type: "error", inputs: [], name: "ReaderNotAtEnd" },
|
|
626
|
+
{ type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
|
|
627
|
+
{
|
|
628
|
+
type: "error",
|
|
629
|
+
inputs: [{ name: "token", internalType: "address", type: "address" }],
|
|
630
|
+
name: "SafeERC20FailedOperation"
|
|
631
|
+
}
|
|
632
|
+
];
|
|
633
|
+
|
|
634
|
+
// src/evm/abis/provisioner.ts
|
|
635
|
+
var provisionerAbi = [
|
|
636
|
+
{
|
|
637
|
+
type: "constructor",
|
|
638
|
+
inputs: [
|
|
639
|
+
{
|
|
640
|
+
name: "priceAndFeeCalculator",
|
|
641
|
+
internalType: "contract IPriceAndFeeCalculator",
|
|
642
|
+
type: "address"
|
|
643
|
+
},
|
|
644
|
+
{ name: "multiDepositorVault", internalType: "address", type: "address" },
|
|
645
|
+
{ name: "owner_", internalType: "address", type: "address" },
|
|
646
|
+
{ name: "authority_", internalType: "contract Authority", type: "address" }
|
|
647
|
+
],
|
|
648
|
+
stateMutability: "nonpayable"
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
type: "function",
|
|
652
|
+
inputs: [],
|
|
653
|
+
name: "MULTI_DEPOSITOR_VAULT",
|
|
654
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
655
|
+
stateMutability: "view"
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
type: "function",
|
|
659
|
+
inputs: [],
|
|
660
|
+
name: "PRICE_FEE_CALCULATOR",
|
|
661
|
+
outputs: [{ name: "", internalType: "contract IPriceAndFeeCalculator", type: "address" }],
|
|
662
|
+
stateMutability: "view"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
type: "function",
|
|
666
|
+
inputs: [],
|
|
667
|
+
name: "acceptOwnership",
|
|
668
|
+
outputs: [],
|
|
669
|
+
stateMutability: "nonpayable"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
type: "function",
|
|
673
|
+
inputs: [{ name: "user", internalType: "address", type: "address" }],
|
|
674
|
+
name: "areUserUnitsLocked",
|
|
675
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
676
|
+
stateMutability: "view"
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
type: "function",
|
|
680
|
+
inputs: [{ name: "asyncDepositHash", internalType: "bytes32", type: "bytes32" }],
|
|
681
|
+
name: "asyncDepositHashes",
|
|
682
|
+
outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
|
|
683
|
+
stateMutability: "view"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
type: "function",
|
|
687
|
+
inputs: [{ name: "asyncRedeemHash", internalType: "bytes32", type: "bytes32" }],
|
|
688
|
+
name: "asyncRedeemHashes",
|
|
689
|
+
outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
|
|
690
|
+
stateMutability: "view"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
type: "function",
|
|
694
|
+
inputs: [],
|
|
695
|
+
name: "authority",
|
|
696
|
+
outputs: [{ name: "", internalType: "contract Authority", type: "address" }],
|
|
697
|
+
stateMutability: "view"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
type: "function",
|
|
701
|
+
inputs: [
|
|
702
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
703
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256" },
|
|
704
|
+
{ name: "minUnitsOut", internalType: "uint256", type: "uint256" }
|
|
705
|
+
],
|
|
706
|
+
name: "deposit",
|
|
707
|
+
outputs: [{ name: "unitsOut", internalType: "uint256", type: "uint256" }],
|
|
708
|
+
stateMutability: "nonpayable"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
type: "function",
|
|
712
|
+
inputs: [],
|
|
713
|
+
name: "depositCap",
|
|
714
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
715
|
+
stateMutability: "view"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
type: "function",
|
|
719
|
+
inputs: [],
|
|
720
|
+
name: "depositRefundTimeout",
|
|
721
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
722
|
+
stateMutability: "view"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
type: "function",
|
|
726
|
+
inputs: [
|
|
727
|
+
{ name: "user", internalType: "address", type: "address" },
|
|
728
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
729
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" },
|
|
730
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" },
|
|
731
|
+
{ name: "refundableUntil", internalType: "uint256", type: "uint256" }
|
|
732
|
+
],
|
|
733
|
+
name: "getDepositHash",
|
|
734
|
+
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
|
|
735
|
+
stateMutability: "pure"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
type: "function",
|
|
739
|
+
inputs: [
|
|
740
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
741
|
+
{
|
|
742
|
+
name: "request",
|
|
743
|
+
internalType: "struct Request",
|
|
744
|
+
type: "tuple",
|
|
745
|
+
components: [
|
|
746
|
+
{ name: "requestType", internalType: "enum RequestType", type: "uint8" },
|
|
747
|
+
{ name: "user", internalType: "address", type: "address" },
|
|
748
|
+
{ name: "units", internalType: "uint256", type: "uint256" },
|
|
749
|
+
{ name: "tokens", internalType: "uint256", type: "uint256" },
|
|
750
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
751
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
752
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" }
|
|
753
|
+
]
|
|
754
|
+
}
|
|
755
|
+
],
|
|
756
|
+
name: "getRequestHash",
|
|
757
|
+
outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
|
|
758
|
+
stateMutability: "pure"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
type: "function",
|
|
762
|
+
inputs: [],
|
|
763
|
+
name: "maxDeposit",
|
|
764
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
765
|
+
stateMutability: "view"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
type: "function",
|
|
769
|
+
inputs: [
|
|
770
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
771
|
+
{ name: "unitsOut", internalType: "uint256", type: "uint256" },
|
|
772
|
+
{ name: "maxTokensIn", internalType: "uint256", type: "uint256" }
|
|
773
|
+
],
|
|
774
|
+
name: "mint",
|
|
775
|
+
outputs: [{ name: "tokensIn", internalType: "uint256", type: "uint256" }],
|
|
776
|
+
stateMutability: "nonpayable"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
type: "function",
|
|
780
|
+
inputs: [],
|
|
781
|
+
name: "owner",
|
|
782
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
783
|
+
stateMutability: "view"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
type: "function",
|
|
787
|
+
inputs: [],
|
|
788
|
+
name: "pendingOwner",
|
|
789
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
790
|
+
stateMutability: "view"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
type: "function",
|
|
794
|
+
inputs: [
|
|
795
|
+
{ name: "sender", internalType: "address", type: "address" },
|
|
796
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
797
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" },
|
|
798
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" },
|
|
799
|
+
{ name: "refundableUntil", internalType: "uint256", type: "uint256" }
|
|
800
|
+
],
|
|
801
|
+
name: "refundDeposit",
|
|
802
|
+
outputs: [],
|
|
803
|
+
stateMutability: "nonpayable"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
type: "function",
|
|
807
|
+
inputs: [
|
|
808
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
809
|
+
{
|
|
810
|
+
name: "request",
|
|
811
|
+
internalType: "struct Request",
|
|
812
|
+
type: "tuple",
|
|
813
|
+
components: [
|
|
814
|
+
{ name: "requestType", internalType: "enum RequestType", type: "uint8" },
|
|
815
|
+
{ name: "user", internalType: "address", type: "address" },
|
|
816
|
+
{ name: "units", internalType: "uint256", type: "uint256" },
|
|
817
|
+
{ name: "tokens", internalType: "uint256", type: "uint256" },
|
|
818
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
819
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
820
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" }
|
|
821
|
+
]
|
|
822
|
+
}
|
|
823
|
+
],
|
|
824
|
+
name: "refundRequest",
|
|
825
|
+
outputs: [],
|
|
826
|
+
stateMutability: "nonpayable"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
type: "function",
|
|
830
|
+
inputs: [{ name: "token", internalType: "contract IERC20", type: "address" }],
|
|
831
|
+
name: "removeToken",
|
|
832
|
+
outputs: [],
|
|
833
|
+
stateMutability: "nonpayable"
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
type: "function",
|
|
837
|
+
inputs: [
|
|
838
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
839
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256" },
|
|
840
|
+
{ name: "minUnitsOut", internalType: "uint256", type: "uint256" },
|
|
841
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
842
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
843
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" },
|
|
844
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool" }
|
|
845
|
+
],
|
|
846
|
+
name: "requestDeposit",
|
|
847
|
+
outputs: [],
|
|
848
|
+
stateMutability: "nonpayable"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
type: "function",
|
|
852
|
+
inputs: [
|
|
853
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
854
|
+
{ name: "unitsIn", internalType: "uint256", type: "uint256" },
|
|
855
|
+
{ name: "minTokensOut", internalType: "uint256", type: "uint256" },
|
|
856
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
857
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
858
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" },
|
|
859
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool" }
|
|
860
|
+
],
|
|
861
|
+
name: "requestRedeem",
|
|
862
|
+
outputs: [],
|
|
863
|
+
stateMutability: "nonpayable"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
type: "function",
|
|
867
|
+
inputs: [{ name: "newAuthority", internalType: "contract Authority", type: "address" }],
|
|
868
|
+
name: "setAuthority",
|
|
869
|
+
outputs: [],
|
|
870
|
+
stateMutability: "nonpayable"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
type: "function",
|
|
874
|
+
inputs: [
|
|
875
|
+
{ name: "depositCap_", internalType: "uint256", type: "uint256" },
|
|
876
|
+
{ name: "depositRefundTimeout_", internalType: "uint256", type: "uint256" }
|
|
877
|
+
],
|
|
878
|
+
name: "setDepositDetails",
|
|
879
|
+
outputs: [],
|
|
880
|
+
stateMutability: "nonpayable"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
type: "function",
|
|
884
|
+
inputs: [
|
|
885
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
886
|
+
{
|
|
887
|
+
name: "details",
|
|
888
|
+
internalType: "struct TokenDetails",
|
|
889
|
+
type: "tuple",
|
|
890
|
+
components: [
|
|
891
|
+
{ name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
|
|
892
|
+
{ name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
|
|
893
|
+
{ name: "syncDepositEnabled", internalType: "bool", type: "bool" },
|
|
894
|
+
{ name: "depositMultiplier", internalType: "uint16", type: "uint16" },
|
|
895
|
+
{ name: "redeemMultiplier", internalType: "uint16", type: "uint16" }
|
|
896
|
+
]
|
|
897
|
+
}
|
|
898
|
+
],
|
|
899
|
+
name: "setTokenDetails",
|
|
900
|
+
outputs: [],
|
|
901
|
+
stateMutability: "nonpayable"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
type: "function",
|
|
905
|
+
inputs: [
|
|
906
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
907
|
+
{
|
|
908
|
+
name: "requests",
|
|
909
|
+
internalType: "struct Request[]",
|
|
910
|
+
type: "tuple[]",
|
|
911
|
+
components: [
|
|
912
|
+
{ name: "requestType", internalType: "enum RequestType", type: "uint8" },
|
|
913
|
+
{ name: "user", internalType: "address", type: "address" },
|
|
914
|
+
{ name: "units", internalType: "uint256", type: "uint256" },
|
|
915
|
+
{ name: "tokens", internalType: "uint256", type: "uint256" },
|
|
916
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
917
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
918
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" }
|
|
919
|
+
]
|
|
920
|
+
}
|
|
921
|
+
],
|
|
922
|
+
name: "solveRequestsDirect",
|
|
923
|
+
outputs: [],
|
|
924
|
+
stateMutability: "nonpayable"
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
type: "function",
|
|
928
|
+
inputs: [
|
|
929
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
930
|
+
{
|
|
931
|
+
name: "requests",
|
|
932
|
+
internalType: "struct Request[]",
|
|
933
|
+
type: "tuple[]",
|
|
934
|
+
components: [
|
|
935
|
+
{ name: "requestType", internalType: "enum RequestType", type: "uint8" },
|
|
936
|
+
{ name: "user", internalType: "address", type: "address" },
|
|
937
|
+
{ name: "units", internalType: "uint256", type: "uint256" },
|
|
938
|
+
{ name: "tokens", internalType: "uint256", type: "uint256" },
|
|
939
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
940
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
941
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" }
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
],
|
|
945
|
+
name: "solveRequestsVault",
|
|
946
|
+
outputs: [],
|
|
947
|
+
stateMutability: "nonpayable"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
type: "function",
|
|
951
|
+
inputs: [{ name: "syncDepositHash", internalType: "bytes32", type: "bytes32" }],
|
|
952
|
+
name: "syncDepositHashes",
|
|
953
|
+
outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
|
|
954
|
+
stateMutability: "view"
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
type: "function",
|
|
958
|
+
inputs: [{ name: "token", internalType: "contract IERC20", type: "address" }],
|
|
959
|
+
name: "tokensDetails",
|
|
960
|
+
outputs: [
|
|
961
|
+
{ name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
|
|
962
|
+
{ name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
|
|
963
|
+
{ name: "syncDepositEnabled", internalType: "bool", type: "bool" },
|
|
964
|
+
{ name: "depositMultiplier", internalType: "uint16", type: "uint16" },
|
|
965
|
+
{ name: "redeemMultiplier", internalType: "uint16", type: "uint16" }
|
|
966
|
+
],
|
|
967
|
+
stateMutability: "view"
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
type: "function",
|
|
971
|
+
inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
|
|
972
|
+
name: "transferOwnership",
|
|
973
|
+
outputs: [],
|
|
974
|
+
stateMutability: "nonpayable"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
type: "function",
|
|
978
|
+
inputs: [{ name: "user", internalType: "address", type: "address" }],
|
|
979
|
+
name: "userUnitsRefundableUntil",
|
|
980
|
+
outputs: [{ name: "unitsLockedUntil", internalType: "uint256", type: "uint256" }],
|
|
981
|
+
stateMutability: "view"
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
type: "event",
|
|
985
|
+
anonymous: false,
|
|
986
|
+
inputs: [
|
|
987
|
+
{ name: "index", internalType: "uint256", type: "uint256", indexed: true },
|
|
988
|
+
{ name: "amount", internalType: "uint256", type: "uint256", indexed: false },
|
|
989
|
+
{ name: "bound", internalType: "uint256", type: "uint256", indexed: false }
|
|
990
|
+
],
|
|
991
|
+
name: "AmountBoundExceeded"
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
type: "event",
|
|
995
|
+
anonymous: false,
|
|
996
|
+
inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
|
|
997
|
+
name: "AsyncDepositDisabled"
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
type: "event",
|
|
1001
|
+
anonymous: false,
|
|
1002
|
+
inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
|
|
1003
|
+
name: "AsyncRedeemDisabled"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
type: "event",
|
|
1007
|
+
anonymous: false,
|
|
1008
|
+
inputs: [
|
|
1009
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1010
|
+
{ name: "newAuthority", internalType: "contract Authority", type: "address", indexed: true }
|
|
1011
|
+
],
|
|
1012
|
+
name: "AuthorityUpdated"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
type: "event",
|
|
1016
|
+
anonymous: false,
|
|
1017
|
+
inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
|
|
1018
|
+
name: "DepositCapExceeded"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
type: "event",
|
|
1022
|
+
anonymous: false,
|
|
1023
|
+
inputs: [
|
|
1024
|
+
{ name: "depositCap", internalType: "uint256", type: "uint256", indexed: false },
|
|
1025
|
+
{ name: "depositRefundTimeout", internalType: "uint256", type: "uint256", indexed: false }
|
|
1026
|
+
],
|
|
1027
|
+
name: "DepositDetailsUpdated"
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
type: "event",
|
|
1031
|
+
anonymous: false,
|
|
1032
|
+
inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
|
|
1033
|
+
name: "DepositRefunded"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
type: "event",
|
|
1037
|
+
anonymous: false,
|
|
1038
|
+
inputs: [
|
|
1039
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1040
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1041
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256", indexed: false },
|
|
1042
|
+
{ name: "minUnitsOut", internalType: "uint256", type: "uint256", indexed: false },
|
|
1043
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
|
|
1044
|
+
{ name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
|
|
1045
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
|
|
1046
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
|
|
1047
|
+
{ name: "depositRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
|
|
1048
|
+
],
|
|
1049
|
+
name: "DepositRequested"
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
type: "event",
|
|
1053
|
+
anonymous: false,
|
|
1054
|
+
inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
|
|
1055
|
+
name: "DepositSolved"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
type: "event",
|
|
1059
|
+
anonymous: false,
|
|
1060
|
+
inputs: [
|
|
1061
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1062
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1063
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256", indexed: false },
|
|
1064
|
+
{ name: "unitsOut", internalType: "uint256", type: "uint256", indexed: false },
|
|
1065
|
+
{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: false }
|
|
1066
|
+
],
|
|
1067
|
+
name: "Deposited"
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
type: "event",
|
|
1071
|
+
anonymous: false,
|
|
1072
|
+
inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
|
|
1073
|
+
name: "DirectDepositRefunded"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
type: "event",
|
|
1077
|
+
anonymous: false,
|
|
1078
|
+
inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
|
|
1079
|
+
name: "InsufficientTokensForTip"
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
type: "event",
|
|
1083
|
+
anonymous: false,
|
|
1084
|
+
inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
|
|
1085
|
+
name: "InvalidRequestHash"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
type: "event",
|
|
1089
|
+
anonymous: false,
|
|
1090
|
+
inputs: [
|
|
1091
|
+
{ name: "previousOwner", internalType: "address", type: "address", indexed: true },
|
|
1092
|
+
{ name: "newOwner", internalType: "address", type: "address", indexed: true }
|
|
1093
|
+
],
|
|
1094
|
+
name: "OwnershipTransferStarted"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
type: "event",
|
|
1098
|
+
anonymous: false,
|
|
1099
|
+
inputs: [
|
|
1100
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1101
|
+
{ name: "newOwner", internalType: "address", type: "address", indexed: true }
|
|
1102
|
+
],
|
|
1103
|
+
name: "OwnershipTransferred"
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
type: "event",
|
|
1107
|
+
anonymous: false,
|
|
1108
|
+
inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
|
|
1109
|
+
name: "PriceAgeExceeded"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
type: "event",
|
|
1113
|
+
anonymous: false,
|
|
1114
|
+
inputs: [{ name: "redeemHash", internalType: "bytes32", type: "bytes32", indexed: true }],
|
|
1115
|
+
name: "RedeemRefunded"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
type: "event",
|
|
1119
|
+
anonymous: false,
|
|
1120
|
+
inputs: [
|
|
1121
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1122
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1123
|
+
{ name: "minTokensOut", internalType: "uint256", type: "uint256", indexed: false },
|
|
1124
|
+
{ name: "unitsIn", internalType: "uint256", type: "uint256", indexed: false },
|
|
1125
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
|
|
1126
|
+
{ name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
|
|
1127
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
|
|
1128
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
|
|
1129
|
+
{ name: "redeemRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
|
|
1130
|
+
],
|
|
1131
|
+
name: "RedeemRequested"
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
type: "event",
|
|
1135
|
+
anonymous: false,
|
|
1136
|
+
inputs: [{ name: "redeemHash", internalType: "bytes32", type: "bytes32", indexed: true }],
|
|
1137
|
+
name: "RedeemSolved"
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
type: "event",
|
|
1141
|
+
anonymous: false,
|
|
1142
|
+
inputs: [
|
|
1143
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1144
|
+
{
|
|
1145
|
+
name: "tokensDetails",
|
|
1146
|
+
internalType: "struct TokenDetails",
|
|
1147
|
+
type: "tuple",
|
|
1148
|
+
components: [
|
|
1149
|
+
{ name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
|
|
1150
|
+
{ name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
|
|
1151
|
+
{ name: "syncDepositEnabled", internalType: "bool", type: "bool" },
|
|
1152
|
+
{ name: "depositMultiplier", internalType: "uint16", type: "uint16" },
|
|
1153
|
+
{ name: "redeemMultiplier", internalType: "uint16", type: "uint16" }
|
|
1154
|
+
],
|
|
1155
|
+
indexed: false
|
|
1156
|
+
}
|
|
1157
|
+
],
|
|
1158
|
+
name: "TokenDetailsSet"
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
type: "event",
|
|
1162
|
+
anonymous: false,
|
|
1163
|
+
inputs: [{ name: "token", internalType: "contract IERC20", type: "address", indexed: true }],
|
|
1164
|
+
name: "TokenRemoved"
|
|
1165
|
+
},
|
|
1166
|
+
{ type: "error", inputs: [], name: "Aera__AsyncDepositDisabled" },
|
|
1167
|
+
{ type: "error", inputs: [], name: "Aera__AsyncRedeemDisabled" },
|
|
1168
|
+
{ type: "error", inputs: [], name: "Aera__AutoPriceSolveNotAllowed" },
|
|
1169
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsVault" },
|
|
1170
|
+
{ type: "error", inputs: [], name: "Aera__DeadlineInFutureAndUnauthorized" },
|
|
1171
|
+
{ type: "error", inputs: [], name: "Aera__DeadlineInPast" },
|
|
1172
|
+
{ type: "error", inputs: [], name: "Aera__DeadlineTooFarInFuture" },
|
|
1173
|
+
{ type: "error", inputs: [], name: "Aera__DepositCapExceeded" },
|
|
1174
|
+
{ type: "error", inputs: [], name: "Aera__DepositCapZero" },
|
|
1175
|
+
{ type: "error", inputs: [], name: "Aera__DepositHashNotFound" },
|
|
1176
|
+
{ type: "error", inputs: [], name: "Aera__DepositMultiplierTooHigh" },
|
|
1177
|
+
{ type: "error", inputs: [], name: "Aera__DepositMultiplierTooLow" },
|
|
1178
|
+
{ type: "error", inputs: [], name: "Aera__FixedPriceSolverTipNotAllowed" },
|
|
1179
|
+
{ type: "error", inputs: [], name: "Aera__HashCollision" },
|
|
1180
|
+
{ type: "error", inputs: [], name: "Aera__HashNotFound" },
|
|
1181
|
+
{ type: "error", inputs: [], name: "Aera__InvalidToken" },
|
|
1182
|
+
{ type: "error", inputs: [], name: "Aera__MaxDepositRefundTimeoutExceeded" },
|
|
1183
|
+
{ type: "error", inputs: [], name: "Aera__MaxTokensInExceeded" },
|
|
1184
|
+
{ type: "error", inputs: [], name: "Aera__MaxTokensInZero" },
|
|
1185
|
+
{ type: "error", inputs: [], name: "Aera__MinTokenOutZero" },
|
|
1186
|
+
{ type: "error", inputs: [], name: "Aera__MinUnitsOutNotMet" },
|
|
1187
|
+
{ type: "error", inputs: [], name: "Aera__MinUnitsOutZero" },
|
|
1188
|
+
{ type: "error", inputs: [], name: "Aera__PriceAndFeeCalculatorVaultPaused" },
|
|
1189
|
+
{ type: "error", inputs: [], name: "Aera__RedeemMultiplierTooHigh" },
|
|
1190
|
+
{ type: "error", inputs: [], name: "Aera__RedeemMultiplierTooLow" },
|
|
1191
|
+
{ type: "error", inputs: [], name: "Aera__RefundPeriodExpired" },
|
|
1192
|
+
{ type: "error", inputs: [], name: "Aera__SyncDepositDisabled" },
|
|
1193
|
+
{ type: "error", inputs: [], name: "Aera__TokenCantBePriced" },
|
|
1194
|
+
{ type: "error", inputs: [], name: "Aera__TokensInZero" },
|
|
1195
|
+
{ type: "error", inputs: [], name: "Aera__Unauthorized" },
|
|
1196
|
+
{ type: "error", inputs: [], name: "Aera__UnitsInZero" },
|
|
1197
|
+
{ type: "error", inputs: [], name: "Aera__UnitsOutZero" },
|
|
1198
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
|
|
1199
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressMultiDepositorVault" },
|
|
1200
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressPriceAndFeeCalculator" },
|
|
1201
|
+
{ type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
|
|
1202
|
+
{
|
|
1203
|
+
type: "error",
|
|
1204
|
+
inputs: [{ name: "token", internalType: "address", type: "address" }],
|
|
1205
|
+
name: "SafeERC20FailedOperation"
|
|
1206
|
+
}
|
|
1207
|
+
];
|
|
1208
|
+
|
|
1209
|
+
// src/evm/abis/provisionerV2.ts
|
|
1210
|
+
var provisionerV2Abi = [
|
|
1211
|
+
{
|
|
1212
|
+
type: "function",
|
|
1213
|
+
inputs: [],
|
|
1214
|
+
name: "SOLVING_GATE_ENABLED",
|
|
1215
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
1216
|
+
stateMutability: "view"
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
type: "function",
|
|
1220
|
+
inputs: [
|
|
1221
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1222
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256" },
|
|
1223
|
+
{ name: "minUnitsOut", internalType: "uint256", type: "uint256" },
|
|
1224
|
+
{ name: "receiver", internalType: "address", type: "address" }
|
|
1225
|
+
],
|
|
1226
|
+
name: "deposit",
|
|
1227
|
+
outputs: [{ name: "unitsOut", internalType: "uint256", type: "uint256" }],
|
|
1228
|
+
stateMutability: "nonpayable"
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
type: "function",
|
|
1232
|
+
inputs: [
|
|
1233
|
+
{ name: "receiver", internalType: "address", type: "address" },
|
|
1234
|
+
{ name: "depositor", internalType: "address", type: "address" }
|
|
1235
|
+
],
|
|
1236
|
+
name: "depositReceiverApprovals",
|
|
1237
|
+
outputs: [{ name: "approved", internalType: "bool", type: "bool" }],
|
|
1238
|
+
stateMutability: "view"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
type: "function",
|
|
1242
|
+
inputs: [
|
|
1243
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1244
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256" },
|
|
1245
|
+
{ name: "minUnitsOut", internalType: "uint256", type: "uint256" },
|
|
1246
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
1247
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
1248
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" },
|
|
1249
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool" },
|
|
1250
|
+
{ name: "receiver", internalType: "address", type: "address" }
|
|
1251
|
+
],
|
|
1252
|
+
name: "requestDeposit",
|
|
1253
|
+
outputs: [{ name: "depositRequestHash", internalType: "bytes32", type: "bytes32" }],
|
|
1254
|
+
stateMutability: "nonpayable"
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
type: "function",
|
|
1258
|
+
inputs: [],
|
|
1259
|
+
name: "getSyncRedeemDetails",
|
|
1260
|
+
outputs: [
|
|
1261
|
+
{ name: "maxPriceAge", internalType: "uint24", type: "uint24" },
|
|
1262
|
+
{ name: "relativeCapBps", internalType: "uint16", type: "uint16" },
|
|
1263
|
+
{ name: "maxDynamicPremiumBps", internalType: "uint16", type: "uint16" },
|
|
1264
|
+
{ name: "epochTimestamp", internalType: "uint32", type: "uint32" },
|
|
1265
|
+
{ name: "absoluteCapNumeraire", internalType: "uint80", type: "uint80" },
|
|
1266
|
+
{ name: "epochRedeemedNumeraire", internalType: "uint80", type: "uint80" }
|
|
1267
|
+
],
|
|
1268
|
+
stateMutability: "view"
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
type: "function",
|
|
1272
|
+
inputs: [],
|
|
1273
|
+
name: "getSyncRedeemEpochState",
|
|
1274
|
+
outputs: [
|
|
1275
|
+
{ name: "epochTimestamp", internalType: "uint256", type: "uint256" },
|
|
1276
|
+
{ name: "epochStartTvlNumeraire", internalType: "uint256", type: "uint256" },
|
|
1277
|
+
{ name: "epochRedeemedNumeraire", internalType: "uint256", type: "uint256" },
|
|
1278
|
+
{ name: "epochCapNumeraire", internalType: "uint256", type: "uint256" }
|
|
1279
|
+
],
|
|
1280
|
+
stateMutability: "view"
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
type: "function",
|
|
1284
|
+
inputs: [{ name: "user", internalType: "address", type: "address" }],
|
|
1285
|
+
name: "userUnitsRefundableUntil",
|
|
1286
|
+
outputs: [{ name: "unitsLockedUntil", internalType: "uint256", type: "uint256" }],
|
|
1287
|
+
stateMutability: "view"
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
type: "function",
|
|
1291
|
+
inputs: [
|
|
1292
|
+
{ name: "depositor", internalType: "address", type: "address" },
|
|
1293
|
+
{ name: "approved", internalType: "bool", type: "bool" }
|
|
1294
|
+
],
|
|
1295
|
+
name: "setDepositReceiverApproval",
|
|
1296
|
+
outputs: [],
|
|
1297
|
+
stateMutability: "nonpayable"
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
type: "function",
|
|
1301
|
+
inputs: [],
|
|
1302
|
+
name: "solvingGate",
|
|
1303
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
1304
|
+
stateMutability: "view"
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
type: "function",
|
|
1308
|
+
inputs: [{ name: "token", internalType: "contract IERC20", type: "address" }],
|
|
1309
|
+
name: "tokensDetails",
|
|
1310
|
+
outputs: [
|
|
1311
|
+
{ name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
|
|
1312
|
+
{ name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
|
|
1313
|
+
{ name: "syncDepositEnabled", internalType: "bool", type: "bool" },
|
|
1314
|
+
{ name: "syncRedeemEnabled", internalType: "bool", type: "bool" },
|
|
1315
|
+
{ name: "asyncDepositMultiplier", internalType: "uint16", type: "uint16" },
|
|
1316
|
+
{ name: "asyncRedeemMultiplier", internalType: "uint16", type: "uint16" },
|
|
1317
|
+
{ name: "syncDepositMultiplier", internalType: "uint16", type: "uint16" },
|
|
1318
|
+
{ name: "syncRedeemMultiplier", internalType: "uint16", type: "uint16" },
|
|
1319
|
+
{
|
|
1320
|
+
name: "pushFundsSubmitDataPointer",
|
|
1321
|
+
internalType: "address",
|
|
1322
|
+
type: "address"
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
name: "pullFundsSubmitDataPointer",
|
|
1326
|
+
internalType: "address",
|
|
1327
|
+
type: "address"
|
|
1328
|
+
}
|
|
1329
|
+
],
|
|
1330
|
+
stateMutability: "view"
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
type: "function",
|
|
1334
|
+
inputs: [
|
|
1335
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1336
|
+
{ name: "unitsIn", internalType: "uint256", type: "uint256" },
|
|
1337
|
+
{ name: "minTokensOut", internalType: "uint256", type: "uint256" },
|
|
1338
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256" },
|
|
1339
|
+
{ name: "deadline", internalType: "uint256", type: "uint256" },
|
|
1340
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256" },
|
|
1341
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool" },
|
|
1342
|
+
{ name: "receiver", internalType: "address", type: "address" }
|
|
1343
|
+
],
|
|
1344
|
+
name: "requestRedeem",
|
|
1345
|
+
outputs: [{ name: "redeemRequestHash", internalType: "bytes32", type: "bytes32" }],
|
|
1346
|
+
stateMutability: "nonpayable"
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
type: "function",
|
|
1350
|
+
inputs: [
|
|
1351
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1352
|
+
{ name: "unitsIn", internalType: "uint256", type: "uint256" },
|
|
1353
|
+
{ name: "minTokensOut", internalType: "uint256", type: "uint256" },
|
|
1354
|
+
{ name: "receiver", internalType: "address", type: "address" }
|
|
1355
|
+
],
|
|
1356
|
+
name: "redeem",
|
|
1357
|
+
outputs: [{ name: "tokensOut", internalType: "uint256", type: "uint256" }],
|
|
1358
|
+
stateMutability: "nonpayable"
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
type: "function",
|
|
1362
|
+
inputs: [
|
|
1363
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1364
|
+
{ name: "tokensOut", internalType: "uint256", type: "uint256" },
|
|
1365
|
+
{ name: "maxUnitsIn", internalType: "uint256", type: "uint256" },
|
|
1366
|
+
{ name: "receiver", internalType: "address", type: "address" }
|
|
1367
|
+
],
|
|
1368
|
+
name: "withdraw",
|
|
1369
|
+
outputs: [{ name: "unitsIn", internalType: "uint256", type: "uint256" }],
|
|
1370
|
+
stateMutability: "nonpayable"
|
|
1371
|
+
},
|
|
1372
|
+
{
|
|
1373
|
+
type: "function",
|
|
1374
|
+
inputs: [{ name: "asyncRequestHash", internalType: "bytes32", type: "bytes32" }],
|
|
1375
|
+
name: "asyncRequestHashes",
|
|
1376
|
+
outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
|
|
1377
|
+
stateMutability: "view"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
type: "function",
|
|
1381
|
+
inputs: [],
|
|
1382
|
+
name: "version",
|
|
1383
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
1384
|
+
stateMutability: "pure"
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
type: "event",
|
|
1388
|
+
inputs: [
|
|
1389
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1390
|
+
{ name: "receiver", internalType: "address", type: "address", indexed: true },
|
|
1391
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1392
|
+
{ name: "tokensIn", internalType: "uint256", type: "uint256", indexed: false },
|
|
1393
|
+
{ name: "minUnitsOut", internalType: "uint256", type: "uint256", indexed: false },
|
|
1394
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
|
|
1395
|
+
{ name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
|
|
1396
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
|
|
1397
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
|
|
1398
|
+
{ name: "depositRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
|
|
1399
|
+
],
|
|
1400
|
+
name: "DepositRequested",
|
|
1401
|
+
anonymous: false
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
type: "event",
|
|
1405
|
+
inputs: [
|
|
1406
|
+
{ name: "receiver", internalType: "address", type: "address", indexed: true },
|
|
1407
|
+
{ name: "depositor", internalType: "address", type: "address", indexed: true },
|
|
1408
|
+
{ name: "approved", internalType: "bool", type: "bool", indexed: false }
|
|
1409
|
+
],
|
|
1410
|
+
name: "DepositReceiverApprovalSet",
|
|
1411
|
+
anonymous: false
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
type: "event",
|
|
1415
|
+
inputs: [
|
|
1416
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1417
|
+
{ name: "receiver", internalType: "address", type: "address", indexed: true },
|
|
1418
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1419
|
+
{ name: "minTokensOut", internalType: "uint256", type: "uint256", indexed: false },
|
|
1420
|
+
{ name: "unitsIn", internalType: "uint256", type: "uint256", indexed: false },
|
|
1421
|
+
{ name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
|
|
1422
|
+
{ name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
|
|
1423
|
+
{ name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
|
|
1424
|
+
{ name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
|
|
1425
|
+
{ name: "redeemRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
|
|
1426
|
+
],
|
|
1427
|
+
name: "RedeemRequested",
|
|
1428
|
+
anonymous: false
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
type: "event",
|
|
1432
|
+
inputs: [
|
|
1433
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
1434
|
+
{ name: "receiver", internalType: "address", type: "address", indexed: true },
|
|
1435
|
+
{ name: "token", internalType: "contract IERC20", type: "address", indexed: true },
|
|
1436
|
+
{ name: "unitsIn", internalType: "uint256", type: "uint256", indexed: false },
|
|
1437
|
+
{ name: "tokensOut", internalType: "uint256", type: "uint256", indexed: false }
|
|
1438
|
+
],
|
|
1439
|
+
name: "Redeemed",
|
|
1440
|
+
anonymous: false
|
|
1441
|
+
},
|
|
1442
|
+
{ type: "error", inputs: [], name: "Aera__AsyncDepositDisabled" },
|
|
1443
|
+
{ type: "error", inputs: [], name: "Aera__AsyncRedeemDisabled" },
|
|
1444
|
+
{ type: "error", inputs: [], name: "Aera__AutoPriceSolveNotAllowed" },
|
|
1445
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotRequestUser" },
|
|
1446
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsVault" },
|
|
1447
|
+
{ type: "error", inputs: [], name: "Aera__CancellationFeeExceedsRequestAmount" },
|
|
1448
|
+
{ type: "error", inputs: [], name: "Aera__DeadlineInFutureAndUnauthorized" },
|
|
1449
|
+
{ type: "error", inputs: [], name: "Aera__DeadlineInPast" },
|
|
1450
|
+
{ type: "error", inputs: [], name: "Aera__DeadlineTooFarInFuture" },
|
|
1451
|
+
{ type: "error", inputs: [], name: "Aera__DepositCancellationDetailsNotZero" },
|
|
1452
|
+
{ type: "error", inputs: [], name: "Aera__DepositCapExceeded" },
|
|
1453
|
+
{ type: "error", inputs: [], name: "Aera__DepositCapZero" },
|
|
1454
|
+
{ type: "error", inputs: [], name: "Aera__DepositHashNotFound" },
|
|
1455
|
+
{ type: "error", inputs: [], name: "Aera__DepositRequestCancellationDisabled" },
|
|
1456
|
+
{ type: "error", inputs: [], name: "Aera__FixedPriceSolverTipNotAllowed" },
|
|
1457
|
+
{ type: "error", inputs: [], name: "Aera__HashCollision" },
|
|
1458
|
+
{ type: "error", inputs: [], name: "Aera__HashNotFound" },
|
|
1459
|
+
{ type: "error", inputs: [], name: "Aera__InvalidToken" },
|
|
1460
|
+
{ type: "error", inputs: [], name: "Aera__MaxDepositRefundTimeoutExceeded" },
|
|
1461
|
+
{ type: "error", inputs: [], name: "Aera__MaxTokensInExceeded" },
|
|
1462
|
+
{ type: "error", inputs: [], name: "Aera__MaxUnitsInExceeded" },
|
|
1463
|
+
{ type: "error", inputs: [], name: "Aera__MinTokensOutNotMet" },
|
|
1464
|
+
{ type: "error", inputs: [], name: "Aera__MinUnitsOutNotMet" },
|
|
1465
|
+
{ type: "error", inputs: [], name: "Aera__MultiplierOutOfRange" },
|
|
1466
|
+
{ type: "error", inputs: [], name: "Aera__PriceAndFeeCalculatorVaultPaused" },
|
|
1467
|
+
{ type: "error", inputs: [], name: "Aera__PullFundsSubmitDataNotSet" },
|
|
1468
|
+
{ type: "error", inputs: [], name: "Aera__ReceiverNotApproved" },
|
|
1469
|
+
{ type: "error", inputs: [], name: "Aera__RedeemCancellationCapNumeraireZero" },
|
|
1470
|
+
{ type: "error", inputs: [], name: "Aera__RedeemCancellationDetailsNotZero" },
|
|
1471
|
+
{ type: "error", inputs: [], name: "Aera__RedeemRequestCancellationDisabled" },
|
|
1472
|
+
{ type: "error", inputs: [], name: "Aera__RefundPeriodExpired" },
|
|
1473
|
+
{ type: "error", inputs: [], name: "Aera__RequestAmountExceedsRefundCap" },
|
|
1474
|
+
{ type: "error", inputs: [], name: "Aera__SolvingGateDisabled" },
|
|
1475
|
+
{ type: "error", inputs: [], name: "Aera__SolvingPaused" },
|
|
1476
|
+
{ type: "error", inputs: [], name: "Aera__SyncDepositDisabled" },
|
|
1477
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemAbsoluteCapNumeraireZero" },
|
|
1478
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemDisabled" },
|
|
1479
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemEpochCapExceeded" },
|
|
1480
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemMaxDynamicPremiumBpsTooHigh" },
|
|
1481
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemMaxPriceAgeExceeded" },
|
|
1482
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemMaxPriceAgeZero" },
|
|
1483
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemNotConfigured" },
|
|
1484
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemRelativeCapBpsTooHigh" },
|
|
1485
|
+
{ type: "error", inputs: [], name: "Aera__SyncRedeemRelativeCapBpsZero" },
|
|
1486
|
+
{ type: "error", inputs: [], name: "Aera__TokenCantBePriced" },
|
|
1487
|
+
{ type: "error", inputs: [], name: "Aera__TokensZero" },
|
|
1488
|
+
{ type: "error", inputs: [], name: "Aera__Unauthorized" },
|
|
1489
|
+
{ type: "error", inputs: [], name: "Aera__UnitsLocked" },
|
|
1490
|
+
{ type: "error", inputs: [], name: "Aera__UnitsZero" },
|
|
1491
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
|
|
1492
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressMultiDepositorVault" },
|
|
1493
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressPriceAndFeeCalculator" },
|
|
1494
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressReceiver" },
|
|
1495
|
+
{ type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
|
|
1496
|
+
{
|
|
1497
|
+
type: "error",
|
|
1498
|
+
inputs: [{ name: "token", internalType: "address", type: "address" }],
|
|
1499
|
+
name: "SafeERC20FailedOperation"
|
|
1500
|
+
}
|
|
1501
|
+
];
|
|
1502
|
+
|
|
1503
|
+
// src/evm/aeraContracts/readOptions.ts
|
|
1504
|
+
function readAtBlock(options = {}) {
|
|
1505
|
+
return options.blockNumber === void 0 ? {} : { blockNumber: options.blockNumber };
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
// src/evm/aeraContracts.ts
|
|
1509
|
+
var contractVersionAbi = [
|
|
1510
|
+
{
|
|
1511
|
+
type: "function",
|
|
1512
|
+
inputs: [],
|
|
1513
|
+
name: "version",
|
|
1514
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
1515
|
+
stateMutability: "view"
|
|
1516
|
+
}
|
|
1517
|
+
];
|
|
1518
|
+
var solvingGateAbi = [
|
|
1519
|
+
{
|
|
1520
|
+
type: "function",
|
|
1521
|
+
inputs: [
|
|
1522
|
+
{ name: "provisioner", internalType: "address", type: "address" },
|
|
1523
|
+
{ name: "token", internalType: "address", type: "address" }
|
|
1524
|
+
],
|
|
1525
|
+
name: "paused",
|
|
1526
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
1527
|
+
stateMutability: "view"
|
|
1528
|
+
}
|
|
1529
|
+
];
|
|
1530
|
+
function requireAeraSyncRedeemRuntime(runtime) {
|
|
1531
|
+
if (runtime.provisioner.version !== ContractVersion.V2) {
|
|
1532
|
+
throw new UnsupportedFeatureError("Aera: sync redeem requires a V2 provisioner");
|
|
1533
|
+
}
|
|
1534
|
+
if (runtime.feeCalculator.version !== ContractVersion.V2) {
|
|
1535
|
+
throw new UnsupportedFeatureError("Aera: sync redeem requires a V2 price and fee calculator");
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
function applySlippageDown(amount, slippageBps) {
|
|
1539
|
+
return amount * (MAX_BPS - BigInt(slippageBps)) / MAX_BPS;
|
|
1540
|
+
}
|
|
1541
|
+
function applySlippageUp(amount, slippageBps) {
|
|
1542
|
+
return (amount * (MAX_BPS + BigInt(slippageBps)) + MAX_BPS - 1n) / MAX_BPS;
|
|
1543
|
+
}
|
|
1544
|
+
function isVersionUnavailableError(error) {
|
|
1545
|
+
if (!(error instanceof ContractFunctionExecutionError) || error.functionName !== "version") {
|
|
1546
|
+
return false;
|
|
1547
|
+
}
|
|
1548
|
+
if (error.cause instanceof ContractFunctionRevertedError) {
|
|
1549
|
+
const hasDecodedError = error.cause.signature !== void 0 || error.cause.data !== void 0 || error.cause.raw !== void 0 && error.cause.raw !== "0x";
|
|
1550
|
+
return !hasDecodedError && (error.cause.reason === void 0 || error.cause.reason === "execution reverted");
|
|
1551
|
+
}
|
|
1552
|
+
return error.cause instanceof ContractFunctionZeroDataError;
|
|
1553
|
+
}
|
|
1554
|
+
function getMultiDepositorVault(client, vaultAddress) {
|
|
1555
|
+
return getContract({
|
|
1556
|
+
address: vaultAddress,
|
|
1557
|
+
abi: multiDepositorVaultAbi,
|
|
1558
|
+
client
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
var latestContractVersions = /* @__PURE__ */ new WeakMap();
|
|
1562
|
+
async function resolveContractVersion(client, address, options = {}) {
|
|
1563
|
+
if (options.blockNumber !== void 0) return readContractVersion(client, address, options);
|
|
1564
|
+
let versions = latestContractVersions.get(client);
|
|
1565
|
+
if (versions === void 0) {
|
|
1566
|
+
versions = /* @__PURE__ */ new Map();
|
|
1567
|
+
latestContractVersions.set(client, versions);
|
|
1568
|
+
}
|
|
1569
|
+
const key = address.toLowerCase();
|
|
1570
|
+
const cached = versions.get(key);
|
|
1571
|
+
if (cached !== void 0) return cached;
|
|
1572
|
+
const version = await readContractVersion(client, address, options);
|
|
1573
|
+
versions.set(key, version);
|
|
1574
|
+
return version;
|
|
1575
|
+
}
|
|
1576
|
+
async function readContractVersion(client, address, options) {
|
|
1577
|
+
try {
|
|
1578
|
+
const versionString = await client.readContract({
|
|
1579
|
+
address,
|
|
1580
|
+
abi: contractVersionAbi,
|
|
1581
|
+
functionName: "version",
|
|
1582
|
+
...readAtBlock(options)
|
|
1583
|
+
});
|
|
1584
|
+
if (!/^[12]\./.test(versionString)) {
|
|
1585
|
+
throw new UnsupportedFeatureError(`Aera: unsupported contract version ${versionString}`);
|
|
1586
|
+
}
|
|
1587
|
+
return versionString.startsWith("2.") ? ContractVersion.V2 : ContractVersion.V1;
|
|
1588
|
+
} catch (error) {
|
|
1589
|
+
if (!isVersionUnavailableError(error)) throw error;
|
|
1590
|
+
const code = await client.getCode({ address, ...readAtBlock(options) });
|
|
1591
|
+
if (code === void 0 || code === "0x") throw error;
|
|
1592
|
+
return ContractVersion.V1;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
async function resolveAeraRuntimeContracts(client, vault, options = {}) {
|
|
1596
|
+
if (vault.vaultType !== "multi-depositor") {
|
|
1597
|
+
throw new UnimplementedFeatureError("Aera: single depositor vaults");
|
|
1598
|
+
}
|
|
1599
|
+
const [provisionerAddress, feeCalculatorAddress] = await Promise.all([
|
|
1600
|
+
client.readContract({
|
|
1601
|
+
address: vault.vaultAddress,
|
|
1602
|
+
abi: multiDepositorVaultAbi,
|
|
1603
|
+
functionName: "provisioner",
|
|
1604
|
+
...readAtBlock(options)
|
|
1605
|
+
}),
|
|
1606
|
+
client.readContract({
|
|
1607
|
+
address: vault.vaultAddress,
|
|
1608
|
+
abi: multiDepositorVaultAbi,
|
|
1609
|
+
functionName: "feeCalculator",
|
|
1610
|
+
...readAtBlock(options)
|
|
1611
|
+
})
|
|
1612
|
+
]);
|
|
1613
|
+
if (provisionerAddress === zeroAddress) {
|
|
1614
|
+
throw new UnsupportedFeatureError("Aera: vault without provisioner");
|
|
1615
|
+
}
|
|
1616
|
+
if (feeCalculatorAddress === zeroAddress) {
|
|
1617
|
+
throw new UnsupportedFeatureError("Aera: vault without price and fee calculator");
|
|
1618
|
+
}
|
|
1619
|
+
const [provisionerVersion, feeCalculatorVersion] = await Promise.all([
|
|
1620
|
+
resolveContractVersion(client, provisionerAddress, options),
|
|
1621
|
+
resolveContractVersion(client, feeCalculatorAddress, options)
|
|
1622
|
+
]);
|
|
1623
|
+
return {
|
|
1624
|
+
provisioner: {
|
|
1625
|
+
address: provisionerAddress,
|
|
1626
|
+
version: provisionerVersion
|
|
1627
|
+
},
|
|
1628
|
+
feeCalculator: {
|
|
1629
|
+
address: feeCalculatorAddress,
|
|
1630
|
+
version: feeCalculatorVersion
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
async function resolveAeraTokenModeSupport(client, runtime, token, options = {}) {
|
|
1635
|
+
if (runtime.provisioner.version === ContractVersion.V2) {
|
|
1636
|
+
const tokenDetailsPromise = client.readContract({
|
|
1637
|
+
address: runtime.provisioner.address,
|
|
1638
|
+
abi: provisionerV2Abi,
|
|
1639
|
+
functionName: "tokensDetails",
|
|
1640
|
+
args: [token],
|
|
1641
|
+
...readAtBlock(options)
|
|
1642
|
+
});
|
|
1643
|
+
if (options.includeSyncModes === false) {
|
|
1644
|
+
const tokenDetails3 = await tokenDetailsPromise;
|
|
1645
|
+
return {
|
|
1646
|
+
asyncDeposit: Boolean(tokenDetails3[0]),
|
|
1647
|
+
asyncRedeem: Boolean(tokenDetails3[1]),
|
|
1648
|
+
syncDeposit: false,
|
|
1649
|
+
syncRedeem: false
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
const [tokenDetails2, solvingGateEnabled, solvingGate] = await Promise.all([
|
|
1653
|
+
tokenDetailsPromise,
|
|
1654
|
+
client.readContract({
|
|
1655
|
+
address: runtime.provisioner.address,
|
|
1656
|
+
abi: provisionerV2Abi,
|
|
1657
|
+
functionName: "SOLVING_GATE_ENABLED",
|
|
1658
|
+
...readAtBlock(options)
|
|
1659
|
+
}),
|
|
1660
|
+
client.readContract({
|
|
1661
|
+
address: runtime.provisioner.address,
|
|
1662
|
+
abi: provisionerV2Abi,
|
|
1663
|
+
functionName: "solvingGate",
|
|
1664
|
+
...readAtBlock(options)
|
|
1665
|
+
})
|
|
1666
|
+
]);
|
|
1667
|
+
const solvingPaused = solvingGateEnabled && solvingGate !== zeroAddress ? await client.readContract({
|
|
1668
|
+
address: solvingGate,
|
|
1669
|
+
abi: solvingGateAbi,
|
|
1670
|
+
functionName: "paused",
|
|
1671
|
+
args: [runtime.provisioner.address, token],
|
|
1672
|
+
...readAtBlock(options)
|
|
1673
|
+
}) : false;
|
|
1674
|
+
return {
|
|
1675
|
+
asyncDeposit: Boolean(tokenDetails2[0]),
|
|
1676
|
+
asyncRedeem: Boolean(tokenDetails2[1]),
|
|
1677
|
+
syncDeposit: Boolean(tokenDetails2[2]) && !solvingPaused,
|
|
1678
|
+
syncRedeem: Boolean(tokenDetails2[3]) && !solvingPaused && runtime.feeCalculator.version === ContractVersion.V2
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
const tokenDetails = await client.readContract({
|
|
1682
|
+
address: runtime.provisioner.address,
|
|
1683
|
+
abi: provisionerAbi,
|
|
1684
|
+
functionName: "tokensDetails",
|
|
1685
|
+
args: [token],
|
|
1686
|
+
...readAtBlock(options)
|
|
1687
|
+
});
|
|
1688
|
+
return {
|
|
1689
|
+
asyncDeposit: Boolean(tokenDetails[0]),
|
|
1690
|
+
asyncRedeem: Boolean(tokenDetails[1]),
|
|
1691
|
+
syncDeposit: false,
|
|
1692
|
+
syncRedeem: false
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
// src/evm/abis/priceAndFeeCalculator.ts
|
|
1697
|
+
var priceAndFeeCalculatorAbi = [
|
|
1698
|
+
{
|
|
1699
|
+
type: "constructor",
|
|
1700
|
+
inputs: [
|
|
1701
|
+
{ name: "numeraire", internalType: "contract IERC20", type: "address" },
|
|
1702
|
+
{ name: "oracleRegistry", internalType: "contract IOracleRegistry", type: "address" },
|
|
1703
|
+
{ name: "owner_", internalType: "address", type: "address" },
|
|
1704
|
+
{ name: "authority_", internalType: "contract Authority", type: "address" }
|
|
1705
|
+
],
|
|
1706
|
+
stateMutability: "nonpayable"
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
type: "function",
|
|
1710
|
+
inputs: [],
|
|
1711
|
+
name: "NUMERAIRE",
|
|
1712
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
1713
|
+
stateMutability: "view"
|
|
1714
|
+
},
|
|
1715
|
+
{
|
|
1716
|
+
type: "function",
|
|
1717
|
+
inputs: [],
|
|
1718
|
+
name: "ORACLE_REGISTRY",
|
|
1719
|
+
outputs: [{ name: "", internalType: "contract IOracleRegistry", type: "address" }],
|
|
1720
|
+
stateMutability: "view"
|
|
1721
|
+
},
|
|
1722
|
+
{
|
|
1723
|
+
type: "function",
|
|
1724
|
+
inputs: [],
|
|
1725
|
+
name: "acceptOwnership",
|
|
1726
|
+
outputs: [],
|
|
1727
|
+
stateMutability: "nonpayable"
|
|
1728
|
+
},
|
|
1729
|
+
{
|
|
1730
|
+
type: "function",
|
|
1731
|
+
inputs: [],
|
|
1732
|
+
name: "authority",
|
|
1733
|
+
outputs: [{ name: "", internalType: "contract Authority", type: "address" }],
|
|
1734
|
+
stateMutability: "view"
|
|
1735
|
+
},
|
|
1736
|
+
{
|
|
1737
|
+
type: "function",
|
|
1738
|
+
inputs: [{ name: "feeTokenBalance", internalType: "uint256", type: "uint256" }],
|
|
1739
|
+
name: "claimFees",
|
|
1740
|
+
outputs: [
|
|
1741
|
+
{ name: "", internalType: "uint256", type: "uint256" },
|
|
1742
|
+
{ name: "", internalType: "uint256", type: "uint256" },
|
|
1743
|
+
{ name: "", internalType: "address", type: "address" }
|
|
1744
|
+
],
|
|
1745
|
+
stateMutability: "nonpayable"
|
|
1746
|
+
},
|
|
1747
|
+
{
|
|
1748
|
+
type: "function",
|
|
1749
|
+
inputs: [{ name: "feeTokenBalance", internalType: "uint256", type: "uint256" }],
|
|
1750
|
+
name: "claimProtocolFees",
|
|
1751
|
+
outputs: [
|
|
1752
|
+
{ name: "", internalType: "uint256", type: "uint256" },
|
|
1753
|
+
{ name: "", internalType: "address", type: "address" }
|
|
1754
|
+
],
|
|
1755
|
+
stateMutability: "nonpayable"
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
type: "function",
|
|
1759
|
+
inputs: [
|
|
1760
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1761
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1762
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" }
|
|
1763
|
+
],
|
|
1764
|
+
name: "convertTokenToUnits",
|
|
1765
|
+
outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
|
|
1766
|
+
stateMutability: "view"
|
|
1767
|
+
},
|
|
1768
|
+
{
|
|
1769
|
+
type: "function",
|
|
1770
|
+
inputs: [
|
|
1771
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1772
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1773
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" },
|
|
1774
|
+
{ name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
|
|
1775
|
+
],
|
|
1776
|
+
name: "convertTokenToUnitsIfActive",
|
|
1777
|
+
outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
|
|
1778
|
+
stateMutability: "view"
|
|
1779
|
+
},
|
|
1780
|
+
{
|
|
1781
|
+
type: "function",
|
|
1782
|
+
inputs: [
|
|
1783
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1784
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" }
|
|
1785
|
+
],
|
|
1786
|
+
name: "convertUnitsToNumeraire",
|
|
1787
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
1788
|
+
stateMutability: "view"
|
|
1789
|
+
},
|
|
1790
|
+
{
|
|
1791
|
+
type: "function",
|
|
1792
|
+
inputs: [
|
|
1793
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1794
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1795
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" }
|
|
1796
|
+
],
|
|
1797
|
+
name: "convertUnitsToToken",
|
|
1798
|
+
outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
|
|
1799
|
+
stateMutability: "view"
|
|
1800
|
+
},
|
|
1801
|
+
{
|
|
1802
|
+
type: "function",
|
|
1803
|
+
inputs: [
|
|
1804
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1805
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
1806
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" },
|
|
1807
|
+
{ name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
|
|
1808
|
+
],
|
|
1809
|
+
name: "convertUnitsToTokenIfActive",
|
|
1810
|
+
outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
|
|
1811
|
+
stateMutability: "view"
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
type: "function",
|
|
1815
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
1816
|
+
name: "getVaultState",
|
|
1817
|
+
outputs: [
|
|
1818
|
+
{
|
|
1819
|
+
name: "",
|
|
1820
|
+
internalType: "struct VaultPriceState",
|
|
1821
|
+
type: "tuple",
|
|
1822
|
+
components: [
|
|
1823
|
+
{ name: "paused", internalType: "bool", type: "bool" },
|
|
1824
|
+
{ name: "maxPriceAge", internalType: "uint8", type: "uint8" },
|
|
1825
|
+
{ name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16" },
|
|
1826
|
+
{ name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16" },
|
|
1827
|
+
{ name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16" },
|
|
1828
|
+
{ name: "maxUpdateDelayDays", internalType: "uint8", type: "uint8" },
|
|
1829
|
+
{ name: "timestamp", internalType: "uint32", type: "uint32" },
|
|
1830
|
+
{ name: "accrualLag", internalType: "uint24", type: "uint24" },
|
|
1831
|
+
{ name: "unitPrice", internalType: "uint128", type: "uint128" },
|
|
1832
|
+
{ name: "highestPrice", internalType: "uint128", type: "uint128" },
|
|
1833
|
+
{ name: "lastTotalSupply", internalType: "uint128", type: "uint128" }
|
|
1834
|
+
]
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
name: "",
|
|
1838
|
+
internalType: "struct VaultAccruals",
|
|
1839
|
+
type: "tuple",
|
|
1840
|
+
components: [
|
|
1841
|
+
{
|
|
1842
|
+
name: "fees",
|
|
1843
|
+
internalType: "struct Fee",
|
|
1844
|
+
type: "tuple",
|
|
1845
|
+
components: [
|
|
1846
|
+
{ name: "tvl", internalType: "uint16", type: "uint16" },
|
|
1847
|
+
{ name: "performance", internalType: "uint16", type: "uint16" }
|
|
1848
|
+
]
|
|
1849
|
+
},
|
|
1850
|
+
{ name: "accruedFees", internalType: "uint112", type: "uint112" },
|
|
1851
|
+
{ name: "accruedProtocolFees", internalType: "uint112", type: "uint112" }
|
|
1852
|
+
]
|
|
1853
|
+
}
|
|
1854
|
+
],
|
|
1855
|
+
stateMutability: "view"
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
type: "function",
|
|
1859
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
1860
|
+
name: "getVaultsPriceAge",
|
|
1861
|
+
outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
|
|
1862
|
+
stateMutability: "view"
|
|
1863
|
+
},
|
|
1864
|
+
{
|
|
1865
|
+
type: "function",
|
|
1866
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
1867
|
+
name: "isVaultPaused",
|
|
1868
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
1869
|
+
stateMutability: "view"
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
type: "function",
|
|
1873
|
+
inputs: [],
|
|
1874
|
+
name: "owner",
|
|
1875
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
1876
|
+
stateMutability: "view"
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
type: "function",
|
|
1880
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
1881
|
+
name: "pauseVault",
|
|
1882
|
+
outputs: [],
|
|
1883
|
+
stateMutability: "nonpayable"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
type: "function",
|
|
1887
|
+
inputs: [],
|
|
1888
|
+
name: "pendingOwner",
|
|
1889
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
1890
|
+
stateMutability: "view"
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
type: "function",
|
|
1894
|
+
inputs: [
|
|
1895
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1896
|
+
{ name: "feeTokenBalance", internalType: "uint256", type: "uint256" }
|
|
1897
|
+
],
|
|
1898
|
+
name: "previewFees",
|
|
1899
|
+
outputs: [
|
|
1900
|
+
{ name: "", internalType: "uint256", type: "uint256" },
|
|
1901
|
+
{ name: "", internalType: "uint256", type: "uint256" }
|
|
1902
|
+
],
|
|
1903
|
+
stateMutability: "view"
|
|
1904
|
+
},
|
|
1905
|
+
{
|
|
1906
|
+
type: "function",
|
|
1907
|
+
inputs: [],
|
|
1908
|
+
name: "protocolFeeRecipient",
|
|
1909
|
+
outputs: [{ name: "", internalType: "address", type: "address" }],
|
|
1910
|
+
stateMutability: "view"
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
type: "function",
|
|
1914
|
+
inputs: [],
|
|
1915
|
+
name: "protocolFees",
|
|
1916
|
+
outputs: [
|
|
1917
|
+
{ name: "tvl", internalType: "uint16", type: "uint16" },
|
|
1918
|
+
{ name: "performance", internalType: "uint16", type: "uint16" }
|
|
1919
|
+
],
|
|
1920
|
+
stateMutability: "view"
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
type: "function",
|
|
1924
|
+
inputs: [],
|
|
1925
|
+
name: "registerVault",
|
|
1926
|
+
outputs: [],
|
|
1927
|
+
stateMutability: "nonpayable"
|
|
1928
|
+
},
|
|
1929
|
+
{
|
|
1930
|
+
type: "function",
|
|
1931
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
1932
|
+
name: "resetHighestPrice",
|
|
1933
|
+
outputs: [],
|
|
1934
|
+
stateMutability: "nonpayable"
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
type: "function",
|
|
1938
|
+
inputs: [{ name: "newAuthority", internalType: "contract Authority", type: "address" }],
|
|
1939
|
+
name: "setAuthority",
|
|
1940
|
+
outputs: [],
|
|
1941
|
+
stateMutability: "nonpayable"
|
|
1942
|
+
},
|
|
1943
|
+
{
|
|
1944
|
+
type: "function",
|
|
1945
|
+
inputs: [
|
|
1946
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1947
|
+
{ name: "price", internalType: "uint128", type: "uint128" },
|
|
1948
|
+
{ name: "timestamp", internalType: "uint32", type: "uint32" }
|
|
1949
|
+
],
|
|
1950
|
+
name: "setInitialPrice",
|
|
1951
|
+
outputs: [],
|
|
1952
|
+
stateMutability: "nonpayable"
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
type: "function",
|
|
1956
|
+
inputs: [{ name: "feeRecipient", internalType: "address", type: "address" }],
|
|
1957
|
+
name: "setProtocolFeeRecipient",
|
|
1958
|
+
outputs: [],
|
|
1959
|
+
stateMutability: "nonpayable"
|
|
1960
|
+
},
|
|
1961
|
+
{
|
|
1962
|
+
type: "function",
|
|
1963
|
+
inputs: [
|
|
1964
|
+
{ name: "tvl", internalType: "uint16", type: "uint16" },
|
|
1965
|
+
{ name: "performance", internalType: "uint16", type: "uint16" }
|
|
1966
|
+
],
|
|
1967
|
+
name: "setProtocolFees",
|
|
1968
|
+
outputs: [],
|
|
1969
|
+
stateMutability: "nonpayable"
|
|
1970
|
+
},
|
|
1971
|
+
{
|
|
1972
|
+
type: "function",
|
|
1973
|
+
inputs: [
|
|
1974
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1975
|
+
{ name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16" },
|
|
1976
|
+
{ name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16" },
|
|
1977
|
+
{ name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16" },
|
|
1978
|
+
{ name: "maxPriceAge", internalType: "uint8", type: "uint8" },
|
|
1979
|
+
{ name: "maxUpdateDelayDays", internalType: "uint8", type: "uint8" }
|
|
1980
|
+
],
|
|
1981
|
+
name: "setThresholds",
|
|
1982
|
+
outputs: [],
|
|
1983
|
+
stateMutability: "nonpayable"
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
type: "function",
|
|
1987
|
+
inputs: [
|
|
1988
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
1989
|
+
{ name: "price", internalType: "uint128", type: "uint128" },
|
|
1990
|
+
{ name: "timestamp", internalType: "uint32", type: "uint32" }
|
|
1991
|
+
],
|
|
1992
|
+
name: "setUnitPrice",
|
|
1993
|
+
outputs: [],
|
|
1994
|
+
stateMutability: "nonpayable"
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
type: "function",
|
|
1998
|
+
inputs: [
|
|
1999
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2000
|
+
{ name: "accountant", internalType: "address", type: "address" }
|
|
2001
|
+
],
|
|
2002
|
+
name: "setVaultAccountant",
|
|
2003
|
+
outputs: [],
|
|
2004
|
+
stateMutability: "nonpayable"
|
|
2005
|
+
},
|
|
2006
|
+
{
|
|
2007
|
+
type: "function",
|
|
2008
|
+
inputs: [
|
|
2009
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2010
|
+
{ name: "tvl", internalType: "uint16", type: "uint16" },
|
|
2011
|
+
{ name: "performance", internalType: "uint16", type: "uint16" }
|
|
2012
|
+
],
|
|
2013
|
+
name: "setVaultFees",
|
|
2014
|
+
outputs: [],
|
|
2015
|
+
stateMutability: "nonpayable"
|
|
2016
|
+
},
|
|
2017
|
+
{
|
|
2018
|
+
type: "function",
|
|
2019
|
+
inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
|
|
2020
|
+
name: "transferOwnership",
|
|
2021
|
+
outputs: [],
|
|
2022
|
+
stateMutability: "nonpayable"
|
|
2023
|
+
},
|
|
2024
|
+
{
|
|
2025
|
+
type: "function",
|
|
2026
|
+
inputs: [
|
|
2027
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2028
|
+
{ name: "price", internalType: "uint128", type: "uint128" },
|
|
2029
|
+
{ name: "timestamp", internalType: "uint32", type: "uint32" }
|
|
2030
|
+
],
|
|
2031
|
+
name: "unpauseVault",
|
|
2032
|
+
outputs: [],
|
|
2033
|
+
stateMutability: "nonpayable"
|
|
2034
|
+
},
|
|
2035
|
+
{
|
|
2036
|
+
type: "function",
|
|
2037
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
2038
|
+
name: "vaultAccountant",
|
|
2039
|
+
outputs: [{ name: "accountant", internalType: "address", type: "address" }],
|
|
2040
|
+
stateMutability: "view"
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
type: "event",
|
|
2044
|
+
anonymous: false,
|
|
2045
|
+
inputs: [
|
|
2046
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
2047
|
+
{ name: "newAuthority", internalType: "contract Authority", type: "address", indexed: true }
|
|
2048
|
+
],
|
|
2049
|
+
name: "AuthorityUpdated"
|
|
2050
|
+
},
|
|
2051
|
+
{
|
|
2052
|
+
type: "event",
|
|
2053
|
+
anonymous: false,
|
|
2054
|
+
inputs: [
|
|
2055
|
+
{ name: "vault", internalType: "address", type: "address", indexed: true },
|
|
2056
|
+
{ name: "newHighestPrice", internalType: "uint128", type: "uint128", indexed: false }
|
|
2057
|
+
],
|
|
2058
|
+
name: "HighestPriceReset"
|
|
2059
|
+
},
|
|
2060
|
+
{
|
|
2061
|
+
type: "event",
|
|
2062
|
+
anonymous: false,
|
|
2063
|
+
inputs: [
|
|
2064
|
+
{ name: "previousOwner", internalType: "address", type: "address", indexed: true },
|
|
2065
|
+
{ name: "newOwner", internalType: "address", type: "address", indexed: true }
|
|
2066
|
+
],
|
|
2067
|
+
name: "OwnershipTransferStarted"
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
type: "event",
|
|
2071
|
+
anonymous: false,
|
|
2072
|
+
inputs: [
|
|
2073
|
+
{ name: "user", internalType: "address", type: "address", indexed: true },
|
|
2074
|
+
{ name: "newOwner", internalType: "address", type: "address", indexed: true }
|
|
2075
|
+
],
|
|
2076
|
+
name: "OwnershipTransferred"
|
|
2077
|
+
},
|
|
2078
|
+
{
|
|
2079
|
+
type: "event",
|
|
2080
|
+
anonymous: false,
|
|
2081
|
+
inputs: [{ name: "feeRecipient", internalType: "address", type: "address", indexed: true }],
|
|
2082
|
+
name: "ProtocolFeeRecipientSet"
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
type: "event",
|
|
2086
|
+
anonymous: false,
|
|
2087
|
+
inputs: [
|
|
2088
|
+
{ name: "tvlFee", internalType: "uint16", type: "uint16", indexed: false },
|
|
2089
|
+
{ name: "performanceFee", internalType: "uint16", type: "uint16", indexed: false }
|
|
2090
|
+
],
|
|
2091
|
+
name: "ProtocolFeesSet"
|
|
2092
|
+
},
|
|
2093
|
+
{
|
|
2094
|
+
type: "event",
|
|
2095
|
+
anonymous: false,
|
|
2096
|
+
inputs: [
|
|
2097
|
+
{ name: "vault", internalType: "address", type: "address", indexed: true },
|
|
2098
|
+
{ name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16", indexed: false },
|
|
2099
|
+
{ name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16", indexed: false },
|
|
2100
|
+
{ name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16", indexed: false },
|
|
2101
|
+
{ name: "maxPriceAge", internalType: "uint8", type: "uint8", indexed: false }
|
|
2102
|
+
],
|
|
2103
|
+
name: "ThresholdsSet"
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
type: "event",
|
|
2107
|
+
anonymous: false,
|
|
2108
|
+
inputs: [
|
|
2109
|
+
{ name: "vault", internalType: "address", type: "address", indexed: true },
|
|
2110
|
+
{ name: "price", internalType: "uint128", type: "uint128", indexed: false },
|
|
2111
|
+
{ name: "timestamp", internalType: "uint32", type: "uint32", indexed: false }
|
|
2112
|
+
],
|
|
2113
|
+
name: "UnitPriceUpdated"
|
|
2114
|
+
},
|
|
2115
|
+
{
|
|
2116
|
+
type: "event",
|
|
2117
|
+
anonymous: false,
|
|
2118
|
+
inputs: [
|
|
2119
|
+
{ name: "vault", internalType: "address", type: "address", indexed: false },
|
|
2120
|
+
{ name: "accountant", internalType: "address", type: "address", indexed: false }
|
|
2121
|
+
],
|
|
2122
|
+
name: "VaultAccountantSet"
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
type: "event",
|
|
2126
|
+
anonymous: false,
|
|
2127
|
+
inputs: [
|
|
2128
|
+
{ name: "vault", internalType: "address", type: "address", indexed: true },
|
|
2129
|
+
{ name: "tvlFee", internalType: "uint16", type: "uint16", indexed: false },
|
|
2130
|
+
{ name: "performanceFee", internalType: "uint16", type: "uint16", indexed: false }
|
|
2131
|
+
],
|
|
2132
|
+
name: "VaultFeesSet"
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
type: "event",
|
|
2136
|
+
anonymous: false,
|
|
2137
|
+
inputs: [
|
|
2138
|
+
{ name: "vault", internalType: "address", type: "address", indexed: true },
|
|
2139
|
+
{ name: "paused", internalType: "bool", type: "bool", indexed: false }
|
|
2140
|
+
],
|
|
2141
|
+
name: "VaultPausedChanged"
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
type: "event",
|
|
2145
|
+
anonymous: false,
|
|
2146
|
+
inputs: [{ name: "vault", internalType: "address", type: "address", indexed: true }],
|
|
2147
|
+
name: "VaultRegistered"
|
|
2148
|
+
},
|
|
2149
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotAuthorized" },
|
|
2150
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotVaultAccountant" },
|
|
2151
|
+
{ type: "error", inputs: [], name: "Aera__CallerIsNotVaultOwner" },
|
|
2152
|
+
{ type: "error", inputs: [], name: "Aera__CurrentPriceAboveHighestPrice" },
|
|
2153
|
+
{ type: "error", inputs: [], name: "Aera__InvalidMaxPriceAge" },
|
|
2154
|
+
{ type: "error", inputs: [], name: "Aera__InvalidMaxPriceToleranceRatio" },
|
|
2155
|
+
{ type: "error", inputs: [], name: "Aera__InvalidMaxUpdateDelayDays" },
|
|
2156
|
+
{ type: "error", inputs: [], name: "Aera__InvalidMinPriceToleranceRatio" },
|
|
2157
|
+
{ type: "error", inputs: [], name: "Aera__InvalidPrice" },
|
|
2158
|
+
{ type: "error", inputs: [], name: "Aera__PerformanceFeeTooHigh" },
|
|
2159
|
+
{ type: "error", inputs: [], name: "Aera__StalePrice" },
|
|
2160
|
+
{ type: "error", inputs: [], name: "Aera__ThresholdNotSet" },
|
|
2161
|
+
{ type: "error", inputs: [], name: "Aera__TimestampCantBeInFuture" },
|
|
2162
|
+
{ type: "error", inputs: [], name: "Aera__TimestampMismatch" },
|
|
2163
|
+
{ type: "error", inputs: [], name: "Aera__TimestampMustBeAfterLastUpdate" },
|
|
2164
|
+
{ type: "error", inputs: [], name: "Aera__TvlFeeTooHigh" },
|
|
2165
|
+
{ type: "error", inputs: [], name: "Aera__Unauthorized" },
|
|
2166
|
+
{ type: "error", inputs: [], name: "Aera__UnitPriceMismatch" },
|
|
2167
|
+
{ type: "error", inputs: [], name: "Aera__VaultAlreadyInitialized" },
|
|
2168
|
+
{ type: "error", inputs: [], name: "Aera__VaultAlreadyRegistered" },
|
|
2169
|
+
{ type: "error", inputs: [], name: "Aera__VaultNotInitialized" },
|
|
2170
|
+
{ type: "error", inputs: [], name: "Aera__VaultNotPaused" },
|
|
2171
|
+
{ type: "error", inputs: [], name: "Aera__VaultNotRegistered" },
|
|
2172
|
+
{ type: "error", inputs: [], name: "Aera__VaultPaused" },
|
|
2173
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
|
|
2174
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressNumeraire" },
|
|
2175
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressOracleRegistry" },
|
|
2176
|
+
{ type: "error", inputs: [], name: "Aera__ZeroAddressProtocolFeeRecipient" },
|
|
2177
|
+
{
|
|
2178
|
+
type: "error",
|
|
2179
|
+
inputs: [
|
|
2180
|
+
{ name: "bits", internalType: "uint8", type: "uint8" },
|
|
2181
|
+
{ name: "value", internalType: "uint256", type: "uint256" }
|
|
2182
|
+
],
|
|
2183
|
+
name: "SafeCastOverflowedUintDowncast"
|
|
2184
|
+
}
|
|
2185
|
+
];
|
|
2186
|
+
|
|
2187
|
+
// src/evm/abis/priceAndFeeCalculatorV2.ts
|
|
2188
|
+
var priceAndFeeCalculatorV2Abi = [
|
|
2189
|
+
{
|
|
2190
|
+
type: "function",
|
|
2191
|
+
inputs: [
|
|
2192
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2193
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
2194
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" }
|
|
2195
|
+
],
|
|
2196
|
+
name: "convertTokenToUnits",
|
|
2197
|
+
outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
|
|
2198
|
+
stateMutability: "view"
|
|
2199
|
+
},
|
|
2200
|
+
{
|
|
2201
|
+
type: "function",
|
|
2202
|
+
inputs: [
|
|
2203
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2204
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
2205
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" },
|
|
2206
|
+
{ name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
|
|
2207
|
+
],
|
|
2208
|
+
name: "convertTokenToUnitsIfActive",
|
|
2209
|
+
outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
|
|
2210
|
+
stateMutability: "view"
|
|
2211
|
+
},
|
|
2212
|
+
{
|
|
2213
|
+
type: "function",
|
|
2214
|
+
inputs: [
|
|
2215
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2216
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
2217
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" }
|
|
2218
|
+
],
|
|
2219
|
+
name: "convertUnitsToToken",
|
|
2220
|
+
outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
|
|
2221
|
+
stateMutability: "view"
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
type: "function",
|
|
2225
|
+
inputs: [
|
|
2226
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2227
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
2228
|
+
{ name: "unitsAmount", internalType: "uint256", type: "uint256" },
|
|
2229
|
+
{ name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
|
|
2230
|
+
],
|
|
2231
|
+
name: "convertUnitsToTokenIfActive",
|
|
2232
|
+
outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
|
|
2233
|
+
stateMutability: "view"
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
type: "function",
|
|
2237
|
+
inputs: [
|
|
2238
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2239
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
2240
|
+
{ name: "tokenAmount", internalType: "uint256", type: "uint256" }
|
|
2241
|
+
],
|
|
2242
|
+
name: "convertTokenToNumeraire",
|
|
2243
|
+
outputs: [{ name: "numeraireAmount", internalType: "uint256", type: "uint256" }],
|
|
2244
|
+
stateMutability: "view"
|
|
2245
|
+
},
|
|
2246
|
+
{
|
|
2247
|
+
type: "function",
|
|
2248
|
+
inputs: [
|
|
2249
|
+
{ name: "vault", internalType: "address", type: "address" },
|
|
2250
|
+
{ name: "token", internalType: "contract IERC20", type: "address" },
|
|
2251
|
+
{ name: "numeraireAmount", internalType: "uint256", type: "uint256" }
|
|
2252
|
+
],
|
|
2253
|
+
name: "convertNumeraireToToken",
|
|
2254
|
+
outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
|
|
2255
|
+
stateMutability: "view"
|
|
2256
|
+
},
|
|
2257
|
+
{
|
|
2258
|
+
type: "function",
|
|
2259
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
2260
|
+
name: "getAnchorTimestamp",
|
|
2261
|
+
outputs: [{ name: "timestamp", internalType: "uint32", type: "uint32" }],
|
|
2262
|
+
stateMutability: "view"
|
|
2263
|
+
},
|
|
2264
|
+
{
|
|
2265
|
+
type: "function",
|
|
2266
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
2267
|
+
name: "getVaultState",
|
|
2268
|
+
outputs: [
|
|
2269
|
+
{
|
|
2270
|
+
name: "",
|
|
2271
|
+
internalType: "struct VaultPriceStateV2",
|
|
2272
|
+
type: "tuple",
|
|
2273
|
+
components: [
|
|
2274
|
+
{ name: "paused", internalType: "bool", type: "bool" },
|
|
2275
|
+
{ name: "pauseOnBadAnchorUpdate", internalType: "bool", type: "bool" },
|
|
2276
|
+
{ name: "maxPriceAge", internalType: "uint16", type: "uint16" },
|
|
2277
|
+
{ name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16" },
|
|
2278
|
+
{ name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16" },
|
|
2279
|
+
{ name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16" },
|
|
2280
|
+
{ name: "maxUpdateDelayDays", internalType: "uint8", type: "uint8" },
|
|
2281
|
+
{ name: "accrualLag", internalType: "uint32", type: "uint32" },
|
|
2282
|
+
{ name: "anchorTimestamp", internalType: "uint32", type: "uint32" },
|
|
2283
|
+
{ name: "driftTimestamp", internalType: "uint32", type: "uint32" },
|
|
2284
|
+
{ name: "anchorPrice", internalType: "uint128", type: "uint128" },
|
|
2285
|
+
{ name: "driftPrice", internalType: "uint128", type: "uint128" },
|
|
2286
|
+
{ name: "highestPrice", internalType: "uint128", type: "uint128" },
|
|
2287
|
+
{ name: "lastTotalSupply", internalType: "uint128", type: "uint128" }
|
|
2288
|
+
]
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
name: "",
|
|
2292
|
+
internalType: "struct VaultAccruals",
|
|
2293
|
+
type: "tuple",
|
|
2294
|
+
components: [
|
|
2295
|
+
{
|
|
2296
|
+
name: "fees",
|
|
2297
|
+
internalType: "struct Fee",
|
|
2298
|
+
type: "tuple",
|
|
2299
|
+
components: [
|
|
2300
|
+
{ name: "tvl", internalType: "uint16", type: "uint16" },
|
|
2301
|
+
{ name: "performance", internalType: "uint16", type: "uint16" }
|
|
2302
|
+
]
|
|
2303
|
+
},
|
|
2304
|
+
{ name: "accruedFees", internalType: "uint112", type: "uint112" },
|
|
2305
|
+
{ name: "accruedProtocolFees", internalType: "uint112", type: "uint112" }
|
|
2306
|
+
]
|
|
2307
|
+
}
|
|
2308
|
+
],
|
|
2309
|
+
stateMutability: "view"
|
|
2310
|
+
},
|
|
2311
|
+
{
|
|
2312
|
+
type: "function",
|
|
2313
|
+
inputs: [{ name: "vault", internalType: "address", type: "address" }],
|
|
2314
|
+
name: "isVaultPaused",
|
|
2315
|
+
outputs: [{ name: "", internalType: "bool", type: "bool" }],
|
|
2316
|
+
stateMutability: "view"
|
|
2317
|
+
},
|
|
2318
|
+
{
|
|
2319
|
+
type: "function",
|
|
2320
|
+
inputs: [],
|
|
2321
|
+
name: "version",
|
|
2322
|
+
outputs: [{ name: "", internalType: "string", type: "string" }],
|
|
2323
|
+
stateMutability: "pure"
|
|
2324
|
+
}
|
|
2325
|
+
];
|
|
2326
|
+
|
|
2327
|
+
// src/evm/aeraContracts/priceAndFeeCalculator.ts
|
|
2328
|
+
var ROUNDING_FLOOR = 0;
|
|
2329
|
+
var ROUNDING_CEIL = 1;
|
|
2330
|
+
function toNumber(value) {
|
|
2331
|
+
return typeof value === "bigint" ? Number(value) : value;
|
|
2332
|
+
}
|
|
2333
|
+
function normalizeVaultPriceState(priceState) {
|
|
2334
|
+
if ("unitPrice" in priceState) {
|
|
2335
|
+
return {
|
|
2336
|
+
...priceState,
|
|
2337
|
+
unitPrice: priceState.unitPrice,
|
|
2338
|
+
timestamp: toNumber(priceState.timestamp)
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
const anchorTimestamp = toNumber(priceState.anchorTimestamp);
|
|
2342
|
+
const driftTimestamp = toNumber(priceState.driftTimestamp);
|
|
2343
|
+
const useDriftPrice = driftTimestamp >= anchorTimestamp;
|
|
2344
|
+
return {
|
|
2345
|
+
...priceState,
|
|
2346
|
+
unitPrice: useDriftPrice ? priceState.driftPrice : priceState.anchorPrice,
|
|
2347
|
+
timestamp: useDriftPrice ? driftTimestamp : anchorTimestamp
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
async function convertTokenToUnitsIfActive(client, feeCalculator, feeCalculatorVersion, vault, token, tokenAmount, rounding, options = {}) {
|
|
2351
|
+
if (feeCalculatorVersion === ContractVersion.V2) {
|
|
2352
|
+
return client.readContract({
|
|
2353
|
+
address: feeCalculator,
|
|
2354
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2355
|
+
functionName: "convertTokenToUnitsIfActive",
|
|
2356
|
+
args: [vault, token, tokenAmount, rounding],
|
|
2357
|
+
...readAtBlock(options)
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
return client.readContract({
|
|
2361
|
+
address: feeCalculator,
|
|
2362
|
+
abi: priceAndFeeCalculatorAbi,
|
|
2363
|
+
functionName: "convertTokenToUnitsIfActive",
|
|
2364
|
+
args: [vault, token, tokenAmount, rounding],
|
|
2365
|
+
...readAtBlock(options)
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
async function convertUnitsToTokenIfActive(client, feeCalculator, feeCalculatorVersion, vault, token, unitsAmount, rounding, options = {}) {
|
|
2369
|
+
if (feeCalculatorVersion === ContractVersion.V2) {
|
|
2370
|
+
return client.readContract({
|
|
2371
|
+
address: feeCalculator,
|
|
2372
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2373
|
+
functionName: "convertUnitsToTokenIfActive",
|
|
2374
|
+
args: [vault, token, unitsAmount, rounding],
|
|
2375
|
+
...readAtBlock(options)
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
return client.readContract({
|
|
2379
|
+
address: feeCalculator,
|
|
2380
|
+
abi: priceAndFeeCalculatorAbi,
|
|
2381
|
+
functionName: "convertUnitsToTokenIfActive",
|
|
2382
|
+
args: [vault, token, unitsAmount, rounding],
|
|
2383
|
+
...readAtBlock(options)
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
async function convertTokenToUnits(client, feeCalculator, feeCalculatorVersion, vault, token, tokenAmount, options = {}) {
|
|
2387
|
+
if (feeCalculatorVersion === ContractVersion.V2) {
|
|
2388
|
+
return client.readContract({
|
|
2389
|
+
address: feeCalculator,
|
|
2390
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2391
|
+
functionName: "convertTokenToUnits",
|
|
2392
|
+
args: [vault, token, tokenAmount],
|
|
2393
|
+
...readAtBlock(options)
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
return client.readContract({
|
|
2397
|
+
address: feeCalculator,
|
|
2398
|
+
abi: priceAndFeeCalculatorAbi,
|
|
2399
|
+
functionName: "convertTokenToUnits",
|
|
2400
|
+
args: [vault, token, tokenAmount],
|
|
2401
|
+
...readAtBlock(options)
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
async function convertUnitsToToken(client, feeCalculator, feeCalculatorVersion, vault, token, unitsAmount, options = {}) {
|
|
2405
|
+
if (feeCalculatorVersion === ContractVersion.V2) {
|
|
2406
|
+
return client.readContract({
|
|
2407
|
+
address: feeCalculator,
|
|
2408
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2409
|
+
functionName: "convertUnitsToToken",
|
|
2410
|
+
args: [vault, token, unitsAmount],
|
|
2411
|
+
...readAtBlock(options)
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
return client.readContract({
|
|
2415
|
+
address: feeCalculator,
|
|
2416
|
+
abi: priceAndFeeCalculatorAbi,
|
|
2417
|
+
functionName: "convertUnitsToToken",
|
|
2418
|
+
args: [vault, token, unitsAmount],
|
|
2419
|
+
...readAtBlock(options)
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
async function convertTokenToNumeraire(client, feeCalculator, feeCalculatorVersion, vault, token, tokenAmount, options = {}) {
|
|
2423
|
+
if (feeCalculatorVersion !== ContractVersion.V2) {
|
|
2424
|
+
throw new UnsupportedFeatureError(
|
|
2425
|
+
"Aera: numeraire conversion requires V2 price and fee calculator"
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
return client.readContract({
|
|
2429
|
+
address: feeCalculator,
|
|
2430
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2431
|
+
functionName: "convertTokenToNumeraire",
|
|
2432
|
+
args: [vault, token, tokenAmount],
|
|
2433
|
+
...readAtBlock(options)
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
async function convertNumeraireToToken(client, feeCalculator, feeCalculatorVersion, vault, token, numeraireAmount, options = {}) {
|
|
2437
|
+
if (feeCalculatorVersion !== ContractVersion.V2) {
|
|
2438
|
+
throw new UnsupportedFeatureError(
|
|
2439
|
+
"Aera: numeraire conversion requires V2 price and fee calculator"
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2442
|
+
return client.readContract({
|
|
2443
|
+
address: feeCalculator,
|
|
2444
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2445
|
+
functionName: "convertNumeraireToToken",
|
|
2446
|
+
args: [vault, token, numeraireAmount],
|
|
2447
|
+
...readAtBlock(options)
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
async function getAnchorTimestamp(client, feeCalculator, feeCalculatorVersion, vault, options = {}) {
|
|
2451
|
+
if (feeCalculatorVersion !== ContractVersion.V2) {
|
|
2452
|
+
throw new UnsupportedFeatureError("Aera: sync redeem requires V2 price and fee calculator");
|
|
2453
|
+
}
|
|
2454
|
+
return client.readContract({
|
|
2455
|
+
address: feeCalculator,
|
|
2456
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2457
|
+
functionName: "getAnchorTimestamp",
|
|
2458
|
+
args: [vault],
|
|
2459
|
+
...readAtBlock(options)
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
async function getVaultState(client, feeCalculator, feeCalculatorVersion, vault) {
|
|
2463
|
+
if (feeCalculatorVersion === ContractVersion.V2) {
|
|
2464
|
+
const [priceState2, accruals2] = await client.readContract({
|
|
2465
|
+
address: feeCalculator,
|
|
2466
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2467
|
+
functionName: "getVaultState",
|
|
2468
|
+
args: [vault]
|
|
2469
|
+
});
|
|
2470
|
+
return [normalizeVaultPriceState(priceState2), accruals2];
|
|
2471
|
+
}
|
|
2472
|
+
const [priceState, accruals] = await client.readContract({
|
|
2473
|
+
address: feeCalculator,
|
|
2474
|
+
abi: priceAndFeeCalculatorAbi,
|
|
2475
|
+
functionName: "getVaultState",
|
|
2476
|
+
args: [vault]
|
|
2477
|
+
});
|
|
2478
|
+
return [normalizeVaultPriceState(priceState), accruals];
|
|
2479
|
+
}
|
|
2480
|
+
async function isVaultPaused(client, feeCalculator, feeCalculatorVersion, vault) {
|
|
2481
|
+
if (feeCalculatorVersion === ContractVersion.V2) {
|
|
2482
|
+
return client.readContract({
|
|
2483
|
+
address: feeCalculator,
|
|
2484
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2485
|
+
functionName: "isVaultPaused",
|
|
2486
|
+
args: [vault]
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
return client.readContract({
|
|
2490
|
+
address: feeCalculator,
|
|
2491
|
+
abi: priceAndFeeCalculatorAbi,
|
|
2492
|
+
functionName: "isVaultPaused",
|
|
2493
|
+
args: [vault]
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
var Rounding = {
|
|
2497
|
+
Floor: ROUNDING_FLOOR,
|
|
2498
|
+
Ceil: ROUNDING_CEIL
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
// src/evm/abis/erc20.ts
|
|
2502
|
+
var erc20Abi = [
|
|
2503
|
+
{
|
|
2504
|
+
type: "function",
|
|
2505
|
+
name: "approve",
|
|
2506
|
+
inputs: [
|
|
2507
|
+
{ name: "spender", type: "address" },
|
|
2508
|
+
{ name: "amount", type: "uint256" }
|
|
2509
|
+
],
|
|
2510
|
+
outputs: [{ type: "bool" }],
|
|
2511
|
+
stateMutability: "nonpayable"
|
|
2512
|
+
},
|
|
2513
|
+
{
|
|
2514
|
+
type: "function",
|
|
2515
|
+
name: "allowance",
|
|
2516
|
+
inputs: [
|
|
2517
|
+
{ name: "owner", type: "address" },
|
|
2518
|
+
{ name: "spender", type: "address" }
|
|
2519
|
+
],
|
|
2520
|
+
outputs: [{ type: "uint256" }],
|
|
2521
|
+
stateMutability: "view"
|
|
2522
|
+
},
|
|
2523
|
+
{
|
|
2524
|
+
type: "function",
|
|
2525
|
+
name: "balanceOf",
|
|
2526
|
+
inputs: [{ name: "account", type: "address" }],
|
|
2527
|
+
outputs: [{ type: "uint256" }],
|
|
2528
|
+
stateMutability: "view"
|
|
2529
|
+
}
|
|
2530
|
+
];
|
|
2531
|
+
|
|
2532
|
+
// src/evm/aeraContracts/v1.ts
|
|
2533
|
+
import {
|
|
2534
|
+
getContract as getContract2
|
|
2535
|
+
} from "viem";
|
|
2536
|
+
function getProvisioner(client, address) {
|
|
2537
|
+
return getContract2({
|
|
2538
|
+
address,
|
|
2539
|
+
abi: provisionerAbi,
|
|
2540
|
+
client
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
async function getTokenDetails(client, provisioner, token) {
|
|
2544
|
+
return getProvisioner(client, provisioner).read.tokensDetails([token]);
|
|
2545
|
+
}
|
|
2546
|
+
async function getAsyncDepositUnitsOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
|
|
2547
|
+
const tokenDetails = await getTokenDetails(client, provisioner, token);
|
|
2548
|
+
const depositMultiplier = BigInt(tokenDetails[3]);
|
|
2549
|
+
const adjustedTokensIn = tokensIn * depositMultiplier / MAX_BPS;
|
|
2550
|
+
return convertTokenToUnitsIfActive(
|
|
2551
|
+
client,
|
|
2552
|
+
feeCalculator,
|
|
2553
|
+
feeCalculatorVersion,
|
|
2554
|
+
vault,
|
|
2555
|
+
token,
|
|
2556
|
+
adjustedTokensIn,
|
|
2557
|
+
Rounding.Floor
|
|
2558
|
+
);
|
|
2559
|
+
}
|
|
2560
|
+
async function getAsyncRedeemTokenOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, unitsIn) {
|
|
2561
|
+
const tokenDetails = await getTokenDetails(client, provisioner, token);
|
|
2562
|
+
const redeemMultiplier = BigInt(tokenDetails[4]);
|
|
2563
|
+
const tokensOut = await convertUnitsToTokenIfActive(
|
|
2564
|
+
client,
|
|
2565
|
+
feeCalculator,
|
|
2566
|
+
feeCalculatorVersion,
|
|
2567
|
+
vault,
|
|
2568
|
+
token,
|
|
2569
|
+
unitsIn,
|
|
2570
|
+
Rounding.Floor
|
|
2571
|
+
);
|
|
2572
|
+
return tokensOut * redeemMultiplier / MAX_BPS;
|
|
2573
|
+
}
|
|
2574
|
+
async function getAsyncWithdrawUnitsIn(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensOut) {
|
|
2575
|
+
const tokenDetails = await getTokenDetails(client, provisioner, token);
|
|
2576
|
+
const redeemMultiplier = BigInt(tokenDetails[4]);
|
|
2577
|
+
const preMultiplierTokensOut = (tokensOut * MAX_BPS + redeemMultiplier - 1n) / redeemMultiplier;
|
|
2578
|
+
return convertTokenToUnitsIfActive(
|
|
2579
|
+
client,
|
|
2580
|
+
feeCalculator,
|
|
2581
|
+
feeCalculatorVersion,
|
|
2582
|
+
vault,
|
|
2583
|
+
token,
|
|
2584
|
+
preMultiplierTokensOut,
|
|
2585
|
+
Rounding.Ceil
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
function requestDepositTxRequest(provisioner, token, tokensIn, minUnitsOut, solverTip, deadline, maxPriceAge, isFixedPrice, account) {
|
|
2589
|
+
return {
|
|
2590
|
+
address: provisioner,
|
|
2591
|
+
abi: provisionerAbi,
|
|
2592
|
+
functionName: "requestDeposit",
|
|
2593
|
+
args: [token, tokensIn, minUnitsOut, solverTip, deadline, maxPriceAge, isFixedPrice],
|
|
2594
|
+
account
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2597
|
+
function requestRedeemTxRequest(provisioner, token, unitsIn, minTokenOut, solverTip, deadline, maxPriceAge, isFixedPrice, account) {
|
|
2598
|
+
return {
|
|
2599
|
+
address: provisioner,
|
|
2600
|
+
abi: provisionerAbi,
|
|
2601
|
+
functionName: "requestRedeem",
|
|
2602
|
+
args: [token, unitsIn, minTokenOut, solverTip, deadline, maxPriceAge, isFixedPrice],
|
|
2603
|
+
account
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
// src/evm/aeraContracts/v2.ts
|
|
2608
|
+
import {
|
|
2609
|
+
getContract as getContract3,
|
|
2610
|
+
zeroAddress as zeroAddress2
|
|
2611
|
+
} from "viem";
|
|
2612
|
+
async function resolveReadContext(client, options = {}) {
|
|
2613
|
+
if (options.blockNumber !== void 0 && options.blockTimestamp !== void 0) {
|
|
2614
|
+
return { blockNumber: options.blockNumber, blockTimestamp: options.blockTimestamp };
|
|
2615
|
+
}
|
|
2616
|
+
const block = options.blockNumber === void 0 ? await client.getBlock() : await client.getBlock(options);
|
|
2617
|
+
if (block.number === null) {
|
|
2618
|
+
throw new UnsupportedFeatureError("Aera: sync redeem reads require a numbered block");
|
|
2619
|
+
}
|
|
2620
|
+
return {
|
|
2621
|
+
blockNumber: options.blockNumber ?? block.number,
|
|
2622
|
+
blockTimestamp: options.blockTimestamp ?? BigInt(block.timestamp)
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
async function getTokenDetails2(client, provisioner, token, options = {}) {
|
|
2626
|
+
return client.readContract({
|
|
2627
|
+
address: provisioner,
|
|
2628
|
+
abi: provisionerV2Abi,
|
|
2629
|
+
functionName: "tokensDetails",
|
|
2630
|
+
args: [token],
|
|
2631
|
+
...readAtBlock(options)
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
async function getKnownSyncRedeemLiquidityTokens(client, vault, token, hasPullFundsSubmitData, options = {}) {
|
|
2635
|
+
if (hasPullFundsSubmitData) return void 0;
|
|
2636
|
+
return client.readContract({
|
|
2637
|
+
address: token,
|
|
2638
|
+
abi: erc20Abi,
|
|
2639
|
+
functionName: "balanceOf",
|
|
2640
|
+
args: [vault],
|
|
2641
|
+
...readAtBlock(options)
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
async function getDepositQuote({
|
|
2645
|
+
client,
|
|
2646
|
+
provisioner,
|
|
2647
|
+
feeCalculator,
|
|
2648
|
+
feeCalculatorVersion,
|
|
2649
|
+
vault,
|
|
2650
|
+
token,
|
|
2651
|
+
tokensIn,
|
|
2652
|
+
multiplierIndex,
|
|
2653
|
+
options
|
|
2654
|
+
}) {
|
|
2655
|
+
const tokenDetails = await getTokenDetails2(client, provisioner, token, options);
|
|
2656
|
+
const multiplierBps = BigInt(tokenDetails[multiplierIndex]);
|
|
2657
|
+
const adjustedTokensIn = tokensIn * multiplierBps / MAX_BPS;
|
|
2658
|
+
const unitsOut = await convertTokenToUnitsIfActive(
|
|
2659
|
+
client,
|
|
2660
|
+
feeCalculator,
|
|
2661
|
+
feeCalculatorVersion,
|
|
2662
|
+
vault,
|
|
2663
|
+
token,
|
|
2664
|
+
adjustedTokensIn,
|
|
2665
|
+
Rounding.Floor,
|
|
2666
|
+
options
|
|
2667
|
+
);
|
|
2668
|
+
return { unitsOut, multiplierBps };
|
|
2669
|
+
}
|
|
2670
|
+
async function getRedeemTokenOut({
|
|
2671
|
+
client,
|
|
2672
|
+
provisioner,
|
|
2673
|
+
feeCalculator,
|
|
2674
|
+
feeCalculatorVersion,
|
|
2675
|
+
vault,
|
|
2676
|
+
token,
|
|
2677
|
+
unitsIn,
|
|
2678
|
+
multiplierIndex,
|
|
2679
|
+
options
|
|
2680
|
+
}) {
|
|
2681
|
+
const [tokenDetails, tokensOut] = await Promise.all([
|
|
2682
|
+
getTokenDetails2(client, provisioner, token, options),
|
|
2683
|
+
convertUnitsToTokenIfActive(
|
|
2684
|
+
client,
|
|
2685
|
+
feeCalculator,
|
|
2686
|
+
feeCalculatorVersion,
|
|
2687
|
+
vault,
|
|
2688
|
+
token,
|
|
2689
|
+
unitsIn,
|
|
2690
|
+
Rounding.Floor,
|
|
2691
|
+
options
|
|
2692
|
+
)
|
|
2693
|
+
]);
|
|
2694
|
+
const multiplier = BigInt(tokenDetails[multiplierIndex]);
|
|
2695
|
+
return tokensOut * multiplier / MAX_BPS;
|
|
2696
|
+
}
|
|
2697
|
+
async function getWithdrawUnitsIn({
|
|
2698
|
+
client,
|
|
2699
|
+
provisioner,
|
|
2700
|
+
feeCalculator,
|
|
2701
|
+
feeCalculatorVersion,
|
|
2702
|
+
vault,
|
|
2703
|
+
token,
|
|
2704
|
+
tokensOut,
|
|
2705
|
+
multiplierIndex,
|
|
2706
|
+
options
|
|
2707
|
+
}) {
|
|
2708
|
+
const tokenDetails = await getTokenDetails2(client, provisioner, token, options);
|
|
2709
|
+
const multiplier = BigInt(tokenDetails[multiplierIndex]);
|
|
2710
|
+
const preMultiplierTokens = (tokensOut * MAX_BPS + multiplier - 1n) / multiplier;
|
|
2711
|
+
return convertTokenToUnitsIfActive(
|
|
2712
|
+
client,
|
|
2713
|
+
feeCalculator,
|
|
2714
|
+
feeCalculatorVersion,
|
|
2715
|
+
vault,
|
|
2716
|
+
token,
|
|
2717
|
+
preMultiplierTokens,
|
|
2718
|
+
Rounding.Ceil,
|
|
2719
|
+
options
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
async function getSyncRedeemRateContext(client, provisioner, vault, token, feeCalculator, options = {}) {
|
|
2723
|
+
const readContext = await resolveReadContext(client, options);
|
|
2724
|
+
const [tokenDetails, syncRedeemDetails, anchorTimestamp] = await client.multicall({
|
|
2725
|
+
contracts: [
|
|
2726
|
+
{
|
|
2727
|
+
address: provisioner,
|
|
2728
|
+
abi: provisionerV2Abi,
|
|
2729
|
+
functionName: "tokensDetails",
|
|
2730
|
+
args: [token]
|
|
2731
|
+
},
|
|
2732
|
+
{
|
|
2733
|
+
address: provisioner,
|
|
2734
|
+
abi: provisionerV2Abi,
|
|
2735
|
+
functionName: "getSyncRedeemDetails"
|
|
2736
|
+
},
|
|
2737
|
+
{
|
|
2738
|
+
address: feeCalculator,
|
|
2739
|
+
abi: priceAndFeeCalculatorV2Abi,
|
|
2740
|
+
functionName: "getAnchorTimestamp",
|
|
2741
|
+
args: [vault]
|
|
2742
|
+
}
|
|
2743
|
+
],
|
|
2744
|
+
allowFailure: false,
|
|
2745
|
+
blockNumber: readContext.blockNumber
|
|
2746
|
+
});
|
|
2747
|
+
const baseMultiplierBps = BigInt(tokenDetails[7]);
|
|
2748
|
+
const maxPriceAge = BigInt(syncRedeemDetails[0]);
|
|
2749
|
+
const maxDynamicPremiumBps = BigInt(syncRedeemDetails[2]);
|
|
2750
|
+
const blockTimestamp = readContext.blockTimestamp;
|
|
2751
|
+
const priceTimestamp = BigInt(anchorTimestamp);
|
|
2752
|
+
if (priceTimestamp + maxPriceAge < blockTimestamp) {
|
|
2753
|
+
throw new StalePriceError({
|
|
2754
|
+
blockTimestamp,
|
|
2755
|
+
maxPriceAge,
|
|
2756
|
+
priceTimestamp
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
const dynamicPremiumBps = maxDynamicPremiumBps === 0n || maxPriceAge === 0n ? 0n : ((blockTimestamp - priceTimestamp) * maxDynamicPremiumBps + maxPriceAge - 1n) / maxPriceAge;
|
|
2760
|
+
return {
|
|
2761
|
+
rate: {
|
|
2762
|
+
baseMultiplierBps,
|
|
2763
|
+
dynamicPremiumBps,
|
|
2764
|
+
effectiveMultiplierBps: baseMultiplierBps - dynamicPremiumBps
|
|
2765
|
+
},
|
|
2766
|
+
hasPullFundsSubmitData: tokenDetails[9] !== zeroAddress2
|
|
2767
|
+
};
|
|
2768
|
+
}
|
|
2769
|
+
async function getSyncRedeemRate(client, provisioner, vault, token, feeCalculator, options = {}) {
|
|
2770
|
+
return (await getSyncRedeemRateContext(client, provisioner, vault, token, feeCalculator, options)).rate;
|
|
2771
|
+
}
|
|
2772
|
+
async function getSyncRedeemMultiplier(client, provisioner, vault, token, feeCalculator, options = {}) {
|
|
2773
|
+
return (await getSyncRedeemRate(client, provisioner, vault, token, feeCalculator, options)).effectiveMultiplierBps;
|
|
2774
|
+
}
|
|
2775
|
+
async function getSyncRedeemTokenOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, unitsIn, effectiveMultiplierBps, options = {}) {
|
|
2776
|
+
const readContext = effectiveMultiplierBps === void 0 ? await resolveReadContext(client, options) : options;
|
|
2777
|
+
const [tokenAmount, multiplier] = await Promise.all([
|
|
2778
|
+
convertUnitsToTokenIfActive(
|
|
2779
|
+
client,
|
|
2780
|
+
feeCalculator,
|
|
2781
|
+
feeCalculatorVersion,
|
|
2782
|
+
vault,
|
|
2783
|
+
token,
|
|
2784
|
+
unitsIn,
|
|
2785
|
+
Rounding.Floor,
|
|
2786
|
+
readContext
|
|
2787
|
+
),
|
|
2788
|
+
effectiveMultiplierBps !== void 0 ? Promise.resolve(effectiveMultiplierBps) : getSyncRedeemMultiplier(client, provisioner, vault, token, feeCalculator, readContext)
|
|
2789
|
+
]);
|
|
2790
|
+
return tokenAmount * multiplier / MAX_BPS;
|
|
2791
|
+
}
|
|
2792
|
+
async function getAsyncDepositUnitsOut2(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
|
|
2793
|
+
const quote = await getDepositQuote({
|
|
2794
|
+
client,
|
|
2795
|
+
provisioner,
|
|
2796
|
+
feeCalculator,
|
|
2797
|
+
feeCalculatorVersion,
|
|
2798
|
+
vault,
|
|
2799
|
+
token,
|
|
2800
|
+
tokensIn,
|
|
2801
|
+
multiplierIndex: 4
|
|
2802
|
+
});
|
|
2803
|
+
return quote.unitsOut;
|
|
2804
|
+
}
|
|
2805
|
+
var getSyncDepositQuote = (client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) => getDepositQuote({
|
|
2806
|
+
client,
|
|
2807
|
+
provisioner,
|
|
2808
|
+
feeCalculator,
|
|
2809
|
+
feeCalculatorVersion,
|
|
2810
|
+
vault,
|
|
2811
|
+
token,
|
|
2812
|
+
tokensIn,
|
|
2813
|
+
multiplierIndex: 6
|
|
2814
|
+
});
|
|
2815
|
+
async function getSyncDepositUnitsOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
|
|
2816
|
+
const quote = await getSyncDepositQuote(
|
|
2817
|
+
client,
|
|
2818
|
+
provisioner,
|
|
2819
|
+
feeCalculator,
|
|
2820
|
+
feeCalculatorVersion,
|
|
2821
|
+
vault,
|
|
2822
|
+
token,
|
|
2823
|
+
tokensIn
|
|
2824
|
+
);
|
|
2825
|
+
return quote.unitsOut;
|
|
2826
|
+
}
|
|
2827
|
+
async function getSyncDepositQuoteValues(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
|
|
2828
|
+
const { unitsOut, multiplierBps } = await getSyncDepositQuote(
|
|
2829
|
+
client,
|
|
2830
|
+
provisioner,
|
|
2831
|
+
feeCalculator,
|
|
2832
|
+
feeCalculatorVersion,
|
|
2833
|
+
vault,
|
|
2834
|
+
token,
|
|
2835
|
+
tokensIn
|
|
2836
|
+
);
|
|
2837
|
+
const numeraireOut = await convertTokenToNumeraire(
|
|
2838
|
+
client,
|
|
2839
|
+
feeCalculator,
|
|
2840
|
+
feeCalculatorVersion,
|
|
2841
|
+
vault,
|
|
2842
|
+
token,
|
|
2843
|
+
tokensIn * multiplierBps / MAX_BPS
|
|
2844
|
+
);
|
|
2845
|
+
return { unitsOut, feeBps: MAX_BPS - multiplierBps, numeraireOut };
|
|
2846
|
+
}
|
|
2847
|
+
async function getSyncDepositFeeBps(client, provisioner, token, options = {}) {
|
|
2848
|
+
const tokenDetails = await getTokenDetails2(client, provisioner, token, options);
|
|
2849
|
+
return MAX_BPS - BigInt(tokenDetails[6]);
|
|
2850
|
+
}
|
|
2851
|
+
async function getAsyncRedeemTokenOut2(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, unitsIn) {
|
|
2852
|
+
return getRedeemTokenOut({
|
|
2853
|
+
client,
|
|
2854
|
+
provisioner,
|
|
2855
|
+
feeCalculator,
|
|
2856
|
+
feeCalculatorVersion,
|
|
2857
|
+
vault,
|
|
2858
|
+
token,
|
|
2859
|
+
unitsIn,
|
|
2860
|
+
multiplierIndex: 5
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
async function getAsyncWithdrawUnitsIn2(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensOut) {
|
|
2864
|
+
return getWithdrawUnitsIn({
|
|
2865
|
+
client,
|
|
2866
|
+
provisioner,
|
|
2867
|
+
feeCalculator,
|
|
2868
|
+
feeCalculatorVersion,
|
|
2869
|
+
vault,
|
|
2870
|
+
token,
|
|
2871
|
+
tokensOut,
|
|
2872
|
+
multiplierIndex: 5
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
async function getSyncWithdrawUnitsIn(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensOut, effectiveMultiplierBps, options = {}) {
|
|
2876
|
+
const readContext = effectiveMultiplierBps === void 0 ? await resolveReadContext(client, options) : options;
|
|
2877
|
+
const multiplier = effectiveMultiplierBps ?? await getSyncRedeemMultiplier(client, provisioner, vault, token, feeCalculator, readContext);
|
|
2878
|
+
const prePremiumTokens = (tokensOut * MAX_BPS + multiplier - 1n) / multiplier;
|
|
2879
|
+
return convertTokenToUnitsIfActive(
|
|
2880
|
+
client,
|
|
2881
|
+
feeCalculator,
|
|
2882
|
+
feeCalculatorVersion,
|
|
2883
|
+
vault,
|
|
2884
|
+
token,
|
|
2885
|
+
prePremiumTokens,
|
|
2886
|
+
Rounding.Ceil,
|
|
2887
|
+
readContext
|
|
2888
|
+
);
|
|
2889
|
+
}
|
|
2890
|
+
async function getSyncRedeemEpochState(client, provisioner, options = {}) {
|
|
2891
|
+
const [epochTimestamp, epochStartTvlNumeraire, epochRedeemedNumeraire, epochCapNumeraire] = await client.readContract({
|
|
2892
|
+
address: provisioner,
|
|
2893
|
+
abi: provisionerV2Abi,
|
|
2894
|
+
functionName: "getSyncRedeemEpochState",
|
|
2895
|
+
...readAtBlock(options)
|
|
2896
|
+
});
|
|
2897
|
+
return { epochTimestamp, epochStartTvlNumeraire, epochRedeemedNumeraire, epochCapNumeraire };
|
|
2898
|
+
}
|
|
2899
|
+
async function getUserUnitsRefundableUntil(client, provisioner, user, options = {}) {
|
|
2900
|
+
return client.readContract({
|
|
2901
|
+
address: provisioner,
|
|
2902
|
+
abi: provisionerV2Abi,
|
|
2903
|
+
functionName: "userUnitsRefundableUntil",
|
|
2904
|
+
args: [user],
|
|
2905
|
+
...readAtBlock(options)
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
function depositTxRequest(provisioner, token, tokensIn, minUnitsOut, receiver, account) {
|
|
2909
|
+
return {
|
|
2910
|
+
address: provisioner,
|
|
2911
|
+
abi: provisionerV2Abi,
|
|
2912
|
+
functionName: "deposit",
|
|
2913
|
+
args: [token, tokensIn, minUnitsOut, receiver],
|
|
2914
|
+
account
|
|
2915
|
+
};
|
|
2916
|
+
}
|
|
2917
|
+
function requestDepositTxRequest2(provisioner, token, tokensIn, minUnitsOut, solverTip, deadline, maxPriceAge, isFixedPrice, receiver, account) {
|
|
2918
|
+
return {
|
|
2919
|
+
address: provisioner,
|
|
2920
|
+
abi: provisionerV2Abi,
|
|
2921
|
+
functionName: "requestDeposit",
|
|
2922
|
+
args: [
|
|
2923
|
+
token,
|
|
2924
|
+
tokensIn,
|
|
2925
|
+
minUnitsOut,
|
|
2926
|
+
solverTip,
|
|
2927
|
+
deadline,
|
|
2928
|
+
maxPriceAge,
|
|
2929
|
+
isFixedPrice,
|
|
2930
|
+
receiver
|
|
2931
|
+
],
|
|
2932
|
+
account
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
2935
|
+
function setDepositReceiverApprovalTxRequest(provisioner, depositor, approved, receiver) {
|
|
2936
|
+
return {
|
|
2937
|
+
address: provisioner,
|
|
2938
|
+
abi: provisionerV2Abi,
|
|
2939
|
+
functionName: "setDepositReceiverApproval",
|
|
2940
|
+
args: [depositor, approved],
|
|
2941
|
+
account: receiver
|
|
2942
|
+
};
|
|
2943
|
+
}
|
|
2944
|
+
function requestRedeemTxRequest2(provisioner, token, unitsIn, minTokenOut, solverTip, deadline, maxPriceAge, isFixedPrice, receiver, account) {
|
|
2945
|
+
return {
|
|
2946
|
+
address: provisioner,
|
|
2947
|
+
abi: provisionerV2Abi,
|
|
2948
|
+
functionName: "requestRedeem",
|
|
2949
|
+
args: [
|
|
2950
|
+
token,
|
|
2951
|
+
unitsIn,
|
|
2952
|
+
minTokenOut,
|
|
2953
|
+
solverTip,
|
|
2954
|
+
deadline,
|
|
2955
|
+
maxPriceAge,
|
|
2956
|
+
isFixedPrice,
|
|
2957
|
+
receiver
|
|
2958
|
+
],
|
|
2959
|
+
account
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
function redeemTxRequest(provisioner, token, unitsIn, minTokenOut, receiver, account) {
|
|
2963
|
+
return {
|
|
2964
|
+
address: provisioner,
|
|
2965
|
+
abi: provisionerV2Abi,
|
|
2966
|
+
functionName: "redeem",
|
|
2967
|
+
args: [token, unitsIn, minTokenOut, receiver],
|
|
2968
|
+
account
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2971
|
+
function withdrawTxRequest(provisioner, token, tokensOut, maxUnitsIn, receiver, account) {
|
|
2972
|
+
return {
|
|
2973
|
+
address: provisioner,
|
|
2974
|
+
abi: provisionerV2Abi,
|
|
2975
|
+
functionName: "withdraw",
|
|
2976
|
+
args: [token, tokensOut, maxUnitsIn, receiver],
|
|
2977
|
+
account
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
// src/evm/adapters/aera.ts
|
|
2982
|
+
function subtractSolverTip(tokenAmount, solverTip) {
|
|
2983
|
+
if (solverTip === 0n) return tokenAmount;
|
|
2984
|
+
if (solverTip >= tokenAmount) {
|
|
2985
|
+
throw new InvalidSolverTipError(solverTip, tokenAmount);
|
|
2986
|
+
}
|
|
2987
|
+
return tokenAmount - solverTip;
|
|
2988
|
+
}
|
|
2989
|
+
function getRequestDeadline(expirationDays) {
|
|
2990
|
+
const deadlineBuffer = expirationDays === void 0 ? DEFAULT_REQUEST_DEADLINE_BUFFER : DAY * expirationDays;
|
|
2991
|
+
return BigInt(Math.ceil((/* @__PURE__ */ new Date()).getTime() / 1e3) + deadlineBuffer);
|
|
2992
|
+
}
|
|
2993
|
+
async function getDepositUnitsOut({
|
|
2994
|
+
publicClient,
|
|
2995
|
+
runtime,
|
|
2996
|
+
vault,
|
|
2997
|
+
token,
|
|
2998
|
+
tokensIn,
|
|
2999
|
+
isAsync
|
|
3000
|
+
}) {
|
|
3001
|
+
if (runtime.provisioner.version === ContractVersion.V2) {
|
|
3002
|
+
return isAsync ? getAsyncDepositUnitsOut2(
|
|
3003
|
+
publicClient,
|
|
3004
|
+
runtime.provisioner.address,
|
|
3005
|
+
runtime.feeCalculator.address,
|
|
3006
|
+
runtime.feeCalculator.version,
|
|
3007
|
+
vault,
|
|
3008
|
+
token,
|
|
3009
|
+
tokensIn
|
|
3010
|
+
) : getSyncDepositUnitsOut(
|
|
3011
|
+
publicClient,
|
|
3012
|
+
runtime.provisioner.address,
|
|
3013
|
+
runtime.feeCalculator.address,
|
|
3014
|
+
runtime.feeCalculator.version,
|
|
3015
|
+
vault,
|
|
3016
|
+
token,
|
|
3017
|
+
tokensIn
|
|
3018
|
+
);
|
|
3019
|
+
}
|
|
3020
|
+
return getAsyncDepositUnitsOut(
|
|
3021
|
+
publicClient,
|
|
3022
|
+
runtime.provisioner.address,
|
|
3023
|
+
runtime.feeCalculator.address,
|
|
3024
|
+
runtime.feeCalculator.version,
|
|
3025
|
+
vault,
|
|
3026
|
+
token,
|
|
3027
|
+
tokensIn
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3030
|
+
function getAsyncRedeemTokenOut3(publicClient, runtime, vault, token, unitsIn) {
|
|
3031
|
+
return runtime.provisioner.version === ContractVersion.V2 ? getAsyncRedeemTokenOut2(
|
|
3032
|
+
publicClient,
|
|
3033
|
+
runtime.provisioner.address,
|
|
3034
|
+
runtime.feeCalculator.address,
|
|
3035
|
+
runtime.feeCalculator.version,
|
|
3036
|
+
vault,
|
|
3037
|
+
token,
|
|
3038
|
+
unitsIn
|
|
3039
|
+
) : getAsyncRedeemTokenOut(
|
|
3040
|
+
publicClient,
|
|
3041
|
+
runtime.provisioner.address,
|
|
3042
|
+
runtime.feeCalculator.address,
|
|
3043
|
+
runtime.feeCalculator.version,
|
|
3044
|
+
vault,
|
|
3045
|
+
token,
|
|
3046
|
+
unitsIn
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
function getAsyncWithdrawUnitsIn3(publicClient, runtime, vault, token, tokensOut) {
|
|
3050
|
+
return runtime.provisioner.version === ContractVersion.V2 ? getAsyncWithdrawUnitsIn2(
|
|
3051
|
+
publicClient,
|
|
3052
|
+
runtime.provisioner.address,
|
|
3053
|
+
runtime.feeCalculator.address,
|
|
3054
|
+
runtime.feeCalculator.version,
|
|
3055
|
+
vault,
|
|
3056
|
+
token,
|
|
3057
|
+
tokensOut
|
|
3058
|
+
) : getAsyncWithdrawUnitsIn(
|
|
3059
|
+
publicClient,
|
|
3060
|
+
runtime.provisioner.address,
|
|
3061
|
+
runtime.feeCalculator.address,
|
|
3062
|
+
runtime.feeCalculator.version,
|
|
3063
|
+
vault,
|
|
3064
|
+
token,
|
|
3065
|
+
tokensOut
|
|
3066
|
+
);
|
|
3067
|
+
}
|
|
3068
|
+
function requireAeraRuntime(runtime) {
|
|
3069
|
+
if (!runtime) {
|
|
3070
|
+
throw new UnsupportedFeatureError("Aera: runtime contracts were not resolved");
|
|
3071
|
+
}
|
|
3072
|
+
return runtime;
|
|
3073
|
+
}
|
|
3074
|
+
var aeraAdapter = {
|
|
3075
|
+
async buildDeposit(params) {
|
|
3076
|
+
const {
|
|
3077
|
+
vault,
|
|
3078
|
+
receiver,
|
|
3079
|
+
amount,
|
|
3080
|
+
account,
|
|
3081
|
+
publicClient,
|
|
3082
|
+
asset,
|
|
3083
|
+
async: isAsync,
|
|
3084
|
+
slippageBps = DEFAULT_BPS,
|
|
3085
|
+
solverTip = DEFAULT_SOLVER_TIP,
|
|
3086
|
+
maxPriceAge = DEFAULT_MAX_PRICE_AGE,
|
|
3087
|
+
aeraRuntime,
|
|
3088
|
+
minUnitsOut: requestedMinUnitsOut
|
|
3089
|
+
} = params;
|
|
3090
|
+
const runtime = requireAeraRuntime(aeraRuntime);
|
|
3091
|
+
const provisionerAddress = runtime.provisioner.address;
|
|
3092
|
+
const isContractV2 = runtime.provisioner.version === ContractVersion.V2;
|
|
3093
|
+
if (receiver !== account && !isContractV2) {
|
|
3094
|
+
throw new UnsupportedFeatureError("Aera: separate receiver address on V1");
|
|
3095
|
+
}
|
|
3096
|
+
if (!isAsync && !isContractV2) {
|
|
3097
|
+
throw new UnsupportedFeatureError("Aera: sync operations on V1");
|
|
3098
|
+
}
|
|
3099
|
+
const minUnitsOut = requestedMinUnitsOut ?? applySlippageDown(
|
|
3100
|
+
await getDepositUnitsOut({
|
|
3101
|
+
publicClient,
|
|
3102
|
+
runtime,
|
|
3103
|
+
vault: vault.vaultAddress,
|
|
3104
|
+
token: asset.address,
|
|
3105
|
+
tokensIn: isAsync ? subtractSolverTip(amount, solverTip) : amount,
|
|
3106
|
+
isAsync
|
|
3107
|
+
}),
|
|
3108
|
+
slippageBps
|
|
3109
|
+
);
|
|
3110
|
+
if (isAsync) {
|
|
3111
|
+
const deadline = getRequestDeadline(vault.expirationDays);
|
|
3112
|
+
return [
|
|
3113
|
+
{
|
|
3114
|
+
type: "requestDeposit",
|
|
3115
|
+
...isContractV2 ? requestDepositTxRequest2(
|
|
3116
|
+
provisionerAddress,
|
|
3117
|
+
asset.address,
|
|
3118
|
+
amount,
|
|
3119
|
+
minUnitsOut,
|
|
3120
|
+
solverTip,
|
|
3121
|
+
deadline,
|
|
3122
|
+
maxPriceAge,
|
|
3123
|
+
false,
|
|
3124
|
+
receiver,
|
|
3125
|
+
account
|
|
3126
|
+
) : requestDepositTxRequest(
|
|
3127
|
+
provisionerAddress,
|
|
3128
|
+
asset.address,
|
|
3129
|
+
amount,
|
|
3130
|
+
minUnitsOut,
|
|
3131
|
+
solverTip,
|
|
3132
|
+
deadline,
|
|
3133
|
+
maxPriceAge,
|
|
3134
|
+
false,
|
|
3135
|
+
account
|
|
3136
|
+
)
|
|
3137
|
+
}
|
|
3138
|
+
];
|
|
3139
|
+
}
|
|
3140
|
+
if (isContractV2) {
|
|
3141
|
+
return [
|
|
3142
|
+
{
|
|
3143
|
+
type: "deposit",
|
|
3144
|
+
...depositTxRequest(
|
|
3145
|
+
provisionerAddress,
|
|
3146
|
+
asset.address,
|
|
3147
|
+
amount,
|
|
3148
|
+
minUnitsOut,
|
|
3149
|
+
receiver,
|
|
3150
|
+
account
|
|
3151
|
+
)
|
|
3152
|
+
}
|
|
3153
|
+
];
|
|
3154
|
+
}
|
|
3155
|
+
throw new UnimplementedFeatureError("Aera Sync Operations");
|
|
3156
|
+
},
|
|
3157
|
+
async buildWithdraw(params) {
|
|
3158
|
+
const {
|
|
3159
|
+
vault,
|
|
3160
|
+
receiver,
|
|
3161
|
+
account,
|
|
3162
|
+
asset,
|
|
3163
|
+
publicClient,
|
|
3164
|
+
async: isAsync,
|
|
3165
|
+
slippageBps = DEFAULT_BPS,
|
|
3166
|
+
solverTip = DEFAULT_SOLVER_TIP,
|
|
3167
|
+
maxPriceAge = DEFAULT_MAX_PRICE_AGE,
|
|
3168
|
+
aeraRuntime
|
|
3169
|
+
} = params;
|
|
3170
|
+
const runtime = requireAeraRuntime(aeraRuntime);
|
|
3171
|
+
const provisionerAddress = runtime.provisioner.address;
|
|
3172
|
+
const isContractV2 = runtime.provisioner.version === ContractVersion.V2;
|
|
3173
|
+
if (receiver !== account && !isContractV2) {
|
|
3174
|
+
throw new UnsupportedFeatureError("Aera: separate receiver address on V1");
|
|
3175
|
+
}
|
|
3176
|
+
if (!isAsync) requireAeraSyncRedeemRuntime(runtime);
|
|
3177
|
+
const isV2ExactTokenWithdraw = isContractV2 && !isAsync && "amount" in params && params.amount != null;
|
|
3178
|
+
let minTokenOut;
|
|
3179
|
+
let maxUnitsIn;
|
|
3180
|
+
let shares;
|
|
3181
|
+
if (isContractV2 && !isAsync) {
|
|
3182
|
+
const quote = params.syncWithdrawQuote;
|
|
3183
|
+
if ("entireAmount" in params && params.entireAmount) {
|
|
3184
|
+
const balance = await publicClient.readContract({
|
|
3185
|
+
address: vault.vaultAddress,
|
|
3186
|
+
abi: multiDepositorVaultAbi,
|
|
3187
|
+
functionName: "balanceOf",
|
|
3188
|
+
args: [account]
|
|
3189
|
+
});
|
|
3190
|
+
if (quote !== void 0) {
|
|
3191
|
+
if (quote.kind !== "redeem" || quote.shares !== balance) {
|
|
3192
|
+
throw new InvalidWithdrawParamsError();
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
shares = balance;
|
|
3196
|
+
} else if ("shares" in params && params.shares != null) {
|
|
3197
|
+
if (quote !== void 0 && (quote.kind !== "redeem" || quote.shares !== params.shares)) {
|
|
3198
|
+
throw new InvalidWithdrawParamsError();
|
|
3199
|
+
}
|
|
3200
|
+
shares = params.shares;
|
|
3201
|
+
} else if (!("amount" in params && params.amount != null)) {
|
|
3202
|
+
throw new InvalidWithdrawParamsError();
|
|
3203
|
+
}
|
|
3204
|
+
if (isV2ExactTokenWithdraw) {
|
|
3205
|
+
requireNonZeroSyncWithdrawBound(params.amount, "tokensOut");
|
|
3206
|
+
if (quote !== void 0) {
|
|
3207
|
+
if (quote.kind !== "withdraw" || quote.tokensOut !== params.amount) {
|
|
3208
|
+
throw new InvalidWithdrawParamsError();
|
|
3209
|
+
}
|
|
3210
|
+
minTokenOut = quote.tokensOut;
|
|
3211
|
+
maxUnitsIn = quote.maxUnitsIn;
|
|
3212
|
+
} else {
|
|
3213
|
+
minTokenOut = params.amount;
|
|
3214
|
+
maxUnitsIn = applySlippageUp(
|
|
3215
|
+
await getSyncWithdrawUnitsIn(
|
|
3216
|
+
publicClient,
|
|
3217
|
+
provisionerAddress,
|
|
3218
|
+
runtime.feeCalculator.address,
|
|
3219
|
+
runtime.feeCalculator.version,
|
|
3220
|
+
vault.vaultAddress,
|
|
3221
|
+
asset.address,
|
|
3222
|
+
params.amount
|
|
3223
|
+
),
|
|
3224
|
+
slippageBps
|
|
3225
|
+
);
|
|
3226
|
+
}
|
|
3227
|
+
requireNonZeroSyncWithdrawBound(maxUnitsIn, "maxUnitsIn");
|
|
3228
|
+
} else {
|
|
3229
|
+
if (shares === void 0) {
|
|
3230
|
+
throw new InvalidWithdrawParamsError();
|
|
3231
|
+
}
|
|
3232
|
+
requireNonZeroSyncWithdrawBound(shares, "unitsIn");
|
|
3233
|
+
if (quote !== void 0) {
|
|
3234
|
+
if (quote.kind !== "redeem" || quote.shares !== shares) {
|
|
3235
|
+
throw new InvalidWithdrawParamsError();
|
|
3236
|
+
}
|
|
3237
|
+
minTokenOut = quote.minTokensOut;
|
|
3238
|
+
} else {
|
|
3239
|
+
const tokensOut = await getSyncRedeemTokenOut(
|
|
3240
|
+
publicClient,
|
|
3241
|
+
provisionerAddress,
|
|
3242
|
+
runtime.feeCalculator.address,
|
|
3243
|
+
runtime.feeCalculator.version,
|
|
3244
|
+
vault.vaultAddress,
|
|
3245
|
+
asset.address,
|
|
3246
|
+
shares
|
|
3247
|
+
);
|
|
3248
|
+
minTokenOut = applySlippageDown(tokensOut, slippageBps);
|
|
3249
|
+
}
|
|
3250
|
+
requireNonZeroSyncWithdrawBound(minTokenOut, "minTokensOut");
|
|
3251
|
+
maxUnitsIn = shares;
|
|
3252
|
+
}
|
|
3253
|
+
} else {
|
|
3254
|
+
if ("entireAmount" in params && params.entireAmount) {
|
|
3255
|
+
shares = await publicClient.readContract({
|
|
3256
|
+
address: vault.vaultAddress,
|
|
3257
|
+
abi: multiDepositorVaultAbi,
|
|
3258
|
+
functionName: "balanceOf",
|
|
3259
|
+
args: [account]
|
|
3260
|
+
});
|
|
3261
|
+
} else if ("amount" in params && params.amount != null) {
|
|
3262
|
+
shares = await getAsyncWithdrawUnitsIn3(
|
|
3263
|
+
publicClient,
|
|
3264
|
+
runtime,
|
|
3265
|
+
vault.vaultAddress,
|
|
3266
|
+
asset.address,
|
|
3267
|
+
params.amount + solverTip
|
|
3268
|
+
);
|
|
3269
|
+
} else if ("shares" in params && params.shares != null) {
|
|
3270
|
+
shares = params.shares;
|
|
3271
|
+
} else {
|
|
3272
|
+
throw new InvalidWithdrawParamsError();
|
|
3273
|
+
}
|
|
3274
|
+
const tokensOut = "amount" in params && params.amount != null ? params.amount : subtractSolverTip(
|
|
3275
|
+
await getAsyncRedeemTokenOut3(
|
|
3276
|
+
publicClient,
|
|
3277
|
+
runtime,
|
|
3278
|
+
vault.vaultAddress,
|
|
3279
|
+
asset.address,
|
|
3280
|
+
shares
|
|
3281
|
+
),
|
|
3282
|
+
solverTip
|
|
3283
|
+
);
|
|
3284
|
+
minTokenOut = applySlippageDown(tokensOut, slippageBps);
|
|
3285
|
+
maxUnitsIn = shares;
|
|
3286
|
+
}
|
|
3287
|
+
if (params.maxShares !== void 0) {
|
|
3288
|
+
if (isAsync || typeof params.maxShares !== "bigint" || params.maxShares <= 0n || !isV2ExactTokenWithdraw && shares !== void 0 && shares > params.maxShares) {
|
|
3289
|
+
throw new InvalidWithdrawParamsError();
|
|
3290
|
+
}
|
|
3291
|
+
if (maxUnitsIn > params.maxShares) maxUnitsIn = params.maxShares;
|
|
3292
|
+
}
|
|
3293
|
+
const steps = [];
|
|
3294
|
+
if (isAsync) {
|
|
3295
|
+
if (shares === void 0) {
|
|
3296
|
+
throw new InvalidWithdrawParamsError();
|
|
3297
|
+
}
|
|
3298
|
+
const { sufficient } = await this.checkAllowance({
|
|
3299
|
+
publicClient,
|
|
3300
|
+
token: vault.vaultAddress,
|
|
3301
|
+
owner: account,
|
|
3302
|
+
spender: provisionerAddress,
|
|
3303
|
+
amount: shares
|
|
3304
|
+
});
|
|
3305
|
+
if (!sufficient) {
|
|
3306
|
+
steps.push(
|
|
3307
|
+
this.buildApproval({
|
|
3308
|
+
token: vault.vaultAddress,
|
|
3309
|
+
spender: provisionerAddress,
|
|
3310
|
+
amount: shares,
|
|
3311
|
+
account
|
|
3312
|
+
})
|
|
3313
|
+
);
|
|
3314
|
+
}
|
|
3315
|
+
const deadline = getRequestDeadline(vault.expirationDays);
|
|
3316
|
+
return [
|
|
3317
|
+
...steps,
|
|
3318
|
+
{
|
|
3319
|
+
type: "requestRedeem",
|
|
3320
|
+
...isContractV2 ? requestRedeemTxRequest2(
|
|
3321
|
+
provisionerAddress,
|
|
3322
|
+
asset.address,
|
|
3323
|
+
shares,
|
|
3324
|
+
minTokenOut,
|
|
3325
|
+
solverTip,
|
|
3326
|
+
deadline,
|
|
3327
|
+
maxPriceAge,
|
|
3328
|
+
false,
|
|
3329
|
+
receiver,
|
|
3330
|
+
account
|
|
3331
|
+
) : requestRedeemTxRequest(
|
|
3332
|
+
provisionerAddress,
|
|
3333
|
+
asset.address,
|
|
3334
|
+
shares,
|
|
3335
|
+
minTokenOut,
|
|
3336
|
+
solverTip,
|
|
3337
|
+
deadline,
|
|
3338
|
+
maxPriceAge,
|
|
3339
|
+
false,
|
|
3340
|
+
account
|
|
3341
|
+
)
|
|
3342
|
+
}
|
|
3343
|
+
];
|
|
3344
|
+
}
|
|
3345
|
+
if ("amount" in params && params.amount != null) {
|
|
3346
|
+
return [
|
|
3347
|
+
...steps,
|
|
3348
|
+
{
|
|
3349
|
+
type: "withdraw",
|
|
3350
|
+
...withdrawTxRequest(
|
|
3351
|
+
provisionerAddress,
|
|
3352
|
+
asset.address,
|
|
3353
|
+
params.amount,
|
|
3354
|
+
maxUnitsIn,
|
|
3355
|
+
receiver,
|
|
3356
|
+
account
|
|
3357
|
+
)
|
|
3358
|
+
}
|
|
3359
|
+
];
|
|
3360
|
+
}
|
|
3361
|
+
if (shares === void 0) {
|
|
3362
|
+
throw new InvalidWithdrawParamsError();
|
|
3363
|
+
}
|
|
3364
|
+
return [
|
|
3365
|
+
...steps,
|
|
3366
|
+
{
|
|
3367
|
+
type: "redeem",
|
|
3368
|
+
...redeemTxRequest(
|
|
3369
|
+
provisionerAddress,
|
|
3370
|
+
asset.address,
|
|
3371
|
+
shares,
|
|
3372
|
+
minTokenOut,
|
|
3373
|
+
receiver,
|
|
3374
|
+
account
|
|
3375
|
+
)
|
|
3376
|
+
}
|
|
3377
|
+
];
|
|
3378
|
+
},
|
|
3379
|
+
async checkAllowance(params) {
|
|
3380
|
+
const { publicClient, token, owner, spender, amount } = params;
|
|
3381
|
+
const current = await publicClient.readContract({
|
|
3382
|
+
address: token,
|
|
3383
|
+
abi: erc20Abi,
|
|
3384
|
+
functionName: "allowance",
|
|
3385
|
+
args: [owner, spender]
|
|
3386
|
+
});
|
|
3387
|
+
return { sufficient: current >= amount, current };
|
|
3388
|
+
},
|
|
3389
|
+
buildApproval(params) {
|
|
3390
|
+
return {
|
|
3391
|
+
type: "approve",
|
|
3392
|
+
address: params.token,
|
|
3393
|
+
abi: erc20Abi,
|
|
3394
|
+
functionName: "approve",
|
|
3395
|
+
args: [params.spender, params.amount],
|
|
3396
|
+
account: params.account
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
|
|
3401
|
+
// src/evm/abis/erc4626.ts
|
|
3402
|
+
var erc4626Abi = [
|
|
3403
|
+
{
|
|
3404
|
+
type: "function",
|
|
3405
|
+
name: "deposit",
|
|
3406
|
+
inputs: [
|
|
3407
|
+
{ name: "assets", type: "uint256" },
|
|
3408
|
+
{ name: "receiver", type: "address" }
|
|
3409
|
+
],
|
|
3410
|
+
outputs: [{ type: "uint256" }],
|
|
3411
|
+
stateMutability: "nonpayable"
|
|
3412
|
+
},
|
|
3413
|
+
{
|
|
3414
|
+
type: "function",
|
|
3415
|
+
name: "redeem",
|
|
3416
|
+
inputs: [
|
|
3417
|
+
{ name: "shares", type: "uint256" },
|
|
3418
|
+
{ name: "receiver", type: "address" },
|
|
3419
|
+
{ name: "owner", type: "address" }
|
|
3420
|
+
],
|
|
3421
|
+
outputs: [{ type: "uint256" }],
|
|
3422
|
+
stateMutability: "nonpayable"
|
|
3423
|
+
},
|
|
3424
|
+
{
|
|
3425
|
+
type: "function",
|
|
3426
|
+
name: "convertToShares",
|
|
3427
|
+
inputs: [{ name: "assets", type: "uint256" }],
|
|
3428
|
+
outputs: [{ type: "uint256" }],
|
|
3429
|
+
stateMutability: "view"
|
|
3430
|
+
},
|
|
3431
|
+
{
|
|
3432
|
+
type: "function",
|
|
3433
|
+
name: "convertToAssets",
|
|
3434
|
+
inputs: [{ name: "shares", type: "uint256" }],
|
|
3435
|
+
outputs: [{ type: "uint256" }],
|
|
3436
|
+
stateMutability: "view"
|
|
3437
|
+
},
|
|
3438
|
+
{
|
|
3439
|
+
type: "function",
|
|
3440
|
+
name: "balanceOf",
|
|
3441
|
+
inputs: [{ name: "account", type: "address" }],
|
|
3442
|
+
outputs: [{ type: "uint256" }],
|
|
3443
|
+
stateMutability: "view"
|
|
3444
|
+
},
|
|
3445
|
+
{
|
|
3446
|
+
type: "function",
|
|
3447
|
+
name: "maxDeposit",
|
|
3448
|
+
inputs: [{ name: "receiver", type: "address" }],
|
|
3449
|
+
outputs: [{ type: "uint256" }],
|
|
3450
|
+
stateMutability: "view"
|
|
3451
|
+
},
|
|
3452
|
+
{
|
|
3453
|
+
type: "function",
|
|
3454
|
+
name: "maxRedeem",
|
|
3455
|
+
inputs: [{ name: "owner", type: "address" }],
|
|
3456
|
+
outputs: [{ type: "uint256" }],
|
|
3457
|
+
stateMutability: "view"
|
|
3458
|
+
},
|
|
3459
|
+
{
|
|
3460
|
+
type: "function",
|
|
3461
|
+
name: "withdraw",
|
|
3462
|
+
inputs: [
|
|
3463
|
+
{ name: "assets", type: "uint256" },
|
|
3464
|
+
{ name: "receiver", type: "address" },
|
|
3465
|
+
{ name: "owner", type: "address" }
|
|
3466
|
+
],
|
|
3467
|
+
outputs: [{ type: "uint256" }],
|
|
3468
|
+
stateMutability: "nonpayable"
|
|
3469
|
+
}
|
|
3470
|
+
];
|
|
3471
|
+
|
|
3472
|
+
// src/evm/adapters/morpho.ts
|
|
3473
|
+
var morphoAdapter = {
|
|
3474
|
+
async buildDeposit(params) {
|
|
3475
|
+
const { vault, amount, receiver, account } = params;
|
|
3476
|
+
return [
|
|
3477
|
+
{
|
|
3478
|
+
type: "deposit",
|
|
3479
|
+
address: vault.vaultAddress,
|
|
3480
|
+
abi: erc4626Abi,
|
|
3481
|
+
functionName: "deposit",
|
|
3482
|
+
args: [amount, receiver],
|
|
3483
|
+
account
|
|
3484
|
+
}
|
|
3485
|
+
];
|
|
3486
|
+
},
|
|
3487
|
+
async buildWithdraw(params) {
|
|
3488
|
+
const { vault, receiver, account, publicClient } = params;
|
|
3489
|
+
let shares;
|
|
3490
|
+
if ("entireAmount" in params && params.entireAmount) {
|
|
3491
|
+
shares = await publicClient.readContract({
|
|
3492
|
+
address: vault.vaultAddress,
|
|
3493
|
+
abi: erc4626Abi,
|
|
3494
|
+
functionName: "balanceOf",
|
|
3495
|
+
args: [account]
|
|
3496
|
+
});
|
|
3497
|
+
} else if ("amount" in params && params.amount != null) {
|
|
3498
|
+
return [
|
|
3499
|
+
{
|
|
3500
|
+
type: "withdraw",
|
|
3501
|
+
address: vault.vaultAddress,
|
|
3502
|
+
abi: erc4626Abi,
|
|
3503
|
+
functionName: "withdraw",
|
|
3504
|
+
args: [params.amount, receiver, account],
|
|
3505
|
+
account
|
|
3506
|
+
}
|
|
3507
|
+
];
|
|
3508
|
+
} else if ("shares" in params && params.shares != null) {
|
|
3509
|
+
shares = params.shares;
|
|
3510
|
+
} else {
|
|
3511
|
+
throw new InvalidWithdrawParamsError();
|
|
3512
|
+
}
|
|
3513
|
+
return [
|
|
3514
|
+
{
|
|
3515
|
+
type: "redeem",
|
|
3516
|
+
address: vault.vaultAddress,
|
|
3517
|
+
abi: erc4626Abi,
|
|
3518
|
+
functionName: "redeem",
|
|
3519
|
+
args: [shares, receiver, account],
|
|
3520
|
+
account
|
|
3521
|
+
}
|
|
3522
|
+
];
|
|
3523
|
+
},
|
|
3524
|
+
async checkAllowance(params) {
|
|
3525
|
+
const { publicClient, token, owner, spender, amount } = params;
|
|
3526
|
+
const current = await publicClient.readContract({
|
|
3527
|
+
address: token,
|
|
3528
|
+
abi: erc20Abi,
|
|
3529
|
+
functionName: "allowance",
|
|
3530
|
+
args: [owner, spender]
|
|
3531
|
+
});
|
|
3532
|
+
return { sufficient: current >= amount, current };
|
|
3533
|
+
},
|
|
3534
|
+
buildApproval(params) {
|
|
3535
|
+
return {
|
|
3536
|
+
type: "approve",
|
|
3537
|
+
address: params.token,
|
|
3538
|
+
abi: erc20Abi,
|
|
3539
|
+
functionName: "approve",
|
|
3540
|
+
args: [params.spender, params.amount],
|
|
3541
|
+
account: params.account
|
|
3542
|
+
};
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
|
|
3546
|
+
// src/evm/adapters/index.ts
|
|
3547
|
+
function getAdapter(protocol) {
|
|
3548
|
+
switch (protocol) {
|
|
3549
|
+
case "aera":
|
|
3550
|
+
return aeraAdapter;
|
|
3551
|
+
case "morpho":
|
|
3552
|
+
return morphoAdapter;
|
|
3553
|
+
default:
|
|
3554
|
+
throw new UnsupportedProtocolError(protocol);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
|
|
3558
|
+
// src/attribution/index.ts
|
|
3559
|
+
import { encodeFunctionData } from "viem";
|
|
3560
|
+
|
|
3561
|
+
// src/attribution/erc8021.ts
|
|
3562
|
+
import { toHex } from "viem";
|
|
3563
|
+
var ERC8021_MARKER = "80218021802180218021802180218021";
|
|
3564
|
+
var ERC8021_SCHEMA_ID = "00";
|
|
3565
|
+
function encodeBuilderCode(builderCode) {
|
|
3566
|
+
const codeHex = toHex(builderCode).slice(2);
|
|
3567
|
+
const codeByteLen = codeHex.length / 2;
|
|
3568
|
+
const codeLengthHex = codeByteLen.toString(16).padStart(2, "0");
|
|
3569
|
+
return `0x${codeHex}${codeLengthHex}${ERC8021_SCHEMA_ID}${ERC8021_MARKER}`;
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
// src/attribution/index.ts
|
|
3573
|
+
async function buildAttribution(client) {
|
|
3574
|
+
switch (client.attributionMode) {
|
|
3575
|
+
case "public" /* PUBLIC */:
|
|
3576
|
+
return client.builderCode ? encodeBuilderCode(client.builderCode) : "0x";
|
|
3577
|
+
case "encoded" /* ENCODED */:
|
|
3578
|
+
throw new UnimplementedFeatureError("AttributionMode.ENCODED");
|
|
3579
|
+
case "private" /* PRIVATE */:
|
|
3580
|
+
throw new UnimplementedFeatureError("AttributionMode.PRIVATE");
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
async function encodeTransactionWithAttribution(client, transaction, chainId) {
|
|
3584
|
+
const customAttribution = await buildAttribution(client);
|
|
3585
|
+
const encodedTx = encodeFunctionData({
|
|
3586
|
+
abi: transaction.abi,
|
|
3587
|
+
functionName: transaction.functionName,
|
|
3588
|
+
args: transaction.args
|
|
3589
|
+
});
|
|
3590
|
+
const encodedTxWithAttribution = `${encodedTx}${customAttribution.replace("0x", "")}`;
|
|
3591
|
+
return {
|
|
3592
|
+
payload: {
|
|
3593
|
+
type: transaction.type,
|
|
3594
|
+
account: transaction.account,
|
|
3595
|
+
to: transaction.address,
|
|
3596
|
+
chainId,
|
|
3597
|
+
data: encodedTxWithAttribution
|
|
3598
|
+
},
|
|
3599
|
+
tx: {
|
|
3600
|
+
...transaction,
|
|
3601
|
+
chainId,
|
|
3602
|
+
attribution: customAttribution
|
|
3603
|
+
}
|
|
3604
|
+
};
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3607
|
+
// src/evm/operationMode.ts
|
|
3608
|
+
function formatAvailableModes(support) {
|
|
3609
|
+
if (support.async && support.sync) return "both";
|
|
3610
|
+
if (support.async) return "async";
|
|
3611
|
+
if (support.sync) return "sync";
|
|
3612
|
+
return "none";
|
|
3613
|
+
}
|
|
3614
|
+
function parseOperationMode(vaultId, requested) {
|
|
3615
|
+
if (requested === void 0 || requested === "sync" || requested === "async") {
|
|
3616
|
+
return requested;
|
|
3617
|
+
}
|
|
3618
|
+
throw new UnsupportedDepositModeError(vaultId, requested, "sync, async");
|
|
3619
|
+
}
|
|
3620
|
+
function resolveOperationMode(vaultId, requested, support) {
|
|
3621
|
+
const available = formatAvailableModes(support);
|
|
3622
|
+
if (requested === "sync") {
|
|
3623
|
+
if (!support.sync) throw new UnsupportedDepositModeError(vaultId, "sync", available);
|
|
3624
|
+
return "sync";
|
|
3625
|
+
}
|
|
3626
|
+
if (requested === "async") {
|
|
3627
|
+
if (!support.async) throw new UnsupportedDepositModeError(vaultId, "async", available);
|
|
3628
|
+
return "async";
|
|
3629
|
+
}
|
|
3630
|
+
if (support.async) return "async";
|
|
3631
|
+
if (support.sync) return "sync";
|
|
3632
|
+
throw new UnsupportedDepositModeError(vaultId, "async", available);
|
|
3633
|
+
}
|
|
3634
|
+
function resolveSyncOnlyOperationMode(vaultId, requested) {
|
|
3635
|
+
if (requested === "async") {
|
|
3636
|
+
throw new UnsupportedDepositModeError(vaultId, "async", "sync");
|
|
3637
|
+
}
|
|
3638
|
+
return "sync";
|
|
3639
|
+
}
|
|
3640
|
+
|
|
3641
|
+
// src/evm/deposit.ts
|
|
3642
|
+
async function getDepositTx(client, params) {
|
|
3643
|
+
params = structuredClone(params);
|
|
3644
|
+
const slippageBps = params.slippageBps ?? DEFAULT_BPS;
|
|
3645
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > Number(MAX_BPS)) {
|
|
3646
|
+
throw new InvalidSlippageBPSError(slippageBps);
|
|
3647
|
+
}
|
|
3648
|
+
if (params.minUnitsOut !== void 0 && (typeof params.minUnitsOut !== "bigint" || params.minUnitsOut <= 0n)) {
|
|
3649
|
+
throw new InvalidSyncDepositBoundError();
|
|
3650
|
+
}
|
|
3651
|
+
const resolved = await resolveVault(client, params.vaultId, params.chainId);
|
|
3652
|
+
if (!resolved) throw new VaultNotFoundError(params.vaultId);
|
|
3653
|
+
const chainId = params.chainId ?? resolved.vault.chainId;
|
|
3654
|
+
const account = client.wallet?.account?.address;
|
|
3655
|
+
if (!account) throw new AccountRequiredError();
|
|
3656
|
+
const { vault, protocol } = resolved;
|
|
3657
|
+
const adapter = getAdapter(protocol);
|
|
3658
|
+
const publicClient = client.getPublicClient(chainId);
|
|
3659
|
+
const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
|
|
3660
|
+
if (token === void 0) {
|
|
3661
|
+
throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
|
|
3662
|
+
}
|
|
3663
|
+
const requestedDepositMode = parseOperationMode(params.vaultId, params.depositMode);
|
|
3664
|
+
if (params.minUnitsOut !== void 0 && (protocol !== "aera" || requestedDepositMode !== "sync")) {
|
|
3665
|
+
throw new InvalidSyncDepositBoundError();
|
|
3666
|
+
}
|
|
3667
|
+
let modifiedDepositMode;
|
|
3668
|
+
let aeraRuntime;
|
|
3669
|
+
if (protocol === "aera") {
|
|
3670
|
+
aeraRuntime = await resolveAeraRuntimeContracts(publicClient, vault);
|
|
3671
|
+
const tokenModeSupport = await resolveAeraTokenModeSupport(
|
|
3672
|
+
publicClient,
|
|
3673
|
+
aeraRuntime,
|
|
3674
|
+
token.address,
|
|
3675
|
+
{ includeSyncModes: requestedDepositMode !== "async" }
|
|
3676
|
+
);
|
|
3677
|
+
modifiedDepositMode = resolveOperationMode(params.vaultId, requestedDepositMode, {
|
|
3678
|
+
async: tokenModeSupport.asyncDeposit,
|
|
3679
|
+
sync: tokenModeSupport.syncDeposit
|
|
3680
|
+
});
|
|
3681
|
+
} else {
|
|
3682
|
+
modifiedDepositMode = resolveSyncOnlyOperationMode(params.vaultId, requestedDepositMode);
|
|
3683
|
+
}
|
|
3684
|
+
const spender = protocol === "aera" && modifiedDepositMode === "async" ? aeraRuntime.provisioner.address : vault.vaultAddress;
|
|
3685
|
+
const { sufficient, current } = await adapter.checkAllowance({
|
|
3686
|
+
publicClient,
|
|
3687
|
+
token: token.address,
|
|
3688
|
+
owner: account,
|
|
3689
|
+
spender,
|
|
3690
|
+
amount: params.amount
|
|
3691
|
+
});
|
|
3692
|
+
const steps = [];
|
|
3693
|
+
if (!sufficient) {
|
|
3694
|
+
const approval = adapter.buildApproval({
|
|
3695
|
+
token: token.address,
|
|
3696
|
+
spender,
|
|
3697
|
+
amount: params.amount,
|
|
3698
|
+
account
|
|
3699
|
+
});
|
|
3700
|
+
if (current > 0n && params.amount > 0n) {
|
|
3701
|
+
try {
|
|
3702
|
+
await publicClient.estimateContractGas({
|
|
3703
|
+
address: approval.address,
|
|
3704
|
+
abi: approval.abi,
|
|
3705
|
+
functionName: "approve",
|
|
3706
|
+
args: approval.args,
|
|
3707
|
+
account
|
|
3708
|
+
});
|
|
3709
|
+
} catch (approvalError) {
|
|
3710
|
+
const reset = adapter.buildApproval({
|
|
3711
|
+
token: token.address,
|
|
3712
|
+
spender,
|
|
3713
|
+
amount: 0n,
|
|
3714
|
+
account
|
|
3715
|
+
});
|
|
3716
|
+
try {
|
|
3717
|
+
await publicClient.estimateContractGas({
|
|
3718
|
+
address: reset.address,
|
|
3719
|
+
abi: reset.abi,
|
|
3720
|
+
functionName: "approve",
|
|
3721
|
+
args: reset.args,
|
|
3722
|
+
account
|
|
3723
|
+
});
|
|
3724
|
+
} catch {
|
|
3725
|
+
throw approvalError;
|
|
3726
|
+
}
|
|
3727
|
+
steps.push(reset);
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
steps.push(approval);
|
|
3731
|
+
}
|
|
3732
|
+
const depositSteps = await adapter.buildDeposit({
|
|
3733
|
+
vault,
|
|
3734
|
+
amount: params.amount,
|
|
3735
|
+
receiver: params.receiver ?? account,
|
|
3736
|
+
account,
|
|
3737
|
+
async: modifiedDepositMode === "async",
|
|
3738
|
+
asset: token,
|
|
3739
|
+
publicClient,
|
|
3740
|
+
slippageBps,
|
|
3741
|
+
solverTip: params.solverTip,
|
|
3742
|
+
maxPriceAge: params.maxPriceAge,
|
|
3743
|
+
aeraRuntime,
|
|
3744
|
+
minUnitsOut: params.minUnitsOut
|
|
3745
|
+
});
|
|
3746
|
+
steps.push(...depositSteps);
|
|
3747
|
+
return Promise.all(steps.map((step) => encodeTransactionWithAttribution(client, step, chainId)));
|
|
3748
|
+
}
|
|
3749
|
+
|
|
3750
|
+
// src/evm/depositReceiverApproval.ts
|
|
3751
|
+
async function getDepositReceiverApprovalTx(client, params) {
|
|
3752
|
+
params = { ...params };
|
|
3753
|
+
const resolved = await resolveVault(client, params.vaultId, params.chainId);
|
|
3754
|
+
if (!resolved) throw new VaultNotFoundError(params.vaultId);
|
|
3755
|
+
const chainId = params.chainId ?? resolved.vault.chainId;
|
|
3756
|
+
const receiver = client.wallet?.account?.address;
|
|
3757
|
+
if (!receiver) throw new AccountRequiredError();
|
|
3758
|
+
const { vault } = resolved;
|
|
3759
|
+
const publicClient = client.getPublicClient(chainId);
|
|
3760
|
+
const runtime = await resolveAeraRuntimeContracts(publicClient, vault);
|
|
3761
|
+
if (runtime.provisioner.version !== ContractVersion.V2) {
|
|
3762
|
+
throw new UnsupportedFeatureError("Aera: deposit receiver approval on V1");
|
|
3763
|
+
}
|
|
3764
|
+
return encodeTransactionWithAttribution(
|
|
3765
|
+
client,
|
|
3766
|
+
{
|
|
3767
|
+
type: "setDepositReceiverApproval",
|
|
3768
|
+
...setDepositReceiverApprovalTxRequest(
|
|
3769
|
+
runtime.provisioner.address,
|
|
3770
|
+
params.depositor,
|
|
3771
|
+
params.approved ?? true,
|
|
3772
|
+
receiver
|
|
3773
|
+
)
|
|
3774
|
+
},
|
|
3775
|
+
chainId
|
|
3776
|
+
);
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3779
|
+
// src/evm/depositQuote.ts
|
|
3780
|
+
async function resolveSyncDepositContext(client, params, readKind) {
|
|
3781
|
+
const resolved = await resolveVault(client, params.vaultId, params.chainId);
|
|
3782
|
+
if (!resolved) throw new VaultNotFoundError(params.vaultId, params.chainId);
|
|
3783
|
+
if (resolved.protocol !== "aera") {
|
|
3784
|
+
throw new UnsupportedFeatureError(
|
|
3785
|
+
readKind === "quote" ? "Sync deposit quote is only available for Aera vaults" : "Sync deposit rate is only available for Aera vaults"
|
|
3786
|
+
);
|
|
3787
|
+
}
|
|
3788
|
+
const { vault } = resolved;
|
|
3789
|
+
const token = vault.supplyToken.length > 1 ? vault.supplyToken.find(({ symbol }) => symbol === params.assetSymbol) : vault.supplyToken[0];
|
|
3790
|
+
if (!token) throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
|
|
3791
|
+
const publicClient = client.getPublicClient(params.chainId ?? vault.chainId);
|
|
3792
|
+
const runtime = await resolveAeraRuntimeContracts(publicClient, vault);
|
|
3793
|
+
if (runtime.provisioner.version !== ContractVersion.V2) {
|
|
3794
|
+
throw new UnsupportedFeatureError(
|
|
3795
|
+
readKind === "quote" ? "Sync deposit quote requires an Aera V2 provisioner" : "Sync deposit rate requires an Aera V2 provisioner"
|
|
3796
|
+
);
|
|
3797
|
+
}
|
|
3798
|
+
const tokenModeSupport = await resolveAeraTokenModeSupport(publicClient, runtime, token.address, {
|
|
3799
|
+
includeSyncModes: true
|
|
3800
|
+
});
|
|
3801
|
+
resolveOperationMode(params.vaultId, "sync", {
|
|
3802
|
+
async: tokenModeSupport.asyncDeposit,
|
|
3803
|
+
sync: tokenModeSupport.syncDeposit
|
|
3804
|
+
});
|
|
3805
|
+
return { publicClient, vault, token, runtime };
|
|
3806
|
+
}
|
|
3807
|
+
async function getSyncDepositQuote2(client, params) {
|
|
3808
|
+
params = structuredClone(params);
|
|
3809
|
+
const slippageBps = params.slippageBps ?? DEFAULT_BPS;
|
|
3810
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > Number(MAX_BPS)) {
|
|
3811
|
+
throw new InvalidSlippageBPSError(slippageBps);
|
|
3812
|
+
}
|
|
3813
|
+
const { publicClient, vault, token, runtime } = await resolveSyncDepositContext(
|
|
3814
|
+
client,
|
|
3815
|
+
params,
|
|
3816
|
+
"quote"
|
|
3817
|
+
);
|
|
3818
|
+
const { unitsOut, feeBps, numeraireOut } = await getSyncDepositQuoteValues(
|
|
3819
|
+
publicClient,
|
|
3820
|
+
runtime.provisioner.address,
|
|
3821
|
+
runtime.feeCalculator.address,
|
|
3822
|
+
runtime.feeCalculator.version,
|
|
3823
|
+
vault.vaultAddress,
|
|
3824
|
+
token.address,
|
|
3825
|
+
params.amount
|
|
3826
|
+
);
|
|
3827
|
+
const minUnitsOut = applySlippageDown(unitsOut, slippageBps);
|
|
3828
|
+
if (minUnitsOut <= 0n) throw new InvalidSyncDepositBoundError();
|
|
3829
|
+
return { unitsOut, minUnitsOut, numeraireOut, feeBps, slippageBps };
|
|
3830
|
+
}
|
|
3831
|
+
async function getSyncDepositRate(client, params) {
|
|
3832
|
+
const { publicClient, runtime, token } = await resolveSyncDepositContext(client, params, "rate");
|
|
3833
|
+
const feeBps = await getSyncDepositFeeBps(
|
|
3834
|
+
publicClient,
|
|
3835
|
+
runtime.provisioner.address,
|
|
3836
|
+
token.address
|
|
3837
|
+
);
|
|
3838
|
+
return { feeBps };
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
// src/evm/withdraw.ts
|
|
3842
|
+
function validateWithdrawParams(params) {
|
|
3843
|
+
if (params.entireAmount !== void 0 && typeof params.entireAmount !== "boolean") {
|
|
3844
|
+
throw new InvalidWithdrawParamsError();
|
|
3845
|
+
}
|
|
3846
|
+
if (params.amount !== void 0 && params.amount < 0n || params.shares !== void 0 && params.shares < 0n) {
|
|
3847
|
+
throw new InvalidWithdrawParamsError();
|
|
3848
|
+
}
|
|
3849
|
+
const modes = [
|
|
3850
|
+
"amount" in params && params.amount != null,
|
|
3851
|
+
"shares" in params && params.shares != null,
|
|
3852
|
+
"entireAmount" in params && params.entireAmount === true
|
|
3853
|
+
].filter(Boolean).length;
|
|
3854
|
+
if (modes !== 1) throw new InvalidWithdrawParamsError();
|
|
3855
|
+
}
|
|
3856
|
+
function sameAddress(left, right) {
|
|
3857
|
+
return left.toLowerCase() === right.toLowerCase();
|
|
3858
|
+
}
|
|
3859
|
+
function validateSyncWithdrawQuote({
|
|
3860
|
+
params,
|
|
3861
|
+
account,
|
|
3862
|
+
chainId,
|
|
3863
|
+
slippageBps,
|
|
3864
|
+
tokenAddress
|
|
3865
|
+
}) {
|
|
3866
|
+
const quote = params.syncWithdrawQuote;
|
|
3867
|
+
if (quote === void 0) return;
|
|
3868
|
+
const { context } = quote;
|
|
3869
|
+
if (context.vaultId !== params.vaultId || context.chainId !== chainId || !sameAddress(context.tokenAddress, tokenAddress) || context.slippageBps !== slippageBps) {
|
|
3870
|
+
throw new InvalidWithdrawParamsError();
|
|
3871
|
+
}
|
|
3872
|
+
if (context.account !== void 0 && !sameAddress(context.account, account)) {
|
|
3873
|
+
throw new InvalidWithdrawParamsError();
|
|
3874
|
+
}
|
|
3875
|
+
switch (context.request.mode) {
|
|
3876
|
+
case "amount":
|
|
3877
|
+
if (quote.kind !== "withdraw" || !("amount" in params && params.amount != null) || context.request.amount !== params.amount || quote.tokensOut !== params.amount) {
|
|
3878
|
+
throw new InvalidWithdrawParamsError();
|
|
3879
|
+
}
|
|
3880
|
+
return;
|
|
3881
|
+
case "shares":
|
|
3882
|
+
if (quote.kind !== "redeem" || !("shares" in params && params.shares != null) || context.request.shares !== params.shares || quote.shares !== params.shares) {
|
|
3883
|
+
throw new InvalidWithdrawParamsError();
|
|
3884
|
+
}
|
|
3885
|
+
return;
|
|
3886
|
+
case "entireAmount":
|
|
3887
|
+
if (quote.kind !== "redeem" || !("entireAmount" in params && params.entireAmount) || !sameAddress(context.request.account, account)) {
|
|
3888
|
+
throw new InvalidWithdrawParamsError();
|
|
3889
|
+
}
|
|
3890
|
+
return;
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
async function getWithdrawTx(client, params) {
|
|
3894
|
+
params = structuredClone(params);
|
|
3895
|
+
validateWithdrawParams(params);
|
|
3896
|
+
if (params.slippageBps !== void 0 && (!Number.isInteger(params.slippageBps) || params.slippageBps < 0 || params.slippageBps > Number(MAX_BPS))) {
|
|
3897
|
+
throw new InvalidSlippageBPSError(params.slippageBps);
|
|
3898
|
+
}
|
|
3899
|
+
const resolved = await resolveVault(client, params.vaultId, params.chainId);
|
|
3900
|
+
if (!resolved) throw new VaultNotFoundError(params.vaultId);
|
|
3901
|
+
const chainId = params.chainId ?? resolved.vault.chainId;
|
|
3902
|
+
const account = client.wallet?.account?.address;
|
|
3903
|
+
if (!account) throw new AccountRequiredError();
|
|
3904
|
+
if ("entireAmount" in params && params.entireAmount && params.account !== void 0) {
|
|
3905
|
+
if (!sameAddress(params.account, account)) {
|
|
3906
|
+
throw new AccountMismatchError(account, params.account);
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
const { vault, protocol } = resolved;
|
|
3910
|
+
if (params.maxShares !== void 0 && protocol !== "aera") {
|
|
3911
|
+
throw new UnsupportedFeatureError("maxShares requires an Aera sync withdrawal");
|
|
3912
|
+
}
|
|
3913
|
+
const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
|
|
3914
|
+
if (token === void 0) {
|
|
3915
|
+
throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
|
|
3916
|
+
}
|
|
3917
|
+
const adapter = getAdapter(protocol);
|
|
3918
|
+
const publicClient = client.getPublicClient(chainId);
|
|
3919
|
+
const requestedWithdrawMode = parseOperationMode(params.vaultId, params.depositMode);
|
|
3920
|
+
const slippageBps = params.slippageBps ?? params.syncWithdrawQuote?.context.slippageBps ?? DEFAULT_BPS;
|
|
3921
|
+
let modifiedDepositMode;
|
|
3922
|
+
let aeraRuntime;
|
|
3923
|
+
if (params.syncWithdrawQuote !== void 0) {
|
|
3924
|
+
if (protocol !== "aera" || requestedWithdrawMode === "async") {
|
|
3925
|
+
throw new InvalidWithdrawParamsError();
|
|
3926
|
+
}
|
|
3927
|
+
validateSyncWithdrawQuote({
|
|
3928
|
+
params,
|
|
3929
|
+
account,
|
|
3930
|
+
chainId,
|
|
3931
|
+
slippageBps,
|
|
3932
|
+
tokenAddress: token.address
|
|
3933
|
+
});
|
|
3934
|
+
}
|
|
3935
|
+
if (protocol === "aera") {
|
|
3936
|
+
aeraRuntime = await resolveAeraRuntimeContracts(publicClient, vault);
|
|
3937
|
+
if (aeraRuntime.provisioner.version === ContractVersion.V2 && (requestedWithdrawMode === "sync" || params.syncWithdrawQuote !== void 0)) {
|
|
3938
|
+
requireAeraSyncRedeemRuntime(aeraRuntime);
|
|
3939
|
+
}
|
|
3940
|
+
const tokenModeSupport = await resolveAeraTokenModeSupport(
|
|
3941
|
+
publicClient,
|
|
3942
|
+
aeraRuntime,
|
|
3943
|
+
token.address,
|
|
3944
|
+
{ includeSyncModes: requestedWithdrawMode !== "async" }
|
|
3945
|
+
);
|
|
3946
|
+
modifiedDepositMode = resolveOperationMode(
|
|
3947
|
+
params.vaultId,
|
|
3948
|
+
params.syncWithdrawQuote !== void 0 ? "sync" : requestedWithdrawMode,
|
|
3949
|
+
{
|
|
3950
|
+
async: tokenModeSupport.asyncRedeem,
|
|
3951
|
+
sync: tokenModeSupport.syncRedeem
|
|
3952
|
+
}
|
|
3953
|
+
);
|
|
3954
|
+
if (modifiedDepositMode === "sync") requireAeraSyncRedeemRuntime(aeraRuntime);
|
|
3955
|
+
} else {
|
|
3956
|
+
modifiedDepositMode = resolveSyncOnlyOperationMode(params.vaultId, requestedWithdrawMode);
|
|
3957
|
+
}
|
|
3958
|
+
const withdrawParams = {
|
|
3959
|
+
vault,
|
|
3960
|
+
receiver: params.receiver ?? account,
|
|
3961
|
+
account,
|
|
3962
|
+
async: modifiedDepositMode === "async",
|
|
3963
|
+
asset: token,
|
|
3964
|
+
publicClient,
|
|
3965
|
+
slippageBps,
|
|
3966
|
+
solverTip: params.solverTip,
|
|
3967
|
+
maxPriceAge: params.maxPriceAge,
|
|
3968
|
+
aeraRuntime,
|
|
3969
|
+
syncWithdrawQuote: params.syncWithdrawQuote,
|
|
3970
|
+
maxShares: params.maxShares,
|
|
3971
|
+
..."shares" in params && params.shares != null ? { shares: params.shares } : {},
|
|
3972
|
+
..."amount" in params && params.amount != null ? { amount: params.amount } : {},
|
|
3973
|
+
..."entireAmount" in params && params.entireAmount ? { entireAmount: true } : {}
|
|
3974
|
+
};
|
|
3975
|
+
const steps = await adapter.buildWithdraw(withdrawParams);
|
|
3976
|
+
return await Promise.all(
|
|
3977
|
+
steps.map((step) => encodeTransactionWithAttribution(client, step, chainId))
|
|
3978
|
+
);
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
// src/evm/withdrawQuote.ts
|
|
3982
|
+
function validateSyncWithdrawQuoteParams(params) {
|
|
3983
|
+
const modes = [
|
|
3984
|
+
"amount" in params && params.amount != null,
|
|
3985
|
+
"shares" in params && params.shares != null,
|
|
3986
|
+
"entireAmount" in params && params.entireAmount === true
|
|
3987
|
+
].filter(Boolean).length;
|
|
3988
|
+
if (modes !== 1) throw new InvalidWithdrawParamsError();
|
|
3989
|
+
if ("entireAmount" in params && params.entireAmount === true && !params.account) {
|
|
3990
|
+
throw new AccountRequiredError();
|
|
3991
|
+
}
|
|
3992
|
+
}
|
|
3993
|
+
async function resolveSyncWithdrawContext(client, params, readKind) {
|
|
3994
|
+
const resolved = await resolveVault(client, params.vaultId, params.chainId);
|
|
3995
|
+
if (!resolved) throw new VaultNotFoundError(params.vaultId);
|
|
3996
|
+
const { vault, protocol } = resolved;
|
|
3997
|
+
if (protocol !== "aera") {
|
|
3998
|
+
throw new UnsupportedFeatureError(
|
|
3999
|
+
readKind === "quote" ? "Sync withdraw quote is only available for Aera vaults" : "Sync withdraw rate is only available for Aera vaults"
|
|
4000
|
+
);
|
|
4001
|
+
}
|
|
4002
|
+
const chainId = params.chainId ?? vault.chainId;
|
|
4003
|
+
const publicClient = client.getPublicClient(chainId);
|
|
4004
|
+
const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
|
|
4005
|
+
if (token === void 0) {
|
|
4006
|
+
throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
|
|
4007
|
+
}
|
|
4008
|
+
const quoteBlock = await publicClient.getBlock();
|
|
4009
|
+
if (quoteBlock.number === null) {
|
|
4010
|
+
throw new UnsupportedFeatureError(
|
|
4011
|
+
readKind === "quote" ? "Aera: sync withdraw quote requires a numbered block" : "Aera: sync withdraw rate requires a numbered block"
|
|
4012
|
+
);
|
|
4013
|
+
}
|
|
4014
|
+
const readContext = {
|
|
4015
|
+
blockNumber: quoteBlock.number,
|
|
4016
|
+
blockTimestamp: BigInt(quoteBlock.timestamp)
|
|
4017
|
+
};
|
|
4018
|
+
const runtime = await resolveAeraRuntimeContracts(publicClient, vault, readContext);
|
|
4019
|
+
requireAeraSyncRedeemRuntime(runtime);
|
|
4020
|
+
const support = await resolveAeraTokenModeSupport(
|
|
4021
|
+
publicClient,
|
|
4022
|
+
runtime,
|
|
4023
|
+
token.address,
|
|
4024
|
+
readContext
|
|
4025
|
+
);
|
|
4026
|
+
resolveOperationMode(params.vaultId, "sync", {
|
|
4027
|
+
async: support.asyncRedeem,
|
|
4028
|
+
sync: support.syncRedeem
|
|
4029
|
+
});
|
|
4030
|
+
return { publicClient, vault, token, runtime, chainId, readContext };
|
|
4031
|
+
}
|
|
4032
|
+
async function getSyncWithdrawRate(client, params) {
|
|
4033
|
+
const { publicClient, vault, token, runtime, readContext } = await resolveSyncWithdrawContext(
|
|
4034
|
+
client,
|
|
4035
|
+
params,
|
|
4036
|
+
"rate"
|
|
4037
|
+
);
|
|
4038
|
+
return getSyncRedeemRate(
|
|
4039
|
+
publicClient,
|
|
4040
|
+
runtime.provisioner.address,
|
|
4041
|
+
vault.vaultAddress,
|
|
4042
|
+
token.address,
|
|
4043
|
+
runtime.feeCalculator.address,
|
|
4044
|
+
readContext
|
|
4045
|
+
);
|
|
4046
|
+
}
|
|
4047
|
+
async function getSyncWithdrawQuote(client, params) {
|
|
4048
|
+
params = structuredClone(params);
|
|
4049
|
+
validateSyncWithdrawQuoteParams(params);
|
|
4050
|
+
if (params.slippageBps !== void 0 && (!Number.isInteger(params.slippageBps) || params.slippageBps < 0 || params.slippageBps > Number(MAX_BPS))) {
|
|
4051
|
+
throw new InvalidSlippageBPSError(params.slippageBps);
|
|
4052
|
+
}
|
|
4053
|
+
const slippageBps = params.slippageBps ?? DEFAULT_BPS;
|
|
4054
|
+
const {
|
|
4055
|
+
publicClient,
|
|
4056
|
+
vault,
|
|
4057
|
+
token,
|
|
4058
|
+
runtime,
|
|
4059
|
+
chainId,
|
|
4060
|
+
readContext: quoteReadContext
|
|
4061
|
+
} = await resolveSyncWithdrawContext(client, params, "quote");
|
|
4062
|
+
const provisioner = runtime.provisioner.address;
|
|
4063
|
+
const feeCalculator = runtime.feeCalculator.address;
|
|
4064
|
+
const feeVersion = runtime.feeCalculator.version;
|
|
4065
|
+
const vaultAddress = vault.vaultAddress;
|
|
4066
|
+
const { rate, hasPullFundsSubmitData } = await getSyncRedeemRateContext(
|
|
4067
|
+
publicClient,
|
|
4068
|
+
provisioner,
|
|
4069
|
+
vaultAddress,
|
|
4070
|
+
token.address,
|
|
4071
|
+
feeCalculator,
|
|
4072
|
+
quoteReadContext
|
|
4073
|
+
);
|
|
4074
|
+
let kind;
|
|
4075
|
+
let shares;
|
|
4076
|
+
let tokensOut;
|
|
4077
|
+
let minTokensOut;
|
|
4078
|
+
let maxUnitsIn;
|
|
4079
|
+
let request;
|
|
4080
|
+
let shareSafeTokensOut;
|
|
4081
|
+
if ("amount" in params && params.amount != null) {
|
|
4082
|
+
kind = "withdraw";
|
|
4083
|
+
request = { mode: "amount", amount: params.amount };
|
|
4084
|
+
tokensOut = params.amount;
|
|
4085
|
+
requireNonZeroSyncWithdrawBound(tokensOut, "tokensOut");
|
|
4086
|
+
minTokensOut = params.amount;
|
|
4087
|
+
shares = await getSyncWithdrawUnitsIn(
|
|
4088
|
+
publicClient,
|
|
4089
|
+
provisioner,
|
|
4090
|
+
feeCalculator,
|
|
4091
|
+
feeVersion,
|
|
4092
|
+
vaultAddress,
|
|
4093
|
+
token.address,
|
|
4094
|
+
params.amount,
|
|
4095
|
+
rate.effectiveMultiplierBps,
|
|
4096
|
+
quoteReadContext
|
|
4097
|
+
);
|
|
4098
|
+
maxUnitsIn = applySlippageUp(shares, slippageBps);
|
|
4099
|
+
requireNonZeroSyncWithdrawBound(maxUnitsIn, "maxUnitsIn");
|
|
4100
|
+
} else {
|
|
4101
|
+
kind = "redeem";
|
|
4102
|
+
if ("entireAmount" in params && params.entireAmount) {
|
|
4103
|
+
if (!params.account) throw new AccountRequiredError();
|
|
4104
|
+
request = { mode: "entireAmount", account: params.account };
|
|
4105
|
+
shares = await publicClient.readContract({
|
|
4106
|
+
address: vaultAddress,
|
|
4107
|
+
abi: multiDepositorVaultAbi,
|
|
4108
|
+
functionName: "balanceOf",
|
|
4109
|
+
args: [params.account],
|
|
4110
|
+
blockNumber: quoteReadContext.blockNumber
|
|
4111
|
+
});
|
|
4112
|
+
} else if ("shares" in params && params.shares != null) {
|
|
4113
|
+
request = { mode: "shares", shares: params.shares };
|
|
4114
|
+
shares = params.shares;
|
|
4115
|
+
} else {
|
|
4116
|
+
throw new InvalidWithdrawParamsError();
|
|
4117
|
+
}
|
|
4118
|
+
requireNonZeroSyncWithdrawBound(shares, "unitsIn");
|
|
4119
|
+
const getTokensOut = (unitsIn) => getSyncRedeemTokenOut(
|
|
4120
|
+
publicClient,
|
|
4121
|
+
provisioner,
|
|
4122
|
+
feeCalculator,
|
|
4123
|
+
feeVersion,
|
|
4124
|
+
vaultAddress,
|
|
4125
|
+
token.address,
|
|
4126
|
+
unitsIn,
|
|
4127
|
+
rate.effectiveMultiplierBps,
|
|
4128
|
+
quoteReadContext
|
|
4129
|
+
);
|
|
4130
|
+
const shareSafeUnitsIn = shares * MAX_BPS / (MAX_BPS + BigInt(slippageBps));
|
|
4131
|
+
const tokensOutPromise = getTokensOut(shares);
|
|
4132
|
+
const shareSafeTokensOutPromise = shareSafeUnitsIn === shares ? tokensOutPromise : getTokensOut(shareSafeUnitsIn);
|
|
4133
|
+
[tokensOut, shareSafeTokensOut] = await Promise.all([
|
|
4134
|
+
tokensOutPromise,
|
|
4135
|
+
shareSafeTokensOutPromise
|
|
4136
|
+
]);
|
|
4137
|
+
minTokensOut = applySlippageDown(tokensOut, slippageBps);
|
|
4138
|
+
requireNonZeroSyncWithdrawBound(minTokensOut, "minTokensOut");
|
|
4139
|
+
maxUnitsIn = shares;
|
|
4140
|
+
}
|
|
4141
|
+
const [epoch, requestNumeraire, unitsLockedUntil, knownLiquidityTokens] = await Promise.all([
|
|
4142
|
+
getSyncRedeemEpochState(publicClient, provisioner, quoteReadContext),
|
|
4143
|
+
convertTokenToNumeraire(
|
|
4144
|
+
publicClient,
|
|
4145
|
+
feeCalculator,
|
|
4146
|
+
feeVersion,
|
|
4147
|
+
vaultAddress,
|
|
4148
|
+
token.address,
|
|
4149
|
+
tokensOut,
|
|
4150
|
+
quoteReadContext
|
|
4151
|
+
),
|
|
4152
|
+
params.account ? getUserUnitsRefundableUntil(publicClient, provisioner, params.account, quoteReadContext) : Promise.resolve(void 0),
|
|
4153
|
+
getKnownSyncRedeemLiquidityTokens(
|
|
4154
|
+
publicClient,
|
|
4155
|
+
vaultAddress,
|
|
4156
|
+
token.address,
|
|
4157
|
+
hasPullFundsSubmitData,
|
|
4158
|
+
quoteReadContext
|
|
4159
|
+
)
|
|
4160
|
+
]);
|
|
4161
|
+
const remainingNumeraire = epoch.epochCapNumeraire > epoch.epochRedeemedNumeraire ? epoch.epochCapNumeraire - epoch.epochRedeemedNumeraire : 0n;
|
|
4162
|
+
const remainingTokens = await convertNumeraireToToken(
|
|
4163
|
+
publicClient,
|
|
4164
|
+
feeCalculator,
|
|
4165
|
+
feeVersion,
|
|
4166
|
+
vaultAddress,
|
|
4167
|
+
token.address,
|
|
4168
|
+
remainingNumeraire,
|
|
4169
|
+
quoteReadContext
|
|
4170
|
+
);
|
|
4171
|
+
const quoteDetails = {
|
|
4172
|
+
shares,
|
|
4173
|
+
maxUnitsIn,
|
|
4174
|
+
tokensOut,
|
|
4175
|
+
minTokensOut,
|
|
4176
|
+
shareSafeTokensOut,
|
|
4177
|
+
rate,
|
|
4178
|
+
capacity: {
|
|
4179
|
+
epochCapNumeraire: epoch.epochCapNumeraire,
|
|
4180
|
+
epochRedeemedNumeraire: epoch.epochRedeemedNumeraire,
|
|
4181
|
+
remainingNumeraire,
|
|
4182
|
+
remainingTokens,
|
|
4183
|
+
knownLiquidityTokens,
|
|
4184
|
+
requestNumeraire,
|
|
4185
|
+
exceedsCapacity: requestNumeraire > remainingNumeraire
|
|
4186
|
+
},
|
|
4187
|
+
unitsLockedUntil,
|
|
4188
|
+
context: {
|
|
4189
|
+
vaultId: params.vaultId,
|
|
4190
|
+
chainId,
|
|
4191
|
+
tokenAddress: token.address,
|
|
4192
|
+
...params.account ? { account: params.account } : {},
|
|
4193
|
+
slippageBps,
|
|
4194
|
+
blockNumber: quoteReadContext.blockNumber,
|
|
4195
|
+
request
|
|
4196
|
+
}
|
|
4197
|
+
};
|
|
4198
|
+
if (kind === "redeem") return { kind, ...quoteDetails };
|
|
4199
|
+
return { kind, ...quoteDetails };
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
|
+
// src/evm/tokenModes.ts
|
|
4203
|
+
async function getAeraTokenModeSupport(client, params) {
|
|
4204
|
+
const resolved = await resolveVault(client, params.vaultId, params.chainId);
|
|
4205
|
+
if (!resolved) throw new VaultNotFoundError(params.vaultId);
|
|
4206
|
+
const { vault, protocol } = resolved;
|
|
4207
|
+
if (protocol !== "aera") {
|
|
4208
|
+
throw new UnsupportedFeatureError("Token mode support is only available for Aera vaults");
|
|
4209
|
+
}
|
|
4210
|
+
const chainId = params.chainId ?? vault.chainId;
|
|
4211
|
+
const publicClient = client.getPublicClient(chainId);
|
|
4212
|
+
const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
|
|
4213
|
+
if (token === void 0) {
|
|
4214
|
+
throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
|
|
4215
|
+
}
|
|
4216
|
+
const runtime = await resolveAeraRuntimeContracts(publicClient, vault);
|
|
4217
|
+
return resolveAeraTokenModeSupport(publicClient, runtime, token.address);
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
// src/evm/userCurrentBalance.ts
|
|
4221
|
+
import { parseAbi } from "viem";
|
|
4222
|
+
var LOG_CHUNK_CONCURRENCY = 16;
|
|
4223
|
+
var DEPOSIT_REQUESTED_V1_ABI = [
|
|
4224
|
+
{
|
|
4225
|
+
type: "event",
|
|
4226
|
+
name: "DepositRequested",
|
|
4227
|
+
inputs: [
|
|
4228
|
+
{ type: "address", name: "user", indexed: true },
|
|
4229
|
+
{ type: "address", name: "token", indexed: true },
|
|
4230
|
+
{ type: "uint256", name: "tokensIn", indexed: false },
|
|
4231
|
+
{ type: "uint256", name: "minUnitsOut", indexed: false },
|
|
4232
|
+
{ type: "uint256", name: "solverTip", indexed: false },
|
|
4233
|
+
{ type: "uint256", name: "deadline", indexed: false },
|
|
4234
|
+
{ type: "uint256", name: "maxPriceAge", indexed: false },
|
|
4235
|
+
{ type: "bool", name: "isFixedPrice", indexed: false },
|
|
4236
|
+
{ type: "bytes32", name: "depositRequestHash", indexed: false }
|
|
4237
|
+
]
|
|
4238
|
+
}
|
|
4239
|
+
];
|
|
4240
|
+
var REDEEM_REQUESTED_V1_ABI = [
|
|
4241
|
+
{
|
|
4242
|
+
type: "event",
|
|
4243
|
+
name: "RedeemRequested",
|
|
4244
|
+
inputs: [
|
|
4245
|
+
{ type: "address", name: "user", indexed: true },
|
|
4246
|
+
{ type: "address", name: "token", indexed: true },
|
|
4247
|
+
{ type: "uint256", name: "minTokensOut", indexed: false },
|
|
4248
|
+
{ type: "uint256", name: "unitsIn", indexed: false },
|
|
4249
|
+
{ type: "uint256", name: "solverTip", indexed: false },
|
|
4250
|
+
{ type: "uint256", name: "deadline", indexed: false },
|
|
4251
|
+
{ type: "uint256", name: "maxPriceAge", indexed: false },
|
|
4252
|
+
{ type: "bool", name: "isFixedPrice", indexed: false },
|
|
4253
|
+
{ type: "bytes32", name: "redeemRequestHash", indexed: false }
|
|
4254
|
+
]
|
|
4255
|
+
}
|
|
4256
|
+
];
|
|
4257
|
+
var provisionerV1StateAbi = parseAbi([
|
|
4258
|
+
"function asyncDepositHashes(bytes32 asyncDepositHash) view returns (bool exists)",
|
|
4259
|
+
"function asyncRedeemHashes(bytes32 asyncRedeemHash) view returns (bool exists)"
|
|
4260
|
+
]);
|
|
4261
|
+
function dedupeByRequestHash(logs, hashKey) {
|
|
4262
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4263
|
+
return logs.filter((log) => {
|
|
4264
|
+
const hash = log.args[hashKey];
|
|
4265
|
+
if (hash == null || seen.has(hash)) return false;
|
|
4266
|
+
seen.add(hash);
|
|
4267
|
+
return true;
|
|
4268
|
+
});
|
|
4269
|
+
}
|
|
4270
|
+
async function requestScanStart(publicClient, chainId, blockNumber, days, cutoff) {
|
|
4271
|
+
let span = (BLOCKS_3_DAYS[chainId] ?? DEFAULT_BLOCKS_3_DAYS) * BigInt(days) / 3n;
|
|
4272
|
+
for (; ; ) {
|
|
4273
|
+
if (span >= blockNumber) return 0n;
|
|
4274
|
+
const start = blockNumber - span;
|
|
4275
|
+
const block = await publicClient.getBlock({ blockNumber: start });
|
|
4276
|
+
if (block.timestamp <= cutoff) return start;
|
|
4277
|
+
span *= 2n;
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
async function mapInBatches(items, size, fn) {
|
|
4281
|
+
const results = [];
|
|
4282
|
+
for (let i = 0; i < items.length; i += size) {
|
|
4283
|
+
results.push(...await Promise.all(items.slice(i, i + size).map(fn)));
|
|
4284
|
+
}
|
|
4285
|
+
return results;
|
|
4286
|
+
}
|
|
4287
|
+
async function queryDeploymentBalance(client, deployment, params) {
|
|
4288
|
+
const publicClient = client.getPublicClient(deployment.chainId);
|
|
4289
|
+
const { address } = params;
|
|
4290
|
+
const token = deployment.supplyToken.length > 1 ? deployment.supplyToken.find((candidate) => candidate.symbol === params.assetSymbol) : deployment.supplyToken[0];
|
|
4291
|
+
if (token === void 0)
|
|
4292
|
+
throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
|
|
4293
|
+
const snapshot = await publicClient.getBlock({ blockTag: "latest" });
|
|
4294
|
+
if (snapshot.number === null) {
|
|
4295
|
+
throw new GauntletSDKError("The balance snapshot has no block number");
|
|
4296
|
+
}
|
|
4297
|
+
const blockNumber = snapshot.number;
|
|
4298
|
+
const readOptions = { blockNumber };
|
|
4299
|
+
const expirationDays = deployment.expirationDays ?? 3;
|
|
4300
|
+
if (!Number.isSafeInteger(expirationDays) || expirationDays <= 0) {
|
|
4301
|
+
throw new GauntletSDKError("The request expiration must be a positive integer number of days");
|
|
4302
|
+
}
|
|
4303
|
+
const scanDays = Math.max(3, expirationDays);
|
|
4304
|
+
const cutoff = snapshot.timestamp - BigInt(DAY) * BigInt(scanDays);
|
|
4305
|
+
const fromBlock = params.fromBlock ?? await requestScanStart(publicClient, deployment.chainId, blockNumber, scanDays, cutoff);
|
|
4306
|
+
if (fromBlock < 0n || fromBlock > blockNumber) {
|
|
4307
|
+
throw new GauntletSDKError("The request scan range is invalid");
|
|
4308
|
+
}
|
|
4309
|
+
const vaultContract = getMultiDepositorVault(publicClient, deployment.vaultAddress);
|
|
4310
|
+
const [runtime, units] = await Promise.all([
|
|
4311
|
+
resolveAeraRuntimeContracts(publicClient, deployment, readOptions),
|
|
4312
|
+
vaultContract.read.balanceOf([address], readOptions)
|
|
4313
|
+
]);
|
|
4314
|
+
const provisionerAddress = runtime.provisioner.address;
|
|
4315
|
+
const isV2 = runtime.provisioner.version === ContractVersion.V2;
|
|
4316
|
+
const unitsLockedUntilPromise = isV2 ? getUserUnitsRefundableUntil(publicClient, provisionerAddress, address, readOptions) : Promise.resolve(void 0);
|
|
4317
|
+
const balance = await convertUnitsToToken(
|
|
4318
|
+
publicClient,
|
|
4319
|
+
runtime.feeCalculator.address,
|
|
4320
|
+
runtime.feeCalculator.version,
|
|
4321
|
+
deployment.vaultAddress,
|
|
4322
|
+
token.address,
|
|
4323
|
+
units,
|
|
4324
|
+
readOptions
|
|
4325
|
+
);
|
|
4326
|
+
const chunks = [];
|
|
4327
|
+
for (let cursor = fromBlock; cursor <= blockNumber; cursor += LOG_PAGE_SIZE + 1n) {
|
|
4328
|
+
const end = cursor + LOG_PAGE_SIZE <= blockNumber ? cursor + LOG_PAGE_SIZE : blockNumber;
|
|
4329
|
+
chunks.push([cursor, end]);
|
|
4330
|
+
}
|
|
4331
|
+
const [depositPages, redeemPages] = await Promise.all([
|
|
4332
|
+
mapInBatches(
|
|
4333
|
+
chunks,
|
|
4334
|
+
LOG_CHUNK_CONCURRENCY,
|
|
4335
|
+
([from, to]) => isV2 ? publicClient.getContractEvents({
|
|
4336
|
+
address: provisionerAddress,
|
|
4337
|
+
abi: provisionerV2Abi,
|
|
4338
|
+
eventName: "DepositRequested",
|
|
4339
|
+
args: { receiver: address, token: token.address },
|
|
4340
|
+
fromBlock: from,
|
|
4341
|
+
toBlock: to
|
|
4342
|
+
}) : publicClient.getContractEvents({
|
|
4343
|
+
address: provisionerAddress,
|
|
4344
|
+
abi: DEPOSIT_REQUESTED_V1_ABI,
|
|
4345
|
+
eventName: "DepositRequested",
|
|
4346
|
+
args: { user: address, token: token.address },
|
|
4347
|
+
fromBlock: from,
|
|
4348
|
+
toBlock: to
|
|
4349
|
+
})
|
|
4350
|
+
),
|
|
4351
|
+
mapInBatches(
|
|
4352
|
+
chunks,
|
|
4353
|
+
LOG_CHUNK_CONCURRENCY,
|
|
4354
|
+
([from, to]) => isV2 ? publicClient.getContractEvents({
|
|
4355
|
+
address: provisionerAddress,
|
|
4356
|
+
abi: provisionerV2Abi,
|
|
4357
|
+
eventName: "RedeemRequested",
|
|
4358
|
+
args: { user: address, token: token.address },
|
|
4359
|
+
fromBlock: from,
|
|
4360
|
+
toBlock: to
|
|
4361
|
+
}) : publicClient.getContractEvents({
|
|
4362
|
+
address: provisionerAddress,
|
|
4363
|
+
abi: REDEEM_REQUESTED_V1_ABI,
|
|
4364
|
+
eventName: "RedeemRequested",
|
|
4365
|
+
args: { user: address, token: token.address },
|
|
4366
|
+
fromBlock: from,
|
|
4367
|
+
toBlock: to
|
|
4368
|
+
})
|
|
4369
|
+
)
|
|
4370
|
+
]);
|
|
4371
|
+
const depositLogs = dedupeByRequestHash(depositPages.flat(), "depositRequestHash");
|
|
4372
|
+
const redeemLogs = dedupeByRequestHash(redeemPages.flat(), "redeemRequestHash");
|
|
4373
|
+
const pendingChecks = await publicClient.multicall({
|
|
4374
|
+
contracts: [
|
|
4375
|
+
...depositLogs.map((log) => ({
|
|
4376
|
+
address: provisionerAddress,
|
|
4377
|
+
abi: isV2 ? provisionerV2Abi : provisionerV1StateAbi,
|
|
4378
|
+
functionName: isV2 ? "asyncRequestHashes" : "asyncDepositHashes",
|
|
4379
|
+
args: [log.args.depositRequestHash]
|
|
4380
|
+
})),
|
|
4381
|
+
...redeemLogs.map((log) => ({
|
|
4382
|
+
address: provisionerAddress,
|
|
4383
|
+
abi: isV2 ? provisionerV2Abi : provisionerV1StateAbi,
|
|
4384
|
+
functionName: isV2 ? "asyncRequestHashes" : "asyncRedeemHashes",
|
|
4385
|
+
args: [log.args.redeemRequestHash]
|
|
4386
|
+
}))
|
|
4387
|
+
],
|
|
4388
|
+
allowFailure: false,
|
|
4389
|
+
blockNumber
|
|
4390
|
+
});
|
|
4391
|
+
const depositChecks = pendingChecks.slice(0, depositLogs.length);
|
|
4392
|
+
const redeemChecks = pendingChecks.slice(depositLogs.length);
|
|
4393
|
+
let pendingDeposit = 0n;
|
|
4394
|
+
for (let i = 0; i < depositLogs.length; i++) {
|
|
4395
|
+
if (depositChecks[i]) {
|
|
4396
|
+
pendingDeposit += depositLogs[i].args.tokensIn ?? 0n;
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
let pendingWithdrawUnits = 0n;
|
|
4400
|
+
for (let i = 0; i < redeemLogs.length; i++) {
|
|
4401
|
+
if (redeemChecks[i]) {
|
|
4402
|
+
pendingWithdrawUnits += redeemLogs[i].args.unitsIn ?? 0n;
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
const pendingWithdraw = pendingWithdrawUnits > 0n ? await convertUnitsToToken(
|
|
4406
|
+
publicClient,
|
|
4407
|
+
runtime.feeCalculator.address,
|
|
4408
|
+
runtime.feeCalculator.version,
|
|
4409
|
+
deployment.vaultAddress,
|
|
4410
|
+
token.address,
|
|
4411
|
+
pendingWithdrawUnits,
|
|
4412
|
+
readOptions
|
|
4413
|
+
) : 0n;
|
|
4414
|
+
const unitsLockedUntil = await unitsLockedUntilPromise;
|
|
4415
|
+
return {
|
|
4416
|
+
blockNumber,
|
|
4417
|
+
fromBlock,
|
|
4418
|
+
chain: CHAIN_NAMES[deployment.chainId] ?? `chain-${deployment.chainId}`,
|
|
4419
|
+
chainId: deployment.chainId,
|
|
4420
|
+
token: token.address,
|
|
4421
|
+
decimals: token.decimals,
|
|
4422
|
+
pendingDeposit,
|
|
4423
|
+
balance,
|
|
4424
|
+
pendingWithdraw,
|
|
4425
|
+
...unitsLockedUntil !== void 0 ? { unitsLockedUntil } : {}
|
|
4426
|
+
};
|
|
4427
|
+
}
|
|
4428
|
+
async function getUserCurrentBalance(client, params) {
|
|
4429
|
+
params = { ...params };
|
|
4430
|
+
const manifest = await client.manifest;
|
|
4431
|
+
const vaultInfo = manifest.vaults.find((v) => v.vaultId === params.vaultId);
|
|
4432
|
+
if (!vaultInfo) throw new VaultNotFoundError(params.vaultId);
|
|
4433
|
+
const evmDeployments = vaultInfo.deployments.filter(
|
|
4434
|
+
(d) => d.chain === "evm" && d.vaultType === "multi-depositor"
|
|
4435
|
+
);
|
|
4436
|
+
if (vaultInfo.protocol !== "aera" || evmDeployments.length === 0) {
|
|
4437
|
+
throw new UnsupportedProtocolError(vaultInfo.protocol);
|
|
4438
|
+
}
|
|
4439
|
+
if (params.chainId !== void 0) {
|
|
4440
|
+
const deployment = evmDeployments.find((d) => d.chainId === params.chainId);
|
|
4441
|
+
if (!deployment) {
|
|
4442
|
+
throw new ChainMismatchError(
|
|
4443
|
+
`${params.chainId}`,
|
|
4444
|
+
evmDeployments.map((d) => `${d.chainId}`).join(", ")
|
|
4445
|
+
);
|
|
4446
|
+
}
|
|
4447
|
+
return [await queryDeploymentBalance(client, deployment, params)];
|
|
4448
|
+
}
|
|
4449
|
+
if (params.fromBlock !== void 0 && evmDeployments.length > 1) {
|
|
4450
|
+
throw new GauntletSDKError("fromBlock requires chainId for a vault with several deployments");
|
|
4451
|
+
}
|
|
4452
|
+
return Promise.all(evmDeployments.map((d) => queryDeploymentBalance(client, d, params)));
|
|
4453
|
+
}
|
|
4454
|
+
|
|
4455
|
+
export {
|
|
4456
|
+
ContractVersion,
|
|
4457
|
+
resolveContractVersion,
|
|
4458
|
+
resolveAeraRuntimeContracts,
|
|
4459
|
+
convertTokenToUnitsIfActive,
|
|
4460
|
+
convertUnitsToTokenIfActive,
|
|
4461
|
+
convertTokenToUnits,
|
|
4462
|
+
convertUnitsToToken,
|
|
4463
|
+
getAnchorTimestamp,
|
|
4464
|
+
getVaultState,
|
|
4465
|
+
isVaultPaused,
|
|
4466
|
+
Rounding,
|
|
4467
|
+
getDepositTx,
|
|
4468
|
+
getDepositReceiverApprovalTx,
|
|
4469
|
+
getSyncDepositQuote2 as getSyncDepositQuote,
|
|
4470
|
+
getSyncDepositRate,
|
|
4471
|
+
getWithdrawTx,
|
|
4472
|
+
getSyncWithdrawRate,
|
|
4473
|
+
getSyncWithdrawQuote,
|
|
4474
|
+
getAeraTokenModeSupport,
|
|
4475
|
+
getUserCurrentBalance
|
|
4476
|
+
};
|
|
4477
|
+
//# sourceMappingURL=chunk-YQXTLIJA.js.map
|