@gearbox-protocol/sdk 14.11.3 → 14.12.0-next.10
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/dist/cjs/abi/iZapper.js +62 -24
- package/dist/cjs/common-utils/utils/index.js +2 -0
- package/dist/cjs/{history/trace-utils.js → common-utils/utils/trace.js} +62 -5
- package/dist/cjs/dev/AccountOpener.js +7 -13
- package/dist/cjs/dev/index.js +3 -1
- package/dist/cjs/dev/verifyTestnet.js +52 -0
- package/dist/cjs/history/assembleOperations.js +6 -6
- package/dist/cjs/history/classifyMulticallOperations.js +33 -25
- package/dist/cjs/history/index.js +0 -2
- package/dist/cjs/history/mapOperations.js +7 -0
- package/dist/cjs/history/parseCreditAccountTransaction.js +5 -6
- package/dist/cjs/history/toLegacyOperation.js +5 -1
- package/dist/cjs/plugins/adapters/abi/iConvexV1BoosterAdapter.js +143 -0
- package/dist/cjs/plugins/adapters/abi/index.js +2 -0
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +61 -37
- package/dist/cjs/plugins/adapters/contracts/AbstractCurveAdapter.js +66 -0
- package/dist/cjs/plugins/adapters/contracts/AccountMigratorAdapterContract.js +9 -0
- package/dist/cjs/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +19 -0
- package/dist/cjs/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +15 -0
- package/dist/cjs/plugins/adapters/contracts/CamelotV3AdapterContract.js +20 -0
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +18 -0
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +28 -2
- package/dist/cjs/plugins/adapters/contracts/Curve2AssetsAdapterContract.js +2 -7
- package/dist/cjs/plugins/adapters/contracts/Curve3AssetsAdapterContract.js +2 -7
- package/dist/cjs/plugins/adapters/contracts/Curve4AssetsAdapterContract.js +2 -7
- package/dist/cjs/plugins/adapters/contracts/CurveV1AdapterDeposit.js +2 -2
- package/dist/cjs/plugins/adapters/contracts/CurveV1AdapterStETHContract.js +2 -7
- package/dist/cjs/plugins/adapters/contracts/CurveV1StableNGAdapterContract.js +2 -7
- package/dist/cjs/plugins/adapters/contracts/DaiUsdsAdapterContract.js +14 -0
- package/dist/cjs/plugins/adapters/contracts/ERC4626AdapterContract.js +15 -0
- package/dist/cjs/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +14 -0
- package/dist/cjs/plugins/adapters/contracts/FluidDexAdapterContract.js +15 -0
- package/dist/cjs/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +21 -0
- package/dist/cjs/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +10 -0
- package/dist/cjs/plugins/adapters/contracts/LidoV1AdapterContract.js +11 -0
- package/dist/cjs/plugins/adapters/contracts/MellowDVVAdapterContract.js +15 -0
- package/dist/cjs/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +15 -0
- package/dist/cjs/plugins/adapters/contracts/MellowWrapperAdapterContract.js +11 -0
- package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +10 -0
- package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +12 -0
- package/dist/cjs/plugins/adapters/contracts/PendleRouterAdapterContract.js +58 -0
- package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +11 -0
- package/dist/cjs/plugins/adapters/contracts/SecuritizeSwapAdapterContract.js +22 -1
- package/dist/cjs/plugins/adapters/contracts/StakingRewardsAdapterContract.js +17 -0
- package/dist/cjs/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +10 -0
- package/dist/cjs/plugins/adapters/contracts/UniswapV2AdapterContract.js +10 -0
- package/dist/cjs/plugins/adapters/contracts/UniswapV3AdapterContract.js +20 -0
- package/dist/cjs/plugins/adapters/contracts/UniswapV4AdapterContract.js +15 -0
- package/dist/cjs/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +14 -0
- package/dist/cjs/plugins/adapters/contracts/VelodromeV2AdapterContract.js +10 -0
- package/dist/cjs/plugins/adapters/contracts/WstETHV1AdapterContract.js +15 -0
- package/dist/cjs/{history/internal-types.js → plugins/adapters/transfers.js} +2 -2
- package/dist/cjs/preview/index.js +26 -0
- package/dist/cjs/preview/package.json +1 -0
- package/dist/cjs/preview/parse/classifyInnerOperations.js +105 -0
- package/dist/cjs/preview/parse/errors.js +50 -0
- package/dist/cjs/preview/parse/index.js +34 -0
- package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +108 -0
- package/dist/cjs/preview/parse/parseOperationCalldata.js +85 -0
- package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +89 -0
- package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +104 -0
- package/dist/cjs/{history/inner-operations.js → preview/parse/types-adapters.js} +2 -2
- package/dist/cjs/preview/parse/types-facades.js +16 -0
- package/dist/cjs/preview/parse/types-pools.js +16 -0
- package/dist/cjs/preview/parse/types-rwa.js +16 -0
- package/dist/cjs/preview/parse/types.js +44 -0
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +78 -0
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +95 -0
- package/dist/cjs/preview/prerequisites/Prerequisite.js +85 -0
- package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +66 -0
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +297 -0
- package/dist/cjs/preview/prerequisites/index.js +36 -0
- package/dist/cjs/preview/prerequisites/prepareAction.js +48 -0
- package/dist/cjs/preview/prerequisites/runPrerequisites.js +71 -0
- package/dist/cjs/preview/prerequisites/types.js +16 -0
- package/dist/cjs/preview/preview/applyInnerOperations.js +132 -0
- package/dist/cjs/preview/preview/errors.js +52 -0
- package/dist/cjs/preview/preview/index.js +30 -0
- package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +95 -0
- package/dist/cjs/preview/preview/previewOpenCreditAccount.js +69 -0
- package/dist/cjs/preview/preview/previewOperation.js +45 -0
- package/dist/cjs/preview/preview/previewPoolOperation.js +75 -0
- package/dist/cjs/preview/preview/types.js +16 -0
- package/dist/cjs/preview/preview/unwrapNativeCollateral.js +45 -0
- package/dist/cjs/preview/simulate/errors.js +91 -0
- package/dist/cjs/preview/simulate/index.js +40 -0
- package/dist/cjs/preview/simulate/simulateFacadeOperation.js +30 -0
- package/dist/cjs/preview/simulate/simulateOperation.js +41 -0
- package/dist/cjs/preview/simulate/simulatePoolOperation.js +91 -0
- package/dist/cjs/preview/simulate/simulateRWAOperation.js +30 -0
- package/dist/cjs/preview/simulate/types.js +16 -0
- package/dist/cjs/{history → preview/trace}/errors.js +0 -26
- package/dist/cjs/preview/trace/extractAdapterCallTraces.js +58 -0
- package/dist/cjs/{history → preview/trace}/extractTransfers.js +9 -12
- package/dist/cjs/{history → preview/trace}/findFacadeCalls.js +3 -3
- package/dist/cjs/preview/trace/index.js +30 -0
- package/dist/cjs/preview/trace/types.js +16 -0
- package/dist/cjs/sdk/MultichainSDK.js +1 -0
- package/dist/cjs/sdk/OnchainSDK.js +7 -3
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +157 -4
- package/dist/cjs/sdk/base/BaseContract.js +4 -2
- package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -0
- package/dist/cjs/sdk/market/MarketRegister.js +10 -5
- package/dist/cjs/sdk/market/ZapperRegister.js +54 -0
- package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +30 -0
- package/dist/cjs/sdk/market/rwa/types.js +5 -2
- package/dist/cjs/sdk/market/zapper/IERC20ZapperContract.js +3 -38
- package/dist/cjs/sdk/market/zapper/IETHZapperContract.js +3 -38
- package/dist/cjs/sdk/market/zapper/ZapperContract.js +106 -0
- package/dist/cjs/sdk/market/zapper/createZapper.js +12 -4
- package/dist/cjs/sdk/market/zapper/{Zapper.js → errors.js} +13 -23
- package/dist/cjs/sdk/market/zapper/index.js +6 -2
- package/dist/cjs/sdk/market/zapper/types.js +16 -0
- package/dist/cjs/sdk/options.js +41 -17
- package/dist/cjs/sdk/router/AbstractRouterContract.js +21 -27
- package/dist/cjs/sdk/router/RouterV310Contract.js +11 -12
- package/dist/cjs/sdk/router/helpers.js +0 -5
- package/dist/cjs/sdk/utils/AddressMap.js +6 -0
- package/dist/cjs/sdk/utils/AssetsMap.js +62 -0
- package/dist/cjs/sdk/utils/index.js +2 -0
- package/dist/esm/abi/iZapper.js +62 -24
- package/dist/esm/common-utils/utils/index.js +1 -0
- package/dist/esm/common-utils/utils/trace.js +93 -0
- package/dist/esm/dev/AccountOpener.js +8 -13
- package/dist/esm/dev/index.js +1 -0
- package/dist/esm/dev/verifyTestnet.js +27 -0
- package/dist/esm/history/assembleOperations.js +8 -6
- package/dist/esm/history/classifyMulticallOperations.js +31 -23
- package/dist/esm/history/index.js +0 -1
- package/dist/esm/history/mapOperations.js +7 -0
- package/dist/esm/history/parseCreditAccountTransaction.js +3 -4
- package/dist/esm/history/toLegacyOperation.js +5 -1
- package/dist/esm/plugins/adapters/abi/iConvexV1BoosterAdapter.js +119 -0
- package/dist/esm/plugins/adapters/abi/index.js +1 -0
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +64 -38
- package/dist/esm/plugins/adapters/contracts/AbstractCurveAdapter.js +42 -0
- package/dist/esm/plugins/adapters/contracts/AccountMigratorAdapterContract.js +9 -0
- package/dist/esm/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +22 -1
- package/dist/esm/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +18 -1
- package/dist/esm/plugins/adapters/contracts/CamelotV3AdapterContract.js +23 -1
- package/dist/esm/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +22 -1
- package/dist/esm/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +30 -2
- package/dist/esm/plugins/adapters/contracts/Curve2AssetsAdapterContract.js +2 -7
- package/dist/esm/plugins/adapters/contracts/Curve3AssetsAdapterContract.js +2 -7
- package/dist/esm/plugins/adapters/contracts/Curve4AssetsAdapterContract.js +2 -7
- package/dist/esm/plugins/adapters/contracts/CurveV1AdapterDeposit.js +2 -2
- package/dist/esm/plugins/adapters/contracts/CurveV1AdapterStETHContract.js +2 -7
- package/dist/esm/plugins/adapters/contracts/CurveV1StableNGAdapterContract.js +2 -7
- package/dist/esm/plugins/adapters/contracts/DaiUsdsAdapterContract.js +17 -1
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +19 -1
- package/dist/esm/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +17 -1
- package/dist/esm/plugins/adapters/contracts/FluidDexAdapterContract.js +18 -1
- package/dist/esm/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +24 -1
- package/dist/esm/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +13 -1
- package/dist/esm/plugins/adapters/contracts/LidoV1AdapterContract.js +14 -1
- package/dist/esm/plugins/adapters/contracts/MellowDVVAdapterContract.js +18 -1
- package/dist/esm/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +18 -1
- package/dist/esm/plugins/adapters/contracts/MellowWrapperAdapterContract.js +14 -1
- package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +13 -1
- package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +15 -1
- package/dist/esm/plugins/adapters/contracts/PendleRouterAdapterContract.js +61 -1
- package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +14 -1
- package/dist/esm/plugins/adapters/contracts/SecuritizeSwapAdapterContract.js +25 -2
- package/dist/esm/plugins/adapters/contracts/StakingRewardsAdapterContract.js +20 -1
- package/dist/esm/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +13 -1
- package/dist/esm/plugins/adapters/contracts/UniswapV2AdapterContract.js +10 -0
- package/dist/esm/plugins/adapters/contracts/UniswapV3AdapterContract.js +20 -0
- package/dist/esm/plugins/adapters/contracts/UniswapV4AdapterContract.js +18 -1
- package/dist/esm/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +17 -1
- package/dist/esm/plugins/adapters/contracts/VelodromeV2AdapterContract.js +13 -1
- package/dist/esm/plugins/adapters/contracts/WstETHV1AdapterContract.js +18 -1
- package/dist/esm/preview/index.js +3 -0
- package/dist/esm/preview/package.json +1 -0
- package/dist/esm/preview/parse/classifyInnerOperations.js +81 -0
- package/dist/esm/preview/parse/errors.js +24 -0
- package/dist/esm/preview/parse/index.js +7 -0
- package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +84 -0
- package/dist/esm/preview/parse/parseOperationCalldata.js +66 -0
- package/dist/esm/preview/parse/parsePoolOperationCalldata.js +65 -0
- package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +85 -0
- package/dist/esm/preview/parse/types-facades.js +0 -0
- package/dist/esm/preview/parse/types-pools.js +0 -0
- package/dist/esm/preview/parse/types-rwa.js +0 -0
- package/dist/esm/preview/parse/types.js +14 -0
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +57 -0
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +74 -0
- package/dist/esm/preview/prerequisites/Prerequisite.js +63 -0
- package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +42 -0
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +279 -0
- package/dist/esm/preview/prerequisites/index.js +8 -0
- package/dist/esm/preview/prerequisites/prepareAction.js +23 -0
- package/dist/esm/preview/prerequisites/runPrerequisites.js +47 -0
- package/dist/esm/preview/prerequisites/types.js +0 -0
- package/dist/esm/preview/preview/applyInnerOperations.js +110 -0
- package/dist/esm/preview/preview/errors.js +27 -0
- package/dist/esm/preview/preview/index.js +5 -0
- package/dist/esm/preview/preview/previewAdjustCreditAccount.js +79 -0
- package/dist/esm/preview/preview/previewOpenCreditAccount.js +51 -0
- package/dist/esm/preview/preview/previewOperation.js +21 -0
- package/dist/esm/preview/preview/previewPoolOperation.js +53 -0
- package/dist/esm/preview/preview/types.js +0 -0
- package/dist/esm/preview/preview/unwrapNativeCollateral.js +21 -0
- package/dist/esm/preview/simulate/errors.js +69 -0
- package/dist/esm/preview/simulate/index.js +12 -0
- package/dist/esm/preview/simulate/simulateFacadeOperation.js +6 -0
- package/dist/esm/preview/simulate/simulateOperation.js +20 -0
- package/dist/esm/preview/simulate/simulatePoolOperation.js +67 -0
- package/dist/esm/preview/simulate/simulateRWAOperation.js +6 -0
- package/dist/esm/preview/simulate/types.js +0 -0
- package/dist/esm/{history → preview/trace}/errors.js +0 -24
- package/dist/esm/preview/trace/extractAdapterCallTraces.js +40 -0
- package/dist/esm/{history → preview/trace}/extractTransfers.js +9 -12
- package/dist/esm/{history → preview/trace}/findFacadeCalls.js +4 -2
- package/dist/esm/preview/trace/index.js +5 -0
- package/dist/esm/preview/trace/types.js +0 -0
- package/dist/esm/sdk/MultichainSDK.js +1 -0
- package/dist/esm/sdk/OnchainSDK.js +7 -3
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +158 -5
- package/dist/esm/sdk/base/BaseContract.js +4 -2
- package/dist/esm/sdk/base/ChainContractsRegister.js +1 -0
- package/dist/esm/sdk/market/MarketRegister.js +10 -5
- package/dist/esm/sdk/market/ZapperRegister.js +54 -0
- package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +33 -1
- package/dist/esm/sdk/market/rwa/types.js +5 -2
- package/dist/esm/sdk/market/zapper/IERC20ZapperContract.js +3 -38
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +3 -38
- package/dist/esm/sdk/market/zapper/ZapperContract.js +82 -0
- package/dist/esm/sdk/market/zapper/createZapper.js +12 -4
- package/dist/esm/sdk/market/zapper/errors.js +13 -0
- package/dist/esm/sdk/market/zapper/index.js +3 -1
- package/dist/esm/sdk/market/zapper/types.js +0 -0
- package/dist/esm/sdk/options.js +39 -15
- package/dist/esm/sdk/router/AbstractRouterContract.js +25 -29
- package/dist/esm/sdk/router/RouterV310Contract.js +11 -12
- package/dist/esm/sdk/router/helpers.js +0 -4
- package/dist/esm/sdk/utils/AddressMap.js +6 -0
- package/dist/esm/sdk/utils/AssetsMap.js +38 -0
- package/dist/esm/sdk/utils/index.js +1 -0
- package/dist/types/abi/iERC20Zapper.d.ts +91 -23
- package/dist/types/abi/iETHZapper.d.ts +91 -23
- package/dist/types/abi/iZapper.d.ts +91 -23
- package/dist/types/common-utils/utils/index.d.ts +1 -0
- package/dist/types/common-utils/utils/strategies/assets/assets.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-apy.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/tokens/add-amount-in-target.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.d.ts +1 -1
- package/dist/types/common-utils/utils/strategies/types/strategy-earnings.d.ts +1 -1
- package/dist/types/common-utils/utils/trace.d.ts +73 -0
- package/dist/types/common-utils/utils/validation/validate-balances.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-quota.d.ts +1 -1
- package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +1 -1
- package/dist/types/dev/index.d.ts +1 -0
- package/dist/types/dev/verifyTestnet.d.ts +24 -0
- package/dist/types/history/assembleOperations.d.ts +11 -6
- package/dist/types/history/classifyMulticallOperations.d.ts +21 -9
- package/dist/types/history/index.d.ts +0 -1
- package/dist/types/history/mapOperations.d.ts +7 -9
- package/dist/types/history/types.d.ts +22 -71
- package/dist/types/plugins/adapters/abi/iConvexV1BoosterAdapter.d.ts +204 -0
- package/dist/types/plugins/adapters/abi/index.d.ts +1 -0
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +33 -16
- package/dist/types/plugins/adapters/contracts/AbstractCurveAdapter.d.ts +18 -0
- package/dist/types/plugins/adapters/contracts/AccountMigratorAdapterContract.d.ts +10 -1
- package/dist/types/plugins/adapters/contracts/BalancerV3RouterAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/CamelotV3AdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +9 -7
- package/dist/types/plugins/adapters/contracts/Curve2AssetsAdapterContract.d.ts +3 -6
- package/dist/types/plugins/adapters/contracts/Curve3AssetsAdapterContract.d.ts +3 -6
- package/dist/types/plugins/adapters/contracts/Curve4AssetsAdapterContract.d.ts +3 -6
- package/dist/types/plugins/adapters/contracts/CurveV1AdapterDeposit.d.ts +3 -3
- package/dist/types/plugins/adapters/contracts/CurveV1AdapterStETHContract.d.ts +3 -6
- package/dist/types/plugins/adapters/contracts/CurveV1StableNGAdapterContract.d.ts +3 -6
- package/dist/types/plugins/adapters/contracts/DaiUsdsAdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/FluidDexAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/InfinifiGatewayAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/LidoV1AdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/MellowWrapperAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/PendleRouterAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/SecuritizeSwapAdapterContract.d.ts +15 -3
- package/dist/types/plugins/adapters/contracts/StakingRewardsAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/TraderJoeRouterAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/UniswapV2AdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/UniswapV3AdapterContract.d.ts +3 -1
- package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/contracts/UpshiftVaultAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/VelodromeV2AdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/WstETHV1AdapterContract.d.ts +5 -3
- package/dist/types/plugins/adapters/transferHelpers.d.ts +1 -1
- package/dist/types/plugins/adapters/transfers.d.ts +17 -0
- package/dist/types/plugins/adapters/types.d.ts +18 -46
- package/dist/types/preview/index.d.ts +3 -0
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +19 -0
- package/dist/types/preview/parse/errors.d.ts +18 -0
- package/dist/types/preview/parse/index.d.ts +7 -0
- package/dist/types/preview/parse/parseFacadeOperationCalldata.d.ts +19 -0
- package/dist/types/preview/parse/parseOperationCalldata.d.ts +23 -0
- package/dist/types/preview/parse/parsePoolOperationCalldata.d.ts +17 -0
- package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +22 -0
- package/dist/types/preview/parse/types-adapters.d.ts +73 -0
- package/dist/types/preview/parse/types-facades.d.ts +147 -0
- package/dist/types/preview/parse/types-pools.d.ts +143 -0
- package/dist/types/preview/parse/types-rwa.d.ts +48 -0
- package/dist/types/preview/parse/types.d.ts +49 -0
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +22 -0
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +26 -0
- package/dist/types/preview/prerequisites/Prerequisite.d.ts +60 -0
- package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +36 -0
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +25 -0
- package/dist/types/preview/prerequisites/index.d.ts +8 -0
- package/dist/types/preview/prerequisites/prepareAction.d.ts +52 -0
- package/dist/types/preview/prerequisites/runPrerequisites.d.ts +12 -0
- package/dist/types/preview/prerequisites/types.d.ts +80 -0
- package/dist/types/preview/preview/applyInnerOperations.d.ts +77 -0
- package/dist/types/preview/preview/errors.d.ts +21 -0
- package/dist/types/preview/preview/index.d.ts +5 -0
- package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +11 -0
- package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +4 -0
- package/dist/types/preview/preview/previewOperation.d.ts +7 -0
- package/dist/types/preview/preview/previewPoolOperation.d.ts +5 -0
- package/dist/types/preview/preview/types.d.ts +177 -0
- package/dist/types/preview/preview/unwrapNativeCollateral.d.ts +20 -0
- package/dist/types/preview/simulate/errors.d.ts +45 -0
- package/dist/types/preview/simulate/index.d.ts +10 -0
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +23 -0
- package/dist/types/preview/simulate/simulateOperation.d.ts +18 -0
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +14 -0
- package/dist/types/preview/simulate/simulateRWAOperation.d.ts +23 -0
- package/dist/types/preview/simulate/types.d.ts +52 -0
- package/dist/types/{history → preview/trace}/errors.d.ts +0 -10
- package/dist/types/preview/trace/extractAdapterCallTraces.d.ts +23 -0
- package/dist/types/{history → preview/trace}/extractTransfers.d.ts +14 -5
- package/dist/types/{history → preview/trace}/findFacadeCalls.d.ts +3 -2
- package/dist/types/preview/trace/index.d.ts +5 -0
- package/dist/types/preview/trace/types.d.ts +21 -0
- package/dist/types/sdk/MultichainSDK.d.ts +5 -0
- package/dist/types/sdk/OnchainSDK.d.ts +4 -0
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +22 -2
- package/dist/types/sdk/accounts/types.d.ts +84 -2
- package/dist/types/sdk/base/BaseContract.d.ts +1 -1
- package/dist/types/sdk/base/TokensMeta.d.ts +1 -1
- package/dist/types/sdk/base/types.d.ts +18 -0
- package/dist/types/sdk/market/MarketRegister.d.ts +15 -6
- package/dist/types/sdk/market/ZapperRegister.d.ts +25 -4
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +6 -1
- package/dist/types/sdk/market/rwa/types.d.ts +13 -5
- package/dist/types/sdk/market/zapper/IERC20ZapperContract.d.ts +93 -39
- package/dist/types/sdk/market/zapper/IETHZapperContract.d.ts +93 -39
- package/dist/types/sdk/market/zapper/ZapperContract.d.ts +35 -0
- package/dist/types/sdk/market/zapper/createZapper.d.ts +2 -4
- package/dist/types/sdk/market/zapper/errors.d.ts +10 -0
- package/dist/types/sdk/market/zapper/index.d.ts +3 -1
- package/dist/types/sdk/market/zapper/types.d.ts +64 -0
- package/dist/types/sdk/options.d.ts +10 -5
- package/dist/types/sdk/pools/types.d.ts +4 -4
- package/dist/types/sdk/router/AbstractRouterContract.d.ts +5 -5
- package/dist/types/sdk/router/helpers.d.ts +1 -2
- package/dist/types/sdk/router/types.d.ts +1 -15
- package/dist/types/sdk/types/state-human.d.ts +9 -0
- package/dist/types/sdk/types/state.d.ts +7 -0
- package/dist/types/sdk/utils/AddressMap.d.ts +4 -0
- package/dist/types/sdk/utils/AssetsMap.d.ts +27 -0
- package/dist/types/sdk/utils/index.d.ts +1 -0
- package/package.json +8 -3
- package/dist/cjs/history/extractProtocolCalls.js +0 -53
- package/dist/esm/history/extractProtocolCalls.js +0 -32
- package/dist/esm/history/trace-utils.js +0 -36
- package/dist/esm/sdk/market/zapper/Zapper.js +0 -23
- package/dist/types/history/extractProtocolCalls.d.ts +0 -8
- package/dist/types/history/inner-operations.d.ts +0 -57
- package/dist/types/history/internal-types.d.ts +0 -47
- package/dist/types/history/trace-utils.d.ts +0 -12
- package/dist/types/sdk/market/zapper/Zapper.d.ts +0 -13
- /package/dist/esm/{history/inner-operations.js → plugins/adapters/transfers.js} +0 -0
- /package/dist/esm/{history/internal-types.js → preview/parse/types-adapters.js} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a transaction's attached native value (`msg.value`) does not fit
|
|
3
|
+
* into the WETH collateral declared by the multicall: such a transaction is
|
|
4
|
+
* malformed and would not execute successfully.
|
|
5
|
+
*/
|
|
6
|
+
export declare class InvalidTransactionValueError extends Error {
|
|
7
|
+
/** Transaction `msg.value`. */
|
|
8
|
+
readonly value: bigint;
|
|
9
|
+
/** Amount of wrapped native token added as collateral. */
|
|
10
|
+
readonly wethCollateral: bigint;
|
|
11
|
+
constructor(value: bigint, wethCollateral: bigint);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Thrown by `previewOperation` for parsed operations it cannot preview yet.
|
|
15
|
+
* Currently only pool operations and credit account opening are supported.
|
|
16
|
+
*/
|
|
17
|
+
export declare class UnsupportedOperationError extends Error {
|
|
18
|
+
/** The parsed operation kind (the `operation` discriminant). */
|
|
19
|
+
readonly operation: string;
|
|
20
|
+
constructor(operation: string);
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PluginsMap } from "../../sdk/index.js";
|
|
2
|
+
import type { MulticallOperation, SecuritizeMulticallOperation } from "../parse/index.js";
|
|
3
|
+
import type { AdjustCreditAccountPreview, PreviewOperationInput, PreviewOperationOptions } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Previews a `multicall`/`botMulticall` operation on an existing credit
|
|
6
|
+
* account: fetches the account's pre-state (unless provided via options),
|
|
7
|
+
* threads the multicall through {@link applyInnerOperations} and reports the
|
|
8
|
+
* minimal guaranteed post-state alongside the changes relative to the
|
|
9
|
+
* pre-state.
|
|
10
|
+
*/
|
|
11
|
+
export declare function previewAdjustCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation | SecuritizeMulticallOperation, options?: PreviewOperationOptions): Promise<AdjustCreditAccountPreview>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PluginsMap } from "../../sdk/index.js";
|
|
2
|
+
import type { OpenCreditAccountOperation, SecuritizeOpenCreditAccountOperation } from "../parse/index.js";
|
|
3
|
+
import type { OpenCreditAccountPreview, PreviewOperationInput } from "./types.js";
|
|
4
|
+
export declare function previewOpenCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | SecuritizeOpenCreditAccountOperation): OpenCreditAccountPreview;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginsMap } from "../../sdk/index.js";
|
|
2
|
+
import type { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Previews a raw operation calldata: decodes it into a typed operation and
|
|
5
|
+
* assembles an operation-specific, human-displayable preview.
|
|
6
|
+
*/
|
|
7
|
+
export declare function previewOperation<P extends PluginsMap = PluginsMap>(input: PreviewOperationInput<P>, options?: PreviewOperationOptions): Promise<OperationPreview>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PluginsMap } from "../../sdk/index.js";
|
|
2
|
+
import type { PoolOperation } from "../parse/index.js";
|
|
3
|
+
import { type OperationSimulationOptions } from "../simulate/index.js";
|
|
4
|
+
import type { PoolOperationPreview, PreviewOperationInput } from "./types.js";
|
|
5
|
+
export declare function previewPoolOperation<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: PoolOperation, options?: OperationSimulationOptions): Promise<PoolOperationPreview>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { Asset, CreditAccountData, PluginsMap } from "../../sdk/index.js";
|
|
3
|
+
import type { PoolOperationType, SdkWithAdapters } from "../parse/index.js";
|
|
4
|
+
import type { OperationSimulationOptions } from "../simulate/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Input of {@link previewOperation}: the raw operation calldata plus the
|
|
7
|
+
* already-attached SDK
|
|
8
|
+
*/
|
|
9
|
+
export interface PreviewOperationInput<P extends PluginsMap = PluginsMap> {
|
|
10
|
+
/**
|
|
11
|
+
* Already-attached SDK; chain, RPC and block are baked in at attach time.
|
|
12
|
+
* Must be created with the adapters plugin (enforced at compile time) so
|
|
13
|
+
* adapter contracts resolve during multicall classification.
|
|
14
|
+
*/
|
|
15
|
+
sdk: SdkWithAdapters<P>;
|
|
16
|
+
/**
|
|
17
|
+
* Contract address that was called
|
|
18
|
+
*/
|
|
19
|
+
to: Address;
|
|
20
|
+
/**
|
|
21
|
+
* Raw calldata of the operation
|
|
22
|
+
*/
|
|
23
|
+
calldata: Hex;
|
|
24
|
+
/**
|
|
25
|
+
* Transaction sender
|
|
26
|
+
*/
|
|
27
|
+
sender: Address;
|
|
28
|
+
/**
|
|
29
|
+
* Transaction `msg.value`
|
|
30
|
+
**/
|
|
31
|
+
value?: bigint;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options of {@link previewOperation}, extending the simulation options with
|
|
35
|
+
* preview-specific inputs.
|
|
36
|
+
*/
|
|
37
|
+
export interface PreviewOperationOptions extends OperationSimulationOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Pre-fetched state of the credit account being adjusted. When omitted,
|
|
40
|
+
* multicall/botMulticall previews fetch it via
|
|
41
|
+
* `sdk.accounts.getCreditAccountData` (one compressor read). Ignored by
|
|
42
|
+
* other operation kinds.
|
|
43
|
+
*/
|
|
44
|
+
creditAccount?: CreditAccountData;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A token amount that may require an additional async call (e.g. an ERC4626
|
|
48
|
+
* preview read) to determine. When that call fails, only the token address and
|
|
49
|
+
* the error are returned.
|
|
50
|
+
*/
|
|
51
|
+
export type PreviewedAsset = Asset | {
|
|
52
|
+
token: Address;
|
|
53
|
+
error: Error;
|
|
54
|
+
};
|
|
55
|
+
export interface PoolOperationPreview {
|
|
56
|
+
operation: PoolOperationType;
|
|
57
|
+
/**
|
|
58
|
+
* Pool address
|
|
59
|
+
*/
|
|
60
|
+
pool: Address;
|
|
61
|
+
/**
|
|
62
|
+
* Token that goes from user to pool
|
|
63
|
+
* In case of deposit, underlying for direct deposit, zapper input for zapper-routed deposit
|
|
64
|
+
* In case of withdraw, pool shares (diesel token) for direct withdraw or zapper token out
|
|
65
|
+
*
|
|
66
|
+
* For mint/withdraw the amount of tokenIn cannot be determined from
|
|
67
|
+
* transaction calldata alone and requires an additional async call
|
|
68
|
+
* (previewMint/previewWithdraw). In case of error only the token address is
|
|
69
|
+
* returned.
|
|
70
|
+
*/
|
|
71
|
+
tokenIn: PreviewedAsset;
|
|
72
|
+
/**
|
|
73
|
+
* Token that goes from pool to user
|
|
74
|
+
* In case of deposit, pool shares (diesel token) for direct deposit or zapper token out
|
|
75
|
+
* In case of withdraw, underlying for direct withdraw or zapper token in
|
|
76
|
+
*
|
|
77
|
+
* For deposit/redeem the amount of tokenOut cannot be determined from
|
|
78
|
+
* transaction calldata alone and requires an additional async call
|
|
79
|
+
* (previewDeposit/previewRedeem). In case of error only the token address is
|
|
80
|
+
* returned.
|
|
81
|
+
*/
|
|
82
|
+
tokenOut: PreviewedAsset;
|
|
83
|
+
}
|
|
84
|
+
export interface OpenCreditAccountPreview {
|
|
85
|
+
operation: "OpenCreditAccount" | "SecuritizeOpenCreditAccount";
|
|
86
|
+
/**
|
|
87
|
+
* Credit manager the account is opened in
|
|
88
|
+
*/
|
|
89
|
+
creditManager: Address;
|
|
90
|
+
/**
|
|
91
|
+
* Target token of strategy: the first quoted token, with its balance taken
|
|
92
|
+
* from `assets`. Undefined when nothing is quoted.
|
|
93
|
+
*/
|
|
94
|
+
target?: Asset;
|
|
95
|
+
/**
|
|
96
|
+
* Tokens that were added as collateral during account opening.
|
|
97
|
+
*
|
|
98
|
+
* When the transaction has native value attached, it is represented as a
|
|
99
|
+
* `NATIVE_ADDRESS` entry, with the wrapped native token amount reduced
|
|
100
|
+
* accordingly (omitted entirely when it reaches zero).
|
|
101
|
+
*/
|
|
102
|
+
collateral: Asset[];
|
|
103
|
+
/**
|
|
104
|
+
* Sum of collateral tokens in underlying
|
|
105
|
+
*/
|
|
106
|
+
collateralValue: bigint;
|
|
107
|
+
/**
|
|
108
|
+
* Borrowed amount in underlying
|
|
109
|
+
*/
|
|
110
|
+
debt: bigint;
|
|
111
|
+
/**
|
|
112
|
+
* Desired quotas
|
|
113
|
+
*/
|
|
114
|
+
quotas: Asset[];
|
|
115
|
+
/**
|
|
116
|
+
* Minimum amount of assets on credit account after it's opened,
|
|
117
|
+
* as estimated by router
|
|
118
|
+
*/
|
|
119
|
+
assets: Asset[];
|
|
120
|
+
}
|
|
121
|
+
export interface AdjustCreditAccountPreview {
|
|
122
|
+
operation: "AdjustCreditAccount";
|
|
123
|
+
/**
|
|
124
|
+
* Credit manager the account is opened in
|
|
125
|
+
*/
|
|
126
|
+
creditManager: Address;
|
|
127
|
+
/**
|
|
128
|
+
* Credit account that is being adjusted
|
|
129
|
+
*/
|
|
130
|
+
creditAccount: Address;
|
|
131
|
+
/**
|
|
132
|
+
* Tokens that were added as collateral during account opening.
|
|
133
|
+
*
|
|
134
|
+
* When the transaction has native value attached, it is represented as a
|
|
135
|
+
* `NATIVE_ADDRESS` entry, with the wrapped native token amount reduced
|
|
136
|
+
* accordingly (omitted entirely when it reaches zero).
|
|
137
|
+
*/
|
|
138
|
+
collateralAdded: Asset[];
|
|
139
|
+
/**
|
|
140
|
+
* Tokens that were withdrawn as collateral during account adjustment.
|
|
141
|
+
*/
|
|
142
|
+
collateralWithdrawn: Asset[];
|
|
143
|
+
/**
|
|
144
|
+
* Sum of collateral tokens in underlying
|
|
145
|
+
*/
|
|
146
|
+
totalValue: bigint;
|
|
147
|
+
/**
|
|
148
|
+
* Borrowed amount in underlying
|
|
149
|
+
*/
|
|
150
|
+
debt: bigint;
|
|
151
|
+
/**
|
|
152
|
+
* Debt after minus debt before
|
|
153
|
+
*/
|
|
154
|
+
debtChange: bigint;
|
|
155
|
+
/**
|
|
156
|
+
* Desired quotas
|
|
157
|
+
*/
|
|
158
|
+
quotas: Asset[];
|
|
159
|
+
/**
|
|
160
|
+
* Quotas after minus quotas before
|
|
161
|
+
*/
|
|
162
|
+
quotasChange: Asset[];
|
|
163
|
+
/**
|
|
164
|
+
* Minimum amount of assets on credit account after the operation,
|
|
165
|
+
* as estimated by router
|
|
166
|
+
*/
|
|
167
|
+
assets: Asset[];
|
|
168
|
+
/**
|
|
169
|
+
* Assets after minus assets before
|
|
170
|
+
*/
|
|
171
|
+
assetsChange: Asset[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Result of previewing a raw operation calldata: currently pool operations and
|
|
175
|
+
* credit account opening are supported.
|
|
176
|
+
*/
|
|
177
|
+
export type OperationPreview = PoolOperationPreview | OpenCreditAccountPreview | AdjustCreditAccountPreview;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type Asset } from "../../sdk/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the transaction's attached native value as a `NATIVE_ADDRESS`
|
|
5
|
+
* entry in the collateral list.
|
|
6
|
+
*
|
|
7
|
+
* The credit facade wraps `msg.value` into WETH before `AddCollateral(WETH)`
|
|
8
|
+
* pulls it, so the WETH collateral amount already includes the attached native
|
|
9
|
+
* value. This helper splits the WETH entry back: the native amount is shown as
|
|
10
|
+
* `NATIVE_ADDRESS` and the WETH entry is reduced accordingly (dropped when it
|
|
11
|
+
* reaches zero). Other entries are preserved.
|
|
12
|
+
*
|
|
13
|
+
* @param collateral - Collateral assets as declared by the multicall.
|
|
14
|
+
* @param nativeAmount - Transaction `msg.value`.
|
|
15
|
+
* @param wethToken - Wrapped native token address.
|
|
16
|
+
* @returns Collateral with the native amount unwrapped from the WETH entry.
|
|
17
|
+
* @throws InvalidTransactionValueError when `nativeAmount` is positive but the
|
|
18
|
+
* WETH collateral is missing or smaller than it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function unwrapNativeCollateral(collateral: Asset[], nativeAmount: bigint, wethToken: Address): Asset[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseError, type Hex } from "viem";
|
|
2
|
+
/** Which simulation flow produced a failure. */
|
|
3
|
+
export type SimulationFlowSource = "multicall" | "unknown";
|
|
4
|
+
/** A single flow failure with its decoded revert detail. */
|
|
5
|
+
export interface SimulationFlowFailure {
|
|
6
|
+
source: SimulationFlowSource;
|
|
7
|
+
detail: SimulationError;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error returned by the pool simulation when it fails. It wraps the flow's
|
|
11
|
+
* decoded revert reason (see {@link failures}).
|
|
12
|
+
*/
|
|
13
|
+
export declare class PreviewSimulationError extends BaseError {
|
|
14
|
+
name: string;
|
|
15
|
+
/** Per-flow decoded failures behind this error. */
|
|
16
|
+
readonly failures: SimulationFlowFailure[];
|
|
17
|
+
constructor(failures: SimulationFlowFailure[]);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Normalises an unknown rejection reason into a {@link PreviewSimulationError}.
|
|
21
|
+
* Pass-through when it already is one; otherwise decodes it under `source`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function asPreviewSimulationError(reason: unknown, source: SimulationFlowSource): PreviewSimulationError;
|
|
24
|
+
/** Decoded revert of the simulated transaction. */
|
|
25
|
+
export interface SimulationError {
|
|
26
|
+
/** Human-readable revert reason / error name. */
|
|
27
|
+
reason: string;
|
|
28
|
+
/** Original error, kept for debugging. */
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** Per-call slice of a multicall failure we need to decode. */
|
|
32
|
+
export interface SimulationRevert {
|
|
33
|
+
error?: Error;
|
|
34
|
+
/** Raw revert return data, when present. */
|
|
35
|
+
data?: Hex;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Decodes a simulated call revert into a {@link SimulationError}.
|
|
39
|
+
*
|
|
40
|
+
* We first try to decode any raw return bytes against the SDK's
|
|
41
|
+
* {@link errorAbis} (Gearbox protocol exceptions plus standard ERC-20 custom
|
|
42
|
+
* errors); failing that, we walk viem's error chain for a
|
|
43
|
+
* {@link ContractFunctionRevertedError} (covers `Error(string)` / `Panic`).
|
|
44
|
+
*/
|
|
45
|
+
export declare function decodeSimulationError(revert: SimulationRevert): SimulationError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { SimulationError, SimulationFlowFailure, SimulationFlowSource, } from "./errors.js";
|
|
2
|
+
export { PreviewSimulationError } from "./errors.js";
|
|
3
|
+
export type { SimulateFacadeOperationInput } from "./simulateFacadeOperation.js";
|
|
4
|
+
export { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
5
|
+
export type { SimulateOperationInput } from "./simulateOperation.js";
|
|
6
|
+
export { simulateOperation } from "./simulateOperation.js";
|
|
7
|
+
export { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
8
|
+
export type { SimulateRWAOperationInput } from "./simulateRWAOperation.js";
|
|
9
|
+
export { simulateRWAOperation } from "./simulateRWAOperation.js";
|
|
10
|
+
export type { OperationSimulationOptions, PoolOperationSimulation, PoolOperationSimulationInput, PoolOperationSimulationResult, } from "./types.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { OuterFacadeOperation } from "../parse/index.js";
|
|
4
|
+
import type { OperationSimulationOptions, PoolOperationSimulation } from "./types.js";
|
|
5
|
+
export interface SimulateFacadeOperationInput {
|
|
6
|
+
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
7
|
+
sdk: OnchainSDK;
|
|
8
|
+
/** Parsed credit-facade operation to simulate. */
|
|
9
|
+
operation: OuterFacadeOperation;
|
|
10
|
+
/** Target contract the calldata is sent to (the credit facade). */
|
|
11
|
+
to: Address;
|
|
12
|
+
/** Raw credit-facade calldata to simulate. */
|
|
13
|
+
calldata: Hex;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Simulates a credit-facade operation.
|
|
17
|
+
*
|
|
18
|
+
* Not yet implemented: credit-facade simulation requires multicall-aware
|
|
19
|
+
* balance/transfer accounting that the pool simulation does not cover. The
|
|
20
|
+
* signature mirrors {@link simulatePoolOperation} so the
|
|
21
|
+
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
22
|
+
*/
|
|
23
|
+
export declare function simulateFacadeOperation(_input: SimulateFacadeOperationInput, _options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import { type Operation } from "../parse/index.js";
|
|
4
|
+
import type { OperationSimulationOptions, PoolOperationSimulation } from "./types.js";
|
|
5
|
+
export interface SimulateOperationInput {
|
|
6
|
+
/** Gearbox SDK instance. */
|
|
7
|
+
sdk: OnchainSDK;
|
|
8
|
+
/** Parsed pool or credit account operation */
|
|
9
|
+
operation: Operation;
|
|
10
|
+
/** Target contract the calldata is sent to. */
|
|
11
|
+
to: Address;
|
|
12
|
+
/** Raw operation calldata to simulate. */
|
|
13
|
+
calldata: Hex;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Simulates a parsed pool or credit account operation {@link Operation}
|
|
17
|
+
*/
|
|
18
|
+
export declare function simulateOperation(input: SimulateOperationInput, options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OperationSimulationOptions, PoolOperationSimulation, PoolOperationSimulationInput } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Simulates a pool deposit/mint/withdraw/redeem (direct or zapper-routed) and
|
|
4
|
+
* returns the resulting token amounts going in and out, or a decoded failure.
|
|
5
|
+
*
|
|
6
|
+
* Performs the matching preview read (the pool's ERC4626
|
|
7
|
+
* `previewDeposit`/`previewMint`/`previewWithdraw`/`previewRedeem`, or the
|
|
8
|
+
* zapper's `previewDeposit`/`previewRedeem`) to convert the calldata-known
|
|
9
|
+
* amount into its counterpart. It works on every network the SDK supports.
|
|
10
|
+
*
|
|
11
|
+
* It does not execute the calldata, so it ignores balance/allowance
|
|
12
|
+
* prerequisites (preview reads succeed regardless).
|
|
13
|
+
*/
|
|
14
|
+
export declare function simulatePoolOperation(input: PoolOperationSimulationInput, options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { RWAOperation } from "../parse/index.js";
|
|
4
|
+
import type { OperationSimulationOptions, PoolOperationSimulation } from "./types.js";
|
|
5
|
+
export interface SimulateRWAOperationInput {
|
|
6
|
+
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
7
|
+
sdk: OnchainSDK;
|
|
8
|
+
/** Parsed RWA-factory operation to simulate. */
|
|
9
|
+
operation: RWAOperation;
|
|
10
|
+
/** Target contract the calldata is sent to (the RWA factory). */
|
|
11
|
+
to: Address;
|
|
12
|
+
/** Raw RWA-factory calldata to simulate. */
|
|
13
|
+
calldata: Hex;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Simulates an RWA-factory operation.
|
|
17
|
+
*
|
|
18
|
+
* Not yet implemented: like credit-facade simulation, it requires
|
|
19
|
+
* multicall-aware balance/transfer accounting that the pool simulation does
|
|
20
|
+
* not cover. The signature mirrors {@link simulatePoolOperation} so the
|
|
21
|
+
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
22
|
+
*/
|
|
23
|
+
export declare function simulateRWAOperation(_input: SimulateRWAOperationInput, _options?: OperationSimulationOptions): Promise<PoolOperationSimulation>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import type { ILogger } from "../../sdk/types/logger.js";
|
|
4
|
+
import type { PoolOperation } from "../parse/index.js";
|
|
5
|
+
import type { PreviewSimulationError } from "./errors.js";
|
|
6
|
+
export interface PoolOperationSimulationInput {
|
|
7
|
+
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
8
|
+
sdk: OnchainSDK;
|
|
9
|
+
/** Parsed operation, used to resolve the underlying and pool tokens. */
|
|
10
|
+
operation: PoolOperation;
|
|
11
|
+
/** Target contract the calldata is sent to (the pool). */
|
|
12
|
+
to: Address;
|
|
13
|
+
/** Raw deposit/mint/withdraw/redeem calldata to simulate. */
|
|
14
|
+
calldata: Hex;
|
|
15
|
+
}
|
|
16
|
+
export interface OperationSimulationOptions {
|
|
17
|
+
/** Block to simulate at; defaults to latest. */
|
|
18
|
+
blockNumber?: bigint;
|
|
19
|
+
/**
|
|
20
|
+
* Optional logger.
|
|
21
|
+
**/
|
|
22
|
+
logger?: ILogger;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Successful simulation of a pool operation: the amounts of tokens going in
|
|
26
|
+
* and out. One side comes from calldata, the other from the matching ERC4626
|
|
27
|
+
* preview read. This is the success payload of {@link PoolOperationSimulation}
|
|
28
|
+
* without the `status` discriminant.
|
|
29
|
+
*/
|
|
30
|
+
export interface PoolOperationSimulationResult {
|
|
31
|
+
/**
|
|
32
|
+
* Amount of tokens going from the user to the pool (underlying or zapper
|
|
33
|
+
* input token for deposit/mint, pool shares for withdraw/redeem).
|
|
34
|
+
**/
|
|
35
|
+
amountIn: bigint;
|
|
36
|
+
/**
|
|
37
|
+
* Amount of tokens going from the pool to the user (pool shares or zapper
|
|
38
|
+
* output token for deposit/mint, underlying for withdraw/redeem).
|
|
39
|
+
**/
|
|
40
|
+
amountOut: bigint;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Outcome of simulating a pool operation. On success it carries a
|
|
44
|
+
* {@link PoolOperationSimulationResult}; on failure it carries a
|
|
45
|
+
* {@link PreviewSimulationError}.
|
|
46
|
+
*/
|
|
47
|
+
export type PoolOperationSimulation = ({
|
|
48
|
+
status: "success";
|
|
49
|
+
} & PoolOperationSimulationResult) | {
|
|
50
|
+
status: "failure";
|
|
51
|
+
error: PreviewSimulationError;
|
|
52
|
+
};
|
|
@@ -9,16 +9,6 @@ export declare class TransferAlignmentError extends Error {
|
|
|
9
9
|
export declare class WithdrawCollateralAlignmentError extends Error {
|
|
10
10
|
constructor(expected: number, actual: number);
|
|
11
11
|
}
|
|
12
|
-
export declare class ProtocolCallNotFoundError extends Error {
|
|
13
|
-
readonly targetContract: Address;
|
|
14
|
-
readonly executeIndex: number;
|
|
15
|
-
constructor(targetContract: Address, executeIndex: number);
|
|
16
|
-
}
|
|
17
|
-
export declare class AdapterTraceAlignmentError extends Error {
|
|
18
|
-
readonly expected: number;
|
|
19
|
-
readonly actual: number;
|
|
20
|
-
constructor(expected: number, actual: number);
|
|
21
|
-
}
|
|
22
12
|
export declare class UnexpectedFacadeEventOrderError extends Error {
|
|
23
13
|
constructor(e: {
|
|
24
14
|
eventName: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CallTrace } from "../../common-utils/utils/trace.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the user multicall's adapter-level call traces from a single facade
|
|
4
|
+
* call trace.
|
|
5
|
+
*
|
|
6
|
+
* Returns the direct children of the facade trace that perform an external
|
|
7
|
+
* protocol call (their subtree resolves to a `CreditManager.execute(bytes)`
|
|
8
|
+
* that reaches a leaf CALL to a target contract), in trace order.
|
|
9
|
+
*
|
|
10
|
+
* Scoping to direct children of the facade trace (rather than flattening the
|
|
11
|
+
* whole subtree) avoids over-counting in nested credit-manager scenarios such
|
|
12
|
+
* as account migration, where a single migrate-adapter subtree nests another
|
|
13
|
+
* account's `execute(bytes)` calls.
|
|
14
|
+
*
|
|
15
|
+
* Facade-synthesized phantom-token withdrawals are excluded: while processing
|
|
16
|
+
* `withdrawCollateral` on a phantom token the facade issues its own
|
|
17
|
+
* `withdrawPhantomToken` adapter call, which also reaches an external target
|
|
18
|
+
* but does not correspond to a user multicall inner call. These are detected
|
|
19
|
+
* via the preceding `getPhantomTokenInfo()` probe (see
|
|
20
|
+
* {@link isSynthesizedPhantomWithdrawal}), so the returned traces line up 1:1,
|
|
21
|
+
* in order, with the multicall's adapter inner calls.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractAdapterCallTraces(facadeTrace: CallTrace): CallTrace[];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Address, type Log } from "viem";
|
|
2
|
-
import { AddressMap } from "
|
|
3
|
-
import type {
|
|
4
|
-
import type { DirectTransferInfo } from "./types.js";
|
|
2
|
+
import { AddressMap } from "../../sdk/index.js";
|
|
3
|
+
import type { TokenTransfer } from "../parse/index.js";
|
|
5
4
|
type RawLog = Log<bigint | number, number, false>;
|
|
6
5
|
/**
|
|
7
6
|
* Effective `withdrawCollateral` outcome decoded from the facade's
|
|
@@ -26,8 +25,18 @@ export interface WithdrawCollateralEventInfo {
|
|
|
26
25
|
* @param creditAccount - the credit account address to track
|
|
27
26
|
*/
|
|
28
27
|
export interface ExtractTransfersResult {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/**
|
|
29
|
+
* ERC-20 transfers grouped per facade `Execute` event, one inner array per
|
|
30
|
+
* Execute event across the whole transaction, in emission order. Each inner
|
|
31
|
+
* array holds the transfers to/from the credit account that occurred between
|
|
32
|
+
* that Execute boundary and the previous one.
|
|
33
|
+
*/
|
|
34
|
+
executeTransfers: TokenTransfer[][];
|
|
35
|
+
/**
|
|
36
|
+
* ERC-20 transfers that are not part of a facade `Execute` event and are
|
|
37
|
+
* direct incoming transfers to the credit account.
|
|
38
|
+
*/
|
|
39
|
+
directTransfers: TokenTransfer[];
|
|
31
40
|
liquidationRemainingFunds?: bigint;
|
|
32
41
|
/** Maps phantom token address to its deposited (underlying) token address. */
|
|
33
42
|
phantomTokens: AddressMap<Address>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
2
|
+
import { type CallTrace } from "../../common-utils/utils/trace.js";
|
|
3
|
+
import type { ChainContractsRegister } from "../../sdk/index.js";
|
|
4
|
+
import type { FacadeParsedCall } from "./types.js";
|
|
4
5
|
/**
|
|
5
6
|
* Walks a `debug_traceTransaction` callTracer tree, finds all non-reverted
|
|
6
7
|
* calls to the credit facade, parses them via the register, and returns
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { CallTrace } from "../../common-utils/utils/trace.js";
|
|
3
|
+
import type { ParsedCallV2 } from "../../sdk/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* The set of credit facade entry-point functions that produce history operations.
|
|
6
|
+
*/
|
|
7
|
+
export type FacadeCallType = "MultiCall" | "BotMulticall" | "OpenCreditAccount" | "CloseCreditAccount" | "LiquidateCreditAccount" | "PartiallyLiquidateCreditAccount";
|
|
8
|
+
/**
|
|
9
|
+
* A parsed credit facade call extracted from a call trace,
|
|
10
|
+
* with inner multicall calls already decoded.
|
|
11
|
+
*/
|
|
12
|
+
export interface FacadeParsedCall {
|
|
13
|
+
operation: FacadeCallType;
|
|
14
|
+
creditAccount: Address;
|
|
15
|
+
/** The full ParsedCallV2 from facade calldata parsing. */
|
|
16
|
+
parsed: ParsedCallV2;
|
|
17
|
+
/** Inner multicall entries from rawArgs.calls (empty for partiallyLiquidateCreditAccount). */
|
|
18
|
+
innerCalls: ParsedCallV2[];
|
|
19
|
+
/** The full call trace node for this facade call (used to extract protocol-level calldata). */
|
|
20
|
+
trace: CallTrace;
|
|
21
|
+
}
|
|
@@ -55,6 +55,11 @@ export interface MultichainAttachOptions {
|
|
|
55
55
|
* Options for Pyth price-feed updates (shared cache across chains).
|
|
56
56
|
**/
|
|
57
57
|
pyth?: PythOptions;
|
|
58
|
+
/**
|
|
59
|
+
* When `true`, automatically load zappers after markets are loaded during
|
|
60
|
+
* attach on every chain.
|
|
61
|
+
**/
|
|
62
|
+
loadZappers?: boolean;
|
|
58
63
|
}
|
|
59
64
|
/**
|
|
60
65
|
* Options for {@link MultichainSDK.hydrate}.
|
|
@@ -117,6 +117,10 @@ export interface AttachOptions {
|
|
|
117
117
|
* Options for Pyth price-feed updates.
|
|
118
118
|
**/
|
|
119
119
|
pyth?: PythOptions;
|
|
120
|
+
/**
|
|
121
|
+
* When `true`, automatically call {@link MarketRegister.loadZappers} during attach.
|
|
122
|
+
**/
|
|
123
|
+
loadZappers?: boolean;
|
|
120
124
|
}
|
|
121
125
|
/**
|
|
122
126
|
* Options accepted by {@link OnchainSDK.hydrate}.
|
|
@@ -4,9 +4,9 @@ import { SDKConstruct } from "../base/index.js";
|
|
|
4
4
|
import { type PriceUpdate } from "../market/index.js";
|
|
5
5
|
import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
|
|
6
6
|
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
7
|
-
import {
|
|
7
|
+
import type { RouterCASlice } from "../router/index.js";
|
|
8
8
|
import type { MultiCall, RawTx } from "../types/index.js";
|
|
9
|
-
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
|
|
9
|
+
import type { AccountToCheck, AddCollateralProps, AssembleCaUpdateCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Options for configuring the credit account service.
|
|
12
12
|
**/
|
|
@@ -204,6 +204,26 @@ export declare class CreditAccountsServiceV310 extends SDKConstruct implements I
|
|
|
204
204
|
botMulticall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
205
205
|
ignoreReservePrices?: boolean;
|
|
206
206
|
}): Promise<RawTx>;
|
|
207
|
+
/**
|
|
208
|
+
* {@inheritDoc ICreditAccountsService.prependPriceUpdates}
|
|
209
|
+
*/
|
|
210
|
+
prependPriceUpdates(creditManager: Address, calls: MultiCall[], creditAccount?: RouterCASlice, options?: {
|
|
211
|
+
ignoreReservePrices?: boolean;
|
|
212
|
+
}): Promise<MultiCall[]>;
|
|
213
|
+
/**
|
|
214
|
+
* {@inheritDoc ICreditAccountsService.assembleCaUpdateCalls}
|
|
215
|
+
*/
|
|
216
|
+
assembleCaUpdateCalls({ operations, routerCallGroups, creditFacade, withdrawTo, creditAccount, underlyingToken, }: AssembleCaUpdateCallsProps): MultiCall[];
|
|
217
|
+
/**
|
|
218
|
+
* {@inheritDoc ICreditAccountsService.executeCaUpdate}
|
|
219
|
+
*/
|
|
220
|
+
executeCaUpdate(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
221
|
+
ignoreReservePrices?: boolean;
|
|
222
|
+
ethAmount?: bigint;
|
|
223
|
+
}): Promise<{
|
|
224
|
+
tx: RawTx;
|
|
225
|
+
calls: MultiCall[];
|
|
226
|
+
}>;
|
|
207
227
|
/**
|
|
208
228
|
* Returns addresses of market configurators
|
|
209
229
|
*/
|