@gearbox-protocol/sdk 15.1.0-next.1 → 15.1.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abi/iExpirable.js +15 -0
- package/dist/cjs/common-utils/utils/apy/get-single-quota-borrow-rate.js +2 -0
- package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +24 -22
- package/dist/cjs/common-utils/utils/creditAccount/calc-quota-borrow-rate.js +2 -0
- package/dist/cjs/common-utils/utils/creditAccount/get-time-to-liquidation.js +8 -5
- package/dist/cjs/common-utils/utils/creditAccount/liquidation-price.js +21 -11
- package/dist/cjs/dev/AccountOpener.js +0 -1
- package/dist/cjs/dev/compareOpportunities.js +218 -0
- package/dist/cjs/model/charts.js +147 -0
- package/dist/cjs/model/charts.schema.js +240 -0
- package/dist/cjs/model/index.js +35 -22
- package/dist/cjs/model/liquidations.schema.js +1 -1
- package/dist/cjs/model/notices.schema.js +25 -0
- package/dist/cjs/model/opportunities.schema.js +1 -1
- package/dist/cjs/model/positions.schema.js +48 -2
- package/dist/cjs/new-sdk/AbstractNamespace.js +34 -4
- package/dist/cjs/new-sdk/GearboxSDK.js +72 -3
- package/dist/cjs/new-sdk/execute/ExecuteApi.js +95 -0
- package/dist/cjs/new-sdk/execute/index.js +3 -0
- package/dist/cjs/new-sdk/index.js +7 -0
- package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +29 -6
- package/dist/cjs/new-sdk/positions/PositionsNamespace.js +3 -6
- package/dist/cjs/new-sdk/simulate/SimulateApi.js +361 -0
- package/dist/cjs/new-sdk/simulate/index.js +4 -0
- package/dist/cjs/new-sdk/utils/index.js +0 -1
- package/dist/cjs/offchain/AbstractOffchainNamespace.js +10 -7
- package/dist/cjs/offchain/GearboxAPI.js +7 -0
- package/dist/cjs/offchain/index.js +3 -0
- package/dist/cjs/offchain/notices/OffchainNotices.js +27 -0
- package/dist/cjs/offchain/notices/index.js +3 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +4 -8
- package/dist/cjs/offchain/positions/OffchainPositions.js +12 -12
- package/dist/cjs/preview/preview/CreditAccountState.js +14 -1
- package/dist/cjs/preview/preview/buildDelayedPreview.js +16 -6
- package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +9 -2
- package/dist/cjs/preview/preview/previewOpenCreditAccount.js +11 -3
- package/dist/cjs/preview/preview/previewOperation.js +1 -1
- package/dist/cjs/sdk/MultichainSDK.js +3 -4
- package/dist/cjs/sdk/OnchainSDK.js +42 -13
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +2 -8
- package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +2 -90
- package/dist/cjs/sdk/accounts/index.js +5 -2
- package/dist/cjs/sdk/accounts/intents/guards.js +114 -0
- package/dist/cjs/sdk/accounts/intents/index.js +216 -358
- package/dist/cjs/sdk/accounts/intents/math.js +56 -0
- package/dist/cjs/sdk/accounts/intents/open-strategy.js +133 -0
- package/dist/cjs/sdk/accounts/intents/operations.js +165 -0
- package/dist/cjs/sdk/accounts/intents/plan.js +373 -0
- package/dist/cjs/sdk/accounts/intents/realize.js +301 -0
- package/dist/cjs/sdk/accounts/intents/testing/delayed.js +50 -0
- package/dist/cjs/sdk/accounts/intents/testing/market.js +166 -0
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +194 -35
- package/dist/cjs/sdk/accounts/intents/tests/add-collateral.fixtures.js +123 -0
- package/dist/cjs/sdk/accounts/intents/tests/adjust-leverage.fixtures.js +254 -0
- package/dist/cjs/sdk/accounts/intents/tests/deposit.fixtures.js +324 -0
- package/dist/cjs/sdk/accounts/intents/tests/finish-decrease-leverage.fixtures.js +242 -0
- package/dist/cjs/sdk/accounts/intents/tests/finish-withdraw.fixtures.js +383 -0
- package/dist/cjs/sdk/accounts/intents/tests/open-strategy.fixtures.js +133 -0
- package/dist/cjs/sdk/accounts/intents/tests/withdraw-asset.fixtures.js +131 -0
- package/dist/cjs/sdk/accounts/intents/tests/withdraw.fixtures.js +426 -0
- package/dist/cjs/sdk/accounts/intents/types.js +16 -0
- package/dist/cjs/sdk/accounts/intents/utils/adjust-state-to-snapshot.js +18 -0
- package/dist/cjs/sdk/accounts/intents/utils/credit-account-slice.js +45 -0
- package/dist/cjs/sdk/accounts/intents/utils/index.js +17 -8
- package/dist/cjs/sdk/accounts/intents/utils/ledger.js +94 -0
- package/dist/cjs/sdk/accounts/intents/utils/pick-token.js +72 -0
- package/dist/cjs/sdk/accounts/intents/utils/quotas-for-update.js +27 -0
- package/dist/cjs/sdk/accounts/intents/utils/router-path.js +86 -0
- package/dist/cjs/sdk/accounts/intents/view.js +38 -0
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +0 -3
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
- package/dist/cjs/sdk/base/BaseContract.js +1 -1
- package/dist/cjs/sdk/base/TokensMeta.js +78 -27
- package/dist/cjs/sdk/index.js +30 -7
- package/dist/cjs/sdk/market/MarketRegister.js +16 -7
- package/dist/cjs/sdk/market/ZapperRegister.js +56 -25
- package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +1 -12
- package/dist/cjs/sdk/market/credit/CreditSuite.js +28 -9
- package/dist/cjs/sdk/market/credit/index.js +3 -0
- package/dist/cjs/sdk/market/credit/isStrategyCollateral.js +50 -0
- package/dist/cjs/sdk/market/index.js +17 -0
- package/dist/cjs/sdk/market/math.js +57 -44
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +10 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +15 -1
- package/dist/cjs/sdk/market/rwa/RWARegistry.js +22 -0
- package/dist/cjs/sdk/opportunities/index.js +0 -13
- package/dist/cjs/sdk/options.js +1 -5
- package/dist/cjs/sdk/pools/PoolService.js +132 -3
- package/dist/cjs/sdk/pools/index.js +2 -0
- package/dist/cjs/sdk/positions/PositionsService.js +213 -1
- package/dist/cjs/sdk/positions/calcBorrowRate.js +43 -0
- package/dist/cjs/sdk/positions/calcHealthFactor.js +52 -0
- package/dist/cjs/sdk/positions/calcLiquidationPrice.js +23 -0
- package/dist/cjs/sdk/positions/calcLiquidationPriceForTarget.js +30 -0
- package/dist/cjs/sdk/positions/calcTimeToLiquidationMs.js +19 -0
- package/dist/cjs/sdk/positions/index.js +12 -1
- package/dist/cjs/sdk/positions/types.js +31 -0
- package/dist/cjs/sdk/utils/abi-decode.js +2 -2
- package/dist/cjs/sdk/utils/viem/executeMulticallBatches.js +32 -0
- package/dist/cjs/sdk/utils/viem/index.js +2 -0
- package/dist/esm/abi/iExpirable.js +14 -0
- package/dist/esm/common-utils/utils/apy/get-single-quota-borrow-rate.js +2 -0
- package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +24 -22
- package/dist/esm/common-utils/utils/creditAccount/calc-quota-borrow-rate.js +2 -0
- package/dist/esm/common-utils/utils/creditAccount/get-time-to-liquidation.js +8 -5
- package/dist/esm/common-utils/utils/creditAccount/liquidation-price.js +21 -11
- package/dist/esm/dev/AccountOpener.js +1 -2
- package/dist/esm/dev/compareOpportunities.js +216 -0
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/charts.js +140 -0
- package/dist/esm/model/charts.schema.js +226 -0
- package/dist/esm/model/index.js +9 -7
- package/dist/esm/model/liquidations.schema.js +1 -1
- package/dist/esm/model/notices.schema.js +23 -0
- package/dist/esm/model/opportunities.schema.js +1 -1
- package/dist/esm/model/positions.schema.js +46 -4
- package/dist/esm/new-sdk/AbstractNamespace.js +34 -4
- package/dist/esm/new-sdk/GearboxSDK.js +72 -4
- package/dist/esm/new-sdk/execute/ExecuteApi.js +94 -0
- package/dist/esm/new-sdk/execute/index.js +2 -0
- package/dist/esm/new-sdk/index.js +6 -2
- package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +29 -6
- package/dist/esm/new-sdk/positions/PositionsNamespace.js +3 -6
- package/dist/esm/new-sdk/simulate/SimulateApi.js +360 -0
- package/dist/esm/new-sdk/simulate/index.js +3 -0
- package/dist/esm/new-sdk/utils/index.js +0 -1
- package/dist/esm/offchain/AbstractOffchainNamespace.js +10 -7
- package/dist/esm/offchain/GearboxAPI.js +7 -0
- package/dist/esm/offchain/index.js +3 -1
- package/dist/esm/offchain/notices/OffchainNotices.js +26 -0
- package/dist/esm/offchain/notices/index.js +2 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +4 -8
- package/dist/esm/offchain/positions/OffchainPositions.js +12 -12
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/preview/preview/CreditAccountState.js +14 -1
- package/dist/esm/preview/preview/buildDelayedPreview.js +16 -6
- package/dist/esm/preview/preview/previewAdjustCreditAccount.js +9 -2
- package/dist/esm/preview/preview/previewOpenCreditAccount.js +11 -3
- package/dist/esm/preview/preview/previewOperation.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/MultichainSDK.js +3 -4
- package/dist/esm/sdk/OnchainSDK.js +42 -13
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +4 -10
- package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +2 -90
- package/dist/esm/sdk/accounts/index.js +3 -2
- package/dist/esm/sdk/accounts/intents/guards.js +108 -0
- package/dist/esm/sdk/accounts/intents/index.js +214 -358
- package/dist/esm/sdk/accounts/intents/math.js +51 -0
- package/dist/esm/sdk/accounts/intents/open-strategy.js +132 -0
- package/dist/esm/sdk/accounts/intents/operations.js +153 -0
- package/dist/esm/sdk/accounts/intents/plan.js +361 -0
- package/dist/esm/sdk/accounts/intents/realize.js +300 -0
- package/dist/esm/sdk/accounts/intents/testing/delayed.js +38 -0
- package/dist/esm/sdk/accounts/intents/testing/market.js +148 -0
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +194 -35
- package/dist/esm/sdk/accounts/intents/tests/add-collateral.fixtures.js +110 -0
- package/dist/esm/sdk/accounts/intents/tests/adjust-leverage.fixtures.js +234 -0
- package/dist/esm/sdk/accounts/intents/tests/deposit.fixtures.js +302 -0
- package/dist/esm/sdk/accounts/intents/tests/finish-decrease-leverage.fixtures.js +220 -0
- package/dist/esm/sdk/accounts/intents/tests/finish-withdraw.fixtures.js +355 -0
- package/dist/esm/sdk/accounts/intents/tests/open-strategy.fixtures.js +119 -0
- package/dist/esm/sdk/accounts/intents/tests/withdraw-asset.fixtures.js +117 -0
- package/dist/esm/sdk/accounts/intents/tests/withdraw.fixtures.js +402 -0
- package/dist/esm/sdk/accounts/intents/types.js +16 -1
- package/dist/esm/sdk/accounts/intents/utils/adjust-state-to-snapshot.js +17 -0
- package/dist/esm/sdk/accounts/intents/utils/credit-account-slice.js +43 -0
- package/dist/esm/sdk/accounts/intents/utils/index.js +9 -7
- package/dist/esm/sdk/accounts/intents/utils/ledger.js +93 -0
- package/dist/esm/sdk/accounts/intents/utils/pick-token.js +68 -0
- package/dist/esm/sdk/accounts/intents/utils/quotas-for-update.js +27 -1
- package/dist/esm/sdk/accounts/intents/utils/router-path.js +85 -0
- package/dist/esm/sdk/accounts/intents/view.js +37 -0
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -4
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/BaseContract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +80 -29
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/index.js +13 -4
- package/dist/esm/sdk/market/MarketRegister.js +16 -7
- package/dist/esm/sdk/market/ZapperRegister.js +56 -25
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +2 -13
- package/dist/esm/sdk/market/credit/CreditSuite.js +29 -10
- package/dist/esm/sdk/market/credit/index.js +2 -1
- package/dist/esm/sdk/market/credit/isStrategyCollateral.js +48 -0
- package/dist/esm/sdk/market/index.js +3 -1
- package/dist/esm/sdk/market/math.js +52 -40
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +10 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +17 -3
- package/dist/esm/sdk/market/rwa/RWARegistry.js +22 -0
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/opportunities/index.js +1 -2
- package/dist/esm/sdk/options.js +1 -5
- package/dist/esm/sdk/pools/PoolService.js +133 -6
- package/dist/esm/sdk/pools/index.js +2 -2
- package/dist/esm/sdk/positions/PositionsService.js +213 -1
- package/dist/esm/sdk/positions/calcBorrowRate.js +42 -0
- package/dist/esm/sdk/positions/calcHealthFactor.js +51 -0
- package/dist/esm/sdk/positions/calcLiquidationPrice.js +22 -0
- package/dist/esm/sdk/positions/calcLiquidationPriceForTarget.js +29 -0
- package/dist/esm/sdk/positions/calcTimeToLiquidationMs.js +18 -0
- package/dist/esm/sdk/positions/index.js +7 -2
- package/dist/esm/sdk/positions/types.js +31 -1
- package/dist/esm/sdk/utils/abi-decode.js +2 -2
- package/dist/esm/sdk/utils/viem/executeMulticallBatches.js +31 -0
- package/dist/esm/sdk/utils/viem/index.js +2 -1
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/abi/iExpirable.d.ts +14 -0
- package/dist/types/common-utils/utils/apy/get-single-quota-borrow-rate.d.ts +2 -0
- package/dist/types/common-utils/utils/creditAccount/calc-health-factor.d.ts +3 -0
- package/dist/types/common-utils/utils/creditAccount/calc-quota-borrow-rate.d.ts +2 -0
- package/dist/types/common-utils/utils/creditAccount/get-time-to-liquidation.d.ts +6 -1
- package/dist/types/common-utils/utils/creditAccount/liquidation-price.d.ts +3 -0
- package/dist/types/dev/compareOpportunities.d.ts +153 -0
- package/dist/types/model/charts.d.ts +349 -0
- package/dist/types/model/charts.schema.d.ts +364 -0
- package/dist/types/model/index.d.ts +8 -6
- package/dist/types/model/notices.d.ts +29 -0
- package/dist/types/model/notices.schema.d.ts +23 -0
- package/dist/types/model/opportunities.d.ts +9 -9
- package/dist/types/model/positions.d.ts +133 -7
- package/dist/types/model/positions.schema.d.ts +128 -1
- package/dist/types/new-sdk/AbstractNamespace.d.ts +15 -2
- package/dist/types/new-sdk/GearboxSDK.d.ts +14 -2
- package/dist/types/new-sdk/execute/ExecuteApi.d.ts +108 -0
- package/dist/types/new-sdk/execute/index.d.ts +2 -0
- package/dist/types/new-sdk/index.d.ts +8 -4
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +19 -7
- package/dist/types/new-sdk/opportunities/types.d.ts +30 -9
- package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +4 -5
- package/dist/types/new-sdk/positions/types.d.ts +9 -9
- package/dist/types/new-sdk/simulate/SimulateApi.d.ts +90 -0
- package/dist/types/new-sdk/simulate/index.d.ts +3 -0
- package/dist/types/new-sdk/simulate/types.d.ts +508 -0
- package/dist/types/new-sdk/types.d.ts +35 -1
- package/dist/types/new-sdk/utils/index.d.ts +1 -2
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +5 -21
- package/dist/types/offchain/GearboxAPI.d.ts +6 -0
- package/dist/types/offchain/index.d.ts +4 -2
- package/dist/types/offchain/notices/OffchainNotices.d.ts +19 -0
- package/dist/types/offchain/notices/index.d.ts +2 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +8 -4
- package/dist/types/offchain/positions/OffchainPositions.d.ts +8 -6
- package/dist/types/preview/preview/CreditAccountState.d.ts +6 -0
- package/dist/types/preview/preview/buildDelayedPreview.d.ts +5 -1
- package/dist/types/preview/preview/types.d.ts +4 -2
- package/dist/types/sdk/MultichainSDK.d.ts +0 -5
- package/dist/types/sdk/OnchainSDK.d.ts +1 -5
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -7
- package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts +3 -12
- package/dist/types/sdk/accounts/credit-account-compressor/index.d.ts +2 -2
- package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +1 -19
- package/dist/types/sdk/accounts/index.d.ts +7 -5
- package/dist/types/sdk/accounts/intents/guards.d.ts +72 -0
- package/dist/types/sdk/accounts/intents/index.d.ts +130 -15
- package/dist/types/sdk/accounts/intents/math.d.ts +46 -0
- package/dist/types/sdk/accounts/intents/open-strategy.d.ts +64 -0
- package/dist/types/sdk/accounts/intents/operations.d.ts +215 -0
- package/dist/types/sdk/accounts/intents/plan.d.ts +189 -0
- package/dist/types/sdk/accounts/intents/realize.d.ts +35 -0
- package/dist/types/sdk/accounts/intents/testing/delayed.d.ts +50 -0
- package/dist/types/sdk/accounts/intents/testing/expect.d.ts +17 -21
- package/dist/types/sdk/accounts/intents/testing/market.d.ts +91 -0
- package/dist/types/sdk/accounts/intents/testing/sdk-mock.d.ts +64 -16
- package/dist/types/sdk/accounts/intents/tests/add-collateral.fixtures.d.ts +45 -0
- package/dist/types/sdk/accounts/intents/tests/adjust-leverage.fixtures.d.ts +56 -0
- package/dist/types/sdk/accounts/intents/tests/deposit.fixtures.d.ts +64 -0
- package/dist/types/sdk/accounts/intents/tests/finish-decrease-leverage.fixtures.d.ts +107 -0
- package/dist/types/sdk/accounts/intents/tests/finish-withdraw.fixtures.d.ts +136 -0
- package/dist/types/sdk/accounts/intents/tests/open-strategy.fixtures.d.ts +56 -0
- package/dist/types/sdk/accounts/intents/tests/withdraw-asset.fixtures.d.ts +60 -0
- package/dist/types/sdk/accounts/intents/tests/withdraw.fixtures.d.ts +79 -0
- package/dist/types/sdk/accounts/intents/types.d.ts +369 -43
- package/dist/types/sdk/accounts/intents/utils/adjust-state-to-snapshot.d.ts +13 -0
- package/dist/types/sdk/accounts/intents/utils/assemble-operation-calls.d.ts +1 -1
- package/dist/types/sdk/accounts/intents/utils/credit-account-slice.d.ts +29 -0
- package/dist/types/sdk/accounts/intents/utils/index.d.ts +7 -5
- package/dist/types/sdk/accounts/intents/utils/ledger.d.ts +41 -0
- package/dist/types/sdk/accounts/intents/utils/pick-token.d.ts +55 -0
- package/dist/types/sdk/accounts/intents/utils/quotas-for-update.d.ts +15 -4
- package/dist/types/sdk/accounts/intents/utils/router-path.d.ts +70 -0
- package/dist/types/sdk/accounts/intents/view.d.ts +15 -0
- package/dist/types/sdk/accounts/types.d.ts +17 -14
- package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +6 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +18 -0
- package/dist/types/sdk/base/TokensMeta.d.ts +44 -1
- package/dist/types/sdk/base/index.d.ts +2 -2
- package/dist/types/sdk/base/token-types.d.ts +12 -1
- package/dist/types/sdk/index.d.ts +28 -19
- package/dist/types/sdk/market/MarketRegister.d.ts +7 -3
- package/dist/types/sdk/market/ZapperRegister.d.ts +20 -2
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +0 -4
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +6 -3
- package/dist/types/sdk/market/credit/index.d.ts +2 -1
- package/dist/types/sdk/market/credit/isStrategyCollateral.d.ts +74 -0
- package/dist/types/sdk/market/credit/types.d.ts +2 -9
- package/dist/types/sdk/market/index.d.ts +4 -2
- package/dist/types/sdk/market/math.d.ts +44 -34
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +6 -2
- package/dist/types/sdk/market/oracle/types.d.ts +10 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +5 -0
- package/dist/types/sdk/market/pool/types.d.ts +5 -0
- package/dist/types/sdk/market/rwa/RWARegistry.d.ts +13 -0
- package/dist/types/sdk/market/types.d.ts +5 -1
- package/dist/types/sdk/opportunities/index.d.ts +1 -2
- package/dist/types/sdk/options.d.ts +0 -1
- package/dist/types/sdk/pools/PoolService.d.ts +32 -2
- package/dist/types/sdk/pools/index.d.ts +3 -3
- package/dist/types/sdk/pools/types.d.ts +109 -4
- package/dist/types/sdk/positions/PositionsService.d.ts +33 -2
- package/dist/types/sdk/positions/calcBorrowRate.d.ts +40 -0
- package/dist/types/sdk/positions/calcHealthFactor.d.ts +55 -0
- package/dist/types/sdk/positions/calcLiquidationPrice.d.ts +12 -0
- package/dist/types/sdk/positions/calcLiquidationPriceForTarget.d.ts +43 -0
- package/dist/types/sdk/positions/calcTimeToLiquidationMs.d.ts +16 -0
- package/dist/types/sdk/positions/index.d.ts +7 -2
- package/dist/types/sdk/positions/types.d.ts +58 -1
- package/dist/types/sdk/types/state.d.ts +6 -0
- package/dist/types/sdk/utils/viem/executeMulticallBatches.d.ts +39 -0
- package/dist/types/sdk/utils/viem/index.d.ts +3 -2
- package/package.json +2 -1
- package/dist/cjs/model/history.js +0 -53
- package/dist/cjs/model/history.schema.js +0 -128
- package/dist/cjs/sdk/accounts/intents/intents/index.js +0 -14
- package/dist/cjs/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.js +0 -121
- package/dist/cjs/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.js +0 -15
- package/dist/cjs/sdk/accounts/intents/intents/resume/close/close.fixtures.js +0 -108
- package/dist/cjs/sdk/accounts/intents/intents/resume/close/close.js +0 -51
- package/dist/cjs/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.js +0 -130
- package/dist/cjs/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.js +0 -83
- package/dist/cjs/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.js +0 -117
- package/dist/cjs/sdk/accounts/intents/intents/resume/deposit/deposit.js +0 -15
- package/dist/cjs/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.js +0 -95
- package/dist/cjs/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.js +0 -15
- package/dist/cjs/sdk/accounts/intents/intents/resume/index.js +0 -13
- package/dist/cjs/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.js +0 -138
- package/dist/cjs/sdk/accounts/intents/intents/resume/withdraw/withdraw.js +0 -161
- package/dist/cjs/sdk/accounts/intents/operations/add-collateral/index.js +0 -17
- package/dist/cjs/sdk/accounts/intents/operations/claim-delayed/index.js +0 -54
- package/dist/cjs/sdk/accounts/intents/operations/close-credit-account/index.js +0 -26
- package/dist/cjs/sdk/accounts/intents/operations/decrease-debt/index.js +0 -12
- package/dist/cjs/sdk/accounts/intents/operations/increase-debt/index.js +0 -12
- package/dist/cjs/sdk/accounts/intents/operations/index.js +0 -27
- package/dist/cjs/sdk/accounts/intents/operations/quota-update/index.js +0 -22
- package/dist/cjs/sdk/accounts/intents/operations/repay-credit-account/index.js +0 -22
- package/dist/cjs/sdk/accounts/intents/operations/start-delayed-withdrawal/index.js +0 -18
- package/dist/cjs/sdk/accounts/intents/operations/swap/index.js +0 -18
- package/dist/cjs/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +0 -27
- package/dist/cjs/sdk/accounts/intents/operations/withdraw-collateral/index.js +0 -43
- package/dist/cjs/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +0 -27
- package/dist/cjs/sdk/accounts/intents/quoters/close.js +0 -58
- package/dist/cjs/sdk/accounts/intents/quoters/index.js +0 -7
- package/dist/cjs/sdk/accounts/intents/quoters/swap.js +0 -79
- package/dist/cjs/sdk/accounts/intents/testing/expect.js +0 -167
- package/dist/cjs/sdk/accounts/intents/testing/resume.js +0 -172
- package/dist/cjs/sdk/accounts/intents/utils/simulate-adjust-state.js +0 -39
- package/dist/cjs/sdk/accounts/intents/utils/simulate-assets.js +0 -69
- package/dist/cjs/sdk/accounts/intents/utils/with-quota-update.js +0 -13
- package/dist/esm/model/history.js +0 -49
- package/dist/esm/model/history.schema.js +0 -116
- package/dist/esm/sdk/accounts/intents/intents/index.js +0 -8
- package/dist/esm/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.js +0 -107
- package/dist/esm/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.js +0 -14
- package/dist/esm/sdk/accounts/intents/intents/resume/close/close.fixtures.js +0 -94
- package/dist/esm/sdk/accounts/intents/intents/resume/close/close.js +0 -50
- package/dist/esm/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.js +0 -114
- package/dist/esm/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.js +0 -82
- package/dist/esm/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.js +0 -110
- package/dist/esm/sdk/accounts/intents/intents/resume/deposit/deposit.js +0 -14
- package/dist/esm/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.js +0 -88
- package/dist/esm/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.js +0 -14
- package/dist/esm/sdk/accounts/intents/intents/resume/index.js +0 -7
- package/dist/esm/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.js +0 -121
- package/dist/esm/sdk/accounts/intents/intents/resume/withdraw/withdraw.js +0 -160
- package/dist/esm/sdk/accounts/intents/operations/add-collateral/index.js +0 -16
- package/dist/esm/sdk/accounts/intents/operations/claim-delayed/index.js +0 -52
- package/dist/esm/sdk/accounts/intents/operations/close-credit-account/index.js +0 -25
- package/dist/esm/sdk/accounts/intents/operations/decrease-debt/index.js +0 -11
- package/dist/esm/sdk/accounts/intents/operations/increase-debt/index.js +0 -11
- package/dist/esm/sdk/accounts/intents/operations/index.js +0 -14
- package/dist/esm/sdk/accounts/intents/operations/quota-update/index.js +0 -21
- package/dist/esm/sdk/accounts/intents/operations/repay-credit-account/index.js +0 -21
- package/dist/esm/sdk/accounts/intents/operations/start-delayed-withdrawal/index.js +0 -17
- package/dist/esm/sdk/accounts/intents/operations/swap/index.js +0 -17
- package/dist/esm/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +0 -26
- package/dist/esm/sdk/accounts/intents/operations/withdraw-collateral/index.js +0 -42
- package/dist/esm/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +0 -26
- package/dist/esm/sdk/accounts/intents/quoters/close.js +0 -56
- package/dist/esm/sdk/accounts/intents/quoters/index.js +0 -3
- package/dist/esm/sdk/accounts/intents/quoters/swap.js +0 -77
- package/dist/esm/sdk/accounts/intents/testing/expect.js +0 -162
- package/dist/esm/sdk/accounts/intents/testing/resume.js +0 -157
- package/dist/esm/sdk/accounts/intents/utils/simulate-adjust-state.js +0 -38
- package/dist/esm/sdk/accounts/intents/utils/simulate-assets.js +0 -68
- package/dist/esm/sdk/accounts/intents/utils/with-quota-update.js +0 -12
- package/dist/types/model/history.d.ts +0 -153
- package/dist/types/model/history.schema.d.ts +0 -95
- package/dist/types/new-sdk/utils/history.d.ts +0 -18
- package/dist/types/sdk/accounts/intents/intents/index.d.ts +0 -8
- package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.d.ts +0 -13
- package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.d.ts +0 -38
- package/dist/types/sdk/accounts/intents/intents/resume/close/close.d.ts +0 -26
- package/dist/types/sdk/accounts/intents/intents/resume/close/close.fixtures.d.ts +0 -63
- package/dist/types/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.d.ts +0 -26
- package/dist/types/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.d.ts +0 -86
- package/dist/types/sdk/accounts/intents/intents/resume/deposit/deposit.d.ts +0 -13
- package/dist/types/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.d.ts +0 -48
- package/dist/types/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.d.ts +0 -13
- package/dist/types/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.d.ts +0 -46
- package/dist/types/sdk/accounts/intents/intents/resume/index.d.ts +0 -7
- package/dist/types/sdk/accounts/intents/intents/resume/withdraw/withdraw.d.ts +0 -33
- package/dist/types/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.d.ts +0 -68
- package/dist/types/sdk/accounts/intents/operations/add-collateral/index.d.ts +0 -23
- package/dist/types/sdk/accounts/intents/operations/claim-delayed/index.d.ts +0 -55
- package/dist/types/sdk/accounts/intents/operations/close-credit-account/index.d.ts +0 -22
- package/dist/types/sdk/accounts/intents/operations/decrease-debt/index.d.ts +0 -18
- package/dist/types/sdk/accounts/intents/operations/increase-debt/index.d.ts +0 -18
- package/dist/types/sdk/accounts/intents/operations/index.d.ts +0 -14
- package/dist/types/sdk/accounts/intents/operations/quota-update/index.d.ts +0 -24
- package/dist/types/sdk/accounts/intents/operations/repay-credit-account/index.d.ts +0 -31
- package/dist/types/sdk/accounts/intents/operations/start-delayed-withdrawal/index.d.ts +0 -23
- package/dist/types/sdk/accounts/intents/operations/swap/index.d.ts +0 -28
- package/dist/types/sdk/accounts/intents/operations/types.d.ts +0 -21
- package/dist/types/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.d.ts +0 -30
- package/dist/types/sdk/accounts/intents/operations/withdraw-collateral/index.d.ts +0 -36
- package/dist/types/sdk/accounts/intents/operations/wrap-rwa-collateral/index.d.ts +0 -30
- package/dist/types/sdk/accounts/intents/quoters/close.d.ts +0 -43
- package/dist/types/sdk/accounts/intents/quoters/index.d.ts +0 -3
- package/dist/types/sdk/accounts/intents/quoters/swap.d.ts +0 -43
- package/dist/types/sdk/accounts/intents/testing/resume.d.ts +0 -84
- package/dist/types/sdk/accounts/intents/utils/simulate-adjust-state.d.ts +0 -19
- package/dist/types/sdk/accounts/intents/utils/simulate-assets.d.ts +0 -21
- package/dist/types/sdk/accounts/intents/utils/with-quota-update.d.ts +0 -16
- /package/dist/cjs/{new-sdk/utils/history.js → model/notices.js} +0 -0
- /package/dist/cjs/{sdk/accounts/intents/operations → new-sdk/simulate}/types.js +0 -0
- /package/dist/esm/{new-sdk/utils/history.js → model/notices.js} +0 -0
- /package/dist/esm/{sdk/accounts/intents/operations → new-sdk/simulate}/types.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILogger } from "../sdk/types/logger.js";
|
|
2
2
|
import { ChainId } from "../model/primitives.js";
|
|
3
|
+
import { ChartBundle, ChartMetric, ChartRange } from "../model/charts.js";
|
|
3
4
|
import { ChainScopedFilter } from "../model/filters.js";
|
|
4
|
-
import { HistoryMetric, HistoryRange, HistorySeries } from "../model/history.js";
|
|
5
5
|
import { DataResponse } from "../model/response.js";
|
|
6
6
|
import { GearboxAPIOptions } from "./types.js";
|
|
7
7
|
import { z } from "zod/v4";
|
|
@@ -30,22 +30,6 @@ interface OffchainGetRequest<S extends z.ZodType> {
|
|
|
30
30
|
**/
|
|
31
31
|
schema: S;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
34
|
-
* One backend read of a historical series.
|
|
35
|
-
*
|
|
36
|
-
* @typeParam M - Metric the series carries.
|
|
37
|
-
**/
|
|
38
|
-
interface OffchainHistoryRequest<M extends HistoryMetric> {
|
|
39
|
-
/**
|
|
40
|
-
* Path of the series, metric included.
|
|
41
|
-
**/
|
|
42
|
-
path: string;
|
|
43
|
-
/**
|
|
44
|
-
* Metric the response must carry.
|
|
45
|
-
**/
|
|
46
|
-
metric: M;
|
|
47
|
-
range: HistoryRange;
|
|
48
|
-
}
|
|
49
33
|
/**
|
|
50
34
|
* Base class of every {@link GearboxAPI} namespace: issues the requests,
|
|
51
35
|
* decodes the responses and reports the failures, so that a namespace holds
|
|
@@ -71,10 +55,10 @@ declare abstract class AbstractOffchainNamespace {
|
|
|
71
55
|
**/
|
|
72
56
|
protected get<S extends z.ZodType>(request: OffchainGetRequest<S>): Promise<DataResponse<z.output<S>>>;
|
|
73
57
|
/**
|
|
74
|
-
* Reads
|
|
75
|
-
*
|
|
58
|
+
* Reads the charts of one subject: one series per metric named, onto the one
|
|
59
|
+
* grid that lets them be compared at an index.
|
|
76
60
|
**/
|
|
77
|
-
protected
|
|
61
|
+
protected readCharts<const Metrics extends readonly ChartMetric[]>(path: string, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
78
62
|
}
|
|
79
63
|
//#endregion
|
|
80
|
-
export { AbstractOffchainNamespace, OffchainGetRequest,
|
|
64
|
+
export { AbstractOffchainNamespace, OffchainGetRequest, OffchainQuery };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ChainId } from "../model/primitives.js";
|
|
2
2
|
import { GearboxAPIOptions } from "./types.js";
|
|
3
|
+
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
4
|
+
import "./notices/index.js";
|
|
3
5
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
4
6
|
import "./opportunities/index.js";
|
|
5
7
|
import { OffchainPositions } from "./positions/OffchainPositions.js";
|
|
@@ -35,6 +37,10 @@ declare class GearboxAPI {
|
|
|
35
37
|
* Namespace for the positions a wallet holds.
|
|
36
38
|
**/
|
|
37
39
|
readonly positions: OffchainPositions;
|
|
40
|
+
/**
|
|
41
|
+
* Namespace for the notices the backend attaches to entities.
|
|
42
|
+
**/
|
|
43
|
+
readonly notices: OffchainNotices;
|
|
38
44
|
constructor(options: GearboxAPIOptions);
|
|
39
45
|
}
|
|
40
46
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GearboxAPIOptions } from "./types.js";
|
|
2
|
-
import { AbstractOffchainNamespace, OffchainGetRequest,
|
|
2
|
+
import { AbstractOffchainNamespace, OffchainGetRequest, OffchainQuery } from "./AbstractOffchainNamespace.js";
|
|
3
3
|
import { backendMessage } from "./errors/backendMessage.js";
|
|
4
4
|
import { ErrorCause, errorCause } from "./errors/errorCause.js";
|
|
5
5
|
import { OffchainTransportError, OffchainTransportErrorParams } from "./errors/OffchainTransportError.js";
|
|
@@ -11,9 +11,11 @@ import { OffchainStatusError } from "./errors/OffchainStatusError.js";
|
|
|
11
11
|
import { OffchainValidationError } from "./errors/OffchainValidationError.js";
|
|
12
12
|
import { readResponseBody } from "./errors/readResponseBody.js";
|
|
13
13
|
import "./errors/index.js";
|
|
14
|
+
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
15
|
+
import "./notices/index.js";
|
|
14
16
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
15
17
|
import "./opportunities/index.js";
|
|
16
18
|
import { OffchainPositions } from "./positions/OffchainPositions.js";
|
|
17
19
|
import "./positions/index.js";
|
|
18
20
|
import { GearboxAPI } from "./GearboxAPI.js";
|
|
19
|
-
export { AbstractOffchainNamespace, ErrorCause, GearboxAPI, GearboxAPIOptions, OffchainGetRequest,
|
|
21
|
+
export { AbstractOffchainNamespace, ErrorCause, GearboxAPI, GearboxAPIOptions, OffchainGetRequest, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainQuery, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainTransportErrorParams, OffchainValidationError, backendMessage, errorCause, readResponseBody };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Notice, NoticeSubject } from "../../model/notices.js";
|
|
2
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
|
+
import { GearboxAPIOptions } from "../types.js";
|
|
4
|
+
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
5
|
+
//#region src/offchain/notices/OffchainNotices.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Backend counterpart of `sdk.notices`: banners the backend asks a consumer to
|
|
8
|
+
* show for one entity, see {@link Notice}.
|
|
9
|
+
**/
|
|
10
|
+
declare class OffchainNotices extends AbstractOffchainNamespace {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(options: GearboxAPIOptions);
|
|
13
|
+
/**
|
|
14
|
+
* The notices of one pool opportunity or one strategy position.
|
|
15
|
+
**/
|
|
16
|
+
list(subject: NoticeSubject): Promise<DataResponse<Notice[]>>;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { OffchainNotices };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
|
+
import { Opportunity, OpportunityFilter, OpportunityKey, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { GearboxAPIOptions } from "../types.js";
|
|
5
5
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
6
6
|
//#region src/offchain/opportunities/OffchainOpportunities.d.ts
|
|
7
|
+
type OpportunityChartMetricFor<K extends OpportunityKey> = {
|
|
8
|
+
pool: PoolOpportunityChartMetric;
|
|
9
|
+
strategy: StrategyOpportunityChartMetric;
|
|
10
|
+
}[K["kind"]];
|
|
7
11
|
/**
|
|
8
12
|
* Backend counterpart of the `opportunities` namespace.
|
|
9
13
|
**/
|
|
@@ -24,9 +28,9 @@ declare class OffchainOpportunities extends AbstractOffchainNamespace {
|
|
|
24
28
|
**/
|
|
25
29
|
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Charts of one opportunity: one series per metric, on a shared grid.
|
|
28
32
|
**/
|
|
29
|
-
|
|
33
|
+
getCharts<K extends OpportunityKey, const Metrics extends readonly OpportunityChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
30
34
|
}
|
|
31
35
|
//#endregion
|
|
32
36
|
export { OffchainOpportunities };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
2
|
+
import { Position, PositionKey } from "../../model/positions.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { ListPositionsPropsBase } from "../../sdk/positions/types.js";
|
|
5
5
|
import { GearboxAPIOptions } from "../types.js";
|
|
6
6
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
7
7
|
//#region src/offchain/positions/OffchainPositions.d.ts
|
|
8
|
+
type PositionChartMetricFor<K extends PositionKey> = {
|
|
9
|
+
pool: PoolPositionChartMetric;
|
|
10
|
+
strategy: StrategyPositionChartMetric;
|
|
11
|
+
}[K["kind"]];
|
|
8
12
|
/**
|
|
9
13
|
* Backend counterpart of the `positions` namespace.
|
|
10
14
|
**/
|
|
@@ -16,11 +20,9 @@ declare class OffchainPositions extends AbstractOffchainNamespace {
|
|
|
16
20
|
**/
|
|
17
21
|
list(props: ListPositionsPropsBase): Promise<DataResponse<Position[]>>;
|
|
18
22
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @returns An empty series until the backend client is implemented.
|
|
23
|
+
* Charts of one position: one series per metric, on a shared grid.
|
|
22
24
|
**/
|
|
23
|
-
|
|
25
|
+
getCharts<K extends PositionKey, const Metrics extends readonly PositionChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
24
26
|
}
|
|
25
27
|
//#endregion
|
|
26
28
|
export { OffchainPositions };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CreditAccountData } from "../../sdk/base/types.js";
|
|
2
2
|
import { AssetsMap } from "../../sdk/utils/AssetsMap.js";
|
|
3
|
+
import { AccountSnapshot } from "../../sdk/positions/types.js";
|
|
3
4
|
import "../../sdk/index.js";
|
|
4
5
|
import { Address } from "viem";
|
|
5
6
|
//#region src/preview/preview/CreditAccountState.d.ts
|
|
@@ -60,6 +61,11 @@ declare class CreditAccountState {
|
|
|
60
61
|
* balances and quotas (≤ 1 wei) filtered out.
|
|
61
62
|
*/
|
|
62
63
|
static fromCreditAccountData(ca: CreditAccountData): CreditAccountState;
|
|
64
|
+
/**
|
|
65
|
+
* Immutable snapshot of this projected state for `sdk.positions` metric
|
|
66
|
+
* methods: dust-filtered balances, all quotas, and {@link totalDebt}.
|
|
67
|
+
**/
|
|
68
|
+
toSnapshot(totalValue: bigint): AccountSnapshot;
|
|
63
69
|
clone(): CreditAccountState;
|
|
64
70
|
/**
|
|
65
71
|
* Borrows `amount` of underlying: debt, total debt and the underlying
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { OnchainSDK } from "../../sdk/OnchainSDK.js";
|
|
2
|
+
import "../../sdk/index.js";
|
|
1
3
|
import { CreditAccountState } from "./CreditAccountState.js";
|
|
2
4
|
import { DetectedDelayedOperation } from "./detectDelayedOperation.js";
|
|
3
5
|
import { InstantOperationPreview } from "./types.js";
|
|
@@ -26,7 +28,9 @@ type ConvertFn = (token: Address, to: Address, amount: bigint) => bigint;
|
|
|
26
28
|
* @param receivedToken - Token the `CLOSE_ACCOUNT` resume withdraws to the
|
|
27
29
|
* user: the unwrapped underlying (vault asset) for RWA markets, the
|
|
28
30
|
* underlying itself otherwise.
|
|
31
|
+
* @param sdk - Market data source for the position metrics of the resulting
|
|
32
|
+
* state; read synchronously, no network access.
|
|
29
33
|
*/
|
|
30
|
-
declare function buildDelayedPreview(afterInstant: CreditAccountState, before: CreditAccountState, detected: DetectedDelayedOperation, convert: ConvertFn, receivedToken: Address): InstantOperationPreview;
|
|
34
|
+
declare function buildDelayedPreview(afterInstant: CreditAccountState, before: CreditAccountState, detected: DetectedDelayedOperation, convert: ConvertFn, receivedToken: Address, sdk: OnchainSDK): InstantOperationPreview;
|
|
31
35
|
//#endregion
|
|
32
36
|
export { ConvertFn, buildDelayedPreview };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DelayedIntent } from "../../sdk/accounts/withdrawal-compressor/types.js";
|
|
2
2
|
import { Asset } from "../../sdk/base/types.js";
|
|
3
|
+
import { PositionMetrics } from "../../model/positions.js";
|
|
4
|
+
import "../../model/index.js";
|
|
3
5
|
import "../../sdk/index.js";
|
|
4
6
|
import { PoolOperationType } from "../parse/types-pools.js";
|
|
5
7
|
import "../parse/index.js";
|
|
@@ -89,7 +91,7 @@ interface PoolOperationPreview {
|
|
|
89
91
|
*/
|
|
90
92
|
error?: OperationPreviewError;
|
|
91
93
|
}
|
|
92
|
-
interface OpenCreditAccountPreview {
|
|
94
|
+
interface OpenCreditAccountPreview extends PositionMetrics {
|
|
93
95
|
operation: "OpenCreditAccount" | "RWAOpenCreditAccount";
|
|
94
96
|
/**
|
|
95
97
|
* Credit manager the account is opened in
|
|
@@ -132,7 +134,7 @@ interface OpenCreditAccountPreview {
|
|
|
132
134
|
*/
|
|
133
135
|
error?: OperationPreviewError;
|
|
134
136
|
}
|
|
135
|
-
interface AdjustCreditAccountPreview {
|
|
137
|
+
interface AdjustCreditAccountPreview extends PositionMetrics {
|
|
136
138
|
operation: "AdjustCreditAccount";
|
|
137
139
|
/**
|
|
138
140
|
* Credit manager the account is opened in
|
|
@@ -63,11 +63,6 @@ interface MultichainAttachOptions {
|
|
|
63
63
|
* Options for Redstone price-feed updates (shared cache across chains).
|
|
64
64
|
**/
|
|
65
65
|
redstone?: RedstoneOptions;
|
|
66
|
-
/**
|
|
67
|
-
* When `true`, automatically load zappers after markets are loaded during
|
|
68
|
-
* attach on every chain.
|
|
69
|
-
**/
|
|
70
|
-
loadZappers?: boolean;
|
|
71
66
|
}
|
|
72
67
|
/**
|
|
73
68
|
* Options for {@link MultichainSDK.hydrate}.
|
|
@@ -38,7 +38,7 @@ import { HttpRpcClientOptions } from "viem/utils";
|
|
|
38
38
|
* Serialised state format version, checked during hydration to detect
|
|
39
39
|
* incompatible snapshots.
|
|
40
40
|
**/
|
|
41
|
-
declare const STATE_VERSION =
|
|
41
|
+
declare const STATE_VERSION = 2;
|
|
42
42
|
/**
|
|
43
43
|
* Connection options for the underlying JSON-RPC provider.
|
|
44
44
|
*
|
|
@@ -132,10 +132,6 @@ interface AttachOptions {
|
|
|
132
132
|
* Options for Redstone price-feed updates.
|
|
133
133
|
**/
|
|
134
134
|
redstone?: RedstoneOptions;
|
|
135
|
-
/**
|
|
136
|
-
* When `true`, automatically call {@link MarketRegister.loadZappers} during attach.
|
|
137
|
-
**/
|
|
138
|
-
loadZappers?: boolean;
|
|
139
135
|
}
|
|
140
136
|
/**
|
|
141
137
|
* Options accepted by {@link OnchainSDK.hydrate}.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RequestableWithdrawal } from "./withdrawal-compressor/types.js";
|
|
2
2
|
import { Asset, CreditAccountData, CreditAccountTokensSlice, PermitResult } from "../base/types.js";
|
|
3
|
-
import { StrategyPosition } from "../../model/positions.js";
|
|
4
|
-
import "../../model/index.js";
|
|
5
3
|
import { GetOpenAccountRequirementsProps, RWAOpenAccountRequirements } from "../market/rwa/types.js";
|
|
6
4
|
import "../market/rwa/index.js";
|
|
7
5
|
import { PriceUpdate } from "../market/pricefeeds/types.js";
|
|
@@ -14,7 +12,7 @@ import { OnchainSDK } from "../OnchainSDK.js";
|
|
|
14
12
|
import "../types/index.js";
|
|
15
13
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
16
14
|
import "../base/index.js";
|
|
17
|
-
import { GetCreditAccountsOptions
|
|
15
|
+
import { GetCreditAccountsOptions } from "./credit-account-compressor/types.js";
|
|
18
16
|
import "./credit-account-compressor/index.js";
|
|
19
17
|
import "./withdrawal-compressor/index.js";
|
|
20
18
|
import { AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ClaimFarmRewardsProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, Rewards } from "./types.js";
|
|
@@ -50,10 +48,6 @@ declare class CreditAccountsServiceV310 extends SDKConstruct implements ICreditA
|
|
|
50
48
|
* {@inheritDoc ICreditAccountsService.getBorrowerCreditAccounts}
|
|
51
49
|
**/
|
|
52
50
|
getBorrowerCreditAccounts(borrower: Address, options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData<true>>>;
|
|
53
|
-
/**
|
|
54
|
-
* {@inheritDoc ICreditAccountsService.listPositions}
|
|
55
|
-
**/
|
|
56
|
-
listPositions(props: ListStrategyPositionsProps): Promise<StrategyPosition[]>;
|
|
57
51
|
/**
|
|
58
52
|
* {@inheritDoc ICreditAccountsService.getRewards}
|
|
59
53
|
**/
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { CreditAccountData } from "../../base/types.js";
|
|
2
|
-
import { StrategyPosition } from "../../../model/positions.js";
|
|
3
|
-
import "../../../model/index.js";
|
|
4
2
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
5
3
|
import "../../base/index.js";
|
|
6
|
-
import { GetCreditAccountsOptions
|
|
4
|
+
import { GetCreditAccountsOptions } from "./types.js";
|
|
7
5
|
import { Address } from "viem";
|
|
8
6
|
//#region src/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts
|
|
9
7
|
/**
|
|
10
8
|
* Reads credit accounts of the current chain.
|
|
11
9
|
*
|
|
12
10
|
* Stitches the credit account compressor together with the RWA factories (for
|
|
13
|
-
* accounts owned via an investor EOA) and
|
|
14
|
-
*
|
|
15
|
-
* either as raw account data or as {@link StrategyPosition}s.
|
|
11
|
+
* accounts owned via an investor EOA), and describes the result as raw
|
|
12
|
+
* account data.
|
|
16
13
|
*
|
|
17
14
|
* TODO: create and deploy new compressor contract onchain to avoid all this stitching
|
|
18
15
|
**/
|
|
@@ -49,12 +46,6 @@ declare class CreditAccountCompressor extends SDKConstruct {
|
|
|
49
46
|
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
50
47
|
**/
|
|
51
48
|
getBorrowerCreditAccounts(borrower: Address, options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<CreditAccountData<true>[]>;
|
|
52
|
-
/**
|
|
53
|
-
* Describes all credit accounts of a wallet as strategy positions.
|
|
54
|
-
*
|
|
55
|
-
* @param props - {@link ListStrategyPositionsProps}
|
|
56
|
-
**/
|
|
57
|
-
listPositions(props: ListStrategyPositionsProps): Promise<StrategyPosition[]>;
|
|
58
49
|
}
|
|
59
50
|
//#endregion
|
|
60
51
|
export { CreditAccountCompressor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions
|
|
1
|
+
import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions } from "./types.js";
|
|
2
2
|
import { CreditAccountCompressor } from "./CreditAccountCompressor.js";
|
|
3
3
|
import { CreditAccountCompressorV310Contract } from "./CreditAccountCompressorV310Contract.js";
|
|
4
|
-
export { CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions
|
|
4
|
+
export { CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions };
|
|
@@ -146,23 +146,5 @@ interface GetCreditAccountsOptions {
|
|
|
146
146
|
**/
|
|
147
147
|
ignoreReservePrices?: boolean;
|
|
148
148
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Props for {@link CreditAccountCompressor.listPositions}.
|
|
151
|
-
**/
|
|
152
|
-
interface ListStrategyPositionsProps {
|
|
153
|
-
/**
|
|
154
|
-
* Wallet whose credit accounts to describe. RWA accounts are resolved from
|
|
155
|
-
* the investor EOA, see {@link CreditAccountCompressor.getBorrowerCreditAccounts}.
|
|
156
|
-
**/
|
|
157
|
-
owner: Address;
|
|
158
|
-
/**
|
|
159
|
-
* Whether to include accounts that carry no debt.
|
|
160
|
-
**/
|
|
161
|
-
includeZeroDebt: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Block to read at. Defaults to the latest block.
|
|
164
|
-
**/
|
|
165
|
-
blockNumber?: bigint;
|
|
166
|
-
}
|
|
167
149
|
//#endregion
|
|
168
|
-
export { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions
|
|
150
|
+
export { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClaimableWithdrawal, CurrentWithdrawals, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
2
|
-
import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions
|
|
2
|
+
import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions } from "./credit-account-compressor/types.js";
|
|
3
3
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
4
4
|
import { CreditAccountCompressorV310Contract } from "./credit-account-compressor/CreditAccountCompressorV310Contract.js";
|
|
5
5
|
import "./credit-account-compressor/index.js";
|
|
@@ -20,12 +20,14 @@ import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
|
20
20
|
import { PeripheryCompressorV310Contract } from "./bots/PeripheryCompressorV310Contract.js";
|
|
21
21
|
import "./bots/index.js";
|
|
22
22
|
import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
23
|
+
import { OpenStrategyPreview, OpenStrategyProps } from "./intents/open-strategy.js";
|
|
24
|
+
import { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewError, IntentPreviewResult, IntentRoutesResult, OperationState, PreviewErrorReason, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, WithdrawAssetIntent, WithdrawStrategyIntent } from "./intents/types.js";
|
|
25
|
+
import { AccountCalculatorOperation } from "./intents/operations.js";
|
|
26
|
+
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
|
|
27
|
+
import { CreditAccountOperationsService, OpenStrategyPreviewResult } from "./intents/index.js";
|
|
26
28
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
27
29
|
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo } from "./liquidations/types.js";
|
|
28
30
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
29
31
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
30
32
|
import "./liquidations/index.js";
|
|
31
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, AccountToCheck, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, ClaimFarmRewardsProps, 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, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, EncodableCreditAccountOperation, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type IntentPreviewResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService,
|
|
33
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, ClaimFarmRewardsProps, 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, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawCollateralIntent, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, IntentPreviewError, type IntentPreviewResult, type IntentRoutesResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, type OperationState, PartiallyLiquidateProps, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, type PreviewErrorReason, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteRefusals, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Asset } from "../../base/types.js";
|
|
2
|
+
import { MarketSuite } from "../../market/MarketSuite.js";
|
|
3
|
+
import { CreditSuite } from "../../market/credit/CreditSuite.js";
|
|
4
|
+
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
|
+
import "../../index.js";
|
|
6
|
+
//#region src/sdk/accounts/intents/guards.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* What the market itself refuses, checked before anything is quoted.
|
|
9
|
+
*
|
|
10
|
+
* The planners answer for the arithmetic of an intent and the ledger for the
|
|
11
|
+
* balances it moves, but neither can see that the facade is paused or that the
|
|
12
|
+
* pool has run out of what it lends. On-chain those come back as a reverted
|
|
13
|
+
* multicall with a selector no form can explain, so they are read from the
|
|
14
|
+
* loaded market and reported as refusals instead.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The facade takes no multicall while it is paused or past its expiration, so
|
|
18
|
+
* every intent the engine previews would revert on arrival.
|
|
19
|
+
*/
|
|
20
|
+
declare function assertMarketOperable(suite: CreditSuite): void;
|
|
21
|
+
/**
|
|
22
|
+
* What the pool will hand this manager in one transaction: the tightest of its
|
|
23
|
+
* free liquidity, the manager's remaining debt limit and the per-block cap the
|
|
24
|
+
* facade puts on a single borrow. A zero multiplier switches borrowing off
|
|
25
|
+
* outright, which reads here as nothing being available.
|
|
26
|
+
*/
|
|
27
|
+
declare function borrowable(suite: CreditSuite): bigint;
|
|
28
|
+
/** The pool has to be able to lend what the plan means to draw. */
|
|
29
|
+
declare function assertCanBorrow(suite: CreditSuite, amount: bigint): void;
|
|
30
|
+
/**
|
|
31
|
+
* What the account is allowed to end up holding more of than it started with.
|
|
32
|
+
*
|
|
33
|
+
* A forbidden token may be sold and may leave, but its balance must not grow —
|
|
34
|
+
* the facade checks exactly that at the end of the multicall. A token the
|
|
35
|
+
* market takes no quota for is not forbidden, only worthless as collateral:
|
|
36
|
+
* buying one builds a position the collateral check cannot count, so the plan
|
|
37
|
+
* is refused before it is signed rather than after it reverts.
|
|
38
|
+
*
|
|
39
|
+
* The underlying answers to neither rule, and a phantom token is a redemption
|
|
40
|
+
* in flight rather than a holding.
|
|
41
|
+
*/
|
|
42
|
+
declare function assertGrowthAllowed(args: {
|
|
43
|
+
sdk: OnchainSDK;
|
|
44
|
+
suite: CreditSuite;
|
|
45
|
+
market: MarketSuite;
|
|
46
|
+
before: readonly Asset[];
|
|
47
|
+
after: readonly Asset[];
|
|
48
|
+
}): void;
|
|
49
|
+
/**
|
|
50
|
+
* The facade weighs the account against its debt at the end of every multicall
|
|
51
|
+
* and reverts if the collateral does not cover it, so a plan that lands the
|
|
52
|
+
* account below water is refused here.
|
|
53
|
+
*
|
|
54
|
+
* The bar is the health factor of the state the plan projects: collateral under
|
|
55
|
+
* liquidation thresholds, capped by quota, against the debt. Note that a
|
|
56
|
+
* position already underwater cannot be nursed back one step at a time — the
|
|
57
|
+
* check is on where the transaction ends, not on whether it improved things.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* The caller decides the pricing the factor was computed at: main prices, or
|
|
61
|
+
* the safe ones the facade switches to when the call hands funds over. A token
|
|
62
|
+
* whose reserve feed the SDK cannot read keeps its main price, so a plan can
|
|
63
|
+
* still be refused on-chain after passing here.
|
|
64
|
+
*/
|
|
65
|
+
declare function assertCollateralised(healthFactorBps: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* A quota can only be raised as far as the market still has room for: past the
|
|
68
|
+
* token's limit the keeper takes nothing more, whoever is asking.
|
|
69
|
+
*/
|
|
70
|
+
declare function assertQuotaHeadroom(market: MarketSuite, increases: readonly Asset[]): void;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaHeadroom, borrowable };
|