@gearbox-protocol/sdk 15.1.0-next.1 → 15.1.0-next.11
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 +137 -0
- package/dist/cjs/dev/comparePositions.js +183 -0
- package/dist/cjs/dev/fieldDiff.js +241 -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 +65 -45
- 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 +133 -4
- package/dist/cjs/sdk/pools/index.js +2 -0
- package/dist/cjs/sdk/positions/PositionsService.js +218 -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 +0 -1
- package/dist/esm/dev/compareOpportunities.js +135 -0
- package/dist/esm/dev/comparePositions.js +181 -0
- package/dist/esm/dev/fieldDiff.js +224 -0
- 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/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/sdk/MultichainSDK.js +3 -4
- package/dist/esm/sdk/OnchainSDK.js +42 -13
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -8
- 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 +0 -3
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
- package/dist/esm/sdk/base/BaseContract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +78 -27
- 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/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 +60 -41
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +10 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +16 -2
- package/dist/esm/sdk/market/rwa/RWARegistry.js +22 -0
- 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 +218 -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/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 +105 -0
- package/dist/types/dev/comparePositions.d.ts +149 -0
- package/dist/types/dev/fieldDiff.d.ts +167 -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 +46 -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,157 +0,0 @@
|
|
|
1
|
-
import { toBN } from "../../../utils/formatter.js";
|
|
2
|
-
import "../../../index.js";
|
|
3
|
-
import { MOCK_CLAIM_CALL, buildMockSdk } from "./sdk-mock.js";
|
|
4
|
-
//#region src/sdk/accounts/intents/testing/resume.ts
|
|
5
|
-
/**
|
|
6
|
-
* Shared kit for claim-only resume fixtures (add collateral, increase
|
|
7
|
-
* leverage, deposit, deposit+increase).
|
|
8
|
-
*
|
|
9
|
-
* Unlike the legacy props (which echoed `creditAccount.totalValue`), the
|
|
10
|
-
* service computes totalValue from CA token balances via the price oracle.
|
|
11
|
-
* Each case's base balance is therefore `postClaimTotalValue − claimed value
|
|
12
|
-
* in UND`, so the derived totalValue matches the legacy expectation exactly.
|
|
13
|
-
*/
|
|
14
|
-
const UND_DECIMALS = 8;
|
|
15
|
-
const TOK_DECIMALS = 18;
|
|
16
|
-
const UND = "0x3333333333333333333333333333333333333333";
|
|
17
|
-
const ANY = "0x1111111111111111111111111111111111111111";
|
|
18
|
-
const ANY2 = "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
|
19
|
-
const RWA_ASSET = "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
20
|
-
const RESUME_FIXTURE_PHANTOM = "0xcccccccccccccccccccccccccccccccccccccccc";
|
|
21
|
-
const CREDIT_MANAGER = "0xdddddddddddddddddddddddddddddddddddddddd";
|
|
22
|
-
const CREDIT_FACADE = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
23
|
-
const CREDIT_ACCOUNT = "0xacacacacacacacacacacacacacacacacacacacac";
|
|
24
|
-
const PRICES = {
|
|
25
|
-
[UND]: toBN("2", 8),
|
|
26
|
-
[ANY]: toBN("1", 8),
|
|
27
|
-
[ANY2]: toBN("1", 8),
|
|
28
|
-
[RWA_ASSET]: toBN("2", 8)
|
|
29
|
-
};
|
|
30
|
-
const DECIMALS = {
|
|
31
|
-
[UND]: 8,
|
|
32
|
-
[ANY]: 18,
|
|
33
|
-
[ANY2]: 18,
|
|
34
|
-
[RWA_ASSET]: 8
|
|
35
|
-
};
|
|
36
|
-
const QUOTAS = {
|
|
37
|
-
[ANY]: {
|
|
38
|
-
token: ANY,
|
|
39
|
-
rate: 500n,
|
|
40
|
-
limit: toBN("999999999999999", 18),
|
|
41
|
-
isActive: true
|
|
42
|
-
},
|
|
43
|
-
[ANY2]: {
|
|
44
|
-
token: ANY2,
|
|
45
|
-
rate: 500n,
|
|
46
|
-
limit: toBN("999999999999999", 18),
|
|
47
|
-
isActive: true
|
|
48
|
-
},
|
|
49
|
-
[RWA_ASSET]: {
|
|
50
|
-
token: RWA_ASSET,
|
|
51
|
-
rate: 500n,
|
|
52
|
-
limit: toBN("999999999999999", 8),
|
|
53
|
-
isActive: true
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const LIQUIDATION_THRESHOLDS = {
|
|
57
|
-
[UND]: 9800,
|
|
58
|
-
[ANY]: 9200,
|
|
59
|
-
[ANY2]: 9200,
|
|
60
|
-
[RWA_ASSET]: 9200
|
|
61
|
-
};
|
|
62
|
-
const MAX_DEBT = toBN("200000", 8);
|
|
63
|
-
/** Claimed proceeds converted to UND (mirrors the mock price oracle). */
|
|
64
|
-
function claimedValueInUnd(amount, token) {
|
|
65
|
-
return amount * PRICES[token] * 10n ** BigInt(8) / (PRICES[UND] * 10n ** BigInt(DECIMALS[token]));
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Mock sdk for a resume case. The fixture phantom token gets the claimed
|
|
69
|
-
* token's decimals so the offchain `toTargetDecimals` rescale stays identity
|
|
70
|
-
* (its `10n * decimals` factor is only correct for equal decimals).
|
|
71
|
-
* `closePath` configures the router `findBestClosePath` result (close resume).
|
|
72
|
-
*/
|
|
73
|
-
function buildResumeSdk(c, extras) {
|
|
74
|
-
const phantom = extras?.phantom ?? "0xcccccccccccccccccccccccccccccccccccccccc";
|
|
75
|
-
return buildMockSdk({
|
|
76
|
-
prices: {
|
|
77
|
-
...PRICES,
|
|
78
|
-
...extras?.extraPrices
|
|
79
|
-
},
|
|
80
|
-
decimals: {
|
|
81
|
-
...DECIMALS,
|
|
82
|
-
...extras?.extraDecimals,
|
|
83
|
-
[phantom]: extras?.extraDecimals?.[c.claimedToken] ?? DECIMALS[c.claimedToken]
|
|
84
|
-
},
|
|
85
|
-
quotas: QUOTAS,
|
|
86
|
-
liquidationThresholds: LIQUIDATION_THRESHOLDS,
|
|
87
|
-
maxDebt: MAX_DEBT,
|
|
88
|
-
creditManager: CREDIT_MANAGER,
|
|
89
|
-
creditFacade: CREDIT_FACADE,
|
|
90
|
-
underlying: UND,
|
|
91
|
-
closePath: extras?.closePath,
|
|
92
|
-
rwaAssets: extras?.rwaAssets
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function buildOffchainOptions(c) {
|
|
96
|
-
return {
|
|
97
|
-
kind: "offchain",
|
|
98
|
-
phantomSpent: c.claimedAmount,
|
|
99
|
-
withdrawalConfig: {
|
|
100
|
-
creditManager: CREDIT_MANAGER,
|
|
101
|
-
token: c.claimedToken,
|
|
102
|
-
withdrawalPhantomToken: RESUME_FIXTURE_PHANTOM,
|
|
103
|
-
underlying: c.claimedToken,
|
|
104
|
-
withdrawalLength: 0n
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function buildOnchainOptions(c) {
|
|
109
|
-
return {
|
|
110
|
-
kind: "onchain",
|
|
111
|
-
claimableWithdrawal: {
|
|
112
|
-
token: c.claimedToken,
|
|
113
|
-
withdrawalPhantomToken: RESUME_FIXTURE_PHANTOM,
|
|
114
|
-
withdrawalTokenSpent: c.claimedAmount,
|
|
115
|
-
outputs: [{
|
|
116
|
-
token: c.claimedToken,
|
|
117
|
-
amount: c.claimedAmount,
|
|
118
|
-
isDelayed: false
|
|
119
|
-
}],
|
|
120
|
-
claimCalls: [MOCK_CLAIM_CALL]
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function buildClaimResumeProps(args) {
|
|
125
|
-
const { intent, case: c, sdk, options } = args;
|
|
126
|
-
return {
|
|
127
|
-
intent,
|
|
128
|
-
creditAccount: {
|
|
129
|
-
creditAccount: CREDIT_ACCOUNT,
|
|
130
|
-
creditManager: CREDIT_MANAGER,
|
|
131
|
-
creditFacade: CREDIT_FACADE,
|
|
132
|
-
underlying: UND,
|
|
133
|
-
enabledTokensMask: 0n,
|
|
134
|
-
totalDebtUSD: 0n,
|
|
135
|
-
accountDebt: c.postClaimDebt,
|
|
136
|
-
tokens: [{
|
|
137
|
-
token: RESUME_FIXTURE_PHANTOM,
|
|
138
|
-
balance: c.claimedAmount,
|
|
139
|
-
quota: 0n,
|
|
140
|
-
mask: 0n,
|
|
141
|
-
success: true
|
|
142
|
-
}, ...c.baseAssets ?? [{
|
|
143
|
-
token: "0x3333333333333333333333333333333333333333",
|
|
144
|
-
balance: c.postClaimTotalValue - claimedValueInUnd(c.claimedAmount, c.claimedToken),
|
|
145
|
-
quota: 0n,
|
|
146
|
-
mask: 0n,
|
|
147
|
-
success: true
|
|
148
|
-
}]]
|
|
149
|
-
},
|
|
150
|
-
sdk,
|
|
151
|
-
quotaReserve: void 0,
|
|
152
|
-
options,
|
|
153
|
-
slippage: void 0
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
//#endregion
|
|
157
|
-
export { ANY, ANY2, CREDIT_ACCOUNT, CREDIT_FACADE, CREDIT_MANAGER, RESUME_FIXTURE_PHANTOM, RWA_ASSET, TOK_DECIMALS, UND, UND_DECIMALS, buildClaimResumeProps, buildOffchainOptions, buildOnchainOptions, buildResumeSdk, claimedValueInUnd };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { getQuotasForUpdate } from "./quotas-for-update.js";
|
|
2
|
-
import { simulateOperationAssets } from "./simulate-assets.js";
|
|
3
|
-
//#region src/sdk/accounts/intents/utils/simulate-adjust-state.ts
|
|
4
|
-
function simulateState(props) {
|
|
5
|
-
const market = props.sdk.marketRegister.findByCreditManager(props.creditAccount.creditManager);
|
|
6
|
-
const convert = (token, to, amount) => market.priceOracle.convert(token, to, amount);
|
|
7
|
-
const creditManager = props.sdk.marketRegister.findCreditManager(props.creditAccount.creditManager);
|
|
8
|
-
const { assets, totalValue, debt } = simulateOperationAssets({
|
|
9
|
-
initialAssets: props.creditAccount.tokens,
|
|
10
|
-
operations: props.operations,
|
|
11
|
-
underlyingToken: props.creditAccount.underlying,
|
|
12
|
-
debt: props.creditAccount.accountDebt,
|
|
13
|
-
convert
|
|
14
|
-
});
|
|
15
|
-
const quotaResult = getQuotasForUpdate({
|
|
16
|
-
assetsBefore: props.creditAccount.tokens,
|
|
17
|
-
assetsAfter: assets,
|
|
18
|
-
liquidationThresholds: creditManager.creditManager.liquidationThresholds,
|
|
19
|
-
quotas: market.pool.pqk.quotas,
|
|
20
|
-
initialQuotas: props.creditAccount.tokens,
|
|
21
|
-
quotaReserve: props.quotaReserve,
|
|
22
|
-
underlyingToken: props.creditAccount.underlying,
|
|
23
|
-
maxDebt: creditManager.creditFacade.maxDebt,
|
|
24
|
-
convert
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
state: {
|
|
28
|
-
kind: "adjust",
|
|
29
|
-
totalValue,
|
|
30
|
-
accountDebt: debt,
|
|
31
|
-
assets,
|
|
32
|
-
quotas: quotaResult.desiredQuota
|
|
33
|
-
},
|
|
34
|
-
quotaResult
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
export { simulateState };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { BigIntMath } from "../../../utils/bigint-math.js";
|
|
2
|
-
//#region src/sdk/accounts/intents/utils/simulate-assets.ts
|
|
3
|
-
/** Apply an op chain to CA token balances. Address keys are lowercased. */
|
|
4
|
-
function simulateOperationAssets({ initialAssets, operations, underlyingToken, debt, convert }) {
|
|
5
|
-
let debtAfter = debt;
|
|
6
|
-
const balances = /* @__PURE__ */ new Map();
|
|
7
|
-
for (const asset of initialAssets) {
|
|
8
|
-
const token = asset.token.toLowerCase();
|
|
9
|
-
balances.set(token, (balances.get(token) ?? 0n) + asset.balance);
|
|
10
|
-
}
|
|
11
|
-
const get = (token) => balances.get(token.toLowerCase()) ?? 0n;
|
|
12
|
-
const set = (token, balance) => {
|
|
13
|
-
const key = token.toLowerCase();
|
|
14
|
-
if (balance <= 0n) balances.delete(key);
|
|
15
|
-
else balances.set(key, balance);
|
|
16
|
-
};
|
|
17
|
-
for (const op of operations) switch (op.type) {
|
|
18
|
-
case "changeQuota":
|
|
19
|
-
case "closeCreditAccount":
|
|
20
|
-
case "repayCreditAccount": break;
|
|
21
|
-
case "increaseDebt":
|
|
22
|
-
debtAfter = debtAfter + op.amount;
|
|
23
|
-
set(underlyingToken, get(underlyingToken) + op.amount);
|
|
24
|
-
break;
|
|
25
|
-
case "decreaseDebt":
|
|
26
|
-
debtAfter = BigIntMath.max(0n, debtAfter - op.amount);
|
|
27
|
-
set(underlyingToken, get(underlyingToken) - op.amount);
|
|
28
|
-
break;
|
|
29
|
-
case "addCollateral":
|
|
30
|
-
set(op.token, get(op.token) + op.amount);
|
|
31
|
-
break;
|
|
32
|
-
case "withdrawCollateral":
|
|
33
|
-
set(op.token, get(op.token) - op.amount);
|
|
34
|
-
break;
|
|
35
|
-
case "swap":
|
|
36
|
-
for (const swapInput of op.from) set(swapInput.token, get(swapInput.token) - swapInput.balance);
|
|
37
|
-
set(op.tokenOut, get(op.tokenOut) + op.amountOut);
|
|
38
|
-
break;
|
|
39
|
-
case "wrapRwaCollateral":
|
|
40
|
-
set(op.tokenIn, get(op.tokenIn) - op.amount);
|
|
41
|
-
set(op.tokenOut, get(op.tokenOut) + op.amountOut);
|
|
42
|
-
break;
|
|
43
|
-
case "unwrapRwaCollateral":
|
|
44
|
-
set(op.tokenIn, get(op.tokenIn) - op.amount);
|
|
45
|
-
set(op.tokenOut, get(op.tokenOut) + op.amountOut);
|
|
46
|
-
break;
|
|
47
|
-
case "startDelayedWithdrawal":
|
|
48
|
-
set(op.token, get(op.token) - op.amountIn);
|
|
49
|
-
for (const out of op.outputs) set(out.token, get(out.token) + out.amount);
|
|
50
|
-
break;
|
|
51
|
-
case "claimDelayedWithdrawal":
|
|
52
|
-
set(op.withdrawalPhantomToken, get(op.withdrawalPhantomToken) - op.withdrawalTokenSpent);
|
|
53
|
-
for (const out of op.outputs) set(out.token, get(out.token) + out.amount);
|
|
54
|
-
}
|
|
55
|
-
const assets = [...balances.entries()].map(([token, balance]) => ({
|
|
56
|
-
token: token.toLowerCase(),
|
|
57
|
-
balance
|
|
58
|
-
}));
|
|
59
|
-
return {
|
|
60
|
-
assets,
|
|
61
|
-
totalValue: assets.reduce((acc, a) => {
|
|
62
|
-
return acc + convert(a.token, underlyingToken, a.balance);
|
|
63
|
-
}, 0n),
|
|
64
|
-
debt: debtAfter
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
export { simulateOperationAssets };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { buildQuotaUpdateOperation } from "../operations/quota-update/index.js";
|
|
2
|
-
import "../operations/index.js";
|
|
3
|
-
//#region src/sdk/accounts/intents/utils/with-quota-update.ts
|
|
4
|
-
function getOperationsWithQuotaUpdate({ operations: coreOps, state, creditAccount, sdk, options }) {
|
|
5
|
-
return state.quotaResult.quotaIncrease.length + state.quotaResult.quotaDecrease.length === 0 ? coreOps : [...coreOps, buildQuotaUpdateOperation({
|
|
6
|
-
update: state.quotaResult,
|
|
7
|
-
creditAccount,
|
|
8
|
-
sdk
|
|
9
|
-
}, options)];
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { getOperationsWithQuotaUpdate };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Timestamp } from "./primitives.js";
|
|
2
|
-
import { OpportunityKey } from "./opportunities.js";
|
|
3
|
-
import { PositionKey } from "./positions.js";
|
|
4
|
-
//#region src/model/history.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Historical time series of an opportunity.
|
|
7
|
-
*
|
|
8
|
-
* History is backend-only by construction: the chain serves the present, and
|
|
9
|
-
* reconstructing a series from it would mean archive-node reads per point.
|
|
10
|
-
**/
|
|
11
|
-
/**
|
|
12
|
-
* Time window a series covers, ending at the present.
|
|
13
|
-
*
|
|
14
|
-
* `"max"` is the full history the backend retains for the opportunity.
|
|
15
|
-
**/
|
|
16
|
-
type HistoryRange = "1d" | "1w" | "1m" | "1y" | "max";
|
|
17
|
-
/**
|
|
18
|
-
* Series available for a pool opportunity.
|
|
19
|
-
**/
|
|
20
|
-
type PoolHistoryMetric = "depositApy" | "borrowApy" | "dieselRate" | "supplied" | "borrowed" | "availableLiquidity";
|
|
21
|
-
/**
|
|
22
|
-
* Every {@link PoolHistoryMetric}, for callers that enumerate them.
|
|
23
|
-
**/
|
|
24
|
-
declare const POOL_HISTORY_METRICS: readonly ["depositApy", "borrowApy", "dieselRate", "supplied", "borrowed", "availableLiquidity"];
|
|
25
|
-
/**
|
|
26
|
-
* Series available for a strategy opportunity.
|
|
27
|
-
*
|
|
28
|
-
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
29
|
-
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
30
|
-
**/
|
|
31
|
-
type StrategyHistoryMetric = "netApy" | "borrowApy" | "collateralApy" | "tvl" | "collateralPrice" | "collateralUsdPrice" | "underlyingUsdPrice";
|
|
32
|
-
/**
|
|
33
|
-
* Every {@link StrategyHistoryMetric}, for callers that enumerate them.
|
|
34
|
-
**/
|
|
35
|
-
declare const STRATEGY_HISTORY_METRICS: readonly ["netApy", "borrowApy", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
36
|
-
/**
|
|
37
|
-
* Series available for a pool position.
|
|
38
|
-
*
|
|
39
|
-
* Spelled out rather than aliased to {@link PoolHistoryMetric}: an opportunity
|
|
40
|
-
* and a position are separate contracts with the backend, and the position
|
|
41
|
-
* series are expected to grow their own members (PnL above all) without that
|
|
42
|
-
* change reaching the opportunity charts.
|
|
43
|
-
**/
|
|
44
|
-
type PoolPositionHistoryMetric = "depositApy" | "borrowApy" | "dieselRate" | "supplied" | "borrowed" | "availableLiquidity";
|
|
45
|
-
/**
|
|
46
|
-
* Every {@link PoolPositionHistoryMetric}, for callers that enumerate them.
|
|
47
|
-
**/
|
|
48
|
-
declare const POOL_POSITION_HISTORY_METRICS: readonly ["depositApy", "borrowApy", "dieselRate", "supplied", "borrowed", "availableLiquidity"];
|
|
49
|
-
/**
|
|
50
|
-
* Series available for a strategy position, see the note on
|
|
51
|
-
* {@link PoolPositionHistoryMetric} for why these are spelled out separately
|
|
52
|
-
* from {@link StrategyHistoryMetric}.
|
|
53
|
-
**/
|
|
54
|
-
type StrategyPositionHistoryMetric = "netApy" | "borrowApy" | "collateralApy" | "tvl" | "collateralPrice" | "collateralUsdPrice" | "underlyingUsdPrice";
|
|
55
|
-
/**
|
|
56
|
-
* Every {@link StrategyPositionHistoryMetric}, for callers that enumerate them.
|
|
57
|
-
**/
|
|
58
|
-
declare const STRATEGY_POSITION_HISTORY_METRICS: readonly ["netApy", "borrowApy", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
59
|
-
/**
|
|
60
|
-
* Any series a position can return.
|
|
61
|
-
**/
|
|
62
|
-
type PositionHistoryMetric = PoolPositionHistoryMetric | StrategyPositionHistoryMetric;
|
|
63
|
-
/**
|
|
64
|
-
* Any series the read model can return.
|
|
65
|
-
**/
|
|
66
|
-
type HistoryMetric = PoolHistoryMetric | StrategyHistoryMetric | PositionHistoryMetric;
|
|
67
|
-
/**
|
|
68
|
-
* One sample of a series.
|
|
69
|
-
**/
|
|
70
|
-
interface HistoryPoint {
|
|
71
|
-
/**
|
|
72
|
-
* When the sample was taken.
|
|
73
|
-
**/
|
|
74
|
-
timestamp: Timestamp;
|
|
75
|
-
/**
|
|
76
|
-
* Sampled value. The unit follows from the metric: APY metrics are in basis
|
|
77
|
-
* points, amount metrics are in the underlying's base units expressed as a
|
|
78
|
-
* float, price metrics are plain prices.
|
|
79
|
-
*
|
|
80
|
-
* @example `842` for an 8.42% APY sample
|
|
81
|
-
**/
|
|
82
|
-
value: number;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Annotations the backend ships alongside a series, e.g. what a chart drawn
|
|
86
|
-
* from it should say beyond the points themselves.
|
|
87
|
-
*
|
|
88
|
-
* TODO: the backend has not specified this payload yet. It stays empty until
|
|
89
|
-
* it does, so that filling it in later is additive rather than a rename.
|
|
90
|
-
**/
|
|
91
|
-
interface HistoryChartMetadata {}
|
|
92
|
-
/**
|
|
93
|
-
* A named series of samples ordered by ascending timestamp.
|
|
94
|
-
*
|
|
95
|
-
* @typeParam M - Metric the series carries.
|
|
96
|
-
**/
|
|
97
|
-
interface HistorySeries<M extends string = HistoryMetric> {
|
|
98
|
-
/**
|
|
99
|
-
* Metric the samples belong to; it also defines their unit, so no separate
|
|
100
|
-
* unit field ships.
|
|
101
|
-
**/
|
|
102
|
-
metric: M;
|
|
103
|
-
/**
|
|
104
|
-
* Samples, oldest first.
|
|
105
|
-
**/
|
|
106
|
-
points: HistoryPoint[];
|
|
107
|
-
/**
|
|
108
|
-
* What the backend says about the series, see {@link HistoryChartMetadata}.
|
|
109
|
-
**/
|
|
110
|
-
metadata: HistoryChartMetadata;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* A request for one series of a single opportunity.
|
|
114
|
-
*
|
|
115
|
-
* @typeParam M - Metric requested.
|
|
116
|
-
**/
|
|
117
|
-
interface OpportunityHistoryQuery<M extends HistoryMetric = HistoryMetric> {
|
|
118
|
-
/**
|
|
119
|
-
* Opportunity the series belongs to.
|
|
120
|
-
**/
|
|
121
|
-
opportunity: OpportunityKey;
|
|
122
|
-
/**
|
|
123
|
-
* Window to cover.
|
|
124
|
-
**/
|
|
125
|
-
range: HistoryRange;
|
|
126
|
-
/**
|
|
127
|
-
* Metric to return. A metric that does not apply to the opportunity's kind
|
|
128
|
-
* has no series.
|
|
129
|
-
**/
|
|
130
|
-
metric: M;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* A request for one series of a single position.
|
|
134
|
-
*
|
|
135
|
-
* @typeParam M - Metric requested.
|
|
136
|
-
**/
|
|
137
|
-
interface PositionHistoryQuery<M extends PositionHistoryMetric = PositionHistoryMetric> {
|
|
138
|
-
/**
|
|
139
|
-
* Position the series belongs to.
|
|
140
|
-
**/
|
|
141
|
-
position: PositionKey;
|
|
142
|
-
/**
|
|
143
|
-
* Window to cover.
|
|
144
|
-
**/
|
|
145
|
-
range: HistoryRange;
|
|
146
|
-
/**
|
|
147
|
-
* Metric to return. A metric that does not apply to the position's kind has
|
|
148
|
-
* no series.
|
|
149
|
-
**/
|
|
150
|
-
metric: M;
|
|
151
|
-
}
|
|
152
|
-
//#endregion
|
|
153
|
-
export { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PoolHistoryMetric, PoolPositionHistoryMetric, PositionHistoryMetric, PositionHistoryQuery, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyPositionHistoryMetric };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { HistoryChartMetadata } from "./history.js";
|
|
2
|
-
import { z } from "zod/v4";
|
|
3
|
-
//#region src/model/history.schema.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Runtime schemas for {@link ./history.js}, see the note in
|
|
6
|
-
* `primitives.schema.ts` on why they are written by hand.
|
|
7
|
-
**/
|
|
8
|
-
/**
|
|
9
|
-
* {@link HistoryRange}
|
|
10
|
-
**/
|
|
11
|
-
declare const historyRangeSchema: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
|
|
12
|
-
/**
|
|
13
|
-
* {@link PoolHistoryMetric}
|
|
14
|
-
**/
|
|
15
|
-
declare const poolHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>;
|
|
16
|
-
/**
|
|
17
|
-
* {@link StrategyHistoryMetric}
|
|
18
|
-
**/
|
|
19
|
-
declare const strategyHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>;
|
|
20
|
-
/**
|
|
21
|
-
* {@link PoolPositionHistoryMetric}
|
|
22
|
-
**/
|
|
23
|
-
declare const poolPositionHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>;
|
|
24
|
-
/**
|
|
25
|
-
* {@link StrategyPositionHistoryMetric}
|
|
26
|
-
**/
|
|
27
|
-
declare const strategyPositionHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>;
|
|
28
|
-
/**
|
|
29
|
-
* {@link PositionHistoryMetric}
|
|
30
|
-
**/
|
|
31
|
-
declare const positionHistoryMetricSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
|
|
32
|
-
/**
|
|
33
|
-
* {@link HistoryMetric}
|
|
34
|
-
**/
|
|
35
|
-
declare const historyMetricSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>]>;
|
|
36
|
-
/**
|
|
37
|
-
* {@link HistoryPoint}
|
|
38
|
-
**/
|
|
39
|
-
declare const historyPointSchema: z.ZodObject<{
|
|
40
|
-
timestamp: z.ZodNumber;
|
|
41
|
-
value: z.ZodNumber;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
|
-
/**
|
|
44
|
-
* {@link HistoryChartMetadata}
|
|
45
|
-
*
|
|
46
|
-
* TODO: empty until the backend specifies the payload.
|
|
47
|
-
**/
|
|
48
|
-
declare const historyChartMetadataSchema: z.ZodType<HistoryChartMetadata>;
|
|
49
|
-
/**
|
|
50
|
-
* {@link HistorySeries}
|
|
51
|
-
**/
|
|
52
|
-
declare const historySeriesSchema: z.ZodObject<{
|
|
53
|
-
metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>]>;
|
|
54
|
-
points: z.ZodArray<z.ZodObject<{
|
|
55
|
-
timestamp: z.ZodNumber;
|
|
56
|
-
value: z.ZodNumber;
|
|
57
|
-
}, z.core.$strip>>;
|
|
58
|
-
metadata: z.ZodType<HistoryChartMetadata, unknown, z.core.$ZodTypeInternals<HistoryChartMetadata, unknown>>;
|
|
59
|
-
}, z.core.$strip>;
|
|
60
|
-
/**
|
|
61
|
-
* {@link OpportunityHistoryQuery}
|
|
62
|
-
**/
|
|
63
|
-
declare const opportunityHistoryQuerySchema: z.ZodObject<{
|
|
64
|
-
opportunity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
65
|
-
chainId: z.ZodNumber;
|
|
66
|
-
pool: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
67
|
-
kind: z.ZodLiteral<"pool">;
|
|
68
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
69
|
-
chainId: z.ZodNumber;
|
|
70
|
-
creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
71
|
-
targetCollateral: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
72
|
-
kind: z.ZodLiteral<"strategy">;
|
|
73
|
-
}, z.core.$strip>], "kind">;
|
|
74
|
-
range: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
|
|
75
|
-
metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>]>;
|
|
76
|
-
}, z.core.$strip>;
|
|
77
|
-
/**
|
|
78
|
-
* {@link PositionHistoryQuery}
|
|
79
|
-
**/
|
|
80
|
-
declare const positionHistoryQuerySchema: z.ZodObject<{
|
|
81
|
-
position: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
82
|
-
chainId: z.ZodNumber;
|
|
83
|
-
pool: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
84
|
-
wallet: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
85
|
-
kind: z.ZodLiteral<"pool">;
|
|
86
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
-
chainId: z.ZodNumber;
|
|
88
|
-
creditAccount: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
89
|
-
kind: z.ZodLiteral<"strategy">;
|
|
90
|
-
}, z.core.$strip>], "kind">;
|
|
91
|
-
range: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
|
|
92
|
-
metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
|
|
93
|
-
}, z.core.$strip>;
|
|
94
|
-
//#endregion
|
|
95
|
-
export { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, poolPositionHistoryMetricSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, strategyHistoryMetricSchema, strategyPositionHistoryMetricSchema };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HistoryRange, HistorySeries } from "../../model/history.js";
|
|
2
|
-
import { DataResponse } from "../../model/response.js";
|
|
3
|
-
import "../../model/index.js";
|
|
4
|
-
//#region src/new-sdk/utils/history.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Reads the charts of one subject, one metric and one range at a time.
|
|
7
|
-
*
|
|
8
|
-
* @typeParam Metric - Metrics the subject has.
|
|
9
|
-
**/
|
|
10
|
-
interface HistoryReader<Metric extends string> {
|
|
11
|
-
/**
|
|
12
|
-
* Historical chart of one metric over one window. A metric the subject does
|
|
13
|
-
* not have is a compile error.
|
|
14
|
-
**/
|
|
15
|
-
chart(metric: Metric, range: HistoryRange): Promise<DataResponse<HistorySeries<Metric>>>;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { HistoryReader };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { buildResumeAddCollateralOperations } from "./resume/add-collateral/add-collateral.js";
|
|
2
|
-
import { buildResumeCloseOperations } from "./resume/close/close.js";
|
|
3
|
-
import { buildResumeDecreaseLeverageOperations } from "./resume/decrease-leverage/decrease-leverage.js";
|
|
4
|
-
import { buildResumeDepositOperations } from "./resume/deposit/deposit.js";
|
|
5
|
-
import { buildResumeIncreaseLeverageOperations } from "./resume/increase-leverage/increase-leverage.js";
|
|
6
|
-
import { buildResumeWithdrawOperations } from "./resume/withdraw/withdraw.js";
|
|
7
|
-
import "./resume/index.js";
|
|
8
|
-
export { buildResumeAddCollateralOperations, buildResumeCloseOperations, buildResumeDecreaseLeverageOperations, buildResumeDepositOperations, buildResumeIncreaseLeverageOperations, buildResumeWithdrawOperations };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { OnchainSDK } from "../../../../../OnchainSDK.js";
|
|
2
|
-
import { CreditAccountSlice } from "../../../types.js";
|
|
3
|
-
import { ClaimDelayedOption } from "../../../operations/claim-delayed/index.js";
|
|
4
|
-
import { AccountCalculatorOperation } from "../../../operations/types.js";
|
|
5
|
-
import "../../../operations/index.js";
|
|
6
|
-
import "../../../../../index.js";
|
|
7
|
-
//#region src/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Resume add-collateral: claim only
|
|
10
|
-
*/
|
|
11
|
-
declare function buildResumeAddCollateralOperations(creditAccount: CreditAccountSlice, options: ClaimDelayedOption, sdk: OnchainSDK): Array<AccountCalculatorOperation>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { buildResumeAddCollateralOperations };
|
package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { DelayedAddCollateralIntent } from "../../../../withdrawal-compressor/types.js";
|
|
2
|
-
import { OnchainSDK } from "../../../../../OnchainSDK.js";
|
|
3
|
-
import { CreditAccountSlice } from "../../../types.js";
|
|
4
|
-
import { ClaimDelayedOption } from "../../../operations/claim-delayed/index.js";
|
|
5
|
-
import "../../../operations/index.js";
|
|
6
|
-
import "../../../../../index.js";
|
|
7
|
-
import { ANY, RWA_ASSET, ResumeCase, UND, buildOffchainOptions, buildOnchainOptions, buildResumeSdk } from "../../../testing/resume.js";
|
|
8
|
-
//#region src/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.d.ts
|
|
9
|
-
declare const ADD_UND = 100000000000n;
|
|
10
|
-
declare const ANY_CLAIMED = 2000000000000000000000n;
|
|
11
|
-
declare const RWA_CLAIMED = 100000000000n;
|
|
12
|
-
declare const QUOTA_INCREASE = 92000000000n;
|
|
13
|
-
/**
|
|
14
|
-
* Flow 1.2 — C=und, T=any (swap then quota).
|
|
15
|
-
* Resume: changeQuota(ANY) only.
|
|
16
|
-
*/
|
|
17
|
-
declare const case_1_2_und_any: ResumeCase;
|
|
18
|
-
/**
|
|
19
|
-
* Flow 1.7 — C=any, T=asset (swap then quota).
|
|
20
|
-
* Resume: changeQuota(RWA) only.
|
|
21
|
-
*/
|
|
22
|
-
declare const case_1_7_any_rwa: ResumeCase;
|
|
23
|
-
/** Claimed und — no active quota-buy path. */
|
|
24
|
-
declare const case_claimed_und: ResumeCase;
|
|
25
|
-
declare function buildResumeAddCollateralProps(args: {
|
|
26
|
-
case: ResumeCase;
|
|
27
|
-
sdk: OnchainSDK;
|
|
28
|
-
options: ClaimDelayedOption;
|
|
29
|
-
}): {
|
|
30
|
-
intent: DelayedAddCollateralIntent;
|
|
31
|
-
creditAccount: CreditAccountSlice;
|
|
32
|
-
sdk: OnchainSDK<{}>;
|
|
33
|
-
quotaReserve: undefined;
|
|
34
|
-
options: ClaimDelayedOption;
|
|
35
|
-
slippage: undefined;
|
|
36
|
-
};
|
|
37
|
-
//#endregion
|
|
38
|
-
export { ADD_UND, ANY, ANY_CLAIMED, QUOTA_INCREASE, RWA_ASSET, RWA_CLAIMED, type ResumeCase, UND, buildOffchainOptions, buildOnchainOptions, buildResumeAddCollateralProps, buildResumeSdk, case_1_2_und_any, case_1_7_any_rwa, case_claimed_und };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DelayedCloseAccountIntent } from "../../../../withdrawal-compressor/types.js";
|
|
2
|
-
import { OnchainSDK } from "../../../../../OnchainSDK.js";
|
|
3
|
-
import { CreditAccountSlice } from "../../../types.js";
|
|
4
|
-
import { ClaimDelayedOption } from "../../../operations/claim-delayed/index.js";
|
|
5
|
-
import { CloseQuote, CloseQuoter } from "../../../quoters/close.js";
|
|
6
|
-
import "../../../quoters/index.js";
|
|
7
|
-
import { AccountCalculatorOperation } from "../../../operations/types.js";
|
|
8
|
-
import "../../../operations/index.js";
|
|
9
|
-
import "../../../../../index.js";
|
|
10
|
-
//#region src/sdk/accounts/intents/intents/resume/close/close.d.ts
|
|
11
|
-
/**
|
|
12
|
-
* Resume close — linear op chain: claim, then close against the quoted
|
|
13
|
-
* post-claim balances. Quota zeroing and debt/withdraw live inside
|
|
14
|
-
* assembleCloseCreditAccountCalls — no separate changeQuota / wrap ops.
|
|
15
|
-
*/
|
|
16
|
-
declare function buildResumeCloseOperations(props: {
|
|
17
|
-
intent: DelayedCloseAccountIntent;
|
|
18
|
-
options: ClaimDelayedOption;
|
|
19
|
-
creditAccount: CreditAccountSlice;
|
|
20
|
-
sdk: OnchainSDK;
|
|
21
|
-
}, quoter: CloseQuoter): Promise<{
|
|
22
|
-
operations: AccountCalculatorOperation[];
|
|
23
|
-
quote: CloseQuote;
|
|
24
|
-
}>;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { buildResumeCloseOperations };
|