@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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
//#region src/sdk/market/credit/isStrategyCollateral.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Withdrawal and redemption phantom tokens that can never be acquired as a
|
|
5
|
+
* strategy target. Other `PHANTOM_TOKEN::*` types (Convex, Infrared, staking
|
|
6
|
+
* rewards) can.
|
|
7
|
+
*/
|
|
8
|
+
declare const NON_STRATEGY_PHANTOM_TOKEN_TYPES: readonly ["PHANTOM_TOKEN::INFINIFI_UNWIND", "PHANTOM_TOKEN::MELLOW_WITHDRAWAL", "PHANTOM_TOKEN::MIDAS_REDEMPTION", "PHANTOM_TOKEN::SECURITIZE_RD", "PHANTOM_TOKEN::UPSHIFT_WITHDRAW"];
|
|
9
|
+
/**
|
|
10
|
+
* Inputs of {@link isStrategyCollateral}, all resolved against the credit
|
|
11
|
+
* manager, market, and token metadata by the caller.
|
|
12
|
+
*/
|
|
13
|
+
interface IsStrategyCollateralProps {
|
|
14
|
+
/**
|
|
15
|
+
* Candidate collateral token.
|
|
16
|
+
**/
|
|
17
|
+
token: Address;
|
|
18
|
+
/**
|
|
19
|
+
* Credit manager underlying (debt asset).
|
|
20
|
+
**/
|
|
21
|
+
underlying: Address;
|
|
22
|
+
/**
|
|
23
|
+
* Token the market's underlying wraps (same as `underlying` on non-RWA
|
|
24
|
+
* markets).
|
|
25
|
+
*/
|
|
26
|
+
unwrappedUnderlying: Address;
|
|
27
|
+
/**
|
|
28
|
+
* Liquidation threshold of the token in this credit manager, in bps.
|
|
29
|
+
**/
|
|
30
|
+
liquidationThreshold: number;
|
|
31
|
+
/**
|
|
32
|
+
* Gearbox contract type of the token (e.g. `"PHANTOM_TOKEN::CONVEX"`).
|
|
33
|
+
* Optional — plain tokens have none.
|
|
34
|
+
*/
|
|
35
|
+
contractType?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the token itself is expired (e.g. a matured Pendle PT). Optional
|
|
38
|
+
* — treated as not expired when absent.
|
|
39
|
+
*/
|
|
40
|
+
isExpired?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Latest main oracle price for the token in USD (8 decimals), `undefined`
|
|
43
|
+
* when there is no feed. A failed answer is `0` — PriceFeedCompressor
|
|
44
|
+
* guarantees `price == 0` when `success == false`.
|
|
45
|
+
*/
|
|
46
|
+
mainPrice?: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the market still accepts quota for the token.
|
|
49
|
+
**/
|
|
50
|
+
hasActiveQuota: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether a collateral token can be the target of a leveraged strategy.
|
|
54
|
+
*
|
|
55
|
+
* A token qualifies when it
|
|
56
|
+
*
|
|
57
|
+
* - has a liquidation threshold above `0` and below `100%`, and is not the
|
|
58
|
+
* suite's underlying — borrowing an asset against itself is not a position,
|
|
59
|
+
* and an LT of `0` or at least `100%` would mean unbounded leverage;
|
|
60
|
+
* - is not the token the market's underlying wraps, which for an RWA market
|
|
61
|
+
* is the same exposure as the underlying itself (also rejected when
|
|
62
|
+
* `contractType` starts with `"RWA_UNDERLYING::"`);
|
|
63
|
+
* - is not a withdrawal or redemption phantom token listed in
|
|
64
|
+
* {@link NON_STRATEGY_PHANTOM_TOKEN_TYPES} — those only ever appear as the
|
|
65
|
+
* intermediate step of a withdrawal and cannot be acquired;
|
|
66
|
+
* - is not an expired token, e.g. a matured Pendle PT;
|
|
67
|
+
* - has a non-zero main price in the market's oracle — a zero or missing
|
|
68
|
+
* answer (e.g. a failed or zero price feed) means the position cannot be
|
|
69
|
+
* valued;
|
|
70
|
+
* - the market still accepts quota for.
|
|
71
|
+
*/
|
|
72
|
+
declare function isStrategyCollateral({ token, underlying, unwrappedUnderlying, liquidationThreshold, contractType, isExpired, mainPrice, hasActiveQuota }: IsStrategyCollateralProps): boolean;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { IsStrategyCollateralProps, NON_STRATEGY_PHANTOM_TOKEN_TYPES, isStrategyCollateral };
|
|
@@ -127,21 +127,14 @@ interface ICreditManagerContract extends IBaseContract {
|
|
|
127
127
|
* List of collateral tokens
|
|
128
128
|
*/
|
|
129
129
|
collateralTokens: Address[];
|
|
130
|
-
/**
|
|
131
|
-
* Collateral tokens a leveraged position can be built around: the underlying
|
|
132
|
-
* is excluded, because borrowing an asset against itself is not a position,
|
|
133
|
-
* and so is anything whose liquidation threshold is `0` or at least `100%`,
|
|
134
|
-
* which would mean unbounded leverage.
|
|
135
|
-
*/
|
|
136
|
-
readonly leverageableCollaterals: Address[];
|
|
137
130
|
/**
|
|
138
131
|
* Percentage of liquidated account value in bps paid to the liquidator
|
|
139
132
|
* (i.e. `100% - liquidationDiscount`).
|
|
140
133
|
*/
|
|
141
134
|
readonly liquidationPremium: Bps;
|
|
142
135
|
/**
|
|
143
|
-
* Highest leverage a collateral's liquidation threshold allows
|
|
144
|
-
* `1 / (1
|
|
136
|
+
* Highest total-value leverage a collateral's liquidation threshold allows:
|
|
137
|
+
* `(1 − 0.05) / (1 − lt)`.
|
|
145
138
|
*
|
|
146
139
|
* @param collateral - Collateral token address.
|
|
147
140
|
* @throws If the credit manager does not value the token.
|
|
@@ -56,8 +56,9 @@ import { MarketSuite, StrategyRef } from "./MarketSuite.js";
|
|
|
56
56
|
import { CreditSuite } from "./credit/CreditSuite.js";
|
|
57
57
|
import { dominantCollateral, mustGetDominantCollateral } from "./credit/dominantCollateral.js";
|
|
58
58
|
import { ExpectedBalanceDeltasProps, ExpectedOutput, expectedBalanceDeltas } from "./credit/expectedBalanceDeltas.js";
|
|
59
|
+
import { IsStrategyCollateralProps, NON_STRATEGY_PHANTOM_TOKEN_TYPES, isStrategyCollateral } from "./credit/isStrategyCollateral.js";
|
|
59
60
|
import "./credit/index.js";
|
|
60
|
-
import { ZapperData } from "./types.js";
|
|
61
|
+
import { CompressorZapperData, ZapperData } from "./types.js";
|
|
61
62
|
import { IZapperContract, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem } from "./zapper/types.js";
|
|
62
63
|
import { createZapper } from "./zapper/createZapper.js";
|
|
63
64
|
import { UnsupportedZapperFunctionError } from "./zapper/errors.js";
|
|
@@ -66,4 +67,5 @@ import { IERC20ZapperContract } from "./zapper/IERC20ZapperContract.js";
|
|
|
66
67
|
import { IETHZapperContract } from "./zapper/IETHZapperContract.js";
|
|
67
68
|
import "./zapper/index.js";
|
|
68
69
|
import { MarketRegister, MarketRegistryState, MarketRegistryStateHuman } from "./MarketRegister.js";
|
|
69
|
-
|
|
70
|
+
import { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, calcAdditionalBorrowApy, calcBorrowApy, calcMaxLeverage, calcPositionLeverage, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./math.js";
|
|
71
|
+
export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalanceDelta, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, CompressorZapperData, CreditAccountTokenQuota, CreditConfiguratorV310Contract, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DStokenData, Erc4626PriceFeedContract, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, GaugeContract, GaugeParams, GetOpenAccountRequirementsProps, IAdapterContract, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, IPoolContract, IPriceFeedContract, IPriceOracleContract, IRWAFactory, IRateKeeperContract, IUpdatablePriceFeedContract, IZapperContract, InterestRateModelType, IsStrategyCollateralProps, LatestUpdate, LinearInterestRateModelContract, LiquidationFees, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, NON_STRATEGY_PHANTOM_TOKEN_TYPES, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PlaceholderAdapterContractOptions, PoolQuotaKeeperContract, PoolSuite, PoolV310Contract, PrepareUpdateQuotasProps, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RampEvent, RateKeeperType, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyRef, type TimestampedCalldata, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZapperData, ZeroPriceFeedContract, calcAdditionalBorrowApy, calcBorrowApy, calcMaxLeverage, calcPositionLeverage, calcUtilization, createAdapter, createPriceOracle, createZapper, dominantCollateral, expectedBalanceDeltas, fetchRedstonePayloads, getRawPriceUpdates, healthFactorBps, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, minSeizedAmount, mustGetDominantCollateral, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber };
|
|
@@ -7,7 +7,8 @@ import "../../model/index.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
|
-
*
|
|
10
|
+
* // ray: 5% (0.05 × 10²⁷)
|
|
11
|
+
* rayToBps(50_000_000_000_000_000_000_000_000n) // 500 bps = 5%
|
|
11
12
|
* ```
|
|
12
13
|
**/
|
|
13
14
|
declare function rayToBps(ray: bigint): Bps;
|
|
@@ -16,6 +17,7 @@ declare function rayToBps(ray: bigint): Bps;
|
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```ts
|
|
20
|
+
* // usd: $1500.50 in 8-decimal fixed point
|
|
19
21
|
* usdToNumber(150_050_000_000n) // 1500.5
|
|
20
22
|
* ```
|
|
21
23
|
**/
|
|
@@ -26,78 +28,86 @@ declare function usdToNumber(usd: bigint): number;
|
|
|
26
28
|
*
|
|
27
29
|
* @example
|
|
28
30
|
* ```ts
|
|
29
|
-
*
|
|
31
|
+
* // borrowed: 750, total: 1000
|
|
32
|
+
* calcUtilization(750n, 1000n) // 750 / 1000 = 7500 bps = 75%
|
|
30
33
|
* ```
|
|
31
34
|
**/
|
|
32
|
-
declare function
|
|
35
|
+
declare function calcUtilization(borrowed: bigint, total: bigint): Bps;
|
|
33
36
|
/**
|
|
34
|
-
* Annual cost of debt for a credit manager, in basis points:
|
|
35
|
-
*
|
|
37
|
+
* Annual cost of debt for a credit manager, in basis points:
|
|
38
|
+
* `baseInterestRate × (1 + feeInterest)` — the pool's base rate plus the
|
|
39
|
+
* protocol's cut of the accrued interest.
|
|
36
40
|
*
|
|
37
41
|
* @param baseInterestRate - Pool base rate in ray.
|
|
38
42
|
* @param feeInterest - Credit manager interest fee in basis points.
|
|
39
43
|
*
|
|
40
44
|
* @example
|
|
41
45
|
* ```ts
|
|
42
|
-
* // 5%
|
|
43
|
-
*
|
|
46
|
+
* // baseInterestRate: 5% in ray, feeInterest: 5000 bps = 50%
|
|
47
|
+
* calcBorrowApy(50_000_000_000_000_000_000_000_000n, 5000) // 5% × 1.5 = 750 bps = 7.5%
|
|
44
48
|
* ```
|
|
45
49
|
**/
|
|
46
|
-
declare function
|
|
50
|
+
declare function calcBorrowApy(baseInterestRate: bigint, feeInterest: number): Bps;
|
|
47
51
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
* 5% safety margin subtracted from 100% in {@link calcMaxLeverage}, so a
|
|
53
|
+
* maxed position opens with HF slightly above 1.
|
|
54
|
+
**/
|
|
55
|
+
declare const MAX_LEVERAGE_BUFFER_BPS = 500;
|
|
56
|
+
/**
|
|
57
|
+
* Highest total-value leverage a liquidation threshold allows:
|
|
58
|
+
* `(100% − buffer) / (100% − liquidationThreshold)`. At HF = 1, debt is
|
|
59
|
+
* `liquidationThreshold × totalValue`, leaving `1 − liquidationThreshold` of
|
|
60
|
+
* equity per unit of exposure; the {@link MAX_LEVERAGE_BUFFER_BPS} buffer
|
|
61
|
+
* keeps the maxed position slightly away from that boundary.
|
|
53
62
|
*
|
|
54
63
|
* @example
|
|
55
64
|
* ```ts
|
|
56
|
-
*
|
|
57
|
-
*
|
|
65
|
+
* // liquidationThreshold: 9000 bps = 90%
|
|
66
|
+
* calcMaxLeverage(9000) // (1 − 0.05) / (1 − 0.9) = 9.5x total exposure
|
|
58
67
|
* ```
|
|
59
68
|
**/
|
|
60
|
-
declare function
|
|
69
|
+
declare function calcMaxLeverage(liquidationThreshold: Bps): Leverage;
|
|
61
70
|
/**
|
|
62
71
|
* Converts a credit account's health factor from the 18-decimal fixed point the
|
|
63
72
|
* contracts store to basis points.
|
|
64
73
|
*
|
|
65
|
-
*
|
|
74
|
+
* Accounts with no debt store `MAX_UINT256` on-chain; for those this
|
|
75
|
+
* returns `0`.
|
|
66
76
|
*
|
|
67
77
|
* @example
|
|
68
78
|
* ```ts
|
|
69
|
-
*
|
|
79
|
+
* // healthFactor: 1.25 in 18-decimal fixed point
|
|
80
|
+
* healthFactorBps(1_250_000_000_000_000_000n) // 12500 bps = 1.25
|
|
70
81
|
* ```
|
|
71
82
|
**/
|
|
72
83
|
declare function healthFactorBps(healthFactor: bigint): Bps;
|
|
73
84
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* Returns `0` for a position that carries no debt and for one that is
|
|
78
|
-
* underwater, where there is no equity to lever.
|
|
85
|
+
* Total-value leverage of an open position:
|
|
86
|
+
* `totalValue / (totalValue − totalDebt)`. `1` when unleveraged, `0` when
|
|
87
|
+
* underwater.
|
|
79
88
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
89
|
+
* @param totalValue - Total value of the position.
|
|
90
|
+
* @param totalDebt - Debt principal plus accrued interest and fees, same token.
|
|
82
91
|
*
|
|
83
92
|
* @example
|
|
84
93
|
* ```ts
|
|
85
|
-
*
|
|
94
|
+
* // totalValue: 100k, totalDebt: 80k → equity: 100k − 80k = 20k
|
|
95
|
+
* calcPositionLeverage(100_000n, 80_000n) // 100k / 20k = 5x
|
|
86
96
|
* ```
|
|
87
97
|
**/
|
|
88
|
-
declare function
|
|
98
|
+
declare function calcPositionLeverage(totalValue: bigint, totalDebt: bigint): Leverage;
|
|
89
99
|
/**
|
|
90
|
-
* Annual quota cost
|
|
91
|
-
*
|
|
92
|
-
*
|
|
100
|
+
* Annual quota cost on equity, in basis points:
|
|
101
|
+
* `quotaRate × (1 + feeInterest) × leverage`. Quota accrues on the whole
|
|
102
|
+
* quoted position, and the DAO takes `feeInterest` of it as with base interest.
|
|
93
103
|
*
|
|
94
104
|
* @example
|
|
95
105
|
* ```ts
|
|
96
|
-
* // 2
|
|
97
|
-
*
|
|
106
|
+
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%, leverage: 9.5x
|
|
107
|
+
* calcAdditionalBorrowApy(200, 2500, 9.5) // 2% × 1.25 × 9.5 = 2375 bps = 23.75%
|
|
98
108
|
* ```
|
|
99
109
|
**/
|
|
100
|
-
declare function
|
|
110
|
+
declare function calcAdditionalBorrowApy(quotaRate: Bps, feeInterest: Bps, leverage: Leverage): Bps;
|
|
101
111
|
/**
|
|
102
112
|
* {@link PERCENTAGE_FACTOR} less a 0.1% safety buffer.
|
|
103
113
|
*
|
|
@@ -158,4 +168,4 @@ declare function optimalRepaidAmount({ totalDebt, twvUnderlying, minDebt, optima
|
|
|
158
168
|
**/
|
|
159
169
|
declare function optimalHFForPartialLiquidation(borrowRate: bigint): bigint;
|
|
160
170
|
//#endregion
|
|
161
|
-
export { OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
171
|
+
export { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, calcAdditionalBorrowApy, calcBorrowApy, calcMaxLeverage, calcPositionLeverage, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Amount, TokenAmount } from "../../../model/primitives.js";
|
|
2
|
+
import { DelegatedMulticall } from "../../utils/viem/executeDelegatedMulticalls.js";
|
|
3
|
+
import "../../utils/viem/index.js";
|
|
2
4
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
5
|
import { CreditAccountTokensSlice, PriceOracleData } from "../../base/types.js";
|
|
4
6
|
import { PriceFeedData, PriceFeedSummary } from "../../../model/opportunities.js";
|
|
5
7
|
import "../../../model/index.js";
|
|
6
|
-
import { DelegatedMulticall } from "../../utils/viem/executeDelegatedMulticalls.js";
|
|
7
|
-
import "../../utils/viem/index.js";
|
|
8
8
|
import { PriceOracleStateHuman } from "../../types/state-human.js";
|
|
9
9
|
import { IPriceFeedContract, PriceUpdate, UpdatePriceFeedsResult } from "../pricefeeds/types.js";
|
|
10
10
|
import { PriceFeedRef } from "../pricefeeds/PriceFeedRef.js";
|
|
@@ -92,6 +92,10 @@ declare abstract class PriceOracleBaseContract<abi extends Abi | readonly unknow
|
|
|
92
92
|
* {@inheritDoc IPriceOracleContract.convertFromUSD}
|
|
93
93
|
**/
|
|
94
94
|
convertFromUSD(to: Address, amount: bigint, reserve?: boolean): bigint;
|
|
95
|
+
/**
|
|
96
|
+
* {@inheritDoc IPriceOracleContract.safeConvertToUSD}
|
|
97
|
+
**/
|
|
98
|
+
safeConvertToUSD(token: Address, amount: bigint): bigint | null;
|
|
95
99
|
/**
|
|
96
100
|
* {@inheritDoc IPriceOracleContract.safeUsdValue}
|
|
97
101
|
**/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Amount, TokenAmount } from "../../../model/primitives.js";
|
|
2
|
+
import { DelegatedMulticall } from "../../utils/viem/executeDelegatedMulticalls.js";
|
|
3
|
+
import "../../utils/viem/index.js";
|
|
2
4
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
3
5
|
import { CreditAccountTokensSlice, IBaseContract } from "../../base/types.js";
|
|
4
6
|
import { PriceFeedData, PriceFeedSummary } from "../../../model/opportunities.js";
|
|
5
7
|
import "../../../model/index.js";
|
|
6
|
-
import { DelegatedMulticall } from "../../utils/viem/executeDelegatedMulticalls.js";
|
|
7
|
-
import "../../utils/viem/index.js";
|
|
8
8
|
import { PriceOracleStateHuman } from "../../types/state-human.js";
|
|
9
9
|
import { IPriceFeedContract, PriceUpdate, UpdatePriceFeedsResult } from "../pricefeeds/types.js";
|
|
10
10
|
import { PriceFeedRef } from "../pricefeeds/PriceFeedRef.js";
|
|
@@ -134,6 +134,14 @@ interface IPriceOracleContract extends IBaseContract {
|
|
|
134
134
|
* @param reserve - Use reserve feeds instead of main.
|
|
135
135
|
**/
|
|
136
136
|
convertToUSD: (from: Address, amount: bigint, reserve?: boolean) => bigint;
|
|
137
|
+
/**
|
|
138
|
+
* Like {@link convertToUSD}, but returns `null` instead of throwing when
|
|
139
|
+
* the token cannot be priced (missing or unsuccessful feed).
|
|
140
|
+
*
|
|
141
|
+
* @param token - Token address.
|
|
142
|
+
* @param amount - Amount in token decimals.
|
|
143
|
+
**/
|
|
144
|
+
safeConvertToUSD: (token: Address, amount: bigint) => bigint | null;
|
|
137
145
|
/**
|
|
138
146
|
* Converts a USD amount to a token amount using latest known prices.
|
|
139
147
|
* @param to - Token address.
|
|
@@ -1171,6 +1171,11 @@ declare class PoolV310Contract extends BaseContract<abi> implements IPoolContrac
|
|
|
1171
1171
|
* the receiver.
|
|
1172
1172
|
*/
|
|
1173
1173
|
redeem(amount: bigint, owner: Address, receiver: Address): RawTx;
|
|
1174
|
+
/**
|
|
1175
|
+
* Burns as many of the owner's shares as it takes to send `assets` of the
|
|
1176
|
+
* underlying to the receiver.
|
|
1177
|
+
*/
|
|
1178
|
+
withdraw(assets: bigint, receiver: Address, owner: Address): RawTx;
|
|
1174
1179
|
protected stringifyFunctionParams(params: DecodeFunctionDataReturnType<abi>): string[];
|
|
1175
1180
|
}
|
|
1176
1181
|
//#endregion
|
|
@@ -153,6 +153,11 @@ interface IPoolContract extends IBaseContract {
|
|
|
153
153
|
* the receiver.
|
|
154
154
|
*/
|
|
155
155
|
redeem(amount: bigint, owner: Address, receiver: Address): RawTx;
|
|
156
|
+
/**
|
|
157
|
+
* Burns as many of the owner's shares as it takes to send `assets` of the
|
|
158
|
+
* underlying to the receiver.
|
|
159
|
+
*/
|
|
160
|
+
withdraw(assets: bigint, receiver: Address, owner: Address): RawTx;
|
|
156
161
|
}
|
|
157
162
|
type PoolQuotaKeeperContract = PoolQuotaKeeperV310Contract;
|
|
158
163
|
//#endregion
|
|
@@ -26,6 +26,19 @@ declare class RWARegistry extends SDKConstruct {
|
|
|
26
26
|
* @param rwaFactories - RWA factory contracts to query.
|
|
27
27
|
*/
|
|
28
28
|
getLoadMulticalls(configurators: Address[], rwaFactories?: Address[]): DelegatedMulticall[];
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*
|
|
32
|
+
* Returns delegated multicalls that refresh the RWA state. Unlike the other
|
|
33
|
+
* warmed caches, RWA data carries values that change between blocks (e.g. the
|
|
34
|
+
* deposit allowance and claimable amount of an on-demand liquidity provider),
|
|
35
|
+
* so it is refreshed on every SDK sync.
|
|
36
|
+
*
|
|
37
|
+
* Factories are the ones requested during attach; after hydration the chain
|
|
38
|
+
* defaults are used, since the snapshot does not carry the requested list.
|
|
39
|
+
* An attach that explicitly requested no factories stays disabled.
|
|
40
|
+
**/
|
|
41
|
+
getSyncMulticalls(): DelegatedMulticall[];
|
|
29
42
|
/**
|
|
30
43
|
* Fetches decoded investor data from the on-chain RWA compressor.
|
|
31
44
|
*
|
|
@@ -4,10 +4,14 @@ import "../base/index.js";
|
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
|
|
6
6
|
//#region src/sdk/market/types.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Single zapper as reported by the periphery compressor, before the SDK
|
|
9
|
+
* attaches the pool it belongs to and its {@link ZapperData.type}.
|
|
10
|
+
**/
|
|
7
11
|
type CompressorZapperData = Unarray<AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof peripheryCompressorAbi, "getZappers">["outputs"]>>;
|
|
8
12
|
interface ZapperData extends CompressorZapperData {
|
|
9
13
|
pool: Address;
|
|
10
14
|
type: "migration" | "rwa" | "base";
|
|
11
15
|
}
|
|
12
16
|
//#endregion
|
|
13
|
-
export { ZapperData };
|
|
17
|
+
export { CompressorZapperData, ZapperData };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, additionalBorrowApyBps, borrowApyBps, healthFactorBps, maxLeverage, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, positionLeverage, rayToBps, usdToNumber, utilizationBps } from "../market/math.js";
|
|
2
1
|
import { MultichainOpportunitiesService } from "./MultichainOpportunitiesService.js";
|
|
3
2
|
import { OpportunitiesService } from "./OpportunitiesService.js";
|
|
4
|
-
export { MultichainOpportunitiesService, OpportunitiesService
|
|
3
|
+
export { MultichainOpportunitiesService, OpportunitiesService };
|
|
@@ -30,7 +30,6 @@ declare const attachOptionsSchema: z.ZodObject<{
|
|
|
30
30
|
failOnMissingFeeds: z.ZodOptional<z.ZodBoolean>;
|
|
31
31
|
enableLogging: z.ZodOptional<z.ZodBoolean>;
|
|
32
32
|
}, z.core.$strip>>;
|
|
33
|
-
loadZappers: z.ZodOptional<z.ZodBoolean>;
|
|
34
33
|
}, z.core.$strip>;
|
|
35
34
|
/**
|
|
36
35
|
* SDK constructor options type.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { PoolPosition } from "../../model/positions.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { IPoolContract } from "../market/pool/types.js";
|
|
4
|
+
import "../market/index.js";
|
|
5
|
+
import { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, PoolServiceCallResult, PoolSimulation, RemoveLiquidityProps, SimulatePoolOperationProps, WithdrawalMetadata } from "./types.js";
|
|
4
6
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
5
7
|
import "../base/index.js";
|
|
6
8
|
import { Address } from "viem";
|
|
@@ -31,6 +33,18 @@ declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
|
31
33
|
* {@inheritDoc IPoolsService.getWithdrawalTokensOut}
|
|
32
34
|
*/
|
|
33
35
|
getWithdrawalTokensOut(pool: Address, tokenIn: Address): Address[];
|
|
36
|
+
/**
|
|
37
|
+
* {@inheritDoc IPoolsService.simulateDeposit}
|
|
38
|
+
*/
|
|
39
|
+
simulateDeposit(props: SimulatePoolOperationProps): PoolSimulation;
|
|
40
|
+
/**
|
|
41
|
+
* {@inheritDoc IPoolsService.simulateWithdraw}
|
|
42
|
+
*/
|
|
43
|
+
simulateWithdraw(props: SimulatePoolOperationProps): PoolSimulation;
|
|
44
|
+
/**
|
|
45
|
+
* {@inheritDoc IPoolsService.simulateRedeem}
|
|
46
|
+
*/
|
|
47
|
+
simulateRedeem(props: SimulatePoolOperationProps): PoolSimulation;
|
|
34
48
|
/**
|
|
35
49
|
* {@inheritDoc IPoolsService.removeLiquidity}
|
|
36
50
|
*/
|
|
@@ -44,5 +58,21 @@ declare class PoolService extends SDKConstruct implements IPoolsService {
|
|
|
44
58
|
*/
|
|
45
59
|
listPositions(props: ListPoolPositionsProps): Promise<PoolPosition[]>;
|
|
46
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Shares minted for `assets`, as `previewDeposit` would report them.
|
|
63
|
+
*
|
|
64
|
+
* Both directions convert through the diesel rate — underlying per RAY of
|
|
65
|
+
* shares — because that is the rate the pool itself divides by, and the only
|
|
66
|
+
* exact one the SDK holds: `totalAssets` is this rate multiplied out, so
|
|
67
|
+
* converting back through it costs a wei on large amounts. Rounds down, as
|
|
68
|
+
* minting does.
|
|
69
|
+
*/
|
|
70
|
+
declare function toShares(pool: IPoolContract, assets: bigint): bigint;
|
|
71
|
+
/**
|
|
72
|
+
* Shares a withdrawal of `assets` burns, as `previewWithdraw` would report
|
|
73
|
+
* them: {@link toShares} rounded the other way, since the burn has to cover
|
|
74
|
+
* the payout the caller asked for.
|
|
75
|
+
*/
|
|
76
|
+
declare function toSharesUp(pool: IPoolContract, assets: bigint): bigint;
|
|
47
77
|
//#endregion
|
|
48
|
-
export { PoolService };
|
|
78
|
+
export { PoolService, toShares, toSharesUp };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, MarketType, PoolServiceCall, PoolServiceCallResult, RemoveLiquidityProps, WithdrawalMetadata } from "./types.js";
|
|
2
|
-
import { PoolService } from "./PoolService.js";
|
|
3
|
-
export { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, MarketType, PoolService, PoolServiceCall, PoolServiceCallResult, RemoveLiquidityProps, WithdrawalMetadata };
|
|
1
|
+
import { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, MarketType, PoolServiceCall, PoolServiceCallResult, PoolSimulation, RemoveLiquidityProps, SimulatePoolOperationProps, WithdrawalMetadata } from "./types.js";
|
|
2
|
+
import { PoolService, toShares, toSharesUp } from "./PoolService.js";
|
|
3
|
+
export { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, MarketType, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, RemoveLiquidityProps, SimulatePoolOperationProps, WithdrawalMetadata, toShares, toSharesUp };
|
|
@@ -35,8 +35,8 @@ interface AddLiquidityProps {
|
|
|
35
35
|
/**
|
|
36
36
|
* Parameters for withdrawing liquidity from a Gearbox lending pool.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* A direct withdrawal goes to the pool itself; anything else is routed through
|
|
39
|
+
* a zapper that redeems the share-like token it minted.
|
|
40
40
|
**/
|
|
41
41
|
interface RemoveLiquidityProps {
|
|
42
42
|
/**
|
|
@@ -44,12 +44,21 @@ interface RemoveLiquidityProps {
|
|
|
44
44
|
**/
|
|
45
45
|
pool: Address;
|
|
46
46
|
/**
|
|
47
|
-
* Amount of
|
|
47
|
+
* Amount of underlying the wallet wants back, matching
|
|
48
|
+
* {@link PoolSimulation.tokenOut} when {@link RemoveLiquidityProps.mode} is
|
|
49
|
+
* `"withdraw"`. Amount of pool shares to burn when `mode` is `"redeem"`.
|
|
48
50
|
**/
|
|
49
51
|
amount: bigint;
|
|
50
52
|
wallet: Address;
|
|
51
53
|
permit: PermitResult | undefined;
|
|
52
54
|
meta: WithdrawalMetadata;
|
|
55
|
+
/**
|
|
56
|
+
* `withdraw` calls the pool's ERC-4626 `withdraw(assets, …)`; `redeem` calls
|
|
57
|
+
* `redeem(shares, …)` or the zapper's redeem with shares directly.
|
|
58
|
+
*
|
|
59
|
+
* @default "withdraw"
|
|
60
|
+
**/
|
|
61
|
+
mode?: "withdraw" | "redeem";
|
|
53
62
|
}
|
|
54
63
|
type MarketType = "rwa-on-demand" | "rwa-default" | "classic";
|
|
55
64
|
interface DepositMetadata {
|
|
@@ -92,6 +101,59 @@ interface WithdrawalMetadata {
|
|
|
92
101
|
*/
|
|
93
102
|
type?: MarketType;
|
|
94
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Props shared by {@link IPoolsService.simulateDeposit},
|
|
106
|
+
* {@link IPoolsService.simulateWithdraw}, and
|
|
107
|
+
* {@link IPoolsService.simulateRedeem}.
|
|
108
|
+
**/
|
|
109
|
+
interface SimulatePoolOperationProps {
|
|
110
|
+
/**
|
|
111
|
+
* Address of the Gearbox lending pool.
|
|
112
|
+
**/
|
|
113
|
+
pool: Address;
|
|
114
|
+
/**
|
|
115
|
+
* Operation amount. Means `tokenIn` on deposit and redeem, `tokenOut` on
|
|
116
|
+
* withdraw — see each method's docs.
|
|
117
|
+
**/
|
|
118
|
+
amount: bigint;
|
|
119
|
+
/**
|
|
120
|
+
* Token the user parts with. Defaults to the pool underlying for deposits and
|
|
121
|
+
* to the pool shares (diesel token) for withdrawals.
|
|
122
|
+
**/
|
|
123
|
+
tokenIn?: Address;
|
|
124
|
+
/**
|
|
125
|
+
* Token the user receives. Defaults to the only route available for `tokenIn`;
|
|
126
|
+
* required when several routes exist.
|
|
127
|
+
**/
|
|
128
|
+
tokenOut?: Address;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Both sides of a simulated pool operation, converted at the pool's current
|
|
132
|
+
* share rate.
|
|
133
|
+
**/
|
|
134
|
+
interface PoolSimulation {
|
|
135
|
+
/**
|
|
136
|
+
* Token and amount leaving the wallet — exactly what was asked for.
|
|
137
|
+
**/
|
|
138
|
+
tokenIn: Asset;
|
|
139
|
+
/**
|
|
140
|
+
* Token and amount arriving in the wallet at the rate the pool state implies.
|
|
141
|
+
**/
|
|
142
|
+
tokenOut: Asset;
|
|
143
|
+
/**
|
|
144
|
+
* Zapper the operation would be routed through; unset for direct pool
|
|
145
|
+
* operations.
|
|
146
|
+
**/
|
|
147
|
+
zapper?: Address;
|
|
148
|
+
/**
|
|
149
|
+
* Withdrawals only: underlying the pool can actually pay out right now,
|
|
150
|
+
* shaved by a hair so a withdrawal sized against it does not fail on rounding.
|
|
151
|
+
*
|
|
152
|
+
* The conversion is a rate, not a promise that the pool is liquid enough, so
|
|
153
|
+
* compare `tokenOut.balance` against this to see if the withdrawal fits.
|
|
154
|
+
**/
|
|
155
|
+
availableLiquidity?: bigint;
|
|
156
|
+
}
|
|
95
157
|
/**
|
|
96
158
|
* Props for {@link IPoolsService.listPositions}.
|
|
97
159
|
**/
|
|
@@ -158,6 +220,49 @@ interface IPoolsService {
|
|
|
158
220
|
* @param tokenOut
|
|
159
221
|
*/
|
|
160
222
|
getWithdrawalMetadata(pool: Address, tokenIn: Address, tokenOut?: Address): WithdrawalMetadata;
|
|
223
|
+
/**
|
|
224
|
+
* Simulates a deposit and reports what the wallet would receive.
|
|
225
|
+
*
|
|
226
|
+
* The ERC-4626 conversion of the pool, computed from the state the SDK already
|
|
227
|
+
* holds rather than read back from the chain, so the answer is synchronous and
|
|
228
|
+
* as fresh as the loaded market. Nothing is executed, so balances and
|
|
229
|
+
* allowances are irrelevant.
|
|
230
|
+
*
|
|
231
|
+
* A zapper leg converts one-for-one — every zapper wraps rather than trades —
|
|
232
|
+
* so a routed deposit reports the same amount as a direct one.
|
|
233
|
+
*
|
|
234
|
+
* @param props - {@link SimulatePoolOperationProps}
|
|
235
|
+
* @returns {@link PoolSimulation}
|
|
236
|
+
* @throws If the token pair has no route, or if `tokenOut` is omitted while
|
|
237
|
+
* several routes exist (RWA on-demand markets have no rate at all).
|
|
238
|
+
**/
|
|
239
|
+
simulateDeposit(props: SimulatePoolOperationProps): PoolSimulation;
|
|
240
|
+
/**
|
|
241
|
+
* Simulates a withdrawal and reports what the wallet would receive.
|
|
242
|
+
*
|
|
243
|
+
* The mirror of {@link simulateDeposit}: `amount` is the underlying the
|
|
244
|
+
* wallet wants back, and the result is the shares it costs at the pool's
|
|
245
|
+
* current rate.
|
|
246
|
+
*
|
|
247
|
+
* @param props - {@link SimulatePoolOperationProps}
|
|
248
|
+
* @returns {@link PoolSimulation}
|
|
249
|
+
* @throws If the token pair has no route, or if `tokenOut` is omitted while
|
|
250
|
+
* several routes exist.
|
|
251
|
+
**/
|
|
252
|
+
simulateWithdraw(props: SimulatePoolOperationProps): PoolSimulation;
|
|
253
|
+
/**
|
|
254
|
+
* Simulates a redemption and reports what the wallet would receive.
|
|
255
|
+
*
|
|
256
|
+
* The ERC-4626 `previewRedeem` mirror: `amount` is the shares to burn, and
|
|
257
|
+
* the result is the underlying they convert to, less the pool's withdrawal
|
|
258
|
+
* fee.
|
|
259
|
+
*
|
|
260
|
+
* @param props - {@link SimulatePoolOperationProps}
|
|
261
|
+
* @returns {@link PoolSimulation}
|
|
262
|
+
* @throws If the token pair has no route, or if `tokenOut` is omitted while
|
|
263
|
+
* several routes exist.
|
|
264
|
+
**/
|
|
265
|
+
simulateRedeem(props: SimulatePoolOperationProps): PoolSimulation;
|
|
161
266
|
/**
|
|
162
267
|
* Returns contract call parameters for adding liquidity to a pool
|
|
163
268
|
* Or undefined if no deposit action is required (e.g. for RWA underlying on demand)
|
|
@@ -174,4 +279,4 @@ interface IPoolsService {
|
|
|
174
279
|
removeLiquidity(props: RemoveLiquidityProps): PoolServiceCallResult;
|
|
175
280
|
}
|
|
176
281
|
//#endregion
|
|
177
|
-
export { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, MarketType, PoolServiceCall, PoolServiceCallResult, RemoveLiquidityProps, WithdrawalMetadata };
|
|
282
|
+
export { AddLiquidityProps, DepositMetadata, IPoolsService, ListPoolPositionsProps, MarketType, PoolServiceCall, PoolServiceCallResult, PoolSimulation, RemoveLiquidityProps, SimulatePoolOperationProps, WithdrawalMetadata };
|