@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
|
@@ -4,6 +4,7 @@ import { DataResponse } from "../../model/response.js";
|
|
|
4
4
|
import { GearboxAPIOptions } from "../types.js";
|
|
5
5
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
6
6
|
import { IOffchainOpportunities, OpportunityChartMetricFor } from "./types.js";
|
|
7
|
+
import { Address } from "viem";
|
|
7
8
|
//#region src/offchain/opportunities/OffchainOpportunities.d.ts
|
|
8
9
|
/**
|
|
9
10
|
* Backend counterpart of the `opportunities` namespace.
|
|
@@ -22,7 +23,7 @@ declare class OffchainOpportunities extends AbstractOffchainNamespace implements
|
|
|
22
23
|
/**
|
|
23
24
|
* {@inheritDoc IOffchainOpportunities.getStrategy}
|
|
24
25
|
**/
|
|
25
|
-
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
|
+
getStrategy(key: StrategyOpportunityKey, _wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
27
|
/**
|
|
27
28
|
* {@inheritDoc IOffchainOpportunities.getTotals}
|
|
28
29
|
**/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
2
|
import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
|
+
import { Address } from "viem";
|
|
4
5
|
//#region src/offchain/opportunities/types.d.ts
|
|
5
6
|
type OpportunityChartMetricFor<K extends OpportunityKey> = {
|
|
6
7
|
pool: PoolOpportunityChartMetric;
|
|
@@ -21,8 +22,10 @@ interface IOffchainOpportunities {
|
|
|
21
22
|
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
22
23
|
/**
|
|
23
24
|
* Detailed view of one strategy opportunity.
|
|
25
|
+
*
|
|
26
|
+
* @param wallet - Optional wallet address to check KYC status for.
|
|
24
27
|
**/
|
|
25
|
-
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
28
|
+
getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
29
|
/**
|
|
27
30
|
* Protocol-wide totals across every opportunity the backend serves.
|
|
28
31
|
**/
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { RWAOpenAccountRequirements } from "../../model/rwa.js";
|
|
2
|
+
import "../../model/index.js";
|
|
1
3
|
import { RequestableWithdrawal } from "./withdrawal-compressor/types.js";
|
|
2
4
|
import { Asset, CreditAccountData, CreditAccountTokensSlice, PermitResult } from "../base/types.js";
|
|
3
|
-
import { GetOpenAccountRequirementsProps
|
|
5
|
+
import { GetOpenAccountRequirementsProps } from "../market/rwa/types.js";
|
|
4
6
|
import "../market/rwa/index.js";
|
|
5
7
|
import { PriceUpdate } from "../market/pricefeeds/types.js";
|
|
6
8
|
import { PrepareUpdateQuotasProps } from "../market/credit/types.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { InvalidDelayedIntentError } from "./withdrawal-compressor/errors.js";
|
|
2
1
|
import { ClaimableWithdrawal, CurrentWithdrawals, DelayedIntentExtended, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
3
2
|
import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions } from "./credit-account-compressor/types.js";
|
|
4
3
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
@@ -20,11 +19,10 @@ import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
|
20
19
|
import { PeripheryCompressorV310Contract } from "./bots/PeripheryCompressorV310Contract.js";
|
|
21
20
|
import "./bots/index.js";
|
|
22
21
|
import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
23
|
-
import { borrowable } from "./intents/guards.js";
|
|
24
22
|
import { LeverageBand } from "./intents/leverage-band.js";
|
|
25
23
|
import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
|
|
26
24
|
import { AccountCalculatorOperation } from "./intents/operations.js";
|
|
27
|
-
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent,
|
|
25
|
+
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
|
|
28
26
|
import { OpenStrategyProps, OpenStrategyState } from "./intents/open-strategy.js";
|
|
29
27
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
|
|
30
28
|
import { isPhantomToken } from "./intents/utils/pick-token.js";
|
|
@@ -34,4 +32,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
|
|
|
34
32
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
35
33
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
36
34
|
import "./liquidations/index.js";
|
|
37
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult,
|
|
35
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -2,7 +2,6 @@ import { Asset } from "../../base/types.js";
|
|
|
2
2
|
import { MarketSuite } from "../../market/MarketSuite.js";
|
|
3
3
|
import { CreditSuite } from "../../market/credit/CreditSuite.js";
|
|
4
4
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
|
-
import { BorrowLimitBinding } from "../../validation/refusal.js";
|
|
6
5
|
import "../../index.js";
|
|
7
6
|
//#region src/onchain/accounts/intents/guards.d.ts
|
|
8
7
|
/**
|
|
@@ -24,16 +23,6 @@ import "../../index.js";
|
|
|
24
23
|
* every intent the engine previews would revert on arrival.
|
|
25
24
|
*/
|
|
26
25
|
declare function assertMarketOperable(suite: CreditSuite): void;
|
|
27
|
-
/**
|
|
28
|
-
* What the pool will hand this manager in one transaction: the tightest of its
|
|
29
|
-
* free liquidity, the manager's remaining debt limit and the per-block cap the
|
|
30
|
-
* facade puts on a single borrow. A zero multiplier switches borrowing off
|
|
31
|
-
* outright, which reads here as nothing being available.
|
|
32
|
-
*/
|
|
33
|
-
declare function borrowable(suite: CreditSuite): {
|
|
34
|
-
limit: bigint;
|
|
35
|
-
binding: BorrowLimitBinding;
|
|
36
|
-
};
|
|
37
26
|
/** The pool has to be able to lend what the plan means to draw. */
|
|
38
27
|
declare function assertCanBorrow(sdk: OnchainSDK, suite: CreditSuite, amount: bigint): void;
|
|
39
28
|
/**
|
|
@@ -60,19 +49,20 @@ declare function assertGrowthAllowed(args: {
|
|
|
60
49
|
* and reverts if the collateral does not cover it, so a plan that lands the
|
|
61
50
|
* account below water is refused here.
|
|
62
51
|
*
|
|
63
|
-
* The
|
|
64
|
-
* would the transaction revert. It is deliberately not
|
|
65
|
-
* the three
|
|
52
|
+
* The threshold is the facade's own `1.0`, because this guard answers one
|
|
53
|
+
* question: would the transaction revert. It is deliberately not
|
|
54
|
+
* `MIN_HF_LIMITED`, and the three thresholds in this codebase are three
|
|
55
|
+
* different jobs:
|
|
66
56
|
*
|
|
67
57
|
* - here, `1.0` — what the facade enforces, so what a plan must clear to land;
|
|
68
58
|
* - `maxWithdrawCollateral` sizes at `MIN_HF_LIMITED + 2` — a *sizing* helper
|
|
69
|
-
* leaving
|
|
59
|
+
* leaving a margin, which is not the same as a validity check;
|
|
70
60
|
* - a form refuses at or below `MIN_HF_LIMITED` (`MIN_HEALTH_FACTOR_FORM`).
|
|
71
61
|
*
|
|
72
62
|
* Raising this one to `MIN_HF_LIMITED` was tried and reverted: it made
|
|
73
63
|
* `maxWithdraw` hand back a ceiling this guard then refused, and it blocked
|
|
74
64
|
* small top-ups of an account sitting in `[1.0, 1.01)` — the very operations
|
|
75
|
-
* that rescue it. A form wanting the stricter
|
|
65
|
+
* that rescue it. A form wanting the stricter threshold has `validateHF`.
|
|
76
66
|
*
|
|
77
67
|
* Note that a position already underwater cannot be nursed back one step at a
|
|
78
68
|
* time — the check is on where the transaction ends, not on whether it
|
|
@@ -89,6 +79,6 @@ declare function assertCollateralised(healthFactorBps: number, safePrices: boole
|
|
|
89
79
|
* A quota can only be raised as far as the market still has room for: past the
|
|
90
80
|
* token's limit the keeper takes nothing more, whoever is asking.
|
|
91
81
|
*/
|
|
92
|
-
declare function
|
|
82
|
+
declare function assertQuotaAvailable(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[]): void;
|
|
93
83
|
//#endregion
|
|
94
|
-
export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable,
|
|
84
|
+
export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { SDKError } from "../../../model/result.js";
|
|
2
|
+
import "../../../model/index.js";
|
|
1
3
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
2
|
-
import {
|
|
3
|
-
import { borrowable } from "./guards.js";
|
|
4
|
+
import { IntentValidationError } from "../../validation/raise.js";
|
|
4
5
|
import { LeverageBand, LeverageBandProps } from "./leverage-band.js";
|
|
5
6
|
import { AccountCalculatorOperation } from "./operations.js";
|
|
6
|
-
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent,
|
|
7
|
+
import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./types.js";
|
|
7
8
|
import { OpenStrategyProps, OpenStrategyState } from "./open-strategy.js";
|
|
8
9
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./utils/credit-account-slice.js";
|
|
9
10
|
import { isPhantomToken } from "./utils/pick-token.js";
|
|
@@ -19,7 +20,7 @@ import { Address } from "viem";
|
|
|
19
20
|
type OpenStrategyPreviewResult = {
|
|
20
21
|
ok: true;
|
|
21
22
|
state: OpenStrategyState;
|
|
22
|
-
} |
|
|
23
|
+
} | SDKError<IntentValidationError>;
|
|
23
24
|
/** An intent plus everything previewing it needs. */
|
|
24
25
|
type StartProps = StartIntentProps & {
|
|
25
26
|
intent: StartIntent;
|
|
@@ -37,15 +38,15 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
37
38
|
* Previews an operation on an existing account.
|
|
38
39
|
*
|
|
39
40
|
* @param props - Intent plus account slice, quota reserve and slippage
|
|
40
|
-
* @returns Operations, projected state and calldata, or `{ ok: false,
|
|
41
|
+
* @returns Operations, projected state and calldata, or `{ ok: false, error }`
|
|
41
42
|
* when the intent cannot be satisfied (e.g. the account lacks the source
|
|
42
43
|
* balance)
|
|
43
44
|
*/
|
|
44
45
|
startIntent(props: StartProps): Promise<IntentPreviewResult>;
|
|
45
46
|
/**
|
|
46
47
|
* Both ends of what a `WITHDRAW` can take out, in underlying: the largest
|
|
47
|
-
* partial withdrawal that keeps leverage and stays inside the facade's
|
|
48
|
-
*
|
|
48
|
+
* partial withdrawal that keeps leverage and stays inside the facade's
|
|
49
|
+
* `debtLimits`, and the net value an exit hands over. They are reported together
|
|
49
50
|
* because a withdraw form needs both — the range it may offer, and the one
|
|
50
51
|
* amount past it that is allowed — and because the distance between them is
|
|
51
52
|
* the account's own, not a constant a caller could assume.
|
|
@@ -78,8 +79,8 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
78
79
|
*
|
|
79
80
|
* A credit manager's `maxLeverage` follows from the liquidation threshold
|
|
80
81
|
* alone, so it is the same for a hundred dollars and for a million. What a
|
|
81
|
-
* given deposit reaches is decided by the debt it implies and by the
|
|
82
|
-
* the market puts that debt in — the range a leverage slider should offer.
|
|
82
|
+
* given deposit reaches is decided by the debt it implies and by the
|
|
83
|
+
* `debtLimits` the market puts that debt in — the range a leverage slider should offer.
|
|
83
84
|
*
|
|
84
85
|
* Unlike the other ceilings here this one reads no account: opening has none
|
|
85
86
|
* yet, and adjusting measures against the net value the caller already
|
|
@@ -96,9 +97,9 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
96
97
|
* while its health factor stays at `targetHF` — the ceiling a
|
|
97
98
|
* withdraw-collateral form should offer. Thresholds, prices and quota
|
|
98
99
|
* activity come from the account's market, valued the way the facade values
|
|
99
|
-
* a call that
|
|
100
|
+
* a call that withdraws collateral; zero debt frees the whole balance.
|
|
100
101
|
*
|
|
101
|
-
* The default is {@link MIN_HF_LIMITED}, the
|
|
102
|
+
* The default is {@link MIN_HF_LIMITED}, the threshold a form holds an
|
|
102
103
|
* account to.
|
|
103
104
|
*
|
|
104
105
|
* @param props - Account slice, the SDK holding its market, the collateral
|
|
@@ -115,8 +116,8 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
115
116
|
*
|
|
116
117
|
* Sits apart from {@link startIntent} because it is a different trade route,
|
|
117
118
|
* not a different intent: the request goes to the issuer instead of the
|
|
118
|
-
* router, and
|
|
119
|
-
* later. Both routes of one intent are quoted together by
|
|
119
|
+
* router, and what it sells for — hence the repayment and the withdrawal —
|
|
120
|
+
* arrives days later. Both routes of one intent are quoted together by
|
|
120
121
|
* {@link intentRoutes}; this is the one to call when the delayed route is the
|
|
121
122
|
* only one of interest.
|
|
122
123
|
*
|
|
@@ -128,7 +129,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
128
129
|
*
|
|
129
130
|
* @param props - Intent plus account slice, quota reserve and slippage
|
|
130
131
|
* @returns The request transaction, the state it ends in and what it recorded
|
|
131
|
-
* for the tail, or `{ ok: false,
|
|
132
|
+
* for the tail, or `{ ok: false, error }` — `noDelayedRoute` when this route
|
|
132
133
|
* does not exist for the account at all
|
|
133
134
|
*/
|
|
134
135
|
startDelayedIntent(props: StartIntentProps & {
|
|
@@ -141,7 +142,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
141
142
|
* Which routes an account has depends on the intent and the token it sells,
|
|
142
143
|
* and a form has to know before it can offer a choice — so both are quoted
|
|
143
144
|
* from the same request and each is reported on its own. A route the account
|
|
144
|
-
* cannot take comes back `undefined` with its
|
|
145
|
+
* cannot take comes back `undefined` with its error in `errors`; only when
|
|
145
146
|
* neither answers is the whole result `{ ok: false }`.
|
|
146
147
|
*
|
|
147
148
|
* A route that could not be quoted at all — a pathfinder with no path out of
|
|
@@ -151,7 +152,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
151
152
|
*
|
|
152
153
|
* @param props - A withdraw or adjust-leverage intent plus account slice,
|
|
153
154
|
* quota reserve and slippage
|
|
154
|
-
* @returns Whichever routes are viable, or `{ ok: false,
|
|
155
|
+
* @returns Whichever routes are viable, or `{ ok: false, error }` when none is
|
|
155
156
|
*/
|
|
156
157
|
intentRoutes(props: StartIntentProps & {
|
|
157
158
|
intent: DelayableIntent;
|
|
@@ -166,7 +167,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
166
167
|
* catch up.
|
|
167
168
|
*
|
|
168
169
|
* A claim that brought only part of what the request queued — a legacy Mellow
|
|
169
|
-
* multivault, which
|
|
170
|
+
* multivault, which hands over what it holds liquid and re-queues the rest — is
|
|
170
171
|
* served in proportion, and what it did not settle comes back as `remainder`:
|
|
171
172
|
* the withdrawal still in flight and the intent to finish it with.
|
|
172
173
|
*
|
|
@@ -185,10 +186,10 @@ declare class CreditAccountOperationsService extends SDKConstruct {
|
|
|
185
186
|
*
|
|
186
187
|
* @param props - Credit manager, wallet collateral, target token and leverage
|
|
187
188
|
* @returns Debt, position size, projected balances and quotas for both the
|
|
188
|
-
* expected and the floor branch, or `{ ok: false,
|
|
189
|
+
* expected and the floor branch, or `{ ok: false, error }` when the requested
|
|
189
190
|
* leverage or the resulting debt is not viable
|
|
190
191
|
*/
|
|
191
192
|
openStrategyIntent(props: OpenStrategyProps): Promise<OpenStrategyPreviewResult>;
|
|
192
193
|
}
|
|
193
194
|
//#endregion
|
|
194
|
-
export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, type ClaimRemainder, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type FinishIntentResult, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RepayStrategyIntent, type ResumableIntent, type
|
|
195
|
+
export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, type ClaimRemainder, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type FinishIntentResult, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RepayStrategyIntent, type ResumableIntent, type RouteErrors, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, fetchCreditAccountSlice, isPhantomToken, toCreditAccountSlice };
|
|
@@ -32,7 +32,7 @@ interface LeverageBandProps {
|
|
|
32
32
|
* A credit manager's `maxLeverage` follows from the liquidation threshold
|
|
33
33
|
* alone, so it is the same for a hundred dollars and for a million. What a
|
|
34
34
|
* given deposit reaches is decided by the debt it implies —
|
|
35
|
-
* `debt = netValue × (leverage − 1)` — and by the
|
|
35
|
+
* `debt = netValue × (leverage − 1)` — and by the `debtLimits` the market puts that
|
|
36
36
|
* debt in. This inverts that relation.
|
|
37
37
|
*
|
|
38
38
|
* Rounding is asymmetric because the forward direction truncates: the floor
|
|
@@ -13,8 +13,8 @@ interface Position {
|
|
|
13
13
|
debt: bigint;
|
|
14
14
|
collateral: bigint;
|
|
15
15
|
}
|
|
16
|
-
/** Facade
|
|
17
|
-
interface
|
|
16
|
+
/** Facade `debtLimits`: a non-zero debt must sit in `[minDebt, maxDebt]`. */
|
|
17
|
+
interface DebtLimits {
|
|
18
18
|
minDebt: bigint;
|
|
19
19
|
maxDebt: bigint;
|
|
20
20
|
}
|
|
@@ -32,17 +32,17 @@ declare function proportionalDebt(position: Position, collateralDelta: bigint):
|
|
|
32
32
|
* Largest withdrawal (in underlying) that {@link proportionalDebt} can still
|
|
33
33
|
* pay for: the repayment it implies leaves debt at or above `minDebt`, and
|
|
34
34
|
* strictly less than the collateral goes — the last unit closes the account
|
|
35
|
-
* rather than shrinks it. `0n` when the debt already sits below
|
|
35
|
+
* rather than shrinks it. `0n` when the debt already sits below `minDebt`.
|
|
36
36
|
*
|
|
37
37
|
* Solves `floor(D0 · W / C0) ≤ D0 − minDebt` for `W`.
|
|
38
38
|
*/
|
|
39
|
-
declare function maxProportionalWithdrawal(position: Position,
|
|
39
|
+
declare function maxProportionalWithdrawal(position: Position, debtLimits: DebtLimits): bigint;
|
|
40
40
|
/** Total leverage cannot drop below 1x — that would be negative debt. */
|
|
41
41
|
declare function assertLeverageAtLeastOne(leverage: bigint): void;
|
|
42
42
|
/**
|
|
43
43
|
* Rejects a debt the facade would revert on: zero is always fine (no loan at
|
|
44
44
|
* all), anything else has to sit inside `[minDebt, maxDebt]`.
|
|
45
45
|
*/
|
|
46
|
-
declare function
|
|
46
|
+
declare function assertDebtLimits(sdk: OnchainSDK, debt: bigint, debtLimits: DebtLimits, underlying: Address): void;
|
|
47
47
|
//#endregion
|
|
48
|
-
export {
|
|
48
|
+
export { DebtLimits, Position, assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage, maxProportionalWithdrawal, proportionalDebt };
|
|
@@ -165,7 +165,7 @@ declare function buildWrapRwaCollateralOperation(input: RwaLegInput): Promise<Wr
|
|
|
165
165
|
declare function buildUnwrapRwaCollateralOperation(input: RwaLegInput): Promise<UnwrapRwaCollateralOperation>;
|
|
166
166
|
/**
|
|
167
167
|
* The request that starts a redemption: spends the source token and receives
|
|
168
|
-
* the phantom token standing in for the
|
|
168
|
+
* the phantom token standing in for the claim until it matures.
|
|
169
169
|
*/
|
|
170
170
|
interface StartDelayedWithdrawalOperation {
|
|
171
171
|
type: "startDelayedWithdrawal";
|
|
@@ -173,7 +173,7 @@ interface StartDelayedWithdrawalOperation {
|
|
|
173
173
|
token: Address;
|
|
174
174
|
/** Amount of `token` the issuer burns; capped at the account balance. */
|
|
175
175
|
amountIn: bigint;
|
|
176
|
-
/** Request outputs; a delayed one is the phantom token, not the
|
|
176
|
+
/** Request outputs; a delayed one is the phantom token, not the claim. */
|
|
177
177
|
outputs: WithdrawalOutput[];
|
|
178
178
|
/** Whether anything at all has to be waited for. */
|
|
179
179
|
settlement: "instant" | "delayed";
|
|
@@ -3,7 +3,7 @@ import "../../../model/index.js";
|
|
|
3
3
|
import { ClaimableWithdrawal } from "../withdrawal-compressor/types.js";
|
|
4
4
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
5
|
import { AddCollateralIntent, AdjustLeverageIntent, DepositStrategyIntent, RepayStrategyIntent, WithdrawAssetIntent, WithdrawStrategyIntent } from "./types.js";
|
|
6
|
-
import {
|
|
6
|
+
import { DebtLimits } from "./math.js";
|
|
7
7
|
import { Address } from "viem";
|
|
8
8
|
//#region src/onchain/accounts/intents/plan.d.ts
|
|
9
9
|
/**
|
|
@@ -108,7 +108,7 @@ interface AccountView {
|
|
|
108
108
|
debt: bigint;
|
|
109
109
|
/** TVL − debt, in underlying. */
|
|
110
110
|
collateral: bigint;
|
|
111
|
-
|
|
111
|
+
debtLimits: DebtLimits;
|
|
112
112
|
balanceOf(token: Address): bigint;
|
|
113
113
|
/** Oracle conversion; unpriceable tokens contribute 0n. */
|
|
114
114
|
price(from: Address, to: Address, amount: bigint): bigint;
|
|
@@ -146,8 +146,8 @@ declare function planWithdraw(intent: Omit<WithdrawStrategyIntent, "type">, view
|
|
|
146
146
|
* Intent 2.1 against a source that cannot be sold on a DEX.
|
|
147
147
|
*
|
|
148
148
|
* Some collateral only converts through its issuer — a Securitize dsToken, a
|
|
149
|
-
* Mellow share — which answers a redemption request now and
|
|
150
|
-
* later. The trade is unchanged; what changes is that the
|
|
149
|
+
* Mellow share — which answers a redemption request now and settles days
|
|
150
|
+
* later. The trade is unchanged; what changes is that the money does not exist
|
|
151
151
|
* yet, so this half only requests the redemption:
|
|
152
152
|
*
|
|
153
153
|
* ```
|
|
@@ -174,10 +174,10 @@ declare function planFinishDecreaseLeverage(claimable: ClaimableWithdrawal, clai
|
|
|
174
174
|
amount: bigint;
|
|
175
175
|
}, view: AccountView): Step[];
|
|
176
176
|
/**
|
|
177
|
-
* The claim is split between the promised
|
|
178
|
-
* half deferred:
|
|
179
|
-
*
|
|
180
|
-
*
|
|
177
|
+
* The claim is split between the promised withdrawal `W` and the debt the
|
|
178
|
+
* leading half deferred: `W` is served first, the debt gets what is left, so a
|
|
179
|
+
* bad quote shows as leverage a touch above target rather than as a wallet paid
|
|
180
|
+
* less than it was promised.
|
|
181
181
|
*/
|
|
182
182
|
declare function planFinishWithdraw(intent: {
|
|
183
183
|
withdrawToken: Address;
|
|
@@ -191,7 +191,7 @@ declare function planFinishWithdraw(intent: {
|
|
|
191
191
|
}, view: AccountView): Step[];
|
|
192
192
|
/**
|
|
193
193
|
* The tail of an exit: the claim lands, everything the account holds is sold
|
|
194
|
-
* into the underlying, the loan is settled out of
|
|
194
|
+
* into the underlying, the loan is settled out of what it sells for and the rest
|
|
195
195
|
* goes to the wallet. The account survives it, empty and owing nothing.
|
|
196
196
|
*
|
|
197
197
|
* Nothing is quoted from the request — the same shape {@link planWithdraw}
|
|
@@ -20,7 +20,7 @@ interface TailPlan {
|
|
|
20
20
|
* tail as it is projected the moment the request is made.
|
|
21
21
|
*
|
|
22
22
|
* A claim that brought only part of what was queued is served in proportion,
|
|
23
|
-
* see {@link partialTail}: the intent's
|
|
23
|
+
* see {@link partialTail}: the intent's withdrawal and its repayment are cut to the
|
|
24
24
|
* share that arrived, and the rest of both is handed to the next claim.
|
|
25
25
|
*/
|
|
26
26
|
declare function planTail(args: {
|
|
@@ -33,7 +33,7 @@ declare function planTail(args: {
|
|
|
33
33
|
*
|
|
34
34
|
* A request is only half a withdrawal, so the state it lands in is not the
|
|
35
35
|
* answer to "what does this do to my position": the debt is still there, the
|
|
36
|
-
*
|
|
36
|
+
* withdrawal has not been made, and the position sits in a phantom token. What the
|
|
37
37
|
* caller means is the far side — and that side can be walked now, because the
|
|
38
38
|
* request already fixes the claim it will be finished from.
|
|
39
39
|
*
|
|
@@ -38,10 +38,10 @@ declare function expectAdjustPreview(result: IntentPreviewResult | DelayedStartR
|
|
|
38
38
|
expectedOps: ExpectedFlowOp[];
|
|
39
39
|
expectedCalls?: MultiCall[];
|
|
40
40
|
}): OperationState;
|
|
41
|
-
/** Asserts the preview failed
|
|
42
|
-
declare function expectPreviewError(result: IntentPreviewResult | DelayedStartResult,
|
|
41
|
+
/** Asserts the preview failed with a specific error code. */
|
|
42
|
+
declare function expectPreviewError(result: IntentPreviewResult | DelayedStartResult, code: Extract<IntentPreviewResult, {
|
|
43
43
|
ok: false;
|
|
44
|
-
}>["
|
|
44
|
+
}>["error"]["code"]): void;
|
|
45
45
|
/**
|
|
46
46
|
* What a priced list — holdings or quotas — says the account stands at for
|
|
47
47
|
* `token`. A quota is denominated in the market underlying, so this reads the
|
|
@@ -63,11 +63,11 @@ declare function buildWithdrawFinishProps(args: {
|
|
|
63
63
|
};
|
|
64
64
|
/** Matrix baseline debt: 8U. */
|
|
65
65
|
declare const M4_DEBT = 800000000n;
|
|
66
|
-
/** Matrix
|
|
66
|
+
/** Matrix withdrawal W: 1U. */
|
|
67
67
|
declare const M4_W = 100000000n;
|
|
68
68
|
/** Proportional repayment `dD = D0 * W / C0` = 4U. */
|
|
69
69
|
declare const M4_DD = 400000000n;
|
|
70
|
-
/**
|
|
70
|
+
/** Withdrawal plus repayment: 5U redeemed by the leading half. */
|
|
71
71
|
declare const M4_SPEND: bigint;
|
|
72
72
|
/** Quotable withdrawal phantom: `POS2`, 1:1 with `POS`. */
|
|
73
73
|
declare const M4_PHANTOM: `0x${string}`;
|
|
@@ -85,10 +85,10 @@ interface MatrixWithdrawTailCase {
|
|
|
85
85
|
/**
|
|
86
86
|
* Matrix 4.3 tail — the claim pays `UND` directly.
|
|
87
87
|
*
|
|
88
|
-
* MATRIX MISMATCH: the matrix
|
|
88
|
+
* MATRIX MISMATCH: the matrix withdraws first — `claim →
|
|
89
89
|
* withdrawCollateral(min(W, claim.amount)) → decreaseDebt(rest) →
|
|
90
|
-
* changeQuota`. The engine repays before
|
|
91
|
-
* keep: W)` precedes the
|
|
90
|
+
* changeQuota`. The engine repays before withdrawing (`repay(debtRepaid,
|
|
91
|
+
* keep: W)` precedes the withdrawal leg in `planFinishWithdraw`):
|
|
92
92
|
* `claim → decreaseDebt(dD) → withdrawCollateral(W) → changeQuota`.
|
|
93
93
|
* Amounts are identical; only the order differs.
|
|
94
94
|
*/
|
|
@@ -103,7 +103,7 @@ declare const case_matrix_4_3_tail: MatrixWithdrawTailCase;
|
|
|
103
103
|
*/
|
|
104
104
|
declare const case_matrix_4_4_tail: MatrixWithdrawTailCase;
|
|
105
105
|
/**
|
|
106
|
-
* Matrix 4.5 tail — 4.3 on the RWA market: unwrap before the
|
|
106
|
+
* Matrix 4.5 tail — 4.3 on the RWA market: unwrap before the withdrawal.
|
|
107
107
|
*
|
|
108
108
|
* MATRIX MISMATCH: same ordering divergence as 4.3 — the matrix expects
|
|
109
109
|
* `claim → unwrapRwaCollateral → withdrawCollateral(RWA) → decreaseDebt →
|
|
@@ -7,7 +7,7 @@ import { Address } from "viem";
|
|
|
7
7
|
//#region src/onchain/accounts/intents/tests/withdraw.fixtures.d.ts
|
|
8
8
|
/** 100 UND of value leaving the account. */
|
|
9
9
|
declare const W = 10000000000n;
|
|
10
|
-
/**
|
|
10
|
+
/** Withdrawal plus proportional repayment. */
|
|
11
11
|
declare const SPEND: bigint;
|
|
12
12
|
declare const TVL_BEFORE = 200000000000n;
|
|
13
13
|
declare const DEBT_BEFORE = 100000000000n;
|
|
@@ -28,7 +28,7 @@ interface WithdrawCase {
|
|
|
28
28
|
}
|
|
29
29
|
/** Row 1 — S = U, T = U: repay, then hand over the underlying. */
|
|
30
30
|
declare const case_und_und: WithdrawCase;
|
|
31
|
-
/** Row 2 — S = U, T = POS: repay, then route the
|
|
31
|
+
/** Row 2 — S = U, T = POS: repay, then route the withdrawal out of the underlying. */
|
|
32
32
|
declare const case_und_pos: WithdrawCase;
|
|
33
33
|
/** Row 3 — S = POS, T = U: both legs land in the underlying, so one swap covers them. */
|
|
34
34
|
declare const case_pos_und: WithdrawCase;
|
|
@@ -36,29 +36,29 @@ declare const case_pos_und: WithdrawCase;
|
|
|
36
36
|
declare const case_pos_pos: WithdrawCase;
|
|
37
37
|
/** Row 5 — S = POS, T = POS2: two independent legs out of the same source. */
|
|
38
38
|
declare const case_pos_pos2: WithdrawCase;
|
|
39
|
-
/** RWA market: the underlying
|
|
40
|
-
declare const
|
|
39
|
+
/** RWA market: the underlying withdrawal is force-unwrapped to the asset. */
|
|
40
|
+
declare const case_rwa_pos_und: WithdrawCase;
|
|
41
41
|
/** Matrix baseline: 10A of position against 8U of debt (2U collateral at 5x). */
|
|
42
42
|
declare const M4_BALANCE = 1000000000n;
|
|
43
43
|
declare const M4_DEBT = 800000000n;
|
|
44
|
-
/** Matrix
|
|
44
|
+
/** Matrix withdrawal W: 1U. */
|
|
45
45
|
declare const M4_W = 100000000n;
|
|
46
46
|
/** Proportional repayment `dD = D0 * W / C0` = 4U. */
|
|
47
47
|
declare const M4_DD = 400000000n;
|
|
48
|
-
/**
|
|
48
|
+
/** Withdrawal plus repayment: 5U liquidated in total. */
|
|
49
49
|
declare const M4_SPEND: bigint;
|
|
50
50
|
/**
|
|
51
|
-
* Matrix 4.1 — withdraw 1U, source `POS`,
|
|
51
|
+
* Matrix 4.1 — withdraw 1U, source `POS`, tokenOut `UND`.
|
|
52
52
|
*
|
|
53
|
-
* MATRIX MISMATCH: the matrix
|
|
54
|
-
* decreaseDebt → changeQuota`. The engine repays before
|
|
55
|
-
* (`repay(dD, keep: W)` precedes the
|
|
53
|
+
* MATRIX MISMATCH: the matrix withdraws first — `swap → withdrawCollateral →
|
|
54
|
+
* decreaseDebt → changeQuota`. The engine repays before withdrawing
|
|
55
|
+
* (`repay(dD, keep: W)` precedes the withdrawal leg in `planWithdraw`):
|
|
56
56
|
* `swap → decreaseDebt → withdrawCollateral → changeQuota`. Amounts are
|
|
57
57
|
* identical; only the order differs.
|
|
58
58
|
*/
|
|
59
59
|
declare const case_matrix_4_1: WithdrawCase;
|
|
60
60
|
/**
|
|
61
|
-
* Matrix 4.2 — 4.1 on the RWA market: the
|
|
61
|
+
* Matrix 4.2 — 4.1 on the RWA market: the withdrawal is unwrapped on the way out.
|
|
62
62
|
*
|
|
63
63
|
* MATRIX MISMATCH: same ordering divergence as 4.1 — the matrix expects
|
|
64
64
|
* `swap → unwrapRwaCollateral → withdrawCollateral(RWA) → decreaseDebt →
|
|
@@ -76,4 +76,4 @@ declare function buildWithdrawProps(c: WithdrawCase, sdk: OnchainSDK): {
|
|
|
76
76
|
slippage: undefined;
|
|
77
77
|
};
|
|
78
78
|
//#endregion
|
|
79
|
-
export { DEBT_AFTER, DEBT_BEFORE, M4_BALANCE, M4_DD, M4_DEBT, M4_SPEND, M4_W, QUOTA_AFTER, QUOTA_BEFORE, QUOTA_DELTA, SPEND, TVL_AFTER, TVL_BEFORE, W, WithdrawCase, buildWithdrawProps, buildWithdrawSdk, case_matrix_4_1, case_matrix_4_2, case_pos_pos, case_pos_pos2, case_pos_und,
|
|
79
|
+
export { DEBT_AFTER, DEBT_BEFORE, M4_BALANCE, M4_DD, M4_DEBT, M4_SPEND, M4_W, QUOTA_AFTER, QUOTA_BEFORE, QUOTA_DELTA, SPEND, TVL_AFTER, TVL_BEFORE, W, WithdrawCase, buildWithdrawProps, buildWithdrawSdk, case_matrix_4_1, case_matrix_4_2, case_pos_pos, case_pos_pos2, case_pos_und, case_rwa_pos_und, case_und_pos, case_und_und };
|