@gearbox-protocol/sdk 16.2.0 → 16.3.0-next.2
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/rwa/iMidasAccessControl.js +23 -0
- package/dist/cjs/abi/rwa/iMidasDegenNFT.js +92 -0
- package/dist/cjs/history/assembleOperations.js +3 -3
- package/dist/cjs/history/classifyMulticallOperations.js +7 -7
- package/dist/cjs/history/index.js +13 -0
- package/dist/cjs/history/parseCreditAccountTransaction.js +5 -5
- package/dist/cjs/{preview → history}/trace/errors.js +1 -1
- package/dist/cjs/{preview → history}/trace/extractAdapterCallTraces.js +1 -1
- package/dist/cjs/{preview → history}/trace/extractTransfers.js +3 -3
- package/dist/cjs/{preview → history}/trace/findFacadeCalls.js +3 -3
- package/dist/cjs/history/trace/index.js +14 -0
- package/dist/cjs/model/errors/index.js +37 -0
- package/dist/cjs/model/errors/liquidation-errors.js +32 -0
- package/dist/cjs/model/errors/operation-errors.js +135 -0
- package/dist/cjs/{onchain/market/oracle/errors.js → model/errors/oracle-errors.js} +1 -1
- package/dist/cjs/model/errors/prepare-errors.js +108 -0
- package/dist/cjs/model/errors/preview-errors.js +12 -0
- package/dist/cjs/model/index.js +45 -2
- package/dist/cjs/model/opportunities.schema.js +3 -1
- package/dist/cjs/model/positions.js +1 -1
- package/dist/cjs/model/result.js +0 -8
- package/dist/cjs/model/rwa.js +53 -0
- package/dist/cjs/model/rwa.schema.js +20 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/accounts/index.js +0 -2
- package/dist/cjs/onchain/accounts/intents/guards.js +42 -66
- package/dist/cjs/onchain/accounts/intents/index.js +38 -35
- package/dist/cjs/onchain/accounts/intents/leverage-band.js +1 -1
- package/dist/cjs/onchain/accounts/intents/math.js +19 -15
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +6 -4
- package/dist/cjs/onchain/accounts/intents/plan.js +52 -48
- package/dist/cjs/onchain/accounts/intents/realize.js +26 -24
- package/dist/cjs/onchain/accounts/intents/tail.js +15 -12
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +7 -0
- package/dist/cjs/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +6 -6
- package/dist/cjs/onchain/accounts/intents/tests/withdraw.fixtures.js +12 -12
- package/dist/cjs/onchain/accounts/intents/view.js +1 -1
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/cjs/onchain/accounts/withdrawal-compressor/index.js +0 -1
- package/dist/cjs/onchain/index.js +130 -38
- package/dist/cjs/onchain/market/MarketSuite.js +10 -4
- package/dist/cjs/onchain/market/adapters/index.js +1 -0
- package/dist/cjs/onchain/market/credit/CreditSuite.js +77 -15
- package/dist/cjs/onchain/market/index.js +8 -8
- package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +6 -6
- package/dist/cjs/onchain/market/oracle/index.js +0 -2
- package/dist/cjs/onchain/market/pool/PoolQuotaKeeperV310Contract.js +8 -0
- package/dist/cjs/onchain/market/rwa/RWARegistry.js +3 -2
- package/dist/cjs/onchain/market/rwa/createDegenNFT.js +53 -0
- package/dist/cjs/onchain/market/rwa/index.js +7 -5
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +56 -0
- package/dist/cjs/onchain/market/rwa/midas/constants.js +2 -0
- package/dist/cjs/onchain/market/rwa/midas/index.js +3 -0
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +22 -3
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +9 -9
- package/dist/cjs/onchain/market/rwa/securitize/constants.js +2 -2
- package/dist/cjs/onchain/market/rwa/securitize/index.js +4 -3
- package/dist/cjs/onchain/market/rwa/securitize/types.js +0 -29
- package/dist/cjs/onchain/market/rwa/types.js +0 -7
- package/dist/cjs/onchain/market/zapper/index.js +0 -1
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +11 -3
- package/dist/cjs/onchain/pools/PoolService.js +10 -16
- package/dist/cjs/onchain/preview/index.js +41 -0
- package/dist/cjs/{preview → onchain/preview}/parse/classifyInnerOperations.js +2 -3
- package/dist/cjs/onchain/preview/parse/index.js +14 -0
- package/dist/cjs/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.js +3 -3
- package/dist/cjs/{preview → onchain/preview}/parse/parseOperationCalldata.js +16 -17
- package/dist/cjs/{preview → onchain/preview}/parse/parsePoolOperationCalldata.js +3 -3
- package/dist/cjs/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.js +11 -12
- package/dist/cjs/{preview → onchain/preview}/parse/types.js +1 -1
- package/dist/cjs/{preview → onchain/preview}/preview/CreditAccountState.js +3 -4
- package/dist/cjs/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.js +10 -11
- package/dist/cjs/{preview → onchain/preview}/preview/detectCloseOrRepay.js +2 -3
- package/dist/cjs/{preview → onchain/preview}/preview/detectDelayedClaim.js +4 -5
- package/dist/cjs/{preview → onchain/preview}/preview/detectDelayedOperation.js +5 -6
- package/dist/cjs/{preview → onchain/preview}/preview/estimateClaimableAt.js +1 -1
- package/dist/cjs/onchain/preview/preview/index.js +26 -0
- package/dist/cjs/{preview → onchain/preview}/preview/previewAdjustStrategyPosition.js +18 -22
- package/dist/cjs/{preview → onchain/preview}/preview/previewExitOrRepayStrategyPosition.js +22 -28
- package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +60 -0
- package/dist/cjs/onchain/preview/preview/previewOperation.js +119 -0
- package/dist/cjs/{preview/simulate/simulatePoolOperation.js → onchain/preview/preview/previewPoolPositionOperation.js} +46 -32
- package/dist/cjs/onchain/preview/preview/replayInnerOperations.js +109 -0
- package/dist/cjs/onchain/preview/preview/replayMulticall.js +22 -0
- package/dist/cjs/{preview → onchain/preview}/preview/unwrapNativeCollateral.js +11 -14
- package/dist/cjs/onchain/validation/bundles/checkAccountQuotas.js +20 -0
- package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +59 -0
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +65 -0
- package/dist/cjs/onchain/validation/bundles/checkDraw.js +28 -0
- package/dist/cjs/onchain/validation/bundles/checkHealthFactors.js +27 -0
- package/dist/cjs/onchain/validation/bundles/checkLiquidationEligibility.js +33 -0
- package/dist/cjs/onchain/validation/bundles/checkLiquidationFunding.js +29 -0
- package/dist/cjs/onchain/validation/bundles/checkMarket.js +24 -0
- package/dist/cjs/onchain/validation/bundles/checkObtained.js +13 -0
- package/dist/cjs/onchain/validation/bundles/checkPoolFunding.js +22 -0
- package/dist/cjs/onchain/validation/bundles/checkPoolOperation.js +35 -0
- package/dist/cjs/onchain/validation/bundles/checkQuotasAsked.js +20 -0
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +33 -0
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +24 -0
- package/dist/cjs/onchain/validation/bundles/checkWallet.js +22 -0
- package/dist/cjs/onchain/validation/bundles/checkWalletAllowance.js +32 -0
- package/dist/cjs/onchain/validation/bundles/checkWalletBalance.js +41 -0
- package/dist/cjs/onchain/validation/bundles/index.js +35 -0
- package/dist/cjs/onchain/validation/checkLiquidation.js +22 -0
- package/dist/cjs/onchain/validation/checkOperation.js +62 -0
- package/dist/cjs/onchain/validation/checkSimulation.js +60 -0
- package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +25 -0
- package/dist/cjs/onchain/validation/checks/checkCollateralised.js +26 -0
- package/dist/cjs/onchain/validation/checks/checkCreditAccountFrozen.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkCreditManagerPaused.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +18 -0
- package/dist/cjs/onchain/validation/checks/checkEmergencyLiquidator.js +13 -0
- package/dist/cjs/onchain/validation/checks/checkForbiddenToken.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkLeverage.js +13 -0
- package/dist/cjs/onchain/validation/checks/checkLiquidatorEligible.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkMarketExpired.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +25 -0
- package/dist/cjs/onchain/validation/checks/checkPoolPaused.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkPoolSunset.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkQuotaCount.js +10 -0
- package/dist/cjs/onchain/validation/checks/checkQuotaLimit.js +18 -0
- package/dist/cjs/onchain/validation/checks/index.js +31 -0
- package/dist/cjs/onchain/validation/helpers/amount.js +12 -0
- package/dist/cjs/onchain/validation/helpers/health-factor-limits.js +25 -0
- package/dist/cjs/onchain/validation/helpers/index.js +11 -0
- package/dist/cjs/onchain/validation/{token.js → helpers/token.js} +4 -4
- package/dist/cjs/onchain/validation/index.js +85 -27
- package/dist/cjs/onchain/validation/raise.js +33 -0
- package/dist/cjs/sdk/index.js +6 -11
- package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +9 -0
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +19 -4
- package/dist/cjs/sdk/prepare/PrepareApi.js +40 -50
- package/dist/cjs/sdk/prepare/index.js +7 -11
- package/dist/cjs/sdk/prepare/types.js +0 -4
- package/dist/cjs/sdk/preview/PreviewNamespace.js +24 -13
- package/dist/esm/abi/rwa/iMidasAccessControl.js +22 -0
- package/dist/esm/abi/rwa/iMidasDegenNFT.js +91 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/assembleOperations.js +2 -2
- package/dist/esm/history/classifyMulticallOperations.js +2 -2
- package/dist/esm/history/index.js +6 -1
- package/dist/esm/history/parseCreditAccountTransaction.js +3 -3
- package/dist/esm/{preview → history}/trace/errors.js +1 -1
- package/dist/esm/{preview → history}/trace/extractAdapterCallTraces.js +1 -1
- package/dist/esm/{preview → history}/trace/extractTransfers.js +2 -2
- package/dist/esm/{preview → history}/trace/findFacadeCalls.js +1 -1
- package/dist/esm/model/errors/index.js +7 -0
- package/dist/esm/model/errors/liquidation-errors.js +29 -0
- package/dist/esm/model/errors/operation-errors.js +121 -0
- package/dist/esm/{onchain/market/oracle/errors.js → model/errors/oracle-errors.js} +1 -1
- package/dist/esm/model/errors/prepare-errors.js +97 -0
- package/dist/esm/model/errors/preview-errors.js +11 -0
- package/dist/esm/model/index.js +10 -3
- package/dist/esm/model/opportunities.schema.js +3 -1
- package/dist/esm/model/positions.js +1 -1
- package/dist/esm/model/result.js +1 -8
- package/dist/esm/model/rwa.js +48 -0
- package/dist/esm/model/rwa.schema.js +18 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/index.js +1 -2
- package/dist/esm/onchain/accounts/intents/guards.js +29 -52
- package/dist/esm/onchain/accounts/intents/index.js +39 -35
- package/dist/esm/onchain/accounts/intents/leverage-band.js +1 -1
- package/dist/esm/onchain/accounts/intents/math.js +18 -14
- package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -6
- package/dist/esm/onchain/accounts/intents/plan.js +51 -47
- package/dist/esm/onchain/accounts/intents/realize.js +26 -24
- package/dist/esm/onchain/accounts/intents/tail.js +14 -11
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +7 -0
- package/dist/esm/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +6 -6
- package/dist/esm/onchain/accounts/intents/tests/withdraw.fixtures.js +12 -12
- package/dist/esm/onchain/accounts/intents/view.js +1 -1
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +3 -3
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/index.js +0 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +64 -11
- package/dist/esm/onchain/market/MarketSuite.js +10 -4
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/index.js +1 -0
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditSuite.js +77 -15
- package/dist/esm/onchain/market/index.js +6 -6
- package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/esm/onchain/market/oracle/index.js +1 -2
- package/dist/esm/onchain/market/pool/PoolQuotaKeeperV310Contract.js +8 -0
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/RWARegistry.js +2 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +52 -0
- package/dist/esm/onchain/market/rwa/index.js +6 -5
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +55 -0
- package/dist/esm/onchain/market/rwa/midas/constants.js +2 -1
- package/dist/esm/onchain/market/rwa/midas/index.js +3 -2
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +20 -2
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +4 -4
- package/dist/esm/onchain/market/rwa/securitize/constants.js +2 -2
- package/dist/esm/onchain/market/rwa/securitize/index.js +4 -3
- package/dist/esm/onchain/market/rwa/securitize/types.js +1 -29
- package/dist/esm/onchain/market/rwa/types.js +1 -7
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/index.js +0 -1
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +11 -3
- package/dist/esm/onchain/pools/PoolService.js +10 -16
- package/dist/esm/onchain/preview/index.js +20 -0
- package/dist/esm/{preview → onchain/preview}/parse/classifyInnerOperations.js +2 -3
- package/dist/esm/{preview → onchain/preview}/parse/index.js +0 -1
- package/dist/esm/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.js +1 -1
- package/dist/esm/{preview → onchain/preview}/parse/parseOperationCalldata.js +10 -11
- package/dist/esm/{preview → onchain/preview}/parse/parsePoolOperationCalldata.js +3 -3
- package/dist/esm/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.js +8 -9
- package/dist/esm/{preview → onchain/preview}/parse/types.js +1 -1
- package/dist/esm/{preview → onchain/preview}/preview/CreditAccountState.js +3 -4
- package/dist/esm/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.js +10 -11
- package/dist/esm/{preview → onchain/preview}/preview/detectCloseOrRepay.js +2 -3
- package/dist/esm/{preview → onchain/preview}/preview/detectDelayedClaim.js +4 -5
- package/dist/esm/{preview → onchain/preview}/preview/detectDelayedOperation.js +5 -6
- package/dist/esm/{preview → onchain/preview}/preview/estimateClaimableAt.js +1 -1
- package/dist/esm/{preview → onchain/preview}/preview/index.js +3 -4
- package/dist/esm/{preview → onchain/preview}/preview/previewAdjustStrategyPosition.js +17 -21
- package/dist/esm/{preview → onchain/preview}/preview/previewExitOrRepayStrategyPosition.js +20 -26
- package/dist/esm/{preview → onchain/preview}/preview/previewOpenStrategyPosition.js +25 -15
- package/dist/esm/{preview → onchain/preview}/preview/previewOperation.js +54 -35
- package/dist/esm/{preview/simulate/simulatePoolOperation.js → onchain/preview/preview/previewPoolPositionOperation.js} +46 -30
- package/dist/esm/onchain/preview/preview/replayInnerOperations.js +107 -0
- package/dist/esm/onchain/preview/preview/replayMulticall.js +21 -0
- package/dist/esm/{preview → onchain/preview}/preview/unwrapNativeCollateral.js +11 -14
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/bundles/checkAccountQuotas.js +19 -0
- package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +58 -0
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +64 -0
- package/dist/esm/onchain/validation/bundles/checkDraw.js +27 -0
- package/dist/esm/onchain/validation/bundles/checkHealthFactors.js +26 -0
- package/dist/esm/onchain/validation/bundles/checkLiquidationEligibility.js +32 -0
- package/dist/esm/onchain/validation/bundles/checkLiquidationFunding.js +28 -0
- package/dist/esm/onchain/validation/bundles/checkMarket.js +23 -0
- package/dist/esm/onchain/validation/bundles/checkObtained.js +12 -0
- package/dist/esm/onchain/validation/bundles/checkPoolFunding.js +21 -0
- package/dist/esm/onchain/validation/bundles/checkPoolOperation.js +34 -0
- package/dist/esm/onchain/validation/bundles/checkQuotasAsked.js +19 -0
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +32 -0
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +23 -0
- package/dist/esm/onchain/validation/bundles/checkWallet.js +21 -0
- package/dist/esm/onchain/validation/bundles/checkWalletAllowance.js +31 -0
- package/dist/esm/onchain/validation/bundles/checkWalletBalance.js +40 -0
- package/dist/esm/onchain/validation/bundles/index.js +18 -0
- package/dist/esm/onchain/validation/checkLiquidation.js +21 -0
- package/dist/esm/onchain/validation/checkOperation.js +61 -0
- package/dist/esm/onchain/validation/checkSimulation.js +59 -0
- package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +24 -0
- package/dist/esm/onchain/validation/checks/checkCollateralised.js +25 -0
- package/dist/esm/onchain/validation/checks/checkCreditAccountFrozen.js +9 -0
- package/dist/esm/onchain/validation/checks/checkCreditManagerPaused.js +9 -0
- package/dist/esm/onchain/validation/checks/checkDebtLimits.js +17 -0
- package/dist/esm/onchain/validation/checks/checkEmergencyLiquidator.js +12 -0
- package/dist/esm/onchain/validation/checks/checkForbiddenToken.js +9 -0
- package/dist/esm/onchain/validation/checks/checkLeverage.js +12 -0
- package/dist/esm/onchain/validation/checks/checkLiquidatorEligible.js +9 -0
- package/dist/esm/onchain/validation/checks/checkMarketExpired.js +9 -0
- package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +24 -0
- package/dist/esm/onchain/validation/checks/checkPoolPaused.js +9 -0
- package/dist/esm/onchain/validation/checks/checkPoolSunset.js +9 -0
- package/dist/esm/onchain/validation/checks/checkQuotaCount.js +9 -0
- package/dist/esm/onchain/validation/checks/checkQuotaLimit.js +17 -0
- package/dist/esm/onchain/validation/checks/index.js +16 -0
- package/dist/esm/onchain/validation/helpers/amount.js +11 -0
- package/dist/esm/onchain/validation/helpers/health-factor-limits.js +21 -0
- package/dist/esm/onchain/validation/helpers/index.js +4 -0
- package/dist/esm/onchain/validation/{token.js → helpers/token.js} +3 -3
- package/dist/esm/onchain/validation/index.js +43 -4
- package/dist/esm/onchain/validation/raise.js +31 -0
- package/dist/esm/sdk/index.js +2 -3
- package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +9 -0
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +19 -4
- package/dist/esm/sdk/prepare/PrepareApi.js +25 -35
- package/dist/esm/sdk/prepare/index.js +3 -3
- package/dist/esm/sdk/prepare/types.js +1 -2
- package/dist/esm/sdk/preview/PreviewNamespace.js +24 -13
- package/dist/types/abi/rwa/iMidasAccessControl.d.ts +22 -0
- package/dist/types/abi/rwa/iMidasDegenNFT.d.ts +82 -0
- package/dist/types/history/assembleOperations.d.ts +4 -5
- package/dist/types/history/classifyMulticallOperations.d.ts +3 -4
- package/dist/types/history/index.d.ts +8 -2
- package/dist/types/history/mapOperations.d.ts +1 -1
- package/dist/types/{preview → history}/trace/errors.d.ts +1 -1
- package/dist/types/{preview → history}/trace/extractAdapterCallTraces.d.ts +1 -1
- package/dist/types/{preview → history}/trace/extractTransfers.d.ts +2 -3
- package/dist/types/{preview → history}/trace/findFacadeCalls.d.ts +1 -1
- package/dist/types/{preview → history}/trace/types.d.ts +1 -1
- package/dist/types/history/types.d.ts +2 -3
- package/dist/types/model/errors/base.d.ts +28 -0
- package/dist/types/model/errors/index.d.ts +7 -0
- package/dist/types/model/errors/liquidation-errors.d.ts +45 -0
- package/dist/types/model/errors/operation-errors.d.ts +216 -0
- package/dist/types/{onchain/market/oracle/errors.d.ts → model/errors/oracle-errors.d.ts} +3 -5
- package/dist/types/model/errors/prepare-errors.d.ts +131 -0
- package/dist/types/model/errors/preview-errors.d.ts +72 -0
- package/dist/types/model/index.d.ts +12 -4
- package/dist/types/model/opportunities.d.ts +12 -2
- package/dist/types/model/opportunities.schema.d.ts +30 -0
- package/dist/types/model/positions.d.ts +2 -2
- package/dist/types/model/previews.d.ts +52 -113
- package/dist/types/model/result.d.ts +4 -8
- package/dist/types/model/rwa.d.ts +167 -0
- package/dist/types/model/rwa.schema.d.ts +29 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +2 -1
- package/dist/types/offchain/opportunities/types.d.ts +4 -1
- package/dist/types/onchain/accounts/CreditAccountsServiceV310.d.ts +3 -1
- package/dist/types/onchain/accounts/index.d.ts +2 -4
- package/dist/types/onchain/accounts/intents/guards.d.ts +8 -18
- package/dist/types/onchain/accounts/intents/index.d.ts +20 -19
- package/dist/types/onchain/accounts/intents/leverage-band.d.ts +1 -1
- package/dist/types/onchain/accounts/intents/math.d.ts +6 -6
- package/dist/types/onchain/accounts/intents/operations.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/plan.d.ts +9 -9
- package/dist/types/onchain/accounts/intents/tail.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/testing/expect.d.ts +3 -3
- package/dist/types/onchain/accounts/intents/tests/finish-withdraw.fixtures.d.ts +6 -6
- package/dist/types/onchain/accounts/intents/tests/withdraw.fixtures.d.ts +12 -12
- package/dist/types/onchain/accounts/intents/types.d.ts +32 -30
- package/dist/types/onchain/accounts/types.d.ts +2 -1
- package/dist/types/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +1 -1
- package/dist/types/onchain/accounts/withdrawal-compressor/index.d.ts +1 -2
- package/dist/types/onchain/accounts/withdrawal-compressor/types.d.ts +1 -1
- package/dist/types/onchain/index.d.ts +73 -16
- package/dist/types/onchain/market/MarketSuite.d.ts +5 -1
- package/dist/types/onchain/market/adapters/index.d.ts +2 -1
- package/dist/types/onchain/market/adapters/transfers.d.ts +0 -7
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +30 -8
- package/dist/types/onchain/market/credit/index.d.ts +2 -2
- package/dist/types/onchain/market/credit/types.d.ts +11 -1
- package/dist/types/onchain/market/index.d.ts +11 -10
- package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +1 -1
- package/dist/types/onchain/market/oracle/index.d.ts +1 -2
- package/dist/types/onchain/market/oracle/types.d.ts +1 -1
- package/dist/types/onchain/market/pool/PoolQuotaKeeperV310Contract.d.ts +5 -0
- package/dist/types/onchain/market/rwa/RWARegistry.d.ts +1 -1
- package/dist/types/onchain/market/rwa/createDegenNFT.d.ts +12 -0
- package/dist/types/onchain/market/rwa/index.d.ts +10 -8
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +98 -0
- package/dist/types/onchain/market/rwa/midas/constants.d.ts +2 -1
- package/dist/types/onchain/market/rwa/midas/index.d.ts +3 -2
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +8 -2
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +4 -3
- package/dist/types/onchain/market/rwa/securitize/constants.d.ts +2 -2
- package/dist/types/onchain/market/rwa/securitize/index.d.ts +5 -4
- package/dist/types/onchain/market/rwa/securitize/types.d.ts +4 -110
- package/dist/types/onchain/market/rwa/types.d.ts +24 -32
- package/dist/types/onchain/market/zapper/ZapperContract.d.ts +1 -1
- package/dist/types/onchain/market/zapper/index.d.ts +1 -2
- package/dist/types/onchain/market/zapper/types.d.ts +1 -1
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +2 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/types.d.ts +3 -2
- package/dist/types/onchain/pools/types.d.ts +2 -2
- package/dist/types/onchain/preview/index.d.ts +24 -0
- package/dist/types/{preview → onchain/preview}/parse/classifyInnerOperations.d.ts +4 -4
- package/dist/types/{preview → onchain/preview}/parse/index.d.ts +2 -4
- package/dist/types/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.d.ts +4 -4
- package/dist/types/onchain/preview/parse/parseOperationCalldata.d.ts +18 -0
- package/dist/types/{preview → onchain/preview}/parse/parsePoolOperationCalldata.d.ts +7 -7
- package/dist/types/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.d.ts +4 -4
- package/dist/types/{preview → onchain/preview}/parse/types-adapters.d.ts +5 -16
- package/dist/types/{preview → onchain/preview}/parse/types-facades.d.ts +3 -3
- package/dist/types/{preview → onchain/preview}/parse/types-pools.d.ts +1 -1
- package/dist/types/{preview → onchain/preview}/parse/types-rwa.d.ts +3 -3
- package/dist/types/{preview → onchain/preview}/parse/types.d.ts +3 -3
- package/dist/types/{preview → onchain/preview}/preview/CreditAccountState.d.ts +5 -5
- package/dist/types/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.d.ts +5 -5
- package/dist/types/{preview → onchain/preview}/preview/detectCloseOrRepay.d.ts +1 -1
- package/dist/types/{preview → onchain/preview}/preview/detectDelayedClaim.d.ts +8 -8
- package/dist/types/{preview → onchain/preview}/preview/detectDelayedOperation.d.ts +9 -9
- package/dist/types/{preview → onchain/preview}/preview/estimateClaimableAt.d.ts +6 -6
- package/dist/types/{preview → onchain/preview}/preview/index.d.ts +3 -4
- package/dist/types/onchain/preview/preview/previewAdjustStrategyPosition.d.ts +20 -0
- package/dist/types/onchain/preview/preview/previewExitOrRepayStrategyPosition.d.ts +21 -0
- package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +14 -0
- package/dist/types/onchain/preview/preview/previewOperation.d.ts +32 -0
- package/dist/types/onchain/preview/preview/previewPoolPositionOperation.d.ts +13 -0
- package/dist/types/{preview → onchain/preview}/preview/replayInnerOperations.d.ts +11 -11
- package/dist/types/{preview → onchain/preview}/preview/replayMulticall.d.ts +10 -10
- package/dist/types/{preview → onchain/preview}/preview/unwrapNativeCollateral.d.ts +10 -20
- package/dist/types/onchain/validation/bundles/checkAccountQuotas.d.ts +16 -0
- package/dist/types/onchain/validation/bundles/checkCollateralFunding.d.ts +22 -0
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +31 -0
- package/dist/types/onchain/validation/bundles/checkDraw.d.ts +20 -0
- package/dist/types/onchain/validation/bundles/checkHealthFactors.d.ts +39 -0
- package/dist/types/onchain/validation/bundles/checkLiquidationEligibility.d.ts +20 -0
- package/dist/types/onchain/validation/bundles/checkLiquidationFunding.d.ts +18 -0
- package/dist/types/onchain/validation/bundles/checkMarket.d.ts +15 -0
- package/dist/types/onchain/validation/bundles/checkObtained.d.ts +9 -0
- package/dist/types/onchain/validation/bundles/checkPoolFunding.d.ts +19 -0
- package/dist/types/onchain/validation/bundles/checkPoolOperation.d.ts +31 -0
- package/dist/types/onchain/validation/bundles/checkQuotasAsked.d.ts +10 -0
- package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +21 -0
- package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +19 -0
- package/dist/types/onchain/validation/bundles/checkWallet.d.ts +23 -0
- package/dist/types/onchain/validation/bundles/checkWalletAllowance.d.ts +18 -0
- package/dist/types/onchain/validation/bundles/checkWalletBalance.d.ts +17 -0
- package/dist/types/onchain/validation/bundles/index.d.ts +18 -0
- package/dist/types/onchain/validation/checkLiquidation.d.ts +23 -0
- package/dist/types/onchain/validation/checkOperation.d.ts +32 -0
- package/dist/types/onchain/validation/checkSimulation.d.ts +56 -0
- package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +21 -0
- package/dist/types/onchain/validation/checks/checkCollateralised.d.ts +25 -0
- package/dist/types/onchain/validation/checks/checkCreditAccountFrozen.d.ts +12 -0
- package/dist/types/onchain/validation/checks/checkCreditManagerPaused.d.ts +12 -0
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +21 -0
- package/dist/types/onchain/validation/checks/checkEmergencyLiquidator.d.ts +17 -0
- package/dist/types/onchain/validation/checks/checkForbiddenToken.d.ts +12 -0
- package/dist/types/onchain/validation/checks/checkLeverage.d.ts +12 -0
- package/dist/types/onchain/validation/checks/checkLiquidatorEligible.d.ts +13 -0
- package/dist/types/onchain/validation/checks/checkMarketExpired.d.ts +14 -0
- package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +20 -0
- package/dist/types/onchain/validation/checks/checkPoolPaused.d.ts +12 -0
- package/dist/types/onchain/validation/checks/checkPoolSunset.d.ts +13 -0
- package/dist/types/onchain/validation/checks/checkQuotaCount.d.ts +11 -0
- package/dist/types/onchain/validation/checks/checkQuotaLimit.d.ts +18 -0
- package/dist/types/onchain/validation/checks/index.d.ts +16 -0
- package/dist/types/onchain/validation/helpers/amount.d.ts +7 -0
- package/dist/types/onchain/validation/helpers/health-factor-limits.d.ts +21 -0
- package/dist/types/onchain/validation/helpers/index.d.ts +4 -0
- package/dist/types/onchain/validation/{token.d.ts → helpers/token.d.ts} +4 -4
- package/dist/types/onchain/validation/index.d.ts +43 -4
- package/dist/types/onchain/validation/raise.d.ts +33 -0
- package/dist/types/sdk/execute/types.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +5 -6
- package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +5 -0
- package/dist/types/sdk/liquidations/types.d.ts +8 -0
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +2 -1
- package/dist/types/sdk/opportunities/types.d.ts +8 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +5 -4
- package/dist/types/sdk/prepare/index.d.ts +5 -5
- package/dist/types/sdk/prepare/types.d.ts +41 -22
- package/dist/types/sdk/preview/PreviewNamespace.d.ts +13 -3
- package/dist/types/sdk/preview/index.d.ts +2 -2
- package/dist/types/sdk/preview/types.d.ts +30 -7
- package/package.json +1 -6
- package/dist/cjs/onchain/accounts/withdrawal-compressor/errors.js +0 -1
- package/dist/cjs/onchain/market/zapper/errors.js +0 -1
- package/dist/cjs/onchain/validation/checks.js +0 -258
- package/dist/cjs/onchain/validation/refusal.js +0 -39
- package/dist/cjs/preview/index.js +0 -86
- package/dist/cjs/preview/package.json +0 -1
- package/dist/cjs/preview/parse/errors.js +0 -1
- package/dist/cjs/preview/parse/index.js +0 -15
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +0 -38
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +0 -52
- package/dist/cjs/preview/prerequisites/Prerequisite.js +0 -52
- package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +0 -53
- package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +0 -63
- package/dist/cjs/preview/prerequisites/buildPartialLiquidationPrerequisites.js +0 -19
- package/dist/cjs/preview/prerequisites/buildPoolPrerequisites.js +0 -76
- package/dist/cjs/preview/prerequisites/buildRWAPrerequisites.js +0 -39
- package/dist/cjs/preview/prerequisites/checkPrerequisites.js +0 -74
- package/dist/cjs/preview/prerequisites/helpers.js +0 -23
- package/dist/cjs/preview/prerequisites/index.js +0 -12
- package/dist/cjs/preview/preview/errors.js +0 -85
- package/dist/cjs/preview/preview/index.js +0 -33
- package/dist/cjs/preview/preview/previewOpenStrategyPosition.js +0 -50
- package/dist/cjs/preview/preview/previewOperation.js +0 -100
- package/dist/cjs/preview/preview/previewPoolPositionOperation.js +0 -49
- package/dist/cjs/preview/preview/replayInnerOperations.js +0 -109
- package/dist/cjs/preview/preview/replayMulticall.js +0 -19
- package/dist/cjs/preview/simulate/errors.js +0 -73
- package/dist/cjs/preview/simulate/index.js +0 -11
- package/dist/cjs/preview/simulate/simulateFacadeOperation.js +0 -15
- package/dist/cjs/preview/simulate/simulateOperation.js +0 -29
- package/dist/cjs/preview/simulate/simulateRWAOperation.js +0 -15
- package/dist/cjs/preview/simulate/types.js +0 -1
- package/dist/cjs/preview/trace/index.js +0 -14
- package/dist/cjs/preview/trace/types.js +0 -1
- package/dist/cjs/preview/types.js +0 -1
- package/dist/cjs/preview/validate/checkOperation.js +0 -187
- package/dist/cjs/preview/validate/checkSimulation.js +0 -39
- package/dist/cjs/preview/validate/index.js +0 -8
- package/dist/cjs/sdk/prepare/errors.js +0 -114
- package/dist/esm/onchain/accounts/withdrawal-compressor/errors.js +0 -1
- package/dist/esm/onchain/market/zapper/errors.js +0 -1
- package/dist/esm/onchain/validation/checks.js +0 -238
- package/dist/esm/onchain/validation/refusal.js +0 -36
- package/dist/esm/preview/index.js +0 -38
- package/dist/esm/preview/package.json +0 -1
- package/dist/esm/preview/parse/errors.js +0 -1
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +0 -37
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +0 -51
- package/dist/esm/preview/prerequisites/Prerequisite.js +0 -51
- package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +0 -52
- package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +0 -62
- package/dist/esm/preview/prerequisites/buildPartialLiquidationPrerequisites.js +0 -18
- package/dist/esm/preview/prerequisites/buildPoolPrerequisites.js +0 -75
- package/dist/esm/preview/prerequisites/buildRWAPrerequisites.js +0 -38
- package/dist/esm/preview/prerequisites/checkPrerequisites.js +0 -73
- package/dist/esm/preview/prerequisites/helpers.js +0 -22
- package/dist/esm/preview/prerequisites/index.js +0 -7
- package/dist/esm/preview/preview/errors.js +0 -79
- package/dist/esm/preview/preview/previewPoolPositionOperation.js +0 -48
- package/dist/esm/preview/preview/replayInnerOperations.js +0 -107
- package/dist/esm/preview/preview/replayMulticall.js +0 -18
- package/dist/esm/preview/simulate/errors.js +0 -71
- package/dist/esm/preview/simulate/index.js +0 -6
- package/dist/esm/preview/simulate/simulateFacadeOperation.js +0 -14
- package/dist/esm/preview/simulate/simulateOperation.js +0 -28
- package/dist/esm/preview/simulate/simulateRWAOperation.js +0 -14
- package/dist/esm/preview/simulate/types.js +0 -1
- package/dist/esm/preview/trace/types.js +0 -1
- package/dist/esm/preview/types.js +0 -1
- package/dist/esm/preview/validate/checkOperation.js +0 -183
- package/dist/esm/preview/validate/checkSimulation.js +0 -38
- package/dist/esm/preview/validate/index.js +0 -3
- package/dist/esm/sdk/prepare/errors.js +0 -108
- package/dist/types/model/errors.d.ts +0 -46
- package/dist/types/onchain/accounts/withdrawal-compressor/errors.d.ts +0 -20
- package/dist/types/onchain/market/zapper/errors.d.ts +0 -18
- package/dist/types/onchain/validation/checks.d.ts +0 -164
- package/dist/types/onchain/validation/refusal.d.ts +0 -242
- package/dist/types/preview/index.d.ts +0 -47
- package/dist/types/preview/parse/errors.d.ts +0 -29
- package/dist/types/preview/parse/parseOperationCalldata.d.ts +0 -18
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +0 -26
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +0 -29
- package/dist/types/preview/prerequisites/Prerequisite.d.ts +0 -26
- package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +0 -55
- package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +0 -20
- package/dist/types/preview/prerequisites/buildPartialLiquidationPrerequisites.d.ts +0 -12
- package/dist/types/preview/prerequisites/buildPoolPrerequisites.d.ts +0 -12
- package/dist/types/preview/prerequisites/buildRWAPrerequisites.d.ts +0 -26
- package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +0 -28
- package/dist/types/preview/prerequisites/helpers.d.ts +0 -10
- package/dist/types/preview/prerequisites/index.d.ts +0 -7
- package/dist/types/preview/prerequisites/types.d.ts +0 -53
- package/dist/types/preview/preview/errors.d.ts +0 -44
- package/dist/types/preview/preview/previewAdjustStrategyPosition.d.ts +0 -19
- package/dist/types/preview/preview/previewExitOrRepayStrategyPosition.d.ts +0 -18
- package/dist/types/preview/preview/previewOpenStrategyPosition.d.ts +0 -12
- package/dist/types/preview/preview/previewOperation.d.ts +0 -32
- package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +0 -13
- package/dist/types/preview/simulate/errors.d.ts +0 -52
- package/dist/types/preview/simulate/index.d.ts +0 -7
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +0 -16
- package/dist/types/preview/simulate/simulateOperation.d.ts +0 -12
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +0 -42
- package/dist/types/preview/simulate/simulateRWAOperation.d.ts +0 -16
- package/dist/types/preview/simulate/types.d.ts +0 -48
- package/dist/types/preview/types.d.ts +0 -65
- package/dist/types/preview/validate/checkOperation.d.ts +0 -71
- package/dist/types/preview/validate/checkSimulation.d.ts +0 -32
- package/dist/types/preview/validate/index.d.ts +0 -3
- package/dist/types/sdk/prepare/errors.d.ts +0 -343
- /package/dist/cjs/{preview/prerequisites → history/trace}/types.js +0 -0
- /package/dist/cjs/model/{errors.js → errors/base.js} +0 -0
- /package/dist/cjs/{preview → onchain/preview}/parse/types-adapters.js +0 -0
- /package/dist/cjs/{preview → onchain/preview}/parse/types-facades.js +0 -0
- /package/dist/cjs/{preview → onchain/preview}/parse/types-pools.js +0 -0
- /package/dist/cjs/{preview → onchain/preview}/parse/types-rwa.js +0 -0
- /package/dist/esm/{preview → history}/trace/index.js +0 -0
- /package/dist/esm/{preview/prerequisites → history/trace}/types.js +0 -0
- /package/dist/esm/model/{errors.js → errors/base.js} +0 -0
- /package/dist/esm/{preview → onchain/preview}/parse/types-adapters.js +0 -0
- /package/dist/esm/{preview → onchain/preview}/parse/types-facades.js +0 -0
- /package/dist/esm/{preview → onchain/preview}/parse/types-pools.js +0 -0
- /package/dist/esm/{preview → onchain/preview}/parse/types-rwa.js +0 -0
- /package/dist/types/{preview → history}/trace/index.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, EmptyOpenTakesNothingError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, emptyOpenTakesNothing, noStrategyTargetCollateral, unexpectedFailure } from "../../model/errors/prepare-errors.js";
|
|
2
|
+
import "../../model/index.js";
|
|
2
3
|
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
3
|
-
import { OperationState, PathLossRate, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
4
|
-
import { AccountFlowError,
|
|
5
|
-
import { AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
4
|
+
import { OperationState, PathLossRate, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
5
|
+
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
6
6
|
import { ChainOf, PrepareApi } from "./PrepareApi.js";
|
|
7
|
-
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams,
|
|
7
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, type EmptyOpenTakesNothingError, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareApi, PrepareOptions, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, emptyOpenTakesNothing, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Bps, Timestamp, TokenAmount } from "../../model/primitives.js";
|
|
2
2
|
import { Curator } from "../../model/curators.js";
|
|
3
|
+
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError } from "../../model/errors/operation-errors.js";
|
|
4
|
+
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, EmptyOpenTakesNothingError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
|
|
3
5
|
import { PoolOpportunityKey, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
4
6
|
import { PositionCollateral, StrategyPosition, StrategyPositionKey } from "../../model/positions.js";
|
|
5
7
|
import { SDKReturn } from "../../model/result.js";
|
|
@@ -8,15 +10,32 @@ import "../../model/index.js";
|
|
|
8
10
|
import { Asset } from "../../onchain/base/types.js";
|
|
9
11
|
import { MultiCall } from "../../onchain/types/transactions.js";
|
|
10
12
|
import { PoolSimulation } from "../../onchain/pools/types.js";
|
|
11
|
-
import { BorrowLimitBinding, IntentPreviewError, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, raise, refuse } from "../../onchain/validation/refusal.js";
|
|
12
13
|
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
13
14
|
import { AccountCalculatorOperation } from "../../onchain/accounts/intents/operations.js";
|
|
14
|
-
import { ClaimRemainder, DelayedStart, OperationState, PathLossRate, ResumableIntent,
|
|
15
|
+
import { ClaimRemainder, DelayedStart, OperationState, PathLossRate, ResumableIntent, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
15
16
|
import { OpenStrategyState } from "../../onchain/accounts/intents/open-strategy.js";
|
|
16
17
|
import "../../onchain/index.js";
|
|
17
|
-
import { AccountFlowError, CreditAccountNotEmptyError, CreditAccountNotFoundError, DebtOutOfRangeError, EmptyOpenTakesNothingError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, OpenFlowError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithRouteRefusals, WithdrawalInProgressError } from "./errors.js";
|
|
18
18
|
import { Address } from "viem";
|
|
19
19
|
//#region src/sdk/prepare/types.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* What any operation on an existing account can answer with: the engine's
|
|
22
|
+
* shared guards, the missing account, and a wrapped crash.
|
|
23
|
+
**/
|
|
24
|
+
type AccountFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | CreditAccountNotFoundError | UnexpectedFailureError;
|
|
25
|
+
/** Same guards for the account-less open flow. */
|
|
26
|
+
type OpenFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | UnexpectedFailureError;
|
|
27
|
+
/**
|
|
28
|
+
* What every error of a two-route request carries on top of its own code,
|
|
29
|
+
* see {@link StrategyRoutesResult}.
|
|
30
|
+
*
|
|
31
|
+
* `errors` says why each route is missing, which is the answer a form needs
|
|
32
|
+
* even when neither exists: the error itself is the instant route's — the one
|
|
33
|
+
* a caller can usually act on — or the delayed route's when the instant one
|
|
34
|
+
* did not get far enough to have a reason of its own.
|
|
35
|
+
**/
|
|
36
|
+
interface WithRouteErrors {
|
|
37
|
+
errors: RouteErrors;
|
|
38
|
+
}
|
|
20
39
|
/**
|
|
21
40
|
* Where a pool operation leaves the wallet: the two sides of the trade as
|
|
22
41
|
* `sdk.pools` prices them, plus what a screen needs beside them and the raw
|
|
@@ -104,7 +123,7 @@ interface StrategyResult {
|
|
|
104
123
|
**/
|
|
105
124
|
interface FinalizeResult extends StrategyResult {
|
|
106
125
|
/**
|
|
107
|
-
* What the claim did not bring, when the venue
|
|
126
|
+
* What the claim did not bring, when the venue settled part of the matured
|
|
108
127
|
* withdrawal and left the rest of it queued — only a legacy Mellow multivault
|
|
109
128
|
* does. `undefined` everywhere else, which is the normal case: one request,
|
|
110
129
|
* one claim, one tail.
|
|
@@ -164,27 +183,27 @@ interface DelayedStrategyResult {
|
|
|
164
183
|
* Whether the account can sell that asset on the router, redeem it through its
|
|
165
184
|
* issuer, or both, is not something the caller can know up front, so both routes
|
|
166
185
|
* are quoted from one request. A route the account cannot take is `undefined`
|
|
167
|
-
* with its
|
|
186
|
+
* with its error in `errors`, which is what lets a form offer exactly the
|
|
168
187
|
* routes that exist; a failure means neither does, and the error still carries
|
|
169
|
-
* `
|
|
188
|
+
* `errors`, see {@link WithRouteErrors}.
|
|
170
189
|
**/
|
|
171
190
|
interface StrategyRoutesResult {
|
|
172
191
|
/**
|
|
173
192
|
* The router route: one transaction, settled on the spot. `undefined`
|
|
174
|
-
* when the asset cannot be sold, see `
|
|
193
|
+
* when the asset cannot be sold, see `errors.instant`.
|
|
175
194
|
**/
|
|
176
195
|
instant: StrategyResult | undefined;
|
|
177
196
|
/**
|
|
178
197
|
* The request half of the redemption route, which
|
|
179
198
|
* {@link IOpportunitiesPrepare.finalize} completes once it matures.
|
|
180
199
|
* `undefined` when the route does not exist — no redemption venue for the
|
|
181
|
-
* asset, or a request that settles at once anyway — see `
|
|
200
|
+
* asset, or a request that settles at once anyway — see `errors.delayed`.
|
|
182
201
|
**/
|
|
183
202
|
delayed: DelayedStrategyResult | undefined;
|
|
184
203
|
/**
|
|
185
|
-
* Why a missing route
|
|
204
|
+
* Why a missing route is missing, see {@link RouteErrors}.
|
|
186
205
|
**/
|
|
187
|
-
|
|
206
|
+
errors: RouteErrors;
|
|
188
207
|
/** Block of the chain state this result was computed from. */
|
|
189
208
|
blockNumber: number;
|
|
190
209
|
/** Unix seconds of {@link blockNumber}. */
|
|
@@ -261,7 +280,7 @@ interface WithdrawStrategyParams extends PrepareOptions {
|
|
|
261
280
|
* see {@link IOpportunitiesPrepare.withdrawStrategy}.
|
|
262
281
|
**/
|
|
263
282
|
amount: bigint;
|
|
264
|
-
/**
|
|
283
|
+
/** Token recipient. */
|
|
265
284
|
to: Address;
|
|
266
285
|
/**
|
|
267
286
|
* Token the wallet receives. Defaults to the market underlying, force-unwrapped
|
|
@@ -374,7 +393,7 @@ interface LpParams {
|
|
|
374
393
|
tokenIn?: Address;
|
|
375
394
|
/**
|
|
376
395
|
* Token the user receives. Defaults to the only route available for `tokenIn`;
|
|
377
|
-
* required when the pool offers several, otherwise the preparation
|
|
396
|
+
* required when the pool offers several, otherwise the preparation answers
|
|
378
397
|
* with `unsupportedTokenPair`.
|
|
379
398
|
**/
|
|
380
399
|
tokenOut?: Address;
|
|
@@ -418,11 +437,11 @@ interface FinalizeParams extends PrepareOptions {
|
|
|
418
437
|
* pathfinder for real swap paths. Nothing is executed and nothing is signed —
|
|
419
438
|
* the result is the numbers plus the calldata that would produce them.
|
|
420
439
|
*
|
|
421
|
-
* Not to be confused with `src/preview`, which goes the other way: it takes
|
|
440
|
+
* Not to be confused with `src/onchain/preview`, which goes the other way: it takes
|
|
422
441
|
* calldata that already exists and reports what it would do.
|
|
423
442
|
*
|
|
424
443
|
* Every refusable method answers `SDKReturn` and names, in its own signature,
|
|
425
|
-
* exactly the errors its flow can
|
|
444
|
+
* exactly the errors its flow can answer with — the union is the list of
|
|
426
445
|
* everything a caller has to handle, checked by the compiler. None of them
|
|
427
446
|
* throws: a chain that cannot be reached or a crash on the way arrives as
|
|
428
447
|
* `unexpectedFailure` with the cause attached.
|
|
@@ -494,7 +513,7 @@ interface IOpportunitiesPrepare {
|
|
|
494
513
|
* @see withdrawCollateral to move an asset out without touching debt, which
|
|
495
514
|
* raises leverage instead.
|
|
496
515
|
**/
|
|
497
|
-
withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<SDKReturn<StrategyRoutesResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError) &
|
|
516
|
+
withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<SDKReturn<StrategyRoutesResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError) & WithRouteErrors>>;
|
|
498
517
|
/**
|
|
499
518
|
* How much {@link withdrawStrategy} can take out, both ends of it, in
|
|
500
519
|
* underlying units: `partial` is the largest withdrawal that keeps leverage
|
|
@@ -548,9 +567,9 @@ interface IOpportunitiesPrepare {
|
|
|
548
567
|
* Answers with both routes, like {@link withdrawStrategy}, since deleveraging
|
|
549
568
|
* sells the position token and may only be able to redeem it. Raising leverage
|
|
550
569
|
* buys instead, so there the delayed route is always absent with
|
|
551
|
-
* `
|
|
570
|
+
* `errors.delayed` set to `noDelayedRoute`.
|
|
552
571
|
**/
|
|
553
|
-
adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<SDKReturn<StrategyRoutesResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError | InsufficientPoolLiquidityError | LeverageOutOfRangeError) &
|
|
572
|
+
adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<SDKReturn<StrategyRoutesResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError | InsufficientPoolLiquidityError | LeverageOutOfRangeError) & WithRouteErrors>>;
|
|
554
573
|
/**
|
|
555
574
|
* Putting the position token onto the account at fixed debt, which lowers
|
|
556
575
|
* leverage and raises the health factor.
|
|
@@ -571,7 +590,7 @@ interface IOpportunitiesPrepare {
|
|
|
571
590
|
* `maxLeverage` on the opportunity is the ceiling the liquidation threshold
|
|
572
591
|
* allows, and it is the same number whatever the deposit. What a given
|
|
573
592
|
* deposit reaches is decided by the debt it implies —
|
|
574
|
-
* `debt = netValue x (leverage - 1)` — and by the
|
|
593
|
+
* `debt = netValue x (leverage - 1)` — and by the `debtLimits` the market puts that
|
|
575
594
|
* debt in.
|
|
576
595
|
*
|
|
577
596
|
* Synchronous, unlike the ceilings above it: those read the account from the
|
|
@@ -580,7 +599,7 @@ interface IOpportunitiesPrepare {
|
|
|
580
599
|
* opening takes the tokens being deposited, adjusting the position's own net
|
|
581
600
|
* value in the underlying.
|
|
582
601
|
*
|
|
583
|
-
* Nothing at all when the market has no
|
|
602
|
+
* Nothing at all when the market has no range to offer: a deposit too small
|
|
584
603
|
* to carry `minDebt` at any leverage the threshold allows, or a manager with
|
|
585
604
|
* no borrowing room left. Not the same answer as "every leverage works", and
|
|
586
605
|
* a caller must not mark a range for it.
|
|
@@ -612,7 +631,7 @@ interface IOpportunitiesPrepare {
|
|
|
612
631
|
* withdraw-collateral form should offer.
|
|
613
632
|
*
|
|
614
633
|
* `targetHF` names the health factor to leave the account at, in basis
|
|
615
|
-
* points; omitted, the SDK holds it to the
|
|
634
|
+
* points; omitted, the SDK holds it to the threshold a form would.
|
|
616
635
|
*
|
|
617
636
|
* A bare read: it answers its number, and throws on an account or a chain
|
|
618
637
|
* the SDK does not hold.
|
|
@@ -636,11 +655,11 @@ interface IOpportunitiesPrepare {
|
|
|
636
655
|
* Reports `noRecordedIntent` when the claim names no operation to resume.
|
|
637
656
|
*
|
|
638
657
|
* A claim can settle only part of what was queued — a legacy Mellow
|
|
639
|
-
* multivault
|
|
658
|
+
* multivault hands over what it holds liquid and re-queues the rest — and then
|
|
640
659
|
* the result serves that share and `remainder` says what is left, see
|
|
641
660
|
* {@link FinalizeResult.remainder}.
|
|
642
661
|
**/
|
|
643
662
|
finalize(position: PositionInput, params: FinalizeParams): Promise<SDKReturn<FinalizeResult, AccountFlowError | NoRecordedIntentError | NoDelayedRouteError | WithdrawalInProgressError | UnsupportedTokenPairError>>;
|
|
644
663
|
}
|
|
645
664
|
//#endregion
|
|
646
|
-
export { AddCollateralParams, AdjustLeverageParams,
|
|
665
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, type EmptyOpenTakesNothingError, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError };
|
|
@@ -2,10 +2,12 @@ import { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from
|
|
|
2
2
|
import { SDKReturn } from "../../model/result.js";
|
|
3
3
|
import "../../model/index.js";
|
|
4
4
|
import { MultichainSDK } from "../../onchain/MultichainSDK.js";
|
|
5
|
+
import { PreviewOperationError } from "../../onchain/preview/preview/previewOperation.js";
|
|
6
|
+
import { HealthFactorThresholds } from "../../onchain/validation/bundles/checkHealthFactors.js";
|
|
7
|
+
import { CheckOperationOptions, OperationValidationError } from "../../onchain/validation/checkOperation.js";
|
|
8
|
+
import { CheckSimulationInput, SimulationValidationError } from "../../onchain/validation/checkSimulation.js";
|
|
5
9
|
import "../../onchain/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import "../../preview/index.js";
|
|
8
|
-
import { IPreview } from "./types.js";
|
|
10
|
+
import { CheckOperationProps, IPreview } from "./types.js";
|
|
9
11
|
import { NamespaceOptions } from "../types.js";
|
|
10
12
|
//#region src/sdk/preview/PreviewNamespace.d.ts
|
|
11
13
|
/**
|
|
@@ -18,6 +20,14 @@ declare class PreviewNamespace implements IPreview {
|
|
|
18
20
|
* {@inheritDoc IPreview.previewOperation}
|
|
19
21
|
**/
|
|
20
22
|
previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
|
|
23
|
+
/**
|
|
24
|
+
* {@inheritDoc IPreview.checkOperation}
|
|
25
|
+
**/
|
|
26
|
+
checkOperation(props: CheckOperationProps, options?: CheckOperationOptions): Promise<OperationValidationError[]>;
|
|
27
|
+
/**
|
|
28
|
+
* {@inheritDoc IPreview.checkSimulation}
|
|
29
|
+
**/
|
|
30
|
+
checkSimulation(props: CheckSimulationInput, options?: HealthFactorThresholds): Promise<SimulationValidationError[]>;
|
|
21
31
|
}
|
|
22
32
|
//#endregion
|
|
23
33
|
export { PreviewNamespace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IPreview, IPreviewByMode } from "./types.js";
|
|
1
|
+
import { CheckOperationProps, IPreview, IPreviewByMode } from "./types.js";
|
|
2
2
|
import { PreviewNamespace } from "./PreviewNamespace.js";
|
|
3
|
-
export { IPreview, IPreviewByMode, PreviewNamespace };
|
|
3
|
+
export { CheckOperationProps, IPreview, IPreviewByMode, PreviewNamespace };
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
import { ChainId } from "../../model/primitives.js";
|
|
1
2
|
import { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "../../model/previews.js";
|
|
2
3
|
import { SDKReturn } from "../../model/result.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
|
-
import { PreviewOperationError } from "../../preview/preview/previewOperation.js";
|
|
5
|
-
import "../../
|
|
5
|
+
import { PreviewOperationError } from "../../onchain/preview/preview/previewOperation.js";
|
|
6
|
+
import { HealthFactorThresholds } from "../../onchain/validation/bundles/checkHealthFactors.js";
|
|
7
|
+
import { CheckOperationInput, CheckOperationOptions, OperationValidationError } from "../../onchain/validation/checkOperation.js";
|
|
8
|
+
import { CheckSimulationInput, SimulationValidationError } from "../../onchain/validation/checkSimulation.js";
|
|
9
|
+
import "../../onchain/index.js";
|
|
6
10
|
//#region src/sdk/preview/types.d.ts
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* Parsed-operation check on the namespace: the standalone input minus `sdk`,
|
|
13
|
+
* plus the chain to resolve it on. `OperationPreview` only names the chain
|
|
14
|
+
* inside a token, so `chainId` is required.
|
|
15
|
+
**/
|
|
16
|
+
type CheckOperationProps = Omit<CheckOperationInput, "sdk"> & {
|
|
17
|
+
chainId: ChainId;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* On-chain preview of a raw operation calldata, and checks of a parsed or
|
|
21
|
+
* simulated one.
|
|
9
22
|
**/
|
|
10
23
|
interface IPreview {
|
|
11
24
|
/**
|
|
12
25
|
* Decodes a raw operation and assembles an operation-specific,
|
|
13
|
-
* human-displayable preview.
|
|
14
|
-
* target, function or operation, a foreign delayed intent, a failed
|
|
15
|
-
* simulation — is the `ok: false` half; genuine failures still throw.
|
|
26
|
+
* human-displayable preview.
|
|
16
27
|
**/
|
|
17
28
|
previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether a parsed operation may be signed by `sender`: protocol state first,
|
|
31
|
+
* then what the wallet has to approve, hold or sign.
|
|
32
|
+
**/
|
|
33
|
+
checkOperation(props: CheckOperationProps, options?: CheckOperationOptions): Promise<OperationValidationError[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a simulated operation clears the caller's own thresholds.
|
|
36
|
+
*
|
|
37
|
+
* Async because the namespace refreshes chain state first; the standalone
|
|
38
|
+
* checker is sync.
|
|
39
|
+
**/
|
|
40
|
+
checkSimulation(props: CheckSimulationInput, options?: HealthFactorThresholds): Promise<SimulationValidationError[]>;
|
|
18
41
|
}
|
|
19
42
|
/**
|
|
20
43
|
* `sdk.preview` per mode: an on-chain read, absent when the SDK reads no chain.
|
|
@@ -25,4 +48,4 @@ interface IPreviewByMode {
|
|
|
25
48
|
both: IPreview;
|
|
26
49
|
}
|
|
27
50
|
//#endregion
|
|
28
|
-
export { IPreview, IPreviewByMode };
|
|
51
|
+
export { CheckOperationProps, IPreview, IPreviewByMode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0-next.2",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -59,11 +59,6 @@
|
|
|
59
59
|
"import": "./dist/esm/permissionless/index.js",
|
|
60
60
|
"default": "./dist/cjs/permissionless/index.js"
|
|
61
61
|
},
|
|
62
|
-
"./preview": {
|
|
63
|
-
"types": "./dist/types/preview/index.d.ts",
|
|
64
|
-
"import": "./dist/esm/preview/index.js",
|
|
65
|
-
"default": "./dist/cjs/preview/index.js"
|
|
66
|
-
},
|
|
67
62
|
"./rewards": {
|
|
68
63
|
"types": "./dist/types/rewards/index.d.ts",
|
|
69
64
|
"import": "./dist/esm/rewards/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/onchain/validation/checks.ts
|
|
3
|
-
/**
|
|
4
|
-
* Every refusal the protocol can pass on an operation, as values.
|
|
5
|
-
*
|
|
6
|
-
* Each check is handed the numbers it compares — never a suite, a market or an
|
|
7
|
-
* SDK — so the engine, `checkOperation` and the strategy lists share one
|
|
8
|
-
* implementation.
|
|
9
|
-
*
|
|
10
|
-
* Ladders stay with the caller because they differ deliberately: the engine
|
|
11
|
-
* reports the tightest ceiling it found, the account-opening path the first one
|
|
12
|
-
* exceeded in its own order.
|
|
13
|
-
*/
|
|
14
|
-
/** A factor at or below this is refused; kept for the callers that size on it. */
|
|
15
|
-
const MIN_HF_LIMITED = 10100n;
|
|
16
|
-
/** The same bar as a `required` argument — the lowest factor that passes. */
|
|
17
|
-
const MIN_HEALTH_FACTOR_FORM = 10101;
|
|
18
|
-
/** The bar the facade itself enforces: an account may end exactly at 1.0. */
|
|
19
|
-
const MIN_HEALTH_FACTOR_FACADE = 1e4;
|
|
20
|
-
/**
|
|
21
|
-
* The safe-price bar a form holds an account to. A step above the facade's,
|
|
22
|
-
* because a factor of exactly 1.0 at safe prices is already a refusal.
|
|
23
|
-
*/
|
|
24
|
-
const MIN_SAFE_HEALTH_FACTOR_FORM = 10001;
|
|
25
|
-
/** A refusal names what a limit was measured in, never what it is worth. */
|
|
26
|
-
function amountOf(token, value) {
|
|
27
|
-
return {
|
|
28
|
-
token,
|
|
29
|
-
value,
|
|
30
|
-
valueUsd: null
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** The credit manager takes no multicall while it is paused. */
|
|
34
|
-
function checkCreditManagerPaused(args) {
|
|
35
|
-
if (!args.isPaused) return null;
|
|
36
|
-
return {
|
|
37
|
-
reason: "marketPaused",
|
|
38
|
-
detail: { creditManager: args.creditManager }
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** Past its expiration date the facade takes no more multicalls. */
|
|
42
|
-
function checkMarketExpired(args) {
|
|
43
|
-
if (!args.isExpired) return null;
|
|
44
|
-
return {
|
|
45
|
-
reason: "marketExpired",
|
|
46
|
-
detail: {
|
|
47
|
-
creditManager: args.creditManager,
|
|
48
|
-
expirationDate: args.expirationDate
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/** A paused pool neither takes deposits nor pays out. */
|
|
53
|
-
function checkPoolPaused(args) {
|
|
54
|
-
return args.isPaused ? {
|
|
55
|
-
reason: "marketPaused",
|
|
56
|
-
detail: { pool: args.pool }
|
|
57
|
-
} : null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A pool winding down still pays out, so only what puts money in is refused.
|
|
61
|
-
*/
|
|
62
|
-
function checkPoolSunset(args) {
|
|
63
|
-
return args.isSunset && args.isDeposit ? {
|
|
64
|
-
reason: "poolSunset",
|
|
65
|
-
detail: { pool: args.pool }
|
|
66
|
-
} : null;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* What the pool will hand over, against what is asked for.
|
|
70
|
-
*
|
|
71
|
-
* `binding` and `available` are the caller's answer to "which ceiling stands in
|
|
72
|
-
* the way", not this check's: see the ladder note above. `solutionAmount` is
|
|
73
|
-
* the largest position still openable, left out when none is.
|
|
74
|
-
*/
|
|
75
|
-
function checkBorrowLimit(args) {
|
|
76
|
-
if (args.requested <= args.available) return null;
|
|
77
|
-
return {
|
|
78
|
-
reason: "insufficientPoolLiquidity",
|
|
79
|
-
detail: {
|
|
80
|
-
requested: amountOf(args.underlying, args.requested),
|
|
81
|
-
available: amountOf(args.underlying, args.available),
|
|
82
|
-
binding: args.binding,
|
|
83
|
-
...args.solutionAmount === void 0 ? {} : { solutionAmount: amountOf(args.underlying, args.solutionAmount) }
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* What the pool can pay out, against what is being taken out.
|
|
89
|
-
*
|
|
90
|
-
* The operator is not `checkBorrowLimit`'s: a pool holding exactly the amount
|
|
91
|
-
* asked for still cannot serve it, so equality is already a refusal. That is
|
|
92
|
-
* the rule the legacy withdrawal validator enforced and it is preserved to the
|
|
93
|
-
* unit.
|
|
94
|
-
*/
|
|
95
|
-
function checkPoolPayout(args) {
|
|
96
|
-
if (args.requested < args.available) return null;
|
|
97
|
-
return {
|
|
98
|
-
reason: "insufficientPoolLiquidity",
|
|
99
|
-
detail: {
|
|
100
|
-
requested: amountOf(args.underlying, args.requested),
|
|
101
|
-
available: amountOf(args.underlying, args.available),
|
|
102
|
-
binding: "poolAvailableLiquidity"
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* A debt the facade would revert on.
|
|
108
|
-
*
|
|
109
|
-
* `allowZero` is the one place the two callers genuinely disagree: an account
|
|
110
|
-
* being adjusted may end owing nothing, while one being opened may not — so the
|
|
111
|
-
* exemption is stated rather than assumed.
|
|
112
|
-
*/
|
|
113
|
-
function checkDebtInBand(args) {
|
|
114
|
-
const { debt, minDebt, maxDebt, underlying, allowZero } = args;
|
|
115
|
-
if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return null;
|
|
116
|
-
return {
|
|
117
|
-
reason: "debtOutOfRange",
|
|
118
|
-
detail: {
|
|
119
|
-
requested: amountOf(underlying, debt),
|
|
120
|
-
minDebt: amountOf(underlying, minDebt),
|
|
121
|
-
maxDebt: amountOf(underlying, maxDebt)
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/** Leverage below 1x is not a position, it is a withdrawal. */
|
|
126
|
-
function checkLeverageAtLeastOne(args) {
|
|
127
|
-
return args.leverage < args.min ? {
|
|
128
|
-
reason: "leverageOutOfRange",
|
|
129
|
-
detail: {
|
|
130
|
-
requested: args.leverage,
|
|
131
|
-
min: args.min
|
|
132
|
-
}
|
|
133
|
-
} : null;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The account against its debt, at whichever bar the caller holds it to.
|
|
137
|
-
*
|
|
138
|
-
* An unread factor counts as failing: a check that cannot see the number is not
|
|
139
|
-
* evidence that the number is fine.
|
|
140
|
-
*/
|
|
141
|
-
function checkCollateralised(args) {
|
|
142
|
-
const { healthFactor, required, safePrices, improvesFrom } = args;
|
|
143
|
-
if (healthFactor === void 0) return {
|
|
144
|
-
reason: "insufficientCollateral",
|
|
145
|
-
detail: {
|
|
146
|
-
healthFactor: 0,
|
|
147
|
-
required,
|
|
148
|
-
safePrices
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
if (healthFactor >= required || improvesFrom !== void 0 && healthFactor > improvesFrom) return null;
|
|
152
|
-
return {
|
|
153
|
-
reason: "insufficientCollateral",
|
|
154
|
-
detail: {
|
|
155
|
-
healthFactor,
|
|
156
|
-
required,
|
|
157
|
-
safePrices
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
/** A token the market will not let the account hold. */
|
|
162
|
-
function checkForbiddenToken(args) {
|
|
163
|
-
return args.isForbidden ? {
|
|
164
|
-
reason: "forbiddenToken",
|
|
165
|
-
detail: { token: args.token }
|
|
166
|
-
} : null;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The room the keeper still has for a token's quota, in the underlying.
|
|
170
|
-
*
|
|
171
|
-
* `requested` is absent for a token the market opened no quota for at all —
|
|
172
|
-
* nothing was weighed against a limit, the token simply counts as no collateral.
|
|
173
|
-
*/
|
|
174
|
-
function checkQuotaLimit(args) {
|
|
175
|
-
const { token, requested, available, underlying } = args;
|
|
176
|
-
if (requested !== void 0 && requested <= available) return null;
|
|
177
|
-
return {
|
|
178
|
-
reason: "quotaLimitReached",
|
|
179
|
-
detail: {
|
|
180
|
-
token,
|
|
181
|
-
requested: requested === void 0 ? void 0 : amountOf(underlying, requested),
|
|
182
|
-
available: amountOf(underlying, available)
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
/** How many quoted tokens the facade enables at once. */
|
|
187
|
-
function checkQuotaCount(args) {
|
|
188
|
-
return args.count > args.max ? {
|
|
189
|
-
reason: "quotaCountExceeded",
|
|
190
|
-
detail: {
|
|
191
|
-
count: args.count,
|
|
192
|
-
max: args.max
|
|
193
|
-
}
|
|
194
|
-
} : null;
|
|
195
|
-
}
|
|
196
|
-
/** What the operation is funded from, against what is there. */
|
|
197
|
-
function checkFunding(args) {
|
|
198
|
-
const { token, required, held } = args;
|
|
199
|
-
if (required <= held) return null;
|
|
200
|
-
return {
|
|
201
|
-
reason: "insufficientSourceBalance",
|
|
202
|
-
detail: {
|
|
203
|
-
required: amountOf(token, required),
|
|
204
|
-
held: amountOf(token, held)
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* The SDK could not replay the transaction.
|
|
210
|
-
*
|
|
211
|
-
* Only a {@link MalformedPreviewError} lands here. An `unpriceableToken`
|
|
212
|
-
* warning says the transaction is fine and the SDK could not fully evaluate
|
|
213
|
-
* it, which is a caveat on the numbers rather than a reason to refuse — it
|
|
214
|
-
* stays on the preview for the caller to surface.
|
|
215
|
-
*/
|
|
216
|
-
function checkPreviewError(warning) {
|
|
217
|
-
if (!warning || !isMalformedPreviewError(warning)) return null;
|
|
218
|
-
return {
|
|
219
|
-
reason: "malformedTransaction",
|
|
220
|
-
detail: warning
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Whether the preview warning means the transaction itself is malformed,
|
|
225
|
-
* rather than that only the evaluation was incomplete.
|
|
226
|
-
*/
|
|
227
|
-
function isMalformedPreviewError(warning) {
|
|
228
|
-
switch (warning.code) {
|
|
229
|
-
case "malformedBracket":
|
|
230
|
-
case "adapterCallOutsideBracket":
|
|
231
|
-
case "nonAdapterCallInBracket":
|
|
232
|
-
case "unpreviewableAdapterCall":
|
|
233
|
-
case "unsupportedOutOfBracketCall":
|
|
234
|
-
case "invalidTransactionValue": return true;
|
|
235
|
-
default: return false;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
//#endregion
|
|
239
|
-
exports.MIN_HEALTH_FACTOR_FACADE = MIN_HEALTH_FACTOR_FACADE;
|
|
240
|
-
exports.MIN_HEALTH_FACTOR_FORM = MIN_HEALTH_FACTOR_FORM;
|
|
241
|
-
exports.MIN_HF_LIMITED = MIN_HF_LIMITED;
|
|
242
|
-
exports.MIN_SAFE_HEALTH_FACTOR_FORM = MIN_SAFE_HEALTH_FACTOR_FORM;
|
|
243
|
-
exports.amountOf = amountOf;
|
|
244
|
-
exports.checkBorrowLimit = checkBorrowLimit;
|
|
245
|
-
exports.checkCollateralised = checkCollateralised;
|
|
246
|
-
exports.checkCreditManagerPaused = checkCreditManagerPaused;
|
|
247
|
-
exports.checkDebtInBand = checkDebtInBand;
|
|
248
|
-
exports.checkForbiddenToken = checkForbiddenToken;
|
|
249
|
-
exports.checkFunding = checkFunding;
|
|
250
|
-
exports.checkLeverageAtLeastOne = checkLeverageAtLeastOne;
|
|
251
|
-
exports.checkMarketExpired = checkMarketExpired;
|
|
252
|
-
exports.checkPoolPaused = checkPoolPaused;
|
|
253
|
-
exports.checkPoolPayout = checkPoolPayout;
|
|
254
|
-
exports.checkPoolSunset = checkPoolSunset;
|
|
255
|
-
exports.checkPreviewError = checkPreviewError;
|
|
256
|
-
exports.checkQuotaCount = checkQuotaCount;
|
|
257
|
-
exports.checkQuotaLimit = checkQuotaLimit;
|
|
258
|
-
exports.isMalformedPreviewError = isMalformedPreviewError;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/onchain/validation/refusal.ts
|
|
3
|
-
/** Builds the refusal a caller sees. */
|
|
4
|
-
function refuse(reason, detail) {
|
|
5
|
-
return {
|
|
6
|
-
ok: false,
|
|
7
|
-
reason,
|
|
8
|
-
detail
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Validation failure that maps onto {@link PreviewErrorReason} rather than
|
|
13
|
-
* crashing the caller: raised by the planners and the guards, turned into
|
|
14
|
-
* `{ ok: false }` by `CreditAccountOperationsService`.
|
|
15
|
-
*/
|
|
16
|
-
var IntentPreviewError = class extends Error {
|
|
17
|
-
reason;
|
|
18
|
-
detail;
|
|
19
|
-
constructor(reason, detail, message) {
|
|
20
|
-
super(message ?? reason);
|
|
21
|
-
this.name = "IntentPreviewError";
|
|
22
|
-
this.reason = reason;
|
|
23
|
-
this.detail = detail;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Throws the issue a check found, with the sentence the engine logs for it.
|
|
28
|
-
*
|
|
29
|
-
* Returns normally when there is nothing to raise, so it cannot narrow a type
|
|
30
|
-
* the way a bare `throw` does — a site that guards a value for the code below
|
|
31
|
-
* it keeps throwing directly.
|
|
32
|
-
*/
|
|
33
|
-
function raise(issue, message) {
|
|
34
|
-
if (issue) throw new IntentPreviewError(issue.reason, issue.detail, message);
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
exports.IntentPreviewError = IntentPreviewError;
|
|
38
|
-
exports.raise = raise;
|
|
39
|
-
exports.refuse = refuse;
|