@gearbox-protocol/sdk 14.12.0-next.1 → 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/dev/AccountOpener.js +7 -13
- package/dist/cjs/history/classifyMulticallOperations.js +2 -0
- package/dist/cjs/history/mapOperations.js +7 -0
- 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 +36 -0
- package/dist/cjs/plugins/adapters/contracts/AbstractCurveAdapter.js +66 -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/preview/index.js +2 -4
- package/dist/cjs/preview/parse/classifyInnerOperations.js +14 -1
- package/dist/cjs/preview/parse/errors.js +5 -2
- package/dist/cjs/preview/parse/index.js +2 -2
- package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +5 -12
- package/dist/cjs/preview/parse/parseOperationCalldata.js +40 -1
- package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +14 -2
- package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +104 -0
- package/dist/cjs/preview/parse/types-rwa.js +16 -0
- package/dist/cjs/preview/parse/types.js +9 -2
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +13 -13
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +32 -14
- package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +66 -0
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +124 -14
- package/dist/cjs/preview/prerequisites/index.js +2 -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/{sdk/market/zapper/Zapper.js → preview/preview/unwrapNativeCollateral.js} +20 -22
- package/dist/cjs/preview/simulate/errors.js +0 -7
- package/dist/cjs/preview/simulate/index.js +5 -5
- package/dist/cjs/preview/simulate/simulateOperation.js +4 -0
- package/dist/cjs/preview/simulate/simulatePoolOperation.js +60 -31
- package/dist/cjs/preview/simulate/{constants.js → simulateRWAOperation.js} +8 -6
- package/dist/cjs/sdk/MultichainSDK.js +1 -0
- package/dist/cjs/sdk/OnchainSDK.js +7 -3
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +3 -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/{preview/simulate/holders.js → sdk/market/zapper/errors.js} +13 -21
- 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/dev/AccountOpener.js +8 -13
- package/dist/esm/history/classifyMulticallOperations.js +2 -0
- package/dist/esm/history/mapOperations.js +7 -0
- 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 +36 -0
- package/dist/esm/plugins/adapters/contracts/AbstractCurveAdapter.js +42 -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 +1 -2
- package/dist/esm/preview/parse/classifyInnerOperations.js +14 -1
- package/dist/esm/preview/parse/errors.js +3 -1
- package/dist/esm/preview/parse/index.js +1 -1
- package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +5 -12
- package/dist/esm/preview/parse/parseOperationCalldata.js +43 -2
- package/dist/esm/preview/parse/parsePoolOperationCalldata.js +14 -2
- package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +85 -0
- package/dist/esm/preview/parse/types-rwa.js +0 -0
- package/dist/esm/preview/parse/types.js +6 -1
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +13 -13
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +32 -14
- package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +42 -0
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +130 -14
- package/dist/esm/preview/prerequisites/index.js +1 -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 +0 -6
- package/dist/esm/preview/simulate/index.js +3 -3
- package/dist/esm/preview/simulate/simulateOperation.js +8 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +61 -35
- package/dist/esm/preview/simulate/simulateRWAOperation.js +6 -0
- package/dist/esm/sdk/MultichainSDK.js +1 -0
- package/dist/esm/sdk/OnchainSDK.js +7 -3
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +4 -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/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/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/history/types.d.ts +4 -4
- 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 +21 -3
- package/dist/types/plugins/adapters/contracts/AbstractCurveAdapter.d.ts +18 -0
- 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 +4 -2
- package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +8 -6
- 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 +2 -2
- 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 +4 -2
- package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +4 -2
- 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 +4 -2
- package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +4 -2
- package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +4 -2
- 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 +3 -1
- package/dist/types/plugins/adapters/contracts/UniswapV3AdapterContract.d.ts +3 -1
- package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +4 -2
- 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 +4 -2
- package/dist/types/plugins/adapters/types.d.ts +10 -0
- package/dist/types/preview/index.d.ts +1 -2
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +0 -2
- package/dist/types/preview/parse/errors.d.ts +1 -0
- package/dist/types/preview/parse/index.d.ts +1 -1
- package/dist/types/preview/parse/parseOperationCalldata.d.ts +3 -3
- package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +22 -0
- package/dist/types/preview/parse/types-adapters.d.ts +5 -1
- package/dist/types/preview/parse/types-facades.d.ts +23 -34
- package/dist/types/preview/parse/types-pools.d.ts +90 -2
- package/dist/types/preview/parse/types-rwa.d.ts +48 -0
- package/dist/types/preview/parse/types.d.ts +11 -6
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +1 -3
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +9 -6
- package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +36 -0
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +15 -6
- package/dist/types/preview/prerequisites/index.d.ts +1 -0
- package/dist/types/preview/prerequisites/types.d.ts +10 -8
- 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 +6 -12
- package/dist/types/preview/simulate/index.d.ts +3 -2
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +0 -2
- package/dist/types/preview/simulate/simulateOperation.d.ts +0 -2
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +9 -3
- package/dist/types/preview/simulate/simulateRWAOperation.d.ts +23 -0
- package/dist/types/preview/simulate/types.d.ts +12 -39
- 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 +1 -1
- package/dist/types/sdk/accounts/types.d.ts +2 -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 +3 -3
- package/dist/cjs/preview/parse/extractExpectedBalanceChanges.js +0 -48
- package/dist/cjs/preview/simulate/extractERC20Transfers.js +0 -47
- package/dist/cjs/preview/simulate/simulatePoolOpMulticall.js +0 -155
- package/dist/cjs/preview/simulate/simulatePoolOpV1.js +0 -106
- package/dist/esm/preview/parse/extractExpectedBalanceChanges.js +0 -24
- package/dist/esm/preview/simulate/constants.js +0 -4
- package/dist/esm/preview/simulate/extractERC20Transfers.js +0 -23
- package/dist/esm/preview/simulate/holders.js +0 -21
- package/dist/esm/preview/simulate/simulatePoolOpMulticall.js +0 -130
- package/dist/esm/preview/simulate/simulatePoolOpV1.js +0 -82
- package/dist/esm/sdk/market/zapper/Zapper.js +0 -23
- package/dist/types/preview/parse/extractExpectedBalanceChanges.d.ts +0 -22
- package/dist/types/preview/simulate/constants.d.ts +0 -6
- package/dist/types/preview/simulate/extractERC20Transfers.d.ts +0 -11
- package/dist/types/preview/simulate/holders.d.ts +0 -7
- package/dist/types/preview/simulate/simulatePoolOpMulticall.d.ts +0 -28
- package/dist/types/preview/simulate/simulatePoolOpV1.d.ts +0 -14
- package/dist/types/sdk/market/zapper/Zapper.d.ts +0 -13
|
@@ -22,10 +22,15 @@ __export(buildPrerequisites_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(buildPrerequisites_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
|
+
var import_sdk = require("../../sdk/index.js");
|
|
26
|
+
var import_parseOperationCalldata = require("../parse/parseOperationCalldata.js");
|
|
25
27
|
var import_AllowancePrerequisite = require("./AllowancePrerequisite.js");
|
|
26
28
|
var import_BalancePrerequisite = require("./BalancePrerequisite.js");
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
var import_RWAOpenRequirementsPrerequisite = require("./RWAOpenRequirementsPrerequisite.js");
|
|
30
|
+
async function buildPrerequisites(input) {
|
|
31
|
+
const { sdk, sender: wallet, blockNumber } = input;
|
|
32
|
+
const tx = (0, import_parseOperationCalldata.parseOperationCalldata)(input);
|
|
33
|
+
const ctx = { sdk, wallet, blockNumber };
|
|
29
34
|
switch (tx.operation) {
|
|
30
35
|
// Deposit and Mint both pull the underlying from the caller into the pool;
|
|
31
36
|
// they only differ in which side (assets vs shares) the caller specifies.
|
|
@@ -34,6 +39,29 @@ function buildPrerequisites(tx, ctx) {
|
|
|
34
39
|
// here we approximate Mint by its shares amount (a lower bound on assets is
|
|
35
40
|
// not knowable from calldata alone).
|
|
36
41
|
case "Deposit":
|
|
42
|
+
if (tx.zapper) {
|
|
43
|
+
const prereqs = [];
|
|
44
|
+
if (!(0, import_viem.isAddressEqual)(tx.tokenIn, import_sdk.NATIVE_ADDRESS)) {
|
|
45
|
+
prereqs.push(
|
|
46
|
+
new import_AllowancePrerequisite.AllowancePrerequisite({
|
|
47
|
+
token: tx.tokenIn,
|
|
48
|
+
owner: wallet,
|
|
49
|
+
spender: tx.zapper,
|
|
50
|
+
required: tx.assets,
|
|
51
|
+
title: "Token approved to zapper"
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
prereqs.push(
|
|
56
|
+
new import_BalancePrerequisite.BalancePrerequisite({
|
|
57
|
+
token: tx.tokenIn,
|
|
58
|
+
owner: wallet,
|
|
59
|
+
required: tx.assets,
|
|
60
|
+
title: "Sufficient token balance"
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
return prereqs;
|
|
64
|
+
}
|
|
37
65
|
return [
|
|
38
66
|
new import_AllowancePrerequisite.AllowancePrerequisite({
|
|
39
67
|
token: tx.underlying,
|
|
@@ -68,6 +96,23 @@ function buildPrerequisites(tx, ctx) {
|
|
|
68
96
|
// Redeem and Withdraw both burn LP shares from `owner`; they only differ in
|
|
69
97
|
// which side (shares vs assets) the caller specifies.
|
|
70
98
|
case "Redeem": {
|
|
99
|
+
if (tx.zapper) {
|
|
100
|
+
return [
|
|
101
|
+
new import_BalancePrerequisite.BalancePrerequisite({
|
|
102
|
+
token: tx.tokenIn,
|
|
103
|
+
owner: wallet,
|
|
104
|
+
required: tx.shares,
|
|
105
|
+
title: "Sufficient share token balance"
|
|
106
|
+
}),
|
|
107
|
+
new import_AllowancePrerequisite.AllowancePrerequisite({
|
|
108
|
+
token: tx.tokenIn,
|
|
109
|
+
owner: wallet,
|
|
110
|
+
spender: tx.zapper,
|
|
111
|
+
required: tx.shares,
|
|
112
|
+
title: "Share token approved to zapper"
|
|
113
|
+
})
|
|
114
|
+
];
|
|
115
|
+
}
|
|
71
116
|
const prereqs = [
|
|
72
117
|
new import_BalancePrerequisite.BalancePrerequisite({
|
|
73
118
|
token: tx.pool,
|
|
@@ -116,7 +161,37 @@ function buildPrerequisites(tx, ctx) {
|
|
|
116
161
|
case "OpenCreditAccount":
|
|
117
162
|
case "CloseCreditAccount":
|
|
118
163
|
case "LiquidateCreditAccount":
|
|
119
|
-
return collateralPrerequisites(
|
|
164
|
+
return collateralPrerequisites(
|
|
165
|
+
tx.operation === "OpenCreditAccount" ? { creditManager: tx.creditManager, borrower: wallet } : {
|
|
166
|
+
creditManager: tx.creditManager,
|
|
167
|
+
creditAccount: tx.creditAccount
|
|
168
|
+
},
|
|
169
|
+
tx.multicall,
|
|
170
|
+
ctx
|
|
171
|
+
);
|
|
172
|
+
// RWA-factory operations: same collateral checks as facade operations,
|
|
173
|
+
// plus (for opening) the factory's open-account requirements. The parsed
|
|
174
|
+
// operation carries template (empty) `tokensToRegister`/`signaturesToCache`;
|
|
175
|
+
// the prerequisite detail provides the real values.
|
|
176
|
+
case "SecuritizeOpenCreditAccount":
|
|
177
|
+
return [
|
|
178
|
+
...await collateralPrerequisites(
|
|
179
|
+
{ creditManager: tx.creditManager, borrower: wallet },
|
|
180
|
+
tx.multicall,
|
|
181
|
+
ctx
|
|
182
|
+
),
|
|
183
|
+
...await rwaOpenRequirementsPrerequisites(
|
|
184
|
+
tx.multicall,
|
|
185
|
+
tx.creditManager,
|
|
186
|
+
ctx
|
|
187
|
+
)
|
|
188
|
+
];
|
|
189
|
+
case "SecuritizeMulticall":
|
|
190
|
+
return collateralPrerequisites(
|
|
191
|
+
{ creditManager: tx.creditManager, creditAccount: tx.creditAccount },
|
|
192
|
+
tx.multicall,
|
|
193
|
+
ctx
|
|
194
|
+
);
|
|
120
195
|
case "PartiallyLiquidateCreditAccount": {
|
|
121
196
|
const underlying = underlyingOf(ctx.sdk, tx.creditManager);
|
|
122
197
|
if (!underlying || tx.repaidAmount === 0n) {
|
|
@@ -142,28 +217,28 @@ function buildPrerequisites(tx, ctx) {
|
|
|
142
217
|
return [];
|
|
143
218
|
}
|
|
144
219
|
}
|
|
145
|
-
function collateralPrerequisites(
|
|
146
|
-
const
|
|
220
|
+
async function collateralPrerequisites(spenderOptions, multicall, ctx) {
|
|
221
|
+
const { sdk, wallet } = ctx;
|
|
222
|
+
const required = new import_sdk.AssetsMap();
|
|
147
223
|
for (const op of multicall) {
|
|
148
224
|
if (op.operation !== "AddCollateral" || op.amount === 0n) {
|
|
149
225
|
continue;
|
|
150
226
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
amount: (existing?.amount ?? 0n) + op.amount
|
|
156
|
-
});
|
|
227
|
+
required.inc(op.token, op.amount);
|
|
228
|
+
}
|
|
229
|
+
if (required.size === 0) {
|
|
230
|
+
return [];
|
|
157
231
|
}
|
|
232
|
+
const spender = await sdk.accounts.getApprovalAddress(spenderOptions);
|
|
158
233
|
const prereqs = [];
|
|
159
|
-
for (const
|
|
234
|
+
for (const [token, amount] of required.entries()) {
|
|
160
235
|
prereqs.push(
|
|
161
236
|
new import_AllowancePrerequisite.AllowancePrerequisite({
|
|
162
237
|
token,
|
|
163
238
|
owner: wallet,
|
|
164
|
-
spender
|
|
239
|
+
spender,
|
|
165
240
|
required: amount,
|
|
166
|
-
title: "Collateral approved
|
|
241
|
+
title: "Collateral approved"
|
|
167
242
|
}),
|
|
168
243
|
new import_BalancePrerequisite.BalancePrerequisite({
|
|
169
244
|
token,
|
|
@@ -175,6 +250,41 @@ function collateralPrerequisites(multicall, creditManager, wallet) {
|
|
|
175
250
|
}
|
|
176
251
|
return prereqs;
|
|
177
252
|
}
|
|
253
|
+
async function rwaOpenRequirementsPrerequisites(multicall, creditManager, ctx) {
|
|
254
|
+
const { sdk, wallet } = ctx;
|
|
255
|
+
const { rwaFactory } = sdk.marketRegister.findByCreditManager(creditManager);
|
|
256
|
+
if (!rwaFactory) {
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
const rwaTokens = new import_sdk.AddressSet(rwaFactory.getTokens());
|
|
260
|
+
const candidates = new import_sdk.AddressSet();
|
|
261
|
+
for (const op of multicall) {
|
|
262
|
+
if (op.operation === "AddCollateral" || op.operation === "UpdateQuota") {
|
|
263
|
+
candidates.add(op.token);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const prereqs = [];
|
|
267
|
+
for (const token of candidates) {
|
|
268
|
+
if (!rwaTokens.has(token)) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
const requirements = await sdk.accounts.getOpenAccountRequirements(
|
|
272
|
+
wallet,
|
|
273
|
+
creditManager,
|
|
274
|
+
{ tokenOutAddress: token }
|
|
275
|
+
);
|
|
276
|
+
if (requirements) {
|
|
277
|
+
prereqs.push(
|
|
278
|
+
new import_RWAOpenRequirementsPrerequisite.RWAOpenRequirementsPrerequisite({
|
|
279
|
+
requirements,
|
|
280
|
+
token,
|
|
281
|
+
factory: rwaFactory.address
|
|
282
|
+
})
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return prereqs;
|
|
287
|
+
}
|
|
178
288
|
function underlyingOf(sdk, creditManager) {
|
|
179
289
|
const suite = sdk.marketRegister.creditManagers.find(
|
|
180
290
|
(cm) => (0, import_viem.isAddressEqual)(cm.creditManager.address, creditManager)
|
|
@@ -20,6 +20,7 @@ __reExport(prerequisites_exports, require("./BalancePrerequisite.js"), module.ex
|
|
|
20
20
|
__reExport(prerequisites_exports, require("./buildPrerequisites.js"), module.exports);
|
|
21
21
|
__reExport(prerequisites_exports, require("./Prerequisite.js"), module.exports);
|
|
22
22
|
__reExport(prerequisites_exports, require("./prepareAction.js"), module.exports);
|
|
23
|
+
__reExport(prerequisites_exports, require("./RWAOpenRequirementsPrerequisite.js"), module.exports);
|
|
23
24
|
__reExport(prerequisites_exports, require("./runPrerequisites.js"), module.exports);
|
|
24
25
|
__reExport(prerequisites_exports, require("./types.js"), module.exports);
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -29,6 +30,7 @@ __reExport(prerequisites_exports, require("./types.js"), module.exports);
|
|
|
29
30
|
...require("./buildPrerequisites.js"),
|
|
30
31
|
...require("./Prerequisite.js"),
|
|
31
32
|
...require("./prepareAction.js"),
|
|
33
|
+
...require("./RWAOpenRequirementsPrerequisite.js"),
|
|
32
34
|
...require("./runPrerequisites.js"),
|
|
33
35
|
...require("./types.js")
|
|
34
36
|
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var applyInnerOperations_exports = {};
|
|
20
|
+
__export(applyInnerOperations_exports, {
|
|
21
|
+
applyInnerOperations: () => applyInnerOperations,
|
|
22
|
+
applyQuotaChanges: () => applyQuotaChanges,
|
|
23
|
+
makeInnerOperationsState: () => makeInnerOperationsState
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(applyInnerOperations_exports);
|
|
26
|
+
var import_adapters = require("../../plugins/adapters/index.js");
|
|
27
|
+
var import_sdk = require("../../sdk/index.js");
|
|
28
|
+
function makeInnerOperationsState() {
|
|
29
|
+
return {
|
|
30
|
+
balances: new import_sdk.AssetsMap(),
|
|
31
|
+
debt: 0n,
|
|
32
|
+
totalDebt: 0n,
|
|
33
|
+
collateralAdded: new import_sdk.AssetsMap(),
|
|
34
|
+
collateralWithdrawn: new import_sdk.AssetsMap(),
|
|
35
|
+
quotaChanges: []
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function applyInnerOperations(sdk, multicall, state) {
|
|
39
|
+
let inBracket = false;
|
|
40
|
+
let storeSeen = false;
|
|
41
|
+
for (const op of multicall) {
|
|
42
|
+
switch (op.operation) {
|
|
43
|
+
case "AddCollateral":
|
|
44
|
+
state.collateralAdded.inc(op.token, op.amount);
|
|
45
|
+
state.balances.inc(op.token, op.amount);
|
|
46
|
+
break;
|
|
47
|
+
case "WithdrawCollateral": {
|
|
48
|
+
const running = state.balances.get(op.token) ?? 0n;
|
|
49
|
+
const amount = op.amount === import_sdk.MAX_UINT256 ? running > 0n ? running : 0n : op.amount;
|
|
50
|
+
state.balances.dec(op.token, amount);
|
|
51
|
+
state.collateralWithdrawn.inc(op.token, amount);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case "IncreaseBorrowedAmount":
|
|
55
|
+
state.debt += op.amount;
|
|
56
|
+
state.totalDebt += op.amount;
|
|
57
|
+
state.balances.inc(op.token, op.amount);
|
|
58
|
+
break;
|
|
59
|
+
case "DecreaseBorrowedAmount": {
|
|
60
|
+
const repaid = op.amount > state.totalDebt ? state.totalDebt : op.amount;
|
|
61
|
+
state.balances.dec(op.token, repaid);
|
|
62
|
+
state.totalDebt -= repaid;
|
|
63
|
+
if (state.debt > state.totalDebt) {
|
|
64
|
+
state.debt = state.totalDebt;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "UpdateQuota":
|
|
69
|
+
state.quotaChanges.push({ token: op.token, balance: op.change });
|
|
70
|
+
break;
|
|
71
|
+
case "StoreExpectedBalances":
|
|
72
|
+
if (storeSeen) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"malformed multicall: duplicate storeExpectedBalances call"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
storeSeen = true;
|
|
78
|
+
inBracket = true;
|
|
79
|
+
for (const { token, balance } of op.deltas) {
|
|
80
|
+
state.balances.inc(token, balance);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "CompareBalances":
|
|
84
|
+
if (!inBracket) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
"malformed multicall: compareBalances without a preceding storeExpectedBalances"
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
inBracket = false;
|
|
90
|
+
break;
|
|
91
|
+
case "Execute":
|
|
92
|
+
if (inBracket) {
|
|
93
|
+
const adapter = sdk.getContract(op.adapter);
|
|
94
|
+
if (!(adapter instanceof import_adapters.AbstractAdapterContract)) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`call to ${op.adapter} between storeExpectedBalances and compareBalances is not an adapter call`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
adapter.previewBalanceChanges(state.balances, op.calldata);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (inBracket) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
"malformed multicall: storeExpectedBalances without a matching compareBalances"
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function applyQuotaChanges(initialQuotas, changes) {
|
|
111
|
+
const final = initialQuotas.clone();
|
|
112
|
+
for (const { token, balance: change } of changes) {
|
|
113
|
+
if (change === import_sdk.MIN_INT96) {
|
|
114
|
+
final.upsert(token, 0n);
|
|
115
|
+
} else {
|
|
116
|
+
const next = (final.get(token) ?? 0n) + change;
|
|
117
|
+
final.upsert(token, next > 0n ? next : 0n);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const quotas = final.entries().filter(([, balance]) => balance > 0n).map(([token, balance]) => ({ token, balance }));
|
|
121
|
+
const quotasChange = final.entries().map(([token, balance]) => ({
|
|
122
|
+
token,
|
|
123
|
+
balance: balance - (initialQuotas.get(token) ?? 0n)
|
|
124
|
+
})).filter(({ balance }) => balance !== 0n);
|
|
125
|
+
return { quotas, quotasChange };
|
|
126
|
+
}
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
applyInnerOperations,
|
|
130
|
+
applyQuotaChanges,
|
|
131
|
+
makeInnerOperationsState
|
|
132
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
InvalidTransactionValueError: () => InvalidTransactionValueError,
|
|
22
|
+
UnsupportedOperationError: () => UnsupportedOperationError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(errors_exports);
|
|
25
|
+
class InvalidTransactionValueError extends Error {
|
|
26
|
+
/** Transaction `msg.value`. */
|
|
27
|
+
value;
|
|
28
|
+
/** Amount of wrapped native token added as collateral. */
|
|
29
|
+
wethCollateral;
|
|
30
|
+
constructor(value, wethCollateral) {
|
|
31
|
+
super(
|
|
32
|
+
`transaction value ${value} exceeds WETH collateral ${wethCollateral}`
|
|
33
|
+
);
|
|
34
|
+
this.name = "InvalidTransactionValueError";
|
|
35
|
+
this.value = value;
|
|
36
|
+
this.wethCollateral = wethCollateral;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class UnsupportedOperationError extends Error {
|
|
40
|
+
/** The parsed operation kind (the `operation` discriminant). */
|
|
41
|
+
operation;
|
|
42
|
+
constructor(operation) {
|
|
43
|
+
super(`operation "${operation}" is not supported by previewOperation`);
|
|
44
|
+
this.name = "UnsupportedOperationError";
|
|
45
|
+
this.operation = operation;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
InvalidTransactionValueError,
|
|
51
|
+
UnsupportedOperationError
|
|
52
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var preview_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(preview_exports);
|
|
18
|
+
__reExport(preview_exports, require("./applyInnerOperations.js"), module.exports);
|
|
19
|
+
__reExport(preview_exports, require("./errors.js"), module.exports);
|
|
20
|
+
__reExport(preview_exports, require("./previewAdjustCreditAccount.js"), module.exports);
|
|
21
|
+
__reExport(preview_exports, require("./previewOperation.js"), module.exports);
|
|
22
|
+
__reExport(preview_exports, require("./types.js"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./applyInnerOperations.js"),
|
|
26
|
+
...require("./errors.js"),
|
|
27
|
+
...require("./previewAdjustCreditAccount.js"),
|
|
28
|
+
...require("./previewOperation.js"),
|
|
29
|
+
...require("./types.js")
|
|
30
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var previewAdjustCreditAccount_exports = {};
|
|
20
|
+
__export(previewAdjustCreditAccount_exports, {
|
|
21
|
+
previewAdjustCreditAccount: () => previewAdjustCreditAccount
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(previewAdjustCreditAccount_exports);
|
|
24
|
+
var import_sdk = require("../../sdk/index.js");
|
|
25
|
+
var import_applyInnerOperations = require("./applyInnerOperations.js");
|
|
26
|
+
var import_unwrapNativeCollateral = require("./unwrapNativeCollateral.js");
|
|
27
|
+
async function previewAdjustCreditAccount(input, operation, options) {
|
|
28
|
+
const { sdk, value = 0n } = input;
|
|
29
|
+
const market = sdk.marketRegister.findByCreditManager(
|
|
30
|
+
operation.creditManager
|
|
31
|
+
);
|
|
32
|
+
let ca = options?.creditAccount;
|
|
33
|
+
if (!ca) {
|
|
34
|
+
ca = await sdk.accounts.getCreditAccountData(
|
|
35
|
+
operation.creditAccount,
|
|
36
|
+
options?.blockNumber
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (!ca) {
|
|
40
|
+
throw new Error(`credit account ${operation.creditAccount} not found`);
|
|
41
|
+
}
|
|
42
|
+
const initialBalances = new import_sdk.AssetsMap();
|
|
43
|
+
const initialQuotas = new import_sdk.AssetsMap();
|
|
44
|
+
for (const t of ca.tokens) {
|
|
45
|
+
if (t.balance > 1n) {
|
|
46
|
+
initialBalances.upsert(t.token, t.balance);
|
|
47
|
+
}
|
|
48
|
+
if (t.quota > 1n) {
|
|
49
|
+
initialQuotas.upsert(t.token, t.quota);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const state = (0, import_applyInnerOperations.makeInnerOperationsState)();
|
|
53
|
+
for (const [token, balance] of initialBalances.entries()) {
|
|
54
|
+
state.balances.upsert(token, balance);
|
|
55
|
+
}
|
|
56
|
+
state.debt = ca.debt;
|
|
57
|
+
state.totalDebt = ca.debt + ca.accruedInterest + ca.accruedFees;
|
|
58
|
+
(0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
59
|
+
const collateralAdded = (0, import_unwrapNativeCollateral.unwrapNativeCollateral)(
|
|
60
|
+
state.collateralAdded.toAssets(),
|
|
61
|
+
value,
|
|
62
|
+
sdk.addressProvider.getAddress(import_sdk.AP_WETH_TOKEN, import_sdk.NO_VERSION)
|
|
63
|
+
);
|
|
64
|
+
const { quotas, quotasChange } = (0, import_applyInnerOperations.applyQuotaChanges)(
|
|
65
|
+
initialQuotas,
|
|
66
|
+
state.quotaChanges
|
|
67
|
+
);
|
|
68
|
+
const assets = state.balances.toAssets(true);
|
|
69
|
+
const assetsChange = state.balances.entries().map(([token, balance]) => ({
|
|
70
|
+
token,
|
|
71
|
+
balance: balance - (initialBalances.get(token) ?? 0n)
|
|
72
|
+
})).filter(({ balance }) => balance !== 0n);
|
|
73
|
+
const totalValue = assets.reduce(
|
|
74
|
+
(acc, { token, balance }) => acc + market.priceOracle.convert(token, market.underlying, balance),
|
|
75
|
+
0n
|
|
76
|
+
);
|
|
77
|
+
return {
|
|
78
|
+
operation: "AdjustCreditAccount",
|
|
79
|
+
creditManager: operation.creditManager,
|
|
80
|
+
creditAccount: operation.creditAccount,
|
|
81
|
+
collateralAdded,
|
|
82
|
+
collateralWithdrawn: state.collateralWithdrawn.toAssets(),
|
|
83
|
+
totalValue,
|
|
84
|
+
debt: state.debt,
|
|
85
|
+
debtChange: state.debt - ca.debt,
|
|
86
|
+
quotas,
|
|
87
|
+
quotasChange,
|
|
88
|
+
assets,
|
|
89
|
+
assetsChange
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
previewAdjustCreditAccount
|
|
95
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var previewOpenCreditAccount_exports = {};
|
|
20
|
+
__export(previewOpenCreditAccount_exports, {
|
|
21
|
+
previewOpenCreditAccount: () => previewOpenCreditAccount
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(previewOpenCreditAccount_exports);
|
|
24
|
+
var import_sdk = require("../../sdk/index.js");
|
|
25
|
+
var import_applyInnerOperations = require("./applyInnerOperations.js");
|
|
26
|
+
var import_unwrapNativeCollateral = require("./unwrapNativeCollateral.js");
|
|
27
|
+
function previewOpenCreditAccount(input, operation) {
|
|
28
|
+
const { sdk, value = 0n } = input;
|
|
29
|
+
const market = sdk.marketRegister.findByCreditManager(
|
|
30
|
+
operation.creditManager
|
|
31
|
+
);
|
|
32
|
+
const state = (0, import_applyInnerOperations.makeInnerOperationsState)();
|
|
33
|
+
(0, import_applyInnerOperations.applyInnerOperations)(sdk, operation.multicall, state);
|
|
34
|
+
let collateral = state.collateralAdded.toAssets();
|
|
35
|
+
const collateralValue = collateral.reduce(
|
|
36
|
+
(acc, { token, balance }) => acc + market.priceOracle.convert(token, market.underlying, balance),
|
|
37
|
+
0n
|
|
38
|
+
);
|
|
39
|
+
collateral = (0, import_unwrapNativeCollateral.unwrapNativeCollateral)(
|
|
40
|
+
collateral,
|
|
41
|
+
value,
|
|
42
|
+
sdk.addressProvider.getAddress(import_sdk.AP_WETH_TOKEN, import_sdk.NO_VERSION)
|
|
43
|
+
);
|
|
44
|
+
const assets = state.balances.entries().filter(([, balance]) => balance > 1n).map(([token, balance]) => ({ token, balance }));
|
|
45
|
+
return {
|
|
46
|
+
operation: operation.operation,
|
|
47
|
+
creditManager: operation.creditManager,
|
|
48
|
+
target: inferTargetAsset(operation.multicall, state.balances),
|
|
49
|
+
collateral,
|
|
50
|
+
collateralValue,
|
|
51
|
+
debt: state.debt,
|
|
52
|
+
// On opening, initial quotas are zero, so the raw changes are the quotas.
|
|
53
|
+
quotas: state.quotaChanges,
|
|
54
|
+
assets
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function inferTargetAsset(multicall, balances) {
|
|
58
|
+
for (const op of multicall) {
|
|
59
|
+
if (op.operation === "UpdateQuota" && op.change > 0n) {
|
|
60
|
+
const balance = balances.get(op.token);
|
|
61
|
+
return balance ? { token: op.token, balance } : void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
previewOpenCreditAccount
|
|
69
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var previewOperation_exports = {};
|
|
20
|
+
__export(previewOperation_exports, {
|
|
21
|
+
previewOperation: () => previewOperation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(previewOperation_exports);
|
|
24
|
+
var import_parse = require("../parse/index.js");
|
|
25
|
+
var import_errors = require("./errors.js");
|
|
26
|
+
var import_previewAdjustCreditAccount = require("./previewAdjustCreditAccount.js");
|
|
27
|
+
var import_previewOpenCreditAccount = require("./previewOpenCreditAccount.js");
|
|
28
|
+
var import_previewPoolOperation = require("./previewPoolOperation.js");
|
|
29
|
+
async function previewOperation(input, options) {
|
|
30
|
+
const operation = (0, import_parse.parseOperationCalldata)(input);
|
|
31
|
+
if ((0, import_parse.isPoolOperation)(operation)) {
|
|
32
|
+
return (0, import_previewPoolOperation.previewPoolOperation)(input, operation, options);
|
|
33
|
+
}
|
|
34
|
+
if (operation.operation === "OpenCreditAccount" || operation.operation === "SecuritizeOpenCreditAccount") {
|
|
35
|
+
return (0, import_previewOpenCreditAccount.previewOpenCreditAccount)(input, operation);
|
|
36
|
+
}
|
|
37
|
+
if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "SecuritizeMulticall") {
|
|
38
|
+
return (0, import_previewAdjustCreditAccount.previewAdjustCreditAccount)(input, operation, options);
|
|
39
|
+
}
|
|
40
|
+
throw new import_errors.UnsupportedOperationError(operation.operation);
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
previewOperation
|
|
45
|
+
});
|