@gearbox-protocol/sdk 16.1.2 → 16.3.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +40 -2
- package/dist/cjs/model/positions.js +1 -1
- package/dist/cjs/model/result.js +0 -8
- package/dist/cjs/model/rwa.js +40 -0
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- 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 +44 -8
- 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/withdrawal-compressor/index.js +0 -1
- package/dist/cjs/onchain/index.js +122 -36
- package/dist/cjs/onchain/market/MarketSuite.js +7 -1
- package/dist/cjs/onchain/market/adapters/index.js +1 -0
- package/dist/cjs/onchain/market/credit/CreditSuite.js +47 -15
- package/dist/cjs/onchain/market/index.js +0 -6
- 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/index.js +0 -4
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +7 -7
- package/dist/cjs/onchain/market/rwa/securitize/constants.js +0 -2
- package/dist/cjs/onchain/market/rwa/securitize/index.js +1 -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/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/execute/ExecuteApi.js +1 -0
- package/dist/cjs/sdk/index.js +6 -9
- package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +9 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +55 -48
- package/dist/cjs/sdk/prepare/index.js +7 -9
- package/dist/cjs/sdk/prepare/types.js +0 -4
- package/dist/cjs/sdk/preview/PreviewNamespace.js +24 -13
- 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 +1 -1
- 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 +9 -3
- package/dist/esm/model/positions.js +1 -1
- package/dist/esm/model/result.js +1 -8
- package/dist/esm/model/rwa.js +37 -0
- 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 +46 -10
- 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/withdrawal-compressor/index.js +0 -1
- package/dist/esm/onchain/index.js +61 -10
- package/dist/esm/onchain/market/MarketSuite.js +7 -1
- package/dist/esm/onchain/market/adapters/index.js +1 -0
- package/dist/esm/onchain/market/credit/CreditSuite.js +47 -15
- package/dist/esm/onchain/market/index.js +3 -5
- 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/rwa/RWARegistry.js +2 -1
- package/dist/esm/onchain/market/rwa/index.js +3 -4
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +2 -2
- package/dist/esm/onchain/market/rwa/securitize/constants.js +1 -2
- package/dist/esm/onchain/market/rwa/securitize/index.js +3 -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/index.js +0 -1
- 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/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/execute/ExecuteApi.js +1 -0
- package/dist/esm/sdk/index.js +2 -3
- package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +9 -0
- package/dist/esm/sdk/prepare/PrepareApi.js +43 -36
- 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/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 +11 -4
- package/dist/types/model/opportunities.d.ts +3 -2
- 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 +143 -0
- 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/open-strategy.d.ts +34 -3
- 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/open-strategy.fixtures.d.ts +2 -2
- 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 +4 -2
- 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 +68 -13
- 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 +20 -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 +6 -7
- 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/index.d.ts +4 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +3 -2
- package/dist/types/onchain/market/rwa/securitize/constants.d.ts +1 -2
- package/dist/types/onchain/market/rwa/securitize/index.d.ts +3 -3
- package/dist/types/onchain/market/rwa/securitize/types.d.ts +4 -110
- package/dist/types/onchain/market/rwa/types.d.ts +6 -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/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/prepare/PrepareApi.d.ts +6 -5
- package/dist/types/sdk/prepare/index.d.ts +5 -5
- package/dist/types/sdk/prepare/types.d.ts +65 -23
- 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 -93
- 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 -89
- 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 -319
- /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,53 +0,0 @@
|
|
|
1
|
-
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
2
|
-
import "../../onchain/index.js";
|
|
3
|
-
import { BalanceResult } from "./BalancePrerequisite.js";
|
|
4
|
-
import { RWAOpenRequirementsResult } from "./RWAOpenRequirementsPrerequisite.js";
|
|
5
|
-
import { AllowanceResult } from "./AllowancePrerequisite.js";
|
|
6
|
-
import { Address } from "viem";
|
|
7
|
-
//#region src/preview/prerequisites/types.d.ts
|
|
8
|
-
/** Failure of the underlying on-chain read (revert, decode error, RPC error). */
|
|
9
|
-
interface PrerequisiteError {
|
|
10
|
-
/** Decoded revert reason / error name, human-readable. */
|
|
11
|
-
reason: string;
|
|
12
|
-
/** Original error, kept for debugging. */
|
|
13
|
-
cause?: unknown;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Outcome of verifying a single prerequisite: either the read succeeded (a
|
|
17
|
-
* `satisfied` boolean) or it reverted/failed (an `error` with the revert
|
|
18
|
-
* reason).
|
|
19
|
-
*/
|
|
20
|
-
type PrerequisiteOutcome = {
|
|
21
|
-
satisfied: boolean;
|
|
22
|
-
error?: undefined;
|
|
23
|
-
} | {
|
|
24
|
-
satisfied?: undefined;
|
|
25
|
-
error: PrerequisiteError;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Discriminated union over every prerequisite kind
|
|
29
|
-
*
|
|
30
|
-
* Only add prerequisites that are actionable by tx sender.
|
|
31
|
-
* A valid prerequisite is one the user can resolve themselves before retrying,
|
|
32
|
-
* e.g. approve a token (`allowance`) or perform offchain KYC verification.
|
|
33
|
-
*/
|
|
34
|
-
type PrerequisiteResult = AllowanceResult | BalanceResult | RWAOpenRequirementsResult;
|
|
35
|
-
type PrerequisiteKind = PrerequisiteResult["kind"];
|
|
36
|
-
/** Shared inputs for building and verifying prerequisites. */
|
|
37
|
-
interface PrerequisiteContext {
|
|
38
|
-
sdk: OnchainSDK;
|
|
39
|
-
/**
|
|
40
|
-
* Address whose balances/allowances are checked (the tx sender).
|
|
41
|
-
**/
|
|
42
|
-
wallet: Address;
|
|
43
|
-
/**
|
|
44
|
-
* Block to read at; defaults to latest. Only set for testnet forks.
|
|
45
|
-
**/
|
|
46
|
-
blockNumber?: bigint;
|
|
47
|
-
/**
|
|
48
|
-
* Transaction `msg.value`
|
|
49
|
-
**/
|
|
50
|
-
value: bigint;
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
export { PrerequisiteContext, PrerequisiteError, PrerequisiteKind, PrerequisiteOutcome, PrerequisiteResult };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { IGearboxError } from "../../model/errors.js";
|
|
2
|
-
import { AdapterCallOutsideBracketError, InvalidTransactionValueError, MalformedBracketError, MalformedBracketKind, NonAdapterCallInBracketError, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError } from "../../model/previews.js";
|
|
3
|
-
import "../../model/index.js";
|
|
4
|
-
import { Address } from "viem";
|
|
5
|
-
//#region src/preview/preview/errors.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Refusal answered by `previewOperation` for parsed operations it cannot
|
|
8
|
-
* preview yet. A plain returned object per the SDK's refusal vocabulary —
|
|
9
|
-
* not a thrown `Error`.
|
|
10
|
-
*/
|
|
11
|
-
interface UnsupportedOperationError extends IGearboxError {
|
|
12
|
-
code: "unsupportedOperation";
|
|
13
|
-
/** The parsed operation kind (the `operation` discriminant). */
|
|
14
|
-
operation: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Builds a {@link MalformedBracketError} for the given bracket invariant.
|
|
18
|
-
**/
|
|
19
|
-
declare function malformedBracketError(kind: MalformedBracketKind): MalformedBracketError;
|
|
20
|
-
/**
|
|
21
|
-
* Builds an {@link AdapterCallOutsideBracketError} for `adapter`.
|
|
22
|
-
**/
|
|
23
|
-
declare function adapterCallOutsideBracketError(adapter: Address): AdapterCallOutsideBracketError;
|
|
24
|
-
/**
|
|
25
|
-
* Builds a {@link NonAdapterCallInBracketError} for `target`.
|
|
26
|
-
**/
|
|
27
|
-
declare function nonAdapterCallInBracketError(target: Address): NonAdapterCallInBracketError;
|
|
28
|
-
/**
|
|
29
|
-
* Builds an {@link UnpreviewableAdapterCallError} for a bracketed adapter
|
|
30
|
-
* call that could not be replayed.
|
|
31
|
-
**/
|
|
32
|
-
declare function unpreviewableAdapterCallError(adapter: Address, cause: unknown): UnpreviewableAdapterCallError;
|
|
33
|
-
/**
|
|
34
|
-
* Builds an {@link UnsupportedOutOfBracketCallError} for an allowed
|
|
35
|
-
* out-of-bracket adapter call that could not be replayed.
|
|
36
|
-
**/
|
|
37
|
-
declare function unsupportedOutOfBracketCallError(adapter: Address, cause: unknown): UnsupportedOutOfBracketCallError;
|
|
38
|
-
/**
|
|
39
|
-
* Builds an {@link InvalidTransactionValueError} when `msg.value` does not
|
|
40
|
-
* fit into the declared WETH collateral.
|
|
41
|
-
**/
|
|
42
|
-
declare function invalidTransactionValueError(value: bigint, wethCollateral: bigint): InvalidTransactionValueError;
|
|
43
|
-
//#endregion
|
|
44
|
-
export { UnsupportedOperationError, adapterCallOutsideBracketError, invalidTransactionValueError, malformedBracketError, nonAdapterCallInBracketError, unpreviewableAdapterCallError, unsupportedOutOfBracketCallError };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AdjustStrategyPositionPreview } from "../../model/previews.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
4
|
-
import "../../onchain/index.js";
|
|
5
|
-
import { MulticallOperation } from "../parse/types-facades.js";
|
|
6
|
-
import { RWAMulticallOperation } from "../parse/types-rwa.js";
|
|
7
|
-
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
8
|
-
import "../parse/index.js";
|
|
9
|
-
//#region src/preview/preview/previewAdjustStrategyPosition.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Previews a `multicall`/`botMulticall` operation on an existing credit
|
|
12
|
-
* account: threads the multicall through {@link replayMulticall} over the
|
|
13
|
-
* pre-resolved account state (`options.creditAccount`) and reports the
|
|
14
|
-
* minimal guaranteed post-state alongside the changes relative to the
|
|
15
|
-
* pre-state.
|
|
16
|
-
*/
|
|
17
|
-
declare function previewAdjustStrategyPosition<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation | RWAMulticallOperation, options: PreviewOperationOptions<true>): AdjustStrategyPositionPreview;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { previewAdjustStrategyPosition };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ExitStrategyPositionPreview, RepayStrategyPositionPreview } from "../../model/previews.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
4
|
-
import "../../onchain/index.js";
|
|
5
|
-
import { CloseCreditAccountOperation, MulticallOperation } from "../parse/types-facades.js";
|
|
6
|
-
import { RWAMulticallOperation } from "../parse/types-rwa.js";
|
|
7
|
-
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
8
|
-
import "../parse/index.js";
|
|
9
|
-
//#region src/preview/preview/previewExitOrRepayStrategyPosition.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Any parsed operation that fully closes or repays a credit account: the
|
|
12
|
-
* facade `closeCreditAccount` entry point (permanent closure) or a plain
|
|
13
|
-
* multicall detected by `isCloseOrRepay` (`decreaseDebt(MAX)`).
|
|
14
|
-
*/
|
|
15
|
-
type CloseOrRepayOperation = CloseCreditAccountOperation | MulticallOperation | RWAMulticallOperation;
|
|
16
|
-
declare function previewExitOrRepayStrategyPosition<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: CloseOrRepayOperation, permanent: boolean, options: PreviewOperationOptions<true>): ExitStrategyPositionPreview | RepayStrategyPositionPreview;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { CloseOrRepayOperation, previewExitOrRepayStrategyPosition };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OpenStrategyPositionPreview } from "../../model/previews.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
4
|
-
import "../../onchain/index.js";
|
|
5
|
-
import { OpenCreditAccountOperation } from "../parse/types-facades.js";
|
|
6
|
-
import { RWAOpenCreditAccountOperation } from "../parse/types-rwa.js";
|
|
7
|
-
import { PreviewOperationInput } from "../types.js";
|
|
8
|
-
import "../parse/index.js";
|
|
9
|
-
//#region src/preview/preview/previewOpenStrategyPosition.d.ts
|
|
10
|
-
declare function previewOpenStrategyPosition<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | RWAOpenCreditAccountOperation): OpenStrategyPositionPreview;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { previewOpenStrategyPosition };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { OperationPreview } from "../../model/previews.js";
|
|
2
|
-
import { SDKReturn } from "../../model/result.js";
|
|
3
|
-
import "../../model/index.js";
|
|
4
|
-
import { InvalidDelayedIntentError } from "../../onchain/accounts/withdrawal-compressor/errors.js";
|
|
5
|
-
import { UnsupportedZapperFunctionError } from "../../onchain/market/zapper/errors.js";
|
|
6
|
-
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
7
|
-
import "../../onchain/index.js";
|
|
8
|
-
import { UnsupportedPoolFunctionError, UnsupportedTargetError } from "../parse/errors.js";
|
|
9
|
-
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
10
|
-
import "../parse/index.js";
|
|
11
|
-
import { UnsupportedOperationError } from "./errors.js";
|
|
12
|
-
import { PreviewSimulationError } from "../simulate/errors.js";
|
|
13
|
-
//#region src/preview/preview/previewOperation.d.ts
|
|
14
|
-
/**
|
|
15
|
-
* Everything {@link previewOperation} can refuse with: the refusal errors
|
|
16
|
-
* its pipeline raises, discriminated by `code`. Each is a plain object —
|
|
17
|
-
* never a thrown `Error` — per the SDK's refusal vocabulary.
|
|
18
|
-
*/
|
|
19
|
-
type PreviewOperationError = UnsupportedTargetError | UnsupportedPoolFunctionError | UnsupportedZapperFunctionError | UnsupportedOperationError | InvalidDelayedIntentError | PreviewSimulationError;
|
|
20
|
-
/**
|
|
21
|
-
* Previews a raw operation calldata: decodes it into a typed operation and
|
|
22
|
-
* assembles an operation-specific, human-displayable preview.
|
|
23
|
-
*
|
|
24
|
-
* Answers an {@link SDKReturn} envelope: the preview behind `ok: true`, or —
|
|
25
|
-
* when the transaction is one the previewer refuses to read — a
|
|
26
|
-
* {@link PreviewOperationError} behind `ok: false`. A thrown exception
|
|
27
|
-
* still means the SDK could not do its job (a read failed, the targeted
|
|
28
|
-
* credit account could not be resolved), not a refusal of the transaction.
|
|
29
|
-
*/
|
|
30
|
-
declare function previewOperation<P extends PluginsMap = PluginsMap>(input: PreviewOperationInput<P>, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { PreviewOperationError, previewOperation };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PoolPositionOperationPreview } from "../../model/previews.js";
|
|
2
|
-
import { SDKReturn } from "../../model/result.js";
|
|
3
|
-
import "../../model/index.js";
|
|
4
|
-
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
5
|
-
import "../../onchain/index.js";
|
|
6
|
-
import { PoolOperation } from "../parse/types-pools.js";
|
|
7
|
-
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
8
|
-
import "../parse/index.js";
|
|
9
|
-
import { PreviewSimulationError } from "../simulate/errors.js";
|
|
10
|
-
//#region src/preview/preview/previewPoolPositionOperation.d.ts
|
|
11
|
-
declare function previewPoolPositionOperation<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: PoolOperation, options?: PreviewOperationOptions): Promise<SDKReturn<PoolPositionOperationPreview, PreviewSimulationError>>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { previewPoolPositionOperation };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { IGearboxError } from "../../model/errors.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { Hex } from "viem";
|
|
4
|
-
//#region src/preview/simulate/errors.d.ts
|
|
5
|
-
/** Which simulation flow produced a failure. */
|
|
6
|
-
type SimulationFlowSource = "multicall" | "unknown";
|
|
7
|
-
/** A single flow failure with its decoded revert detail. */
|
|
8
|
-
interface SimulationFlowFailure {
|
|
9
|
-
source: SimulationFlowSource;
|
|
10
|
-
detail: SimulationError;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Refusal answered when the pool simulation fails. It wraps each flow's
|
|
14
|
-
* decoded revert reason (see {@link failures}). A plain returned object per
|
|
15
|
-
* the SDK's refusal vocabulary — not a thrown `Error`.
|
|
16
|
-
*/
|
|
17
|
-
interface PreviewSimulationError extends IGearboxError {
|
|
18
|
-
code: "previewSimulationFailed";
|
|
19
|
-
/** Per-flow decoded failures behind this refusal. */
|
|
20
|
-
failures: SimulationFlowFailure[];
|
|
21
|
-
/** First flow failure that was itself an `Error`, kept for debugging. */
|
|
22
|
-
cause?: Error;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Normalises an unknown rejection reason into a {@link PreviewSimulationError}.
|
|
26
|
-
* Pass-through when it already is one; otherwise decodes it under `source`.
|
|
27
|
-
*/
|
|
28
|
-
declare function asPreviewSimulationError(reason: unknown, source: SimulationFlowSource): PreviewSimulationError;
|
|
29
|
-
/** Decoded revert of the simulated transaction. */
|
|
30
|
-
interface SimulationError {
|
|
31
|
-
/** Human-readable revert reason / error name. */
|
|
32
|
-
reason: string;
|
|
33
|
-
/** Original error, kept for debugging. */
|
|
34
|
-
cause?: unknown;
|
|
35
|
-
}
|
|
36
|
-
/** Per-call slice of a multicall failure we need to decode. */
|
|
37
|
-
interface SimulationRevert {
|
|
38
|
-
error?: Error;
|
|
39
|
-
/** Raw revert return data, when present. */
|
|
40
|
-
data?: Hex;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Decodes a simulated call revert into a {@link SimulationError}.
|
|
44
|
-
*
|
|
45
|
-
* We first try to decode any raw return bytes against the SDK's
|
|
46
|
-
* {@link errorAbis} (Gearbox protocol exceptions plus standard ERC-20 custom
|
|
47
|
-
* errors); failing that, we walk viem's error chain for a
|
|
48
|
-
* {@link ContractFunctionRevertedError} (covers `Error(string)` / `Panic`).
|
|
49
|
-
*/
|
|
50
|
-
declare function decodeSimulationError(revert: SimulationRevert): SimulationError;
|
|
51
|
-
//#endregion
|
|
52
|
-
export { PreviewSimulationError, SimulationError, SimulationFlowFailure, SimulationFlowSource, SimulationRevert, asPreviewSimulationError, decodeSimulationError };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PreviewSimulationError, SimulationError, SimulationFlowFailure, SimulationFlowSource, asPreviewSimulationError } from "./errors.js";
|
|
2
|
-
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
3
|
-
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
4
|
-
import { simulateOperation } from "./simulateOperation.js";
|
|
5
|
-
import { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
6
|
-
import { simulateRWAOperation } from "./simulateRWAOperation.js";
|
|
7
|
-
export { type PoolOperationSimulationResult, type PreviewSimulationError, type SimulationError, type SimulationFlowFailure, type SimulationFlowSource, type SimulationInput, asPreviewSimulationError, simulateFacadeOperation, simulateOperation, simulatePoolOperation, simulateRWAOperation };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { OuterFacadeOperation } from "../parse/types-facades.js";
|
|
2
|
-
import { PreviewOperationOptions } from "../types.js";
|
|
3
|
-
import "../parse/index.js";
|
|
4
|
-
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
5
|
-
//#region src/preview/simulate/simulateFacadeOperation.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Simulates a credit-facade operation.
|
|
8
|
-
*
|
|
9
|
-
* Not yet implemented: credit-facade simulation requires multicall-aware
|
|
10
|
-
* balance/transfer accounting that the pool simulation does not cover. The
|
|
11
|
-
* signature mirrors {@link simulatePoolOperation} so the
|
|
12
|
-
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
13
|
-
*/
|
|
14
|
-
declare function simulateFacadeOperation(_input: SimulationInput<OuterFacadeOperation>, _options?: PreviewOperationOptions): Promise<PoolOperationSimulationResult>;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { simulateFacadeOperation };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SDKReturn } from "../../model/result.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { PreviewOperationOptions } from "../types.js";
|
|
4
|
-
import { PreviewSimulationError } from "./errors.js";
|
|
5
|
-
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
6
|
-
//#region src/preview/simulate/simulateOperation.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Simulates a parsed pool or credit account operation
|
|
9
|
-
*/
|
|
10
|
-
declare function simulateOperation(input: SimulationInput, options?: PreviewOperationOptions): Promise<SDKReturn<PoolOperationSimulationResult, PreviewSimulationError>>;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { simulateOperation };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { SDKReturn } from "../../model/result.js";
|
|
2
|
-
import "../../model/index.js";
|
|
3
|
-
import { PoolOperation } from "../parse/types-pools.js";
|
|
4
|
-
import { PreviewOperationOptions } from "../types.js";
|
|
5
|
-
import "../parse/index.js";
|
|
6
|
-
import { PreviewSimulationError } from "./errors.js";
|
|
7
|
-
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
8
|
-
import { ContractFunctionParameters } from "viem";
|
|
9
|
-
//#region src/preview/simulate/simulatePoolOperation.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* Builds the preview read that converts the operation's known amount into its
|
|
12
|
-
* counterpart. Direct operations read the pool's ERC4626 preview; zapper-routed
|
|
13
|
-
* operations (only ever `Deposit`/`Redeem`) read the zapper's
|
|
14
|
-
* `previewDeposit`/`previewRedeem`, which account for the zapper's own
|
|
15
|
-
* conversion in addition to the pool's.
|
|
16
|
-
*/
|
|
17
|
-
declare function previewContract(operation: PoolOperation): ContractFunctionParameters;
|
|
18
|
-
/**
|
|
19
|
-
* Maps a pool operation and its preview result to the amounts of tokens going
|
|
20
|
-
* in (user -> pool) and out (pool -> user). `previewAmount` is the counterpart
|
|
21
|
-
* amount returned by the matching preview read (shares for deposit/withdraw,
|
|
22
|
-
* assets for mint/redeem, and the zapper's converted amount for zapper-routed
|
|
23
|
-
* deposit/redeem).
|
|
24
|
-
*/
|
|
25
|
-
declare function amountsInOut(operation: PoolOperation, previewAmount: bigint): PoolOperationSimulationResult;
|
|
26
|
-
/**
|
|
27
|
-
* Simulates a pool deposit/mint/withdraw/redeem (direct or zapper-routed) and
|
|
28
|
-
* returns the resulting token amounts going in and out. Throws a
|
|
29
|
-
* {@link PreviewSimulationError} with the decoded revert when the preview read
|
|
30
|
-
* fails.
|
|
31
|
-
*
|
|
32
|
-
* Performs the matching preview read (the pool's ERC4626
|
|
33
|
-
* `previewDeposit`/`previewMint`/`previewWithdraw`/`previewRedeem`, or the
|
|
34
|
-
* zapper's `previewDeposit`/`previewRedeem`) to convert the calldata-known
|
|
35
|
-
* amount into its counterpart. It works on every network the SDK supports.
|
|
36
|
-
*
|
|
37
|
-
* It does not execute the calldata, so it ignores balance/allowance
|
|
38
|
-
* prerequisites (preview reads succeed regardless).
|
|
39
|
-
*/
|
|
40
|
-
declare function simulatePoolOperation(input: SimulationInput<PoolOperation>, options?: PreviewOperationOptions): Promise<SDKReturn<PoolOperationSimulationResult, PreviewSimulationError>>;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { amountsInOut, previewContract, simulatePoolOperation };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RWAOperation } from "../parse/types-rwa.js";
|
|
2
|
-
import { PreviewOperationOptions } from "../types.js";
|
|
3
|
-
import "../parse/index.js";
|
|
4
|
-
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
5
|
-
//#region src/preview/simulate/simulateRWAOperation.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Simulates an RWA-factory operation.
|
|
8
|
-
*
|
|
9
|
-
* Not yet implemented: like credit-facade simulation, it requires
|
|
10
|
-
* multicall-aware balance/transfer accounting that the pool simulation does
|
|
11
|
-
* not cover. The signature mirrors {@link simulatePoolOperation} so the
|
|
12
|
-
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
13
|
-
*/
|
|
14
|
-
declare function simulateRWAOperation(_input: SimulationInput<RWAOperation>, _options?: PreviewOperationOptions): Promise<PoolOperationSimulationResult>;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { simulateRWAOperation };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
2
|
-
import "../../onchain/index.js";
|
|
3
|
-
import { Operation } from "../parse/types.js";
|
|
4
|
-
import "../parse/index.js";
|
|
5
|
-
import { Address, Hex } from "viem";
|
|
6
|
-
//#region src/preview/simulate/types.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Input of the simulation functions, generic over the parsed operation kind
|
|
9
|
-
* so each specialized simulation narrows `operation` while sharing the same
|
|
10
|
-
* shape.
|
|
11
|
-
*/
|
|
12
|
-
interface SimulationInput<Op extends Operation = Operation> {
|
|
13
|
-
/** Only `client`/`networkType` are used, so any OnchainSDK works. */
|
|
14
|
-
sdk: OnchainSDK;
|
|
15
|
-
/** Parsed operation to simulate. */
|
|
16
|
-
operation: Op;
|
|
17
|
-
/** Target contract the calldata is sent to. */
|
|
18
|
-
to: Address;
|
|
19
|
-
/** Raw operation calldata to simulate. */
|
|
20
|
-
calldata: Hex;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Result of simulating a pool operation: the amounts of tokens going in
|
|
24
|
-
* and out. One side comes from calldata, the other from the matching ERC4626
|
|
25
|
-
* preview read.
|
|
26
|
-
*/
|
|
27
|
-
interface PoolOperationSimulationResult {
|
|
28
|
-
/**
|
|
29
|
-
* User -> pool.
|
|
30
|
-
*
|
|
31
|
-
* Deposit/mint: underlying (or zapper input); `withdrawFee` does not apply.
|
|
32
|
-
*
|
|
33
|
-
* Withdraw/redeem: shares burned. On withdraw, `previewWithdraw` inflates
|
|
34
|
-
* that burn for `withdrawFee`; on redeem, the shares from calldata.
|
|
35
|
-
**/
|
|
36
|
-
amountIn: bigint;
|
|
37
|
-
/**
|
|
38
|
-
* Pool -> user.
|
|
39
|
-
*
|
|
40
|
-
* Deposit/mint: shares minted (or zapper output); `withdrawFee` does not apply.
|
|
41
|
-
*
|
|
42
|
-
* Withdraw/redeem: underlying paid out. On withdraw, the requested amount;
|
|
43
|
-
* on redeem, `previewRedeem` after `withdrawFee`.
|
|
44
|
-
**/
|
|
45
|
-
amountOut: bigint;
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { PoolOperationSimulationResult, SimulationInput };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ILogger } from "../onchain/types/logger.js";
|
|
2
|
-
import { CreditAccountData } from "../onchain/base/types.js";
|
|
3
|
-
import { PluginsMap } from "../onchain/plugins/types.js";
|
|
4
|
-
import { OnchainSDK } from "../onchain/OnchainSDK.js";
|
|
5
|
-
import "../onchain/index.js";
|
|
6
|
-
import { Address, Hex } from "viem";
|
|
7
|
-
//#region src/preview/types.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Raw-calldata operation input shared by `parseOperationCalldata`,
|
|
10
|
-
* `previewOperation` and `checkPrerequisites`.
|
|
11
|
-
*/
|
|
12
|
-
interface PreviewOperationInput<P extends PluginsMap = PluginsMap> {
|
|
13
|
-
/**
|
|
14
|
-
* Already-attached SDK; chain, RPC and block are baked in at attach time.
|
|
15
|
-
*/
|
|
16
|
-
sdk: OnchainSDK<P>;
|
|
17
|
-
/**
|
|
18
|
-
* Contract address that was called
|
|
19
|
-
*/
|
|
20
|
-
to: Address;
|
|
21
|
-
/**
|
|
22
|
-
* Raw calldata of the operation
|
|
23
|
-
*/
|
|
24
|
-
calldata: Hex;
|
|
25
|
-
/**
|
|
26
|
-
* Transaction sender
|
|
27
|
-
*/
|
|
28
|
-
sender: Address;
|
|
29
|
-
/**
|
|
30
|
-
* Transaction `msg.value`, required for native-token zapper deposits.
|
|
31
|
-
**/
|
|
32
|
-
value?: bigint;
|
|
33
|
-
}
|
|
34
|
-
interface PreviewOperationOptionsBase {
|
|
35
|
-
/**
|
|
36
|
-
* Block to read/simulate at; defaults to latest. Only set for testnet
|
|
37
|
-
* forks.
|
|
38
|
-
*/
|
|
39
|
-
blockNumber?: bigint;
|
|
40
|
-
/**
|
|
41
|
-
* Optional logger.
|
|
42
|
-
**/
|
|
43
|
-
logger?: ILogger;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Options shared by the preview, simulation and prerequisite-check flows.
|
|
47
|
-
* Each flow uses the subset it needs and ignores the rest.
|
|
48
|
-
*
|
|
49
|
-
* `WithAccount = true` marks options whose credit account state has already
|
|
50
|
-
* been resolved (internal preview paths on an existing credit account).
|
|
51
|
-
*/
|
|
52
|
-
type PreviewOperationOptions<WithAccount extends boolean = false> = WithAccount extends true ? PreviewOperationOptionsBase & {
|
|
53
|
-
/**
|
|
54
|
-
* Pre-resolved state of the credit account the operation targets
|
|
55
|
-
*/
|
|
56
|
-
creditAccount: CreditAccountData;
|
|
57
|
-
} : PreviewOperationOptionsBase & {
|
|
58
|
-
/**
|
|
59
|
-
* @internal
|
|
60
|
-
* Credit account state for testing purposes
|
|
61
|
-
*/
|
|
62
|
-
creditAccount?: CreditAccountData;
|
|
63
|
-
};
|
|
64
|
-
//#endregion
|
|
65
|
-
export { PreviewOperationInput, PreviewOperationOptions };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Bps } from "../../model/primitives.js";
|
|
2
|
-
import { AccountHoldings, AccountMetrics, AccountProjection, OperationPreview } from "../../model/previews.js";
|
|
3
|
-
import "../../model/index.js";
|
|
4
|
-
import { AddressMap } from "../../onchain/utils/AddressMap.js";
|
|
5
|
-
import { CreditSuite } from "../../onchain/market/credit/CreditSuite.js";
|
|
6
|
-
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
7
|
-
import { PreviewIssue } from "../../onchain/validation/refusal.js";
|
|
8
|
-
import "../../onchain/index.js";
|
|
9
|
-
//#region src/preview/validate/checkOperation.d.ts
|
|
10
|
-
/** Omitting a bar switches its check off — there is no single right one. */
|
|
11
|
-
interface CheckOperationOptions {
|
|
12
|
-
/** Lowest acceptable health factor at main prices, in bps. */
|
|
13
|
-
minHealthFactor?: Bps;
|
|
14
|
-
/** Lowest acceptable health factor at safe prices, in bps. */
|
|
15
|
-
minSafeHealthFactor?: Bps;
|
|
16
|
-
/**
|
|
17
|
-
* Balances the operation is funded from, by token. Given, the wallet's side
|
|
18
|
-
* is checked offline; omitted, funding is left to `checkPrerequisites`.
|
|
19
|
-
*/
|
|
20
|
-
balances?: AddressMap<bigint>;
|
|
21
|
-
/**
|
|
22
|
-
* The factor the account stands at now. Given, an operation that raises it
|
|
23
|
-
* passes even from under the bar — the top-ups that rescue a position would
|
|
24
|
-
* otherwise be refused by the very check meant to protect it.
|
|
25
|
-
*/
|
|
26
|
-
currentHealthFactor?: Bps;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Whether a parsed operation may be signed at all — the protocol state that
|
|
30
|
-
* `checkPrerequisites` leaves out, since that one covers only what the sender
|
|
31
|
-
* can fix themselves.
|
|
32
|
-
*
|
|
33
|
-
* Synchronous: the preview carries the numbers and the market is attached.
|
|
34
|
-
* Reports the most fundamental issue it finds and stops there, which is the one
|
|
35
|
-
* a caller acts on.
|
|
36
|
-
*/
|
|
37
|
-
declare function checkOperation(input: {
|
|
38
|
-
sdk: OnchainSDK;
|
|
39
|
-
preview: OperationPreview;
|
|
40
|
-
}, options?: CheckOperationOptions): PreviewIssue | null;
|
|
41
|
-
/** What the market itself refuses, whatever the operation does. */
|
|
42
|
-
declare function marketIssues(suite: CreditSuite): PreviewIssue | null;
|
|
43
|
-
/**
|
|
44
|
-
* A bar that reads nothing but the projected account, so a parsed transaction
|
|
45
|
-
* and a simulated one are held to it by the same code.
|
|
46
|
-
*
|
|
47
|
-
* These stay separate functions rather than one block because the order the
|
|
48
|
-
* checks run in is the answer: `checkOperation` interleaves the checks that
|
|
49
|
-
* need an operation's *delta* between them, and the caller acts on the first
|
|
50
|
-
* issue reported.
|
|
51
|
-
*/
|
|
52
|
-
declare function quotaCountIssue(suite: CreditSuite, account: Pick<AccountProjection, "quotas">): PreviewIssue | null;
|
|
53
|
-
/**
|
|
54
|
-
* An account's factors, in whichever branch of a routed leg the caller means to
|
|
55
|
-
* be held to: `prepare` reports the outcome the router expects, `preview` the
|
|
56
|
-
* floor its calldata guarantees. The bar is indifferent — it weighs the numbers
|
|
57
|
-
* it is handed — and passing them one by one is what makes the choice visible
|
|
58
|
-
* where it is made.
|
|
59
|
-
*/
|
|
60
|
-
interface WeighedFactors extends Pick<AccountHoldings, "totalDebt">, Pick<AccountMetrics, "healthFactor" | "safeHealthFactor"> {}
|
|
61
|
-
/**
|
|
62
|
-
* The account against whichever bars the caller holds it to.
|
|
63
|
-
*
|
|
64
|
-
* A loan-free account is nothing to weigh: the health factor reports its
|
|
65
|
-
* zero-debt sentinel and no bar applies.
|
|
66
|
-
*
|
|
67
|
-
* {@inheritDoc quotaCountIssue}
|
|
68
|
-
*/
|
|
69
|
-
declare function collateralIssue(account: WeighedFactors, options: CheckOperationOptions): PreviewIssue | null;
|
|
70
|
-
//#endregion
|
|
71
|
-
export { CheckOperationOptions, WeighedFactors, checkOperation, collateralIssue, marketIssues, quotaCountIssue };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { OnchainSDK } from "../../onchain/OnchainSDK.js";
|
|
2
|
-
import { PreviewIssue } from "../../onchain/validation/refusal.js";
|
|
3
|
-
import { OperationState } from "../../onchain/accounts/intents/types.js";
|
|
4
|
-
import "../../onchain/index.js";
|
|
5
|
-
import { CheckOperationOptions } from "./checkOperation.js";
|
|
6
|
-
//#region src/preview/validate/checkSimulation.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Whether a simulated operation clears the caller's own bars.
|
|
9
|
-
*
|
|
10
|
-
* The engine holds an account to the facade's `1.0`, because its guards answer
|
|
11
|
-
* "would this revert". A form is wiser to ask for more, and the engine's own
|
|
12
|
-
* note says so — a caller wanting the stricter bar applies it itself. This is
|
|
13
|
-
* that second opinion, over the numbers the engine already reported.
|
|
14
|
-
*
|
|
15
|
-
* Three of the checks below the engine does not make at all: both health-factor
|
|
16
|
-
* bars are its own `1.0`, and the quota count it never weighs. The other two run
|
|
17
|
-
* against the same numbers the engine used, and are here so that a change in the
|
|
18
|
-
* engine cannot pass silently.
|
|
19
|
-
*
|
|
20
|
-
* What is deliberately absent: the forbidden-token, quota-limit and funding
|
|
21
|
-
* checks all need the *delta* an operation applies, and `OperationState` reports
|
|
22
|
-
* only the state after it. Weighing them against absolutes would refuse a
|
|
23
|
-
* forbidden token the account merely holds, or a quota the operation never
|
|
24
|
-
* touched. The engine performed all three during the walk, so a simulation that
|
|
25
|
-
* came back `ok` has already passed them.
|
|
26
|
-
*/
|
|
27
|
-
declare function checkSimulation(input: {
|
|
28
|
-
sdk: OnchainSDK;
|
|
29
|
-
state: OperationState;
|
|
30
|
-
}, options?: CheckOperationOptions): PreviewIssue | null;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { checkSimulation };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { CheckOperationOptions, WeighedFactors, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./checkOperation.js";
|
|
2
|
-
import { checkSimulation } from "./checkSimulation.js";
|
|
3
|
-
export { CheckOperationOptions, WeighedFactors, checkOperation, checkSimulation, collateralIssue, marketIssues, quotaCountIssue };
|