@kestrelfi/lyc-sdk 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +11 -0
- package/README.md +207 -0
- package/dist/sdks/long-yield-carry/scripts/asyncBurn.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/asyncBurn.js +117 -0
- package/dist/sdks/long-yield-carry/scripts/burnToken.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/burnToken.js +98 -0
- package/dist/sdks/long-yield-carry/scripts/claimIncentives.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/claimIncentives.js +108 -0
- package/dist/sdks/long-yield-carry/scripts/closeCpiPlans.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/closeCpiPlans.js +93 -0
- package/dist/sdks/long-yield-carry/scripts/collectInterest.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/collectInterest.js +164 -0
- package/dist/sdks/long-yield-carry/scripts/collectProtocolFees.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/collectProtocolFees.js +120 -0
- package/dist/sdks/long-yield-carry/scripts/computeOptimalAllocations.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/computeOptimalAllocations.js +84 -0
- package/dist/sdks/long-yield-carry/scripts/createToken.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/createToken.js +76 -0
- package/dist/sdks/long-yield-carry/scripts/createTokenLendingPosition.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/createTokenLendingPosition.js +157 -0
- package/dist/sdks/long-yield-carry/scripts/createYieldingBank.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/createYieldingBank.js +69 -0
- package/dist/sdks/long-yield-carry/scripts/decreaseCarryPositions.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/decreaseCarryPositions.js +247 -0
- package/dist/sdks/long-yield-carry/scripts/depositUnlentCollateral.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/depositUnlentCollateral.js +90 -0
- package/dist/sdks/long-yield-carry/scripts/emergency/deleverageAll.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/emergency/deleverageAll.js +202 -0
- package/dist/sdks/long-yield-carry/scripts/emergency/triggerCircuitBreaker.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/emergency/triggerCircuitBreaker.js +68 -0
- package/dist/sdks/long-yield-carry/scripts/env.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/env.js +8 -0
- package/dist/sdks/long-yield-carry/scripts/findTxs.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/findTxs.js +143 -0
- package/dist/sdks/long-yield-carry/scripts/increaseCarryPositions.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/increaseCarryPositions.js +112 -0
- package/dist/sdks/long-yield-carry/scripts/inspect/format.d.ts +13 -0
- package/dist/sdks/long-yield-carry/scripts/inspect/format.js +363 -0
- package/dist/sdks/long-yield-carry/scripts/inspect.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/inspect.js +108 -0
- package/dist/sdks/long-yield-carry/scripts/localUtils.d.ts +53 -0
- package/dist/sdks/long-yield-carry/scripts/localUtils.js +191 -0
- package/dist/sdks/long-yield-carry/scripts/mintToken.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/mintToken.js +103 -0
- package/dist/sdks/long-yield-carry/scripts/processAsyncBurns.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/processAsyncBurns.js +76 -0
- package/dist/sdks/long-yield-carry/scripts/rebalanceToken.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/rebalanceToken.js +210 -0
- package/dist/sdks/long-yield-carry/scripts/rebalanceYieldingBank.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/rebalanceYieldingBank.js +149 -0
- package/dist/sdks/long-yield-carry/scripts/recollateralizeLoss.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/recollateralizeLoss.js +64 -0
- package/dist/sdks/long-yield-carry/scripts/refresh.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/refresh.js +101 -0
- package/dist/sdks/long-yield-carry/scripts/updateFees.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/updateFees.js +369 -0
- package/dist/sdks/long-yield-carry/scripts/updateGeneralLut.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/updateGeneralLut.js +27 -0
- package/dist/sdks/long-yield-carry/scripts/updateLendingPositionConfig.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/updateLendingPositionConfig.js +127 -0
- package/dist/sdks/long-yield-carry/scripts/updateTokenLuts.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/updateTokenLuts.js +27 -0
- package/dist/sdks/long-yield-carry/scripts/updateTokenMetadata.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/updateTokenMetadata.js +194 -0
- package/dist/sdks/long-yield-carry/scripts/updateYieldingBankConfig.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/updateYieldingBankConfig.js +84 -0
- package/dist/sdks/long-yield-carry/scripts/withdrawUnlentCollateral.d.ts +1 -0
- package/dist/sdks/long-yield-carry/scripts/withdrawUnlentCollateral.js +140 -0
- package/dist/sdks/long-yield-carry/src/client/account.d.ts +152 -0
- package/dist/sdks/long-yield-carry/src/client/account.js +349 -0
- package/dist/sdks/long-yield-carry/src/client/builders/args.d.ts +299 -0
- package/dist/sdks/long-yield-carry/src/client/builders/args.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/builders/asyncBurnBuilder.d.ts +20 -0
- package/dist/sdks/long-yield-carry/src/client/builders/asyncBurnBuilder.js +212 -0
- package/dist/sdks/long-yield-carry/src/client/builders/base.d.ts +77 -0
- package/dist/sdks/long-yield-carry/src/client/builders/base.js +191 -0
- package/dist/sdks/long-yield-carry/src/client/builders/burnTokenBuilder.d.ts +18 -0
- package/dist/sdks/long-yield-carry/src/client/builders/burnTokenBuilder.js +165 -0
- package/dist/sdks/long-yield-carry/src/client/builders/claimIncentivesBuilder.d.ts +9 -0
- package/dist/sdks/long-yield-carry/src/client/builders/claimIncentivesBuilder.js +135 -0
- package/dist/sdks/long-yield-carry/src/client/builders/collectFeesBuilder.d.ts +14 -0
- package/dist/sdks/long-yield-carry/src/client/builders/collectFeesBuilder.js +50 -0
- package/dist/sdks/long-yield-carry/src/client/builders/collectInterestBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/collectInterestBuilder.js +86 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createCpiPlanBuilder.d.ts +6 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createCpiPlanBuilder.js +22 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenBuilder.d.ts +7 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenBuilder.js +64 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenLendingPositionBuilder.d.ts +10 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenLendingPositionBuilder.js +138 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankAllocationBuilder.d.ts +7 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankAllocationBuilder.js +29 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankBuilder.d.ts +7 -0
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankBuilder.js +39 -0
- package/dist/sdks/long-yield-carry/src/client/builders/decreaseCarryPositionBuilder.d.ts +30 -0
- package/dist/sdks/long-yield-carry/src/client/builders/decreaseCarryPositionBuilder.js +99 -0
- package/dist/sdks/long-yield-carry/src/client/builders/depositUnlentCollateralBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/depositUnlentCollateralBuilder.js +64 -0
- package/dist/sdks/long-yield-carry/src/client/builders/increaseCarryPositionBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/increaseCarryPositionBuilder.js +73 -0
- package/dist/sdks/long-yield-carry/src/client/builders/index.d.ts +28 -0
- package/dist/sdks/long-yield-carry/src/client/builders/index.js +62 -0
- package/dist/sdks/long-yield-carry/src/client/builders/mintTokenBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/mintTokenBuilder.js +95 -0
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceTokenBuilder.d.ts +11 -0
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceTokenBuilder.js +255 -0
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceYieldingBankBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceYieldingBankBuilder.js +75 -0
- package/dist/sdks/long-yield-carry/src/client/builders/recollateralizeLossBuilder.d.ts +12 -0
- package/dist/sdks/long-yield-carry/src/client/builders/recollateralizeLossBuilder.js +220 -0
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokenStateBuilder.d.ts +9 -0
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokenStateBuilder.js +112 -0
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokensBuilder.d.ts +9 -0
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokensBuilder.js +59 -0
- package/dist/sdks/long-yield-carry/src/client/builders/refreshYieldingBankBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/refreshYieldingBankBuilder.js +29 -0
- package/dist/sdks/long-yield-carry/src/client/builders/resetTokenBurnRateLimitBuilder.d.ts +7 -0
- package/dist/sdks/long-yield-carry/src/client/builders/resetTokenBurnRateLimitBuilder.js +19 -0
- package/dist/sdks/long-yield-carry/src/client/builders/setTokenCircuitBreakerBuilder.d.ts +11 -0
- package/dist/sdks/long-yield-carry/src/client/builders/setTokenCircuitBreakerBuilder.js +31 -0
- package/dist/sdks/long-yield-carry/src/client/builders/setYieldingBankCircuitBreakerBuilder.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/client/builders/setYieldingBankCircuitBreakerBuilder.js +28 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateLendingPositionConfigBuilder.d.ts +10 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateLendingPositionConfigBuilder.js +30 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenConfigurationBuilder.d.ts +11 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenConfigurationBuilder.js +47 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenMetadataBuilder.d.ts +7 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenMetadataBuilder.js +24 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateYieldingBankConfigBuilder.d.ts +10 -0
- package/dist/sdks/long-yield-carry/src/client/builders/updateYieldingBankConfigBuilder.js +31 -0
- package/dist/sdks/long-yield-carry/src/client/builders/utils.d.ts +4 -0
- package/dist/sdks/long-yield-carry/src/client/builders/utils.js +20 -0
- package/dist/sdks/long-yield-carry/src/client/client.d.ts +115 -0
- package/dist/sdks/long-yield-carry/src/client/client.js +166 -0
- package/dist/sdks/long-yield-carry/src/client/externalLiquidityResolver.d.ts +13 -0
- package/dist/sdks/long-yield-carry/src/client/externalLiquidityResolver.js +34 -0
- package/dist/sdks/long-yield-carry/src/client/index.d.ts +10 -0
- package/dist/sdks/long-yield-carry/src/client/index.js +33 -0
- package/dist/sdks/long-yield-carry/src/client/lendingPlatformClients.d.ts +19 -0
- package/dist/sdks/long-yield-carry/src/client/lendingPlatformClients.js +33 -0
- package/dist/sdks/long-yield-carry/src/client/pda.d.ts +33 -0
- package/dist/sdks/long-yield-carry/src/client/pda.js +79 -0
- package/dist/sdks/long-yield-carry/src/client/plans/collectInterest.d.ts +24 -0
- package/dist/sdks/long-yield-carry/src/client/plans/collectInterest.js +150 -0
- package/dist/sdks/long-yield-carry/src/client/plans/decreaseCarryPosition.d.ts +12 -0
- package/dist/sdks/long-yield-carry/src/client/plans/decreaseCarryPosition.js +140 -0
- package/dist/sdks/long-yield-carry/src/client/routes/collectInterest.d.ts +13 -0
- package/dist/sdks/long-yield-carry/src/client/routes/collectInterest.js +39 -0
- package/dist/sdks/long-yield-carry/src/client/transaction.d.ts +41 -0
- package/dist/sdks/long-yield-carry/src/client/transaction.js +55 -0
- package/dist/sdks/long-yield-carry/src/client/types/builders.d.ts +18 -0
- package/dist/sdks/long-yield-carry/src/client/types/builders.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/types/enums.d.ts +22 -0
- package/dist/sdks/long-yield-carry/src/client/types/enums.js +48 -0
- package/dist/sdks/long-yield-carry/src/client/types/general.d.ts +98 -0
- package/dist/sdks/long-yield-carry/src/client/types/general.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/types/index.d.ts +6 -0
- package/dist/sdks/long-yield-carry/src/client/types/index.js +22 -0
- package/dist/sdks/long-yield-carry/src/client/types/ix.d.ts +352 -0
- package/dist/sdks/long-yield-carry/src/client/types/ix.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/collectInterest.d.ts +91 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/collectInterest.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/common.d.ts +28 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/common.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/decreaseCarryPosition.d.ts +128 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/decreaseCarryPosition.js +2 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/index.d.ts +3 -0
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/index.js +19 -0
- package/dist/sdks/long-yield-carry/src/client/types/tx.d.ts +339 -0
- package/dist/sdks/long-yield-carry/src/client/types/tx.js +2 -0
- package/dist/sdks/long-yield-carry/src/constants/configs/allocations.d.ts +3 -0
- package/dist/sdks/long-yield-carry/src/constants/configs/allocations.js +23 -0
- package/dist/sdks/long-yield-carry/src/constants/configs/carryTradePresets.d.ts +58 -0
- package/dist/sdks/long-yield-carry/src/constants/configs/carryTradePresets.js +116 -0
- package/dist/sdks/long-yield-carry/src/constants/configs/index.d.ts +2 -0
- package/dist/sdks/long-yield-carry/src/constants/configs/index.js +18 -0
- package/dist/sdks/long-yield-carry/src/constants/general.d.ts +70 -0
- package/dist/sdks/long-yield-carry/src/constants/general.js +107 -0
- package/dist/sdks/long-yield-carry/src/constants/index.d.ts +3 -0
- package/dist/sdks/long-yield-carry/src/constants/index.js +19 -0
- package/dist/sdks/long-yield-carry/src/constants/lycTokenMetadata.d.ts +36 -0
- package/dist/sdks/long-yield-carry/src/constants/lycTokenMetadata.js +41 -0
- package/dist/sdks/long-yield-carry/src/decoders/decodeTransaction.d.ts +86 -0
- package/dist/sdks/long-yield-carry/src/decoders/decodeTransaction.js +230 -0
- package/dist/sdks/long-yield-carry/src/decoders/discriminators.d.ts +8 -0
- package/dist/sdks/long-yield-carry/src/decoders/discriminators.js +11 -0
- package/dist/sdks/long-yield-carry/src/decoders/idlAccounts.d.ts +29 -0
- package/dist/sdks/long-yield-carry/src/decoders/idlAccounts.js +57 -0
- package/dist/sdks/long-yield-carry/src/decoders/index.d.ts +6 -0
- package/dist/sdks/long-yield-carry/src/decoders/index.js +14 -0
- package/dist/sdks/long-yield-carry/src/decoders/innerCpis.d.ts +68 -0
- package/dist/sdks/long-yield-carry/src/decoders/innerCpis.js +225 -0
- package/dist/sdks/long-yield-carry/src/decoders/lycInstructionNames.d.ts +6 -0
- package/dist/sdks/long-yield-carry/src/decoders/lycInstructionNames.js +73 -0
- package/dist/sdks/long-yield-carry/src/decoders/programIds.d.ts +4 -0
- package/dist/sdks/long-yield-carry/src/decoders/programIds.js +11 -0
- package/dist/sdks/long-yield-carry/src/decoders/solana.d.ts +7 -0
- package/dist/sdks/long-yield-carry/src/decoders/solana.js +30 -0
- package/dist/sdks/long-yield-carry/src/decoders/transactionPayload.d.ts +41 -0
- package/dist/sdks/long-yield-carry/src/decoders/transactionPayload.js +6 -0
- package/dist/sdks/long-yield-carry/src/decoders/types.d.ts +58 -0
- package/dist/sdks/long-yield-carry/src/decoders/types.js +2 -0
- package/dist/sdks/long-yield-carry/src/errors.d.ts +69 -0
- package/dist/sdks/long-yield-carry/src/errors.js +183 -0
- package/dist/sdks/long-yield-carry/src/idl/long_yield_carry.d.ts +7327 -0
- package/dist/sdks/long-yield-carry/src/idl/long_yield_carry.js +7323 -0
- package/dist/sdks/long-yield-carry/src/index.d.ts +10 -0
- package/dist/sdks/long-yield-carry/src/index.js +25 -0
- package/dist/sdks/long-yield-carry/src/metrics/index.d.ts +1 -0
- package/dist/sdks/long-yield-carry/src/metrics/index.js +17 -0
- package/dist/sdks/long-yield-carry/src/metrics/protocolMetrics.d.ts +276 -0
- package/dist/sdks/long-yield-carry/src/metrics/protocolMetrics.js +547 -0
- package/dist/sdks/long-yield-carry/src/models/index.d.ts +3 -0
- package/dist/sdks/long-yield-carry/src/models/index.js +7 -0
- package/dist/sdks/long-yield-carry/src/models/lycToken.d.ts +156 -0
- package/dist/sdks/long-yield-carry/src/models/lycToken.js +288 -0
- package/dist/sdks/long-yield-carry/src/models/yieldingBank.d.ts +52 -0
- package/dist/sdks/long-yield-carry/src/models/yieldingBank.js +109 -0
- package/dist/sdks/long-yield-carry/src/services/allocation/allocationService.d.ts +106 -0
- package/dist/sdks/long-yield-carry/src/services/allocation/allocationService.js +589 -0
- package/dist/sdks/long-yield-carry/src/services/allocation/index.d.ts +2 -0
- package/dist/sdks/long-yield-carry/src/services/allocation/index.js +18 -0
- package/dist/sdks/long-yield-carry/src/services/allocation/types.d.ts +25 -0
- package/dist/sdks/long-yield-carry/src/services/allocation/types.js +2 -0
- package/dist/sdks/long-yield-carry/src/services/carry/carryAllocationConfig.d.ts +103 -0
- package/dist/sdks/long-yield-carry/src/services/carry/carryAllocationConfig.js +146 -0
- package/dist/sdks/long-yield-carry/src/services/carry/index.d.ts +2 -0
- package/dist/sdks/long-yield-carry/src/services/carry/index.js +18 -0
- package/dist/sdks/long-yield-carry/src/services/carry/lycLendingPositionManager.d.ts +39 -0
- package/dist/sdks/long-yield-carry/src/services/carry/lycLendingPositionManager.js +100 -0
- package/dist/sdks/long-yield-carry/src/services/index.d.ts +5 -0
- package/dist/sdks/long-yield-carry/src/services/index.js +21 -0
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/index.d.ts +2 -0
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/index.js +5 -0
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/lendingPositionService.d.ts +88 -0
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/lendingPositionService.js +229 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/index.d.ts +2 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/index.js +18 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/index.d.ts +1 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/index.js +17 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/tokenRebalanceService.d.ts +51 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/tokenRebalanceService.js +99 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/index.d.ts +3 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/index.js +21 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/planner.d.ts +68 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/planner.js +181 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/strategy.d.ts +26 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/strategy.js +26 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/types.d.ts +40 -0
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/types.js +2 -0
- package/dist/sdks/long-yield-carry/src/services/redemption/index.d.ts +2 -0
- package/dist/sdks/long-yield-carry/src/services/redemption/index.js +5 -0
- package/dist/sdks/long-yield-carry/src/services/redemption/redemptionService.d.ts +139 -0
- package/dist/sdks/long-yield-carry/src/services/redemption/redemptionService.js +532 -0
- package/dist/sdks/long-yield-carry/src/types/enriched.d.ts +168 -0
- package/dist/sdks/long-yield-carry/src/types/enriched.js +2 -0
- package/dist/sdks/long-yield-carry/src/types/index.d.ts +1 -0
- package/dist/sdks/long-yield-carry/src/types/index.js +17 -0
- package/dist/sdks/long-yield-carry/src/utils/cache.d.ts +4 -0
- package/dist/sdks/long-yield-carry/src/utils/cache.js +10 -0
- package/dist/sdks/long-yield-carry/src/utils/data.d.ts +12 -0
- package/dist/sdks/long-yield-carry/src/utils/data.js +59 -0
- package/dist/sdks/long-yield-carry/src/utils/enrichment.d.ts +5 -0
- package/dist/sdks/long-yield-carry/src/utils/enrichment.js +244 -0
- package/dist/sdks/long-yield-carry/src/utils/feeDripMetrics.d.ts +36 -0
- package/dist/sdks/long-yield-carry/src/utils/feeDripMetrics.js +93 -0
- package/dist/sdks/long-yield-carry/src/utils/general.d.ts +28 -0
- package/dist/sdks/long-yield-carry/src/utils/general.js +47 -0
- package/dist/sdks/long-yield-carry/src/utils/index.d.ts +13 -0
- package/dist/sdks/long-yield-carry/src/utils/index.js +29 -0
- package/dist/sdks/long-yield-carry/src/utils/ix.d.ts +83 -0
- package/dist/sdks/long-yield-carry/src/utils/ix.js +165 -0
- package/dist/sdks/long-yield-carry/src/utils/lendingPosition.d.ts +68 -0
- package/dist/sdks/long-yield-carry/src/utils/lendingPosition.js +105 -0
- package/dist/sdks/long-yield-carry/src/utils/lookupTables.d.ts +55 -0
- package/dist/sdks/long-yield-carry/src/utils/lookupTables.js +216 -0
- package/dist/sdks/long-yield-carry/src/utils/lycData.d.ts +66 -0
- package/dist/sdks/long-yield-carry/src/utils/lycData.js +211 -0
- package/dist/sdks/long-yield-carry/src/utils/timelock.d.ts +19 -0
- package/dist/sdks/long-yield-carry/src/utils/timelock.js +37 -0
- package/dist/sdks/long-yield-carry/src/utils/tokenFeeMath.d.ts +11 -0
- package/dist/sdks/long-yield-carry/src/utils/tokenFeeMath.js +24 -0
- package/dist/sdks/long-yield-carry/src/utils/transactions.d.ts +20 -0
- package/dist/sdks/long-yield-carry/src/utils/transactions.js +72 -0
- package/dist/sdks/long-yield-carry/src/utils/yieldingBank.d.ts +24 -0
- package/dist/sdks/long-yield-carry/src/utils/yieldingBank.js +36 -0
- package/dist/shared/common/src/constants/accountMetas.d.ts +3 -0
- package/dist/shared/common/src/constants/accountMetas.js +9 -0
- package/dist/shared/common/src/constants/general.d.ts +21 -0
- package/dist/shared/common/src/constants/general.js +30 -0
- package/dist/shared/common/src/constants/generated/cpi.d.ts +23 -0
- package/dist/shared/common/src/constants/generated/cpi.js +28 -0
- package/dist/shared/common/src/constants/generated/index.d.ts +1 -0
- package/dist/shared/common/src/constants/generated/index.js +17 -0
- package/dist/shared/common/src/constants/index.d.ts +3 -0
- package/dist/shared/common/src/constants/index.js +19 -0
- package/dist/shared/common/src/index.d.ts +4 -0
- package/dist/shared/common/src/index.js +20 -0
- package/dist/shared/common/src/services/baseAccountClient.d.ts +22 -0
- package/dist/shared/common/src/services/baseAccountClient.js +38 -0
- package/dist/shared/common/src/services/baseIxBuilderService.d.ts +27 -0
- package/dist/shared/common/src/services/baseIxBuilderService.js +48 -0
- package/dist/shared/common/src/services/dataCache.d.ts +41 -0
- package/dist/shared/common/src/services/dataCache.js +130 -0
- package/dist/shared/common/src/services/index.d.ts +8 -0
- package/dist/shared/common/src/services/index.js +24 -0
- package/dist/shared/common/src/services/lutManager.d.ts +31 -0
- package/dist/shared/common/src/services/lutManager.js +133 -0
- package/dist/shared/common/src/services/mints/defaults.d.ts +2 -0
- package/dist/shared/common/src/services/mints/defaults.js +152 -0
- package/dist/shared/common/src/services/mints/index.d.ts +4 -0
- package/dist/shared/common/src/services/mints/index.js +20 -0
- package/dist/shared/common/src/services/mints/registry.d.ts +70 -0
- package/dist/shared/common/src/services/mints/registry.js +117 -0
- package/dist/shared/common/src/services/mints/symbols.d.ts +6 -0
- package/dist/shared/common/src/services/mints/symbols.js +13 -0
- package/dist/shared/common/src/services/mints/types.d.ts +30 -0
- package/dist/shared/common/src/services/mints/types.js +2 -0
- package/dist/shared/common/src/services/swap/index.d.ts +4 -0
- package/dist/shared/common/src/services/swap/index.js +20 -0
- package/dist/shared/common/src/services/swap/routableSwapClient.d.ts +36 -0
- package/dist/shared/common/src/services/swap/routableSwapClient.js +2 -0
- package/dist/shared/common/src/services/swap/swapClientBase.d.ts +45 -0
- package/dist/shared/common/src/services/swap/swapClientBase.js +2 -0
- package/dist/shared/common/src/services/swap/swapRouting.d.ts +13 -0
- package/dist/shared/common/src/services/swap/swapRouting.js +28 -0
- package/dist/shared/common/src/services/swap/types.d.ts +77 -0
- package/dist/shared/common/src/services/swap/types.js +2 -0
- package/dist/shared/common/src/services/token/index.d.ts +2 -0
- package/dist/shared/common/src/services/token/index.js +18 -0
- package/dist/shared/common/src/services/token/tokenProtocolClientBase.d.ts +51 -0
- package/dist/shared/common/src/services/token/tokenProtocolClientBase.js +2 -0
- package/dist/shared/common/src/services/token/types.d.ts +19 -0
- package/dist/shared/common/src/services/token/types.js +2 -0
- package/dist/shared/common/src/services/transactionSender.d.ts +24 -0
- package/dist/shared/common/src/services/transactionSender.js +30 -0
- package/dist/shared/common/src/types/cpi.d.ts +34 -0
- package/dist/shared/common/src/types/cpi.js +8 -0
- package/dist/shared/common/src/types/enums.d.ts +59 -0
- package/dist/shared/common/src/types/enums.js +122 -0
- package/dist/shared/common/src/types/general.d.ts +38 -0
- package/dist/shared/common/src/types/general.js +2 -0
- package/dist/shared/common/src/types/index.d.ts +4 -0
- package/dist/shared/common/src/types/index.js +20 -0
- package/dist/shared/common/src/types/solana.d.ts +24 -0
- package/dist/shared/common/src/types/solana.js +2 -0
- package/dist/shared/common/src/utils/accounts/index.d.ts +5 -0
- package/dist/shared/common/src/utils/accounts/index.js +21 -0
- package/dist/shared/common/src/utils/accounts/meta.d.ts +21 -0
- package/dist/shared/common/src/utils/accounts/meta.js +27 -0
- package/dist/shared/common/src/utils/accounts/pda.d.ts +2 -0
- package/dist/shared/common/src/utils/accounts/pda.js +17 -0
- package/dist/shared/common/src/utils/accounts/roles.d.ts +26 -0
- package/dist/shared/common/src/utils/accounts/roles.js +54 -0
- package/dist/shared/common/src/utils/accounts/rpc.d.ts +8 -0
- package/dist/shared/common/src/utils/accounts/rpc.js +30 -0
- package/dist/shared/common/src/utils/accounts/splBalances.d.ts +15 -0
- package/dist/shared/common/src/utils/accounts/splBalances.js +52 -0
- package/dist/shared/common/src/utils/anchor.d.ts +17 -0
- package/dist/shared/common/src/utils/anchor.js +29 -0
- package/dist/shared/common/src/utils/asyncConcurrency.d.ts +5 -0
- package/dist/shared/common/src/utils/asyncConcurrency.js +28 -0
- package/dist/shared/common/src/utils/compat.d.ts +46 -0
- package/dist/shared/common/src/utils/compat.js +72 -0
- package/dist/shared/common/src/utils/cpi/args.d.ts +69 -0
- package/dist/shared/common/src/utils/cpi/args.js +100 -0
- package/dist/shared/common/src/utils/cpi/index.d.ts +2 -0
- package/dist/shared/common/src/utils/cpi/index.js +18 -0
- package/dist/shared/common/src/utils/cpi/refs.d.ts +122 -0
- package/dist/shared/common/src/utils/cpi/refs.js +234 -0
- package/dist/shared/common/src/utils/data.d.ts +20 -0
- package/dist/shared/common/src/utils/data.js +27 -0
- package/dist/shared/common/src/utils/general.d.ts +24 -0
- package/dist/shared/common/src/utils/general.js +95 -0
- package/dist/shared/common/src/utils/index.d.ts +22 -0
- package/dist/shared/common/src/utils/index.js +38 -0
- package/dist/shared/common/src/utils/instruction.d.ts +74 -0
- package/dist/shared/common/src/utils/instruction.js +147 -0
- package/dist/shared/common/src/utils/jito.d.ts +113 -0
- package/dist/shared/common/src/utils/jito.js +178 -0
- package/dist/shared/common/src/utils/json.d.ts +5 -0
- package/dist/shared/common/src/utils/json.js +25 -0
- package/dist/shared/common/src/utils/jsonRpcFetch.d.ts +21 -0
- package/dist/shared/common/src/utils/jsonRpcFetch.js +134 -0
- package/dist/shared/common/src/utils/metadata.d.ts +107 -0
- package/dist/shared/common/src/utils/metadata.js +194 -0
- package/dist/shared/common/src/utils/numbers.d.ts +72 -0
- package/dist/shared/common/src/utils/numbers.js +193 -0
- package/dist/shared/common/src/utils/priorityFee.d.ts +18 -0
- package/dist/shared/common/src/utils/priorityFee.js +63 -0
- package/dist/shared/common/src/utils/retry.d.ts +20 -0
- package/dist/shared/common/src/utils/retry.js +69 -0
- package/dist/shared/common/src/utils/rpc.d.ts +40 -0
- package/dist/shared/common/src/utils/rpc.js +130 -0
- package/dist/shared/common/src/utils/solana.d.ts +23 -0
- package/dist/shared/common/src/utils/solana.js +61 -0
- package/dist/shared/common/src/utils/timeSeries.d.ts +18 -0
- package/dist/shared/common/src/utils/timeSeries.js +40 -0
- package/dist/shared/common/src/utils/token.d.ts +33 -0
- package/dist/shared/common/src/utils/token.js +82 -0
- package/dist/shared/common/src/utils/transaction.d.ts +154 -0
- package/dist/shared/common/src/utils/transaction.js +585 -0
- package/dist/shared/common/src/utils/transactionSplitter.d.ts +85 -0
- package/dist/shared/common/src/utils/transactionSplitter.js +127 -0
- package/dist/shared/common/src/utils/txAccountCoverage.d.ts +49 -0
- package/dist/shared/common/src/utils/txAccountCoverage.js +122 -0
- package/dist/shared/jupiter-helpers/src/api.d.ts +59 -0
- package/dist/shared/jupiter-helpers/src/api.js +130 -0
- package/dist/shared/jupiter-helpers/src/client.d.ts +79 -0
- package/dist/shared/jupiter-helpers/src/client.js +173 -0
- package/dist/shared/jupiter-helpers/src/constants.d.ts +35 -0
- package/dist/shared/jupiter-helpers/src/constants.js +38 -0
- package/dist/shared/jupiter-helpers/src/extract.d.ts +30 -0
- package/dist/shared/jupiter-helpers/src/extract.js +57 -0
- package/dist/shared/jupiter-helpers/src/index.d.ts +5 -0
- package/dist/shared/jupiter-helpers/src/index.js +21 -0
- package/dist/shared/jupiter-helpers/src/routePreInstructions.d.ts +19 -0
- package/dist/shared/jupiter-helpers/src/routePreInstructions.js +61 -0
- package/dist/shared/jupiter-helpers/src/sizeExactInForMinOutput.d.ts +70 -0
- package/dist/shared/jupiter-helpers/src/sizeExactInForMinOutput.js +95 -0
- package/dist/shared/jupiter-helpers/src/types.d.ts +66 -0
- package/dist/shared/jupiter-helpers/src/types.js +2 -0
- package/dist/shared/lending-platforms/src/constants/cache.d.ts +8 -0
- package/dist/shared/lending-platforms/src/constants/cache.js +11 -0
- package/dist/shared/lending-platforms/src/constants/index.d.ts +3 -0
- package/dist/shared/lending-platforms/src/constants/index.js +19 -0
- package/dist/shared/lending-platforms/src/constants/kamino.d.ts +7 -0
- package/dist/shared/lending-platforms/src/constants/kamino.js +83 -0
- package/dist/shared/lending-platforms/src/constants/lendingPosition.d.ts +7 -0
- package/dist/shared/lending-platforms/src/constants/lendingPosition.js +10 -0
- package/dist/shared/lending-platforms/src/data/accounts/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/data/accounts/index.js +18 -0
- package/dist/shared/lending-platforms/src/data/accounts/kamino.d.ts +42 -0
- package/dist/shared/lending-platforms/src/data/accounts/kamino.js +104 -0
- package/dist/shared/lending-platforms/src/data/accounts/lpAccountsBase.d.ts +7 -0
- package/dist/shared/lending-platforms/src/data/accounts/lpAccountsBase.js +9 -0
- package/dist/shared/lending-platforms/src/data/incentive/incentiveBase.d.ts +35 -0
- package/dist/shared/lending-platforms/src/data/incentive/incentiveBase.js +26 -0
- package/dist/shared/lending-platforms/src/data/incentive/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/data/incentive/index.js +18 -0
- package/dist/shared/lending-platforms/src/data/incentive/kamino.d.ts +55 -0
- package/dist/shared/lending-platforms/src/data/incentive/kamino.js +101 -0
- package/dist/shared/lending-platforms/src/data/index.d.ts +6 -0
- package/dist/shared/lending-platforms/src/data/index.js +22 -0
- package/dist/shared/lending-platforms/src/data/instructions/index.d.ts +3 -0
- package/dist/shared/lending-platforms/src/data/instructions/index.js +19 -0
- package/dist/shared/lending-platforms/src/data/instructions/kamino.d.ts +55 -0
- package/dist/shared/lending-platforms/src/data/instructions/kamino.js +630 -0
- package/dist/shared/lending-platforms/src/data/instructions/lpInstructionsBase.d.ts +175 -0
- package/dist/shared/lending-platforms/src/data/instructions/lpInstructionsBase.js +192 -0
- package/dist/shared/lending-platforms/src/data/instructions/types.d.ts +7 -0
- package/dist/shared/lending-platforms/src/data/instructions/types.js +2 -0
- package/dist/shared/lending-platforms/src/data/platform/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/data/platform/index.js +18 -0
- package/dist/shared/lending-platforms/src/data/platform/kamino.d.ts +59 -0
- package/dist/shared/lending-platforms/src/data/platform/kamino.js +206 -0
- package/dist/shared/lending-platforms/src/data/platform/lpDataBase.d.ts +35 -0
- package/dist/shared/lending-platforms/src/data/platform/lpDataBase.js +31 -0
- package/dist/shared/lending-platforms/src/data/reserve/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/data/reserve/index.js +18 -0
- package/dist/shared/lending-platforms/src/data/reserve/kamino.d.ts +45 -0
- package/dist/shared/lending-platforms/src/data/reserve/kamino.js +141 -0
- package/dist/shared/lending-platforms/src/data/reserve/reserveBase.d.ts +114 -0
- package/dist/shared/lending-platforms/src/data/reserve/reserveBase.js +125 -0
- package/dist/shared/lending-platforms/src/data/userPosition/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/data/userPosition/index.js +18 -0
- package/dist/shared/lending-platforms/src/data/userPosition/kamino.d.ts +15 -0
- package/dist/shared/lending-platforms/src/data/userPosition/kamino.js +45 -0
- package/dist/shared/lending-platforms/src/data/userPosition/userPositionBase.d.ts +50 -0
- package/dist/shared/lending-platforms/src/data/userPosition/userPositionBase.js +63 -0
- package/dist/shared/lending-platforms/src/index.d.ts +5 -0
- package/dist/shared/lending-platforms/src/index.js +21 -0
- package/dist/shared/lending-platforms/src/services/client/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/services/client/index.js +18 -0
- package/dist/shared/lending-platforms/src/services/client/kamino.d.ts +53 -0
- package/dist/shared/lending-platforms/src/services/client/kamino.js +142 -0
- package/dist/shared/lending-platforms/src/services/client/lpClientBase.d.ts +66 -0
- package/dist/shared/lending-platforms/src/services/client/lpClientBase.js +19 -0
- package/dist/shared/lending-platforms/src/services/flashLoan/flashLoanBase.d.ts +49 -0
- package/dist/shared/lending-platforms/src/services/flashLoan/flashLoanBase.js +16 -0
- package/dist/shared/lending-platforms/src/services/flashLoan/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/services/flashLoan/index.js +18 -0
- package/dist/shared/lending-platforms/src/services/flashLoan/kamino.d.ts +11 -0
- package/dist/shared/lending-platforms/src/services/flashLoan/kamino.js +85 -0
- package/dist/shared/lending-platforms/src/services/index.d.ts +5 -0
- package/dist/shared/lending-platforms/src/services/index.js +21 -0
- package/dist/shared/lending-platforms/src/services/lendingPosition/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/services/lendingPosition/index.js +18 -0
- package/dist/shared/lending-platforms/src/services/lendingPosition/lendingPositionManager.d.ts +117 -0
- package/dist/shared/lending-platforms/src/services/lendingPosition/lendingPositionManager.js +342 -0
- package/dist/shared/lending-platforms/src/services/lendingPosition/types.d.ts +40 -0
- package/dist/shared/lending-platforms/src/services/lendingPosition/types.js +2 -0
- package/dist/shared/lending-platforms/src/services/leverage/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/services/leverage/index.js +18 -0
- package/dist/shared/lending-platforms/src/services/leverage/leverageService.d.ts +104 -0
- package/dist/shared/lending-platforms/src/services/leverage/leverageService.js +437 -0
- package/dist/shared/lending-platforms/src/services/leverage/types.d.ts +261 -0
- package/dist/shared/lending-platforms/src/services/leverage/types.js +2 -0
- package/dist/shared/lending-platforms/src/services/reservesManager.d.ts +53 -0
- package/dist/shared/lending-platforms/src/services/reservesManager.js +112 -0
- package/dist/shared/lending-platforms/src/types/general.d.ts +37 -0
- package/dist/shared/lending-platforms/src/types/general.js +8 -0
- package/dist/shared/lending-platforms/src/types/index.d.ts +2 -0
- package/dist/shared/lending-platforms/src/types/index.js +18 -0
- package/dist/shared/lending-platforms/src/types/kamino.d.ts +10 -0
- package/dist/shared/lending-platforms/src/types/kamino.js +2 -0
- package/dist/shared/lending-platforms/src/utils/accounts.d.ts +16 -0
- package/dist/shared/lending-platforms/src/utils/accounts.js +36 -0
- package/dist/shared/lending-platforms/src/utils/cache.d.ts +3 -0
- package/dist/shared/lending-platforms/src/utils/cache.js +11 -0
- package/dist/shared/lending-platforms/src/utils/index.d.ts +6 -0
- package/dist/shared/lending-platforms/src/utils/index.js +22 -0
- package/dist/shared/lending-platforms/src/utils/kamino.d.ts +87 -0
- package/dist/shared/lending-platforms/src/utils/kamino.js +190 -0
- package/dist/shared/lending-platforms/src/utils/lendingPlatform.d.ts +6 -0
- package/dist/shared/lending-platforms/src/utils/lendingPlatform.js +16 -0
- package/dist/shared/lending-platforms/src/utils/math.d.ts +47 -0
- package/dist/shared/lending-platforms/src/utils/math.js +123 -0
- package/dist/shared/lending-platforms/src/utils/scope.d.ts +38 -0
- package/dist/shared/lending-platforms/src/utils/scope.js +144 -0
- package/dist/shared/oracle-service/src/constants/index.d.ts +3 -0
- package/dist/shared/oracle-service/src/constants/index.js +19 -0
- package/dist/shared/oracle-service/src/constants/pyth.d.ts +7 -0
- package/dist/shared/oracle-service/src/constants/pyth.js +71 -0
- package/dist/shared/oracle-service/src/constants/splStake.d.ts +2 -0
- package/dist/shared/oracle-service/src/constants/splStake.js +6 -0
- package/dist/shared/oracle-service/src/constants/switchboard.d.ts +7 -0
- package/dist/shared/oracle-service/src/constants/switchboard.js +10 -0
- package/dist/shared/oracle-service/src/feeds/custom.d.ts +30 -0
- package/dist/shared/oracle-service/src/feeds/custom.js +56 -0
- package/dist/shared/oracle-service/src/feeds/jupiter.d.ts +7 -0
- package/dist/shared/oracle-service/src/feeds/jupiter.js +43 -0
- package/dist/shared/oracle-service/src/feeds/priceBase.d.ts +13 -0
- package/dist/shared/oracle-service/src/feeds/priceBase.js +25 -0
- package/dist/shared/oracle-service/src/feeds/pyth.d.ts +8 -0
- package/dist/shared/oracle-service/src/feeds/pyth.js +59 -0
- package/dist/shared/oracle-service/src/feeds/splStake.d.ts +26 -0
- package/dist/shared/oracle-service/src/feeds/splStake.js +99 -0
- package/dist/shared/oracle-service/src/feeds/switchboard.d.ts +6 -0
- package/dist/shared/oracle-service/src/feeds/switchboard.js +11 -0
- package/dist/shared/oracle-service/src/index.d.ts +5 -0
- package/dist/shared/oracle-service/src/index.js +26 -0
- package/dist/shared/oracle-service/src/oracle.d.ts +22 -0
- package/dist/shared/oracle-service/src/oracle.js +104 -0
- package/dist/shared/oracle-service/src/types.d.ts +4 -0
- package/dist/shared/oracle-service/src/types.js +2 -0
- package/dist/shared/oracle-service/src/utils/general.d.ts +20 -0
- package/dist/shared/oracle-service/src/utils/general.js +65 -0
- package/dist/shared/oracle-service/src/utils/index.d.ts +1 -0
- package/dist/shared/oracle-service/src/utils/index.js +17 -0
- package/dist/shared/perena-helpers/src/accounts.d.ts +7 -0
- package/dist/shared/perena-helpers/src/accounts.js +12 -0
- package/dist/shared/perena-helpers/src/client.d.ts +299 -0
- package/dist/shared/perena-helpers/src/client.js +680 -0
- package/dist/shared/perena-helpers/src/constants.d.ts +5 -0
- package/dist/shared/perena-helpers/src/constants.js +8 -0
- package/dist/shared/perena-helpers/src/cpi/burn.d.ts +27 -0
- package/dist/shared/perena-helpers/src/cpi/burn.js +22 -0
- package/dist/shared/perena-helpers/src/cpi/index.d.ts +3 -0
- package/dist/shared/perena-helpers/src/cpi/index.js +19 -0
- package/dist/shared/perena-helpers/src/cpi/mint.d.ts +27 -0
- package/dist/shared/perena-helpers/src/cpi/mint.js +22 -0
- package/dist/shared/perena-helpers/src/cpi/requestUnstake.d.ts +19 -0
- package/dist/shared/perena-helpers/src/cpi/requestUnstake.js +16 -0
- package/dist/shared/perena-helpers/src/index.d.ts +5 -0
- package/dist/shared/perena-helpers/src/index.js +21 -0
- package/dist/shared/perena-helpers/src/utils.d.ts +9 -0
- package/dist/shared/perena-helpers/src/utils.js +54 -0
- package/dist/shared/swap-aggregator/src/aggSwapClient.d.ts +71 -0
- package/dist/shared/swap-aggregator/src/aggSwapClient.js +103 -0
- package/dist/shared/swap-aggregator/src/index.d.ts +1 -0
- package/dist/shared/swap-aggregator/src/index.js +17 -0
- package/docs/launchingToken.md +57 -0
- package/package.json +75 -0
- package/scripts/asyncBurn.ts +155 -0
- package/scripts/burnToken.ts +120 -0
- package/scripts/claimIncentives.ts +125 -0
- package/scripts/closeCpiPlans.ts +113 -0
- package/scripts/collectInterest.ts +194 -0
- package/scripts/collectProtocolFees.ts +144 -0
- package/scripts/computeOptimalAllocations.ts +117 -0
- package/scripts/createToken.ts +100 -0
- package/scripts/createTokenLendingPosition.ts +204 -0
- package/scripts/createYieldingBank.ts +91 -0
- package/scripts/decreaseCarryPositions.ts +359 -0
- package/scripts/depositUnlentCollateral.ts +106 -0
- package/scripts/emergency/deleverageAll.ts +287 -0
- package/scripts/emergency/triggerCircuitBreaker.ts +87 -0
- package/scripts/env.ts +4 -0
- package/scripts/findTxs.ts +169 -0
- package/scripts/increaseCarryPositions.ts +134 -0
- package/scripts/inspect/format.ts +576 -0
- package/scripts/inspect.ts +147 -0
- package/scripts/localUtils.ts +249 -0
- package/scripts/mintToken.ts +126 -0
- package/scripts/processAsyncBurns.ts +89 -0
- package/scripts/rebalanceToken.ts +269 -0
- package/scripts/rebalanceYieldingBank.ts +183 -0
- package/scripts/recollateralizeLoss.ts +79 -0
- package/scripts/refresh.ts +156 -0
- package/scripts/updateFees.ts +486 -0
- package/scripts/updateGeneralLut.ts +36 -0
- package/scripts/updateLendingPositionConfig.ts +172 -0
- package/scripts/updateTokenLuts.ts +36 -0
- package/scripts/updateTokenMetadata.ts +199 -0
- package/scripts/updateYieldingBankConfig.ts +100 -0
- package/scripts/withdrawUnlentCollateral.ts +178 -0
- package/src/client/account.ts +503 -0
- package/src/client/builders/args.ts +381 -0
- package/src/client/builders/asyncBurnBuilder.ts +305 -0
- package/src/client/builders/base.ts +303 -0
- package/src/client/builders/burnTokenBuilder.ts +258 -0
- package/src/client/builders/claimIncentivesBuilder.ts +211 -0
- package/src/client/builders/collectFeesBuilder.ts +52 -0
- package/src/client/builders/collectInterestBuilder.ts +165 -0
- package/src/client/builders/createCpiPlanBuilder.ts +21 -0
- package/src/client/builders/createTokenBuilder.ts +73 -0
- package/src/client/builders/createTokenLendingPositionBuilder.ts +219 -0
- package/src/client/builders/createYieldingBankAllocationBuilder.ts +32 -0
- package/src/client/builders/createYieldingBankBuilder.ts +39 -0
- package/src/client/builders/decreaseCarryPositionBuilder.ts +162 -0
- package/src/client/builders/depositUnlentCollateralBuilder.ts +95 -0
- package/src/client/builders/increaseCarryPositionBuilder.ts +105 -0
- package/src/client/builders/index.ts +37 -0
- package/src/client/builders/mintTokenBuilder.ts +137 -0
- package/src/client/builders/rebalanceTokenBuilder.ts +356 -0
- package/src/client/builders/rebalanceYieldingBankBuilder.ts +109 -0
- package/src/client/builders/recollateralizeLossBuilder.ts +367 -0
- package/src/client/builders/refreshTokenStateBuilder.ts +153 -0
- package/src/client/builders/refreshTokensBuilder.ts +82 -0
- package/src/client/builders/refreshYieldingBankBuilder.ts +42 -0
- package/src/client/builders/resetTokenBurnRateLimitBuilder.ts +21 -0
- package/src/client/builders/setTokenCircuitBreakerBuilder.ts +40 -0
- package/src/client/builders/setYieldingBankCircuitBreakerBuilder.ts +37 -0
- package/src/client/builders/updateLendingPositionConfigBuilder.ts +33 -0
- package/src/client/builders/updateTokenConfigurationBuilder.ts +50 -0
- package/src/client/builders/updateTokenMetadataBuilder.ts +24 -0
- package/src/client/builders/updateYieldingBankConfigBuilder.ts +32 -0
- package/src/client/builders/utils.ts +26 -0
- package/src/client/client.ts +264 -0
- package/src/client/externalLiquidityResolver.ts +54 -0
- package/src/client/index.ts +20 -0
- package/src/client/lendingPlatformClients.ts +50 -0
- package/src/client/pda.ts +102 -0
- package/src/client/plans/collectInterest.ts +207 -0
- package/src/client/plans/decreaseCarryPosition.ts +226 -0
- package/src/client/routes/collectInterest.ts +56 -0
- package/src/client/transaction.ts +106 -0
- package/src/client/types/builders.ts +19 -0
- package/src/client/types/enums.ts +47 -0
- package/src/client/types/general.ts +117 -0
- package/src/client/types/index.ts +6 -0
- package/src/client/types/ix.ts +452 -0
- package/src/client/types/planTypes/collectInterest.ts +97 -0
- package/src/client/types/planTypes/common.ts +31 -0
- package/src/client/types/planTypes/decreaseCarryPosition.ts +134 -0
- package/src/client/types/planTypes/index.ts +3 -0
- package/src/client/types/tx.ts +409 -0
- package/src/constants/configs/allocations.ts +30 -0
- package/src/constants/configs/carryTradePresets.ts +164 -0
- package/src/constants/configs/index.ts +2 -0
- package/src/constants/general.ts +141 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/lycTokenMetadata.ts +52 -0
- package/src/decoders/decodeTransaction.ts +319 -0
- package/src/decoders/discriminators.ts +10 -0
- package/src/decoders/idlAccounts.ts +75 -0
- package/src/decoders/index.ts +15 -0
- package/src/decoders/innerCpis.ts +262 -0
- package/src/decoders/lycInstructionNames.ts +73 -0
- package/src/decoders/programIds.ts +12 -0
- package/src/decoders/solana.ts +25 -0
- package/src/decoders/transactionPayload.ts +41 -0
- package/src/decoders/types.ts +60 -0
- package/src/errors.ts +195 -0
- package/src/idl/long_yield_carry.ts +14648 -0
- package/src/index.ts +10 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/protocolMetrics.ts +976 -0
- package/src/models/index.ts +9 -0
- package/src/models/lycToken.ts +380 -0
- package/src/models/yieldingBank.ts +127 -0
- package/src/services/allocation/allocationService.ts +823 -0
- package/src/services/allocation/index.ts +2 -0
- package/src/services/allocation/types.ts +27 -0
- package/src/services/carry/carryAllocationConfig.ts +266 -0
- package/src/services/carry/index.ts +2 -0
- package/src/services/carry/lycLendingPositionManager.ts +167 -0
- package/src/services/index.ts +5 -0
- package/src/services/lendingPosition/index.ts +5 -0
- package/src/services/lendingPosition/lendingPositionService.ts +328 -0
- package/src/services/rebalance/index.ts +2 -0
- package/src/services/rebalance/token/index.ts +1 -0
- package/src/services/rebalance/token/tokenRebalanceService.ts +142 -0
- package/src/services/rebalance/yieldingBank/index.ts +3 -0
- package/src/services/rebalance/yieldingBank/planner.ts +215 -0
- package/src/services/rebalance/yieldingBank/strategy.ts +41 -0
- package/src/services/rebalance/yieldingBank/types.ts +41 -0
- package/src/services/redemption/index.ts +9 -0
- package/src/services/redemption/redemptionService.ts +758 -0
- package/src/types/enriched.ts +187 -0
- package/src/types/index.ts +1 -0
- package/src/utils/cache.ts +12 -0
- package/src/utils/data.ts +65 -0
- package/src/utils/enrichment.ts +330 -0
- package/src/utils/feeDripMetrics.ts +146 -0
- package/src/utils/general.ts +54 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/ix.ts +227 -0
- package/src/utils/lendingPosition.ts +221 -0
- package/src/utils/lookupTables.ts +309 -0
- package/src/utils/lycData.ts +321 -0
- package/src/utils/timelock.ts +63 -0
- package/src/utils/tokenFeeMath.ts +25 -0
- package/src/utils/transactions.ts +109 -0
- package/src/utils/yieldingBank.ts +38 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RebalanceTokenBuilder = void 0;
|
|
4
|
+
const core_1 = require("@anchor-lang/core");
|
|
5
|
+
const common_1 = require("common");
|
|
6
|
+
const oracle_1 = require("oracle");
|
|
7
|
+
const lending_platforms_1 = require("lending-platforms");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const base_1 = require("./base");
|
|
10
|
+
const general_1 = require("../../constants/general");
|
|
11
|
+
const refreshYieldingBankBuilder_1 = require("./refreshYieldingBankBuilder");
|
|
12
|
+
const createCpiPlanBuilder_1 = require("./createCpiPlanBuilder");
|
|
13
|
+
class RebalanceTokenBuilder extends base_1.LongYieldCarryBuilderBase {
|
|
14
|
+
async getIx(args) {
|
|
15
|
+
const tokenData = await this.account.fetchToken(args.token);
|
|
16
|
+
return this.program.methods
|
|
17
|
+
.rebalanceToken({
|
|
18
|
+
lpIndex: args.params.lpIndex,
|
|
19
|
+
destinationDebtOracleType: args.params.destinationDebtOracleType,
|
|
20
|
+
flashFeeAmount: args.params.flashFeeAmount,
|
|
21
|
+
repayAmount: args.params.repayAmount,
|
|
22
|
+
})
|
|
23
|
+
.accountsPartial({
|
|
24
|
+
manager: this.resolveTokenManager(tokenData.data),
|
|
25
|
+
cpiPlan: args.params.cpiPlan,
|
|
26
|
+
})
|
|
27
|
+
.remainingAccounts(args.params.remainingAccounts.map(common_1.toWeb3AccountMeta))
|
|
28
|
+
.instruction()
|
|
29
|
+
.then(common_1.toKitInstruction);
|
|
30
|
+
}
|
|
31
|
+
async getTx(args) {
|
|
32
|
+
const tokenData = await this.account.fetchToken(args.token);
|
|
33
|
+
const { lpIndex, destinationDebtMint } = args.params;
|
|
34
|
+
const position = tokenData.data.lendingPositions[lpIndex];
|
|
35
|
+
if (!position) {
|
|
36
|
+
throw new Error(`rebalance_token: no lending position at index ${lpIndex}`);
|
|
37
|
+
}
|
|
38
|
+
const txId = args.params.txId ?? `rebalance-token-${Date.now()}`;
|
|
39
|
+
const yieldingBank = args.params.yieldingBank ?? (await tokenData.resolveFirstYieldingBankAddress(this.pda));
|
|
40
|
+
const lpClient = this.getLendingPlatformClient(position);
|
|
41
|
+
const pool = (0, common_1.fromWeb3Pk)(position.pool);
|
|
42
|
+
const withdrawAll = args.params.uiAmount === "all";
|
|
43
|
+
const collateralUiAmount = args.params.uiAmount === "all"
|
|
44
|
+
? (0, common_1.toUiAmount)(position.accounting.collateral, tokenData.data.collateral.decimals)
|
|
45
|
+
: args.params.uiAmount;
|
|
46
|
+
// Fetch source debt reserve (by address), supply reserve (by address), and
|
|
47
|
+
// destination debt reserve (by mint, since the position currently holds the old mint).
|
|
48
|
+
const [sourceDebtReserve, supplyReserve, destDebtReserve] = await Promise.all([
|
|
49
|
+
lpClient.data.fetchReserve(pool, (0, common_1.fromWeb3Pk)(position.debtReserve)),
|
|
50
|
+
lpClient.data.fetchReserve(pool, (0, common_1.fromWeb3Pk)(position.collateralReserve)),
|
|
51
|
+
lpClient.data.fetchReserveByMint(pool, destinationDebtMint),
|
|
52
|
+
]);
|
|
53
|
+
if (!sourceDebtReserve || !supplyReserve || !destDebtReserve) {
|
|
54
|
+
throw new Error("rebalance_token: failed to fetch one or more lending-position reserves");
|
|
55
|
+
}
|
|
56
|
+
const manager = this.resolveTokenManager(tokenData.data);
|
|
57
|
+
const flashLoan = lpClient.getFlashLoan();
|
|
58
|
+
const userAccount = (0, common_1.fromWeb3Pk)(position.protocolUserAcc);
|
|
59
|
+
// Both legs operate on the same position: supply never moves, only debt mint changes.
|
|
60
|
+
const flashContext = {
|
|
61
|
+
source: {
|
|
62
|
+
lendingIx: lpClient.ix,
|
|
63
|
+
supplyReserve,
|
|
64
|
+
debtReserve: sourceDebtReserve,
|
|
65
|
+
pool,
|
|
66
|
+
userAccount,
|
|
67
|
+
},
|
|
68
|
+
destination: {
|
|
69
|
+
lendingIx: lpClient.ix,
|
|
70
|
+
supplyReserve,
|
|
71
|
+
debtReserve: destDebtReserve,
|
|
72
|
+
pool,
|
|
73
|
+
userAccount,
|
|
74
|
+
},
|
|
75
|
+
flashLoan,
|
|
76
|
+
swap: this.swap,
|
|
77
|
+
user: args.token,
|
|
78
|
+
payer: manager,
|
|
79
|
+
txId,
|
|
80
|
+
environment: this.environment,
|
|
81
|
+
};
|
|
82
|
+
const flash = await this.buildFlashRebalanceOrSkip(flashContext, {
|
|
83
|
+
collateralUiAmount,
|
|
84
|
+
sourceTargetUtilizationRateBps: position.config.targetUtilizationRateBps,
|
|
85
|
+
destinationMaxUtilizationRateBps: this.maxPostRebalanceUtilizationBps(position),
|
|
86
|
+
swapSlippageBps: args.params.swapSlippageBps,
|
|
87
|
+
maxSwapCostBps: args.params.maxSwapCostBps,
|
|
88
|
+
maxMarketBasisBps: args.params.maxMarketBasisBps,
|
|
89
|
+
withdrawAll,
|
|
90
|
+
});
|
|
91
|
+
const destDebtOracleData = oracle_1.oracle.getOracleData(destinationDebtMint);
|
|
92
|
+
if (!destDebtOracleData) {
|
|
93
|
+
throw new Error(`rebalance_token: no oracle registered for destination debt mint ${destinationDebtMint}`);
|
|
94
|
+
}
|
|
95
|
+
const destDebtOracle = destDebtOracleData.oracle;
|
|
96
|
+
const destDebtOracleType = (0, common_1.enumToOracleType)(destDebtOracleData.oracleType);
|
|
97
|
+
const initialAccounts = await this.account.getRebalanceTokenInitialAccounts(args.token, yieldingBank, lpIndex, destDebtOracle, args.params.lpPosition);
|
|
98
|
+
// Pack all inner CPIs into one remaining-accounts pool that starts with
|
|
99
|
+
// the rebalance-token initial accounts. CPIs that reference the token,
|
|
100
|
+
// yielding bank, ATAs, or LP refresh accounts deduplicate against these
|
|
101
|
+
// fixed slots — shrinking the transaction's account list.
|
|
102
|
+
// The new debt reserve is tracked in the borrow ref (tracked[0]) so the
|
|
103
|
+
// on-chain handler can update the destination lending position's
|
|
104
|
+
// debt_reserve in place without an extra instruction parameter.
|
|
105
|
+
const cpiGroups = this.collectFlashCpiGroups(flash);
|
|
106
|
+
const { accounts: remainingAccounts, refsGroups, lookupTables, } = (0, common_1.createMultiCpiRefs)(cpiGroups.groups, {
|
|
107
|
+
initialAccounts,
|
|
108
|
+
trackAddresses: [destDebtReserve.address, destinationDebtMint],
|
|
109
|
+
});
|
|
110
|
+
const refs = cpiGroups.indices;
|
|
111
|
+
const planRefs = [
|
|
112
|
+
refsGroups[refs.sourceRepay],
|
|
113
|
+
refsGroups[refs.destinationBorrow],
|
|
114
|
+
refsGroups[refs.swap],
|
|
115
|
+
];
|
|
116
|
+
const { instructions: ataCreationIxs, postSuccessCacheInvalidations: ataPostSuccess } = await (0, common_1.getCreateAtaInstructions)(this.rpc, manager, remainingAccounts);
|
|
117
|
+
// The Kamino destination borrow CPI sets `user_destination_liquidity` to
|
|
118
|
+
// the token PDA's destination-debt ATA. When the token has never held
|
|
119
|
+
// that mint, the ATA is missing and Kamino fails with
|
|
120
|
+
// `AccountNotInitialized` (Anchor 3012). The borrow's account meta does
|
|
121
|
+
// carry an `isRequiredAta` seed, but `buildDeduplicatedPool` only
|
|
122
|
+
// preserves the first occurrence's flag — if the same address shows up
|
|
123
|
+
// earlier without seeds, the create-ATA pass above silently skips it.
|
|
124
|
+
// Add an explicit idempotent create here so the destination debt ATA is
|
|
125
|
+
// guaranteed to exist before the rebalance ix runs.
|
|
126
|
+
// TODO: fix `buildDeduplicatedPool` to merge `isRequiredAta` flags
|
|
127
|
+
// across duplicate occurrences instead of keeping only the first, then
|
|
128
|
+
// remove this per-builder workaround. We resolve the mint's
|
|
129
|
+
// token program through the same `mints` registry Kamino's
|
|
130
|
+
// `reserveInteractionDetails` uses (kamino.ts → `liquidityMintTokenProgram`)
|
|
131
|
+
// so the ATA address we create matches the one Kamino derives.
|
|
132
|
+
const destDebtMintInfo = common_1.mints.get(destinationDebtMint);
|
|
133
|
+
if (!destDebtMintInfo) {
|
|
134
|
+
throw new Error(`RebalanceTokenBuilder: destination debt mint ${destinationDebtMint} not found in mint registry`);
|
|
135
|
+
}
|
|
136
|
+
const { instruction: destDebtAtaIx, postSuccessCacheInvalidations: destDebtAtaPostSuccess } = await (0, common_1.getCreateAtaIxIfNeeded)(this.rpc, manager, destinationDebtMint, args.token, destDebtMintInfo.tokenProgram);
|
|
137
|
+
// The on-chain handler calls `verify_price_is_fresh` on the bank, so we
|
|
138
|
+
// only need to prepend a refresh when the cached `lastRefreshedTs` is
|
|
139
|
+
// outside the staleness window.
|
|
140
|
+
const yieldingBankAccount = await this.account.fetchYieldingBank(yieldingBank);
|
|
141
|
+
const refreshYieldingBankInstructions = yieldingBankAccount.isStale
|
|
142
|
+
? (await new refreshYieldingBankBuilder_1.RefreshYieldingBankBuilder(this.context).getTx({
|
|
143
|
+
signer: manager,
|
|
144
|
+
yieldingBank,
|
|
145
|
+
})).instructions
|
|
146
|
+
: [];
|
|
147
|
+
// For a full-position move (`withdrawAll`), send Kamino's `u64::MAX`
|
|
148
|
+
// "repay all" sentinel so the on-chain `RepayObligationLiquidityV2` CPI
|
|
149
|
+
// clears the obligation's actual debt exactly — interest accrual between
|
|
150
|
+
// the off-chain snapshot and bundle landing can't leave dust that trips
|
|
151
|
+
// `NetValueRemainingTooSmall` (klend error 6092). The flash-borrow is
|
|
152
|
+
// over-borrowed by 5 bps in `LeverageService.buildFlashRebalance` to
|
|
153
|
+
// cover that drift; the post-repay surplus is swept into the yielding
|
|
154
|
+
// bank.
|
|
155
|
+
//
|
|
156
|
+
// For a partial rebalance, the flash-borrow only covers `sourceRepay`
|
|
157
|
+
// (sized to bring source utilization back to target) — sending
|
|
158
|
+
// `u64::MAX` would tell Kamino to repay the full obligation debt and
|
|
159
|
+
// the ATA would underfund the SPL transfer (custom 0x1 insufficient
|
|
160
|
+
// funds). Repay exactly what we flash-borrowed so the ATA balance
|
|
161
|
+
// matches the requested CPI amount.
|
|
162
|
+
const repayAllSentinel = lpClient.getRepayAllSentinel();
|
|
163
|
+
if (withdrawAll && !repayAllSentinel) {
|
|
164
|
+
throw new Error("RebalanceTokenBuilder: source lending platform does not expose a repay-all sentinel; cannot build a withdrawAll rebalance");
|
|
165
|
+
}
|
|
166
|
+
const repayAmount = withdrawAll && repayAllSentinel ? repayAllSentinel : flash.flashBorrowAmountBaseUnits;
|
|
167
|
+
const cpiPlanCreatedTs = new core_1.BN(Math.floor(Date.now() / 1000));
|
|
168
|
+
const [cpiPlan] = await this.pda.deriveCpiPlanPda(args.token, BigInt(cpiPlanCreatedTs.toString()));
|
|
169
|
+
const createCpiPlanIx = await new createCpiPlanBuilder_1.CreateCpiPlanBuilder(this.context).getIx({
|
|
170
|
+
manager,
|
|
171
|
+
cpiPlan,
|
|
172
|
+
params: {
|
|
173
|
+
uniqueId: args.token,
|
|
174
|
+
createdTs: cpiPlanCreatedTs,
|
|
175
|
+
refs: planRefs,
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
const rebalanceIx = await this.getIx({
|
|
179
|
+
token: args.token,
|
|
180
|
+
params: {
|
|
181
|
+
lpIndex,
|
|
182
|
+
destinationDebtOracleType: destDebtOracleType,
|
|
183
|
+
flashFeeAmount: flash.flashFeeBaseUnits,
|
|
184
|
+
repayAmount,
|
|
185
|
+
cpiPlan,
|
|
186
|
+
remainingAccounts,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
const mergedLookupTables = (0, utils_1.mergeLycLookupTables)(this.context.environment, args.token, lookupTables ?? []);
|
|
190
|
+
const preambleInstructions = [
|
|
191
|
+
...flash.preInstructions,
|
|
192
|
+
...ataCreationIxs,
|
|
193
|
+
...(destDebtAtaIx ? [destDebtAtaIx] : []),
|
|
194
|
+
...refreshYieldingBankInstructions,
|
|
195
|
+
];
|
|
196
|
+
// The flash group must ride atomically in one tx — Kamino's flash-borrow
|
|
197
|
+
// introspects its own tx's instructions sysvar to find the matching
|
|
198
|
+
// flash-repay (`flash_ixs.rs:NoFlashRepayFound`). We also need its
|
|
199
|
+
// position inside that tx to be predictable so the `borrowInstructionIndex`
|
|
200
|
+
// we encode here matches what Kamino sees at runtime. Marking the group
|
|
201
|
+
// as one indivisible segment AND forcing it to start a fresh bin pins
|
|
202
|
+
// the borrow at index 1 (after the heap-frame ix at index 0), regardless
|
|
203
|
+
// of how the preamble packs.
|
|
204
|
+
const flashBorrowIxIndex = 1;
|
|
205
|
+
const flashRepayIx = await lending_platforms_1.LeverageService.buildFlashRepayIx(flashContext, flash, flashBorrowIxIndex);
|
|
206
|
+
const flashGroup = [
|
|
207
|
+
(0, common_1.requestHeapFrameIx)(general_1.MAX_HEAP_FRAME_BYTES),
|
|
208
|
+
flash.flashBorrowIx,
|
|
209
|
+
rebalanceIx,
|
|
210
|
+
flashRepayIx,
|
|
211
|
+
];
|
|
212
|
+
// Each preamble ix is its own segment (length 1), followed by the CPI plan
|
|
213
|
+
// creation, followed by the flash cycle as one indivisible segment of
|
|
214
|
+
// length 4. Scope refresh-price instructions must remain first in their tx,
|
|
215
|
+
// so the CPI plan creation cannot precede lending-platform pre-instructions.
|
|
216
|
+
const segmentLengths = [...preambleInstructions.map(() => 1), 1, flashGroup.length];
|
|
217
|
+
const flashSegmentIndex = preambleInstructions.length + 1;
|
|
218
|
+
return {
|
|
219
|
+
instructions: [...preambleInstructions, createCpiPlanIx, ...flashGroup],
|
|
220
|
+
lookupTables: mergedLookupTables,
|
|
221
|
+
segmentLengths,
|
|
222
|
+
freshBinSegments: [flashSegmentIndex],
|
|
223
|
+
postSuccessCacheInvalidations: [
|
|
224
|
+
(0, utils_1.getTokenCacheInvalidation)(args.token),
|
|
225
|
+
(0, utils_1.getYieldingBankCacheInvalidation)(yieldingBank),
|
|
226
|
+
...ataPostSuccess,
|
|
227
|
+
...destDebtAtaPostSuccess,
|
|
228
|
+
...flash.postSuccessCacheInvalidations,
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
maxPostRebalanceUtilizationBps(position) {
|
|
233
|
+
return (position.config.targetUtilizationRateBps + position.config.maxDeviationAboveTargetUtilBps);
|
|
234
|
+
}
|
|
235
|
+
async buildFlashRebalanceOrSkip(context, params) {
|
|
236
|
+
return await lending_platforms_1.LeverageService.buildFlashRebalance(context, params);
|
|
237
|
+
}
|
|
238
|
+
collectFlashCpiGroups(flash) {
|
|
239
|
+
// Each op's prereqs (reserve + obligation refreshes) stay bundled with
|
|
240
|
+
// that op. Kamino marks both the obligation AND any written reserves
|
|
241
|
+
// stale after a write op, so the next op's RefreshObligation needs all
|
|
242
|
+
// its referenced reserves re-refreshed before it can pass — we can't
|
|
243
|
+
// dedup `RefreshReserve` CPIs across bundles, even within a single slot.
|
|
244
|
+
const groups = [];
|
|
245
|
+
const indices = {};
|
|
246
|
+
indices.sourceRepay = groups.length;
|
|
247
|
+
groups.push(flash.sourceRepayCpis);
|
|
248
|
+
indices.destinationBorrow = groups.length;
|
|
249
|
+
groups.push(flash.destinationBorrowCpis);
|
|
250
|
+
indices.swap = groups.length;
|
|
251
|
+
groups.push(flash.swapCpis);
|
|
252
|
+
return { groups, indices };
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
exports.RebalanceTokenBuilder = RebalanceTokenBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Instruction } from "@solana/kit";
|
|
2
|
+
import type { LongYieldCarryTransactionPlan } from "../types";
|
|
3
|
+
import { LongYieldCarryBuilderBase } from "./base";
|
|
4
|
+
import type { RebalanceYieldingBankIxArgs, RebalanceYieldingBankTxArgs } from "./args";
|
|
5
|
+
export declare class RebalanceYieldingBankBuilder extends LongYieldCarryBuilderBase<RebalanceYieldingBankIxArgs, RebalanceYieldingBankTxArgs> {
|
|
6
|
+
getIx(args: RebalanceYieldingBankIxArgs): Promise<Instruction>;
|
|
7
|
+
getTx(args: RebalanceYieldingBankTxArgs): Promise<LongYieldCarryTransactionPlan>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RebalanceYieldingBankBuilder = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const common_1 = require("common");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const createYieldingBankAllocationBuilder_1 = require("./createYieldingBankAllocationBuilder");
|
|
8
|
+
class RebalanceYieldingBankBuilder extends base_1.LongYieldCarryBuilderBase {
|
|
9
|
+
async getIx(args) {
|
|
10
|
+
const bankData = await this.account.fetchYieldingBank(args.yieldingBank);
|
|
11
|
+
return this.program.methods
|
|
12
|
+
.rebalanceYieldingBank(args.params.ixRefs)
|
|
13
|
+
.accountsPartial({
|
|
14
|
+
manager: this.resolveYieldingBankManager(bankData.data),
|
|
15
|
+
yieldingBank: args.yieldingBank,
|
|
16
|
+
})
|
|
17
|
+
.remainingAccounts(args.params.remainingAccounts.map(common_1.toWeb3AccountMeta))
|
|
18
|
+
.instruction()
|
|
19
|
+
.then(common_1.toKitInstruction);
|
|
20
|
+
}
|
|
21
|
+
async getTx(args) {
|
|
22
|
+
const bankData = await this.account.fetchYieldingBank(args.yieldingBank);
|
|
23
|
+
const manager = this.resolveYieldingBankManager(bankData.data);
|
|
24
|
+
const resolvedCpiData = [...(args.params.cpiData ?? [])];
|
|
25
|
+
if (args.params.swaps?.length) {
|
|
26
|
+
const swapCpiData = await Promise.all(args.params.swaps.map(async (swap) => {
|
|
27
|
+
const swapClient = swap.swapClient ?? this.swap;
|
|
28
|
+
const quote = await swapClient.getQuote({
|
|
29
|
+
inputMint: swap.inputMint,
|
|
30
|
+
outputMint: swap.outputMint,
|
|
31
|
+
amount: swap.amount,
|
|
32
|
+
slippageBps: swap.slippageBps ?? 50,
|
|
33
|
+
});
|
|
34
|
+
return swapClient.getSwapCpiData(quote, args.yieldingBank, { payer: manager });
|
|
35
|
+
}));
|
|
36
|
+
resolvedCpiData.push(...swapCpiData);
|
|
37
|
+
}
|
|
38
|
+
const { externalLiquiditySources, postSuccessCacheInvalidations: refreshCacheInvalidations } = await this.externalLiquidityResolver.resolveYieldingBankRefreshExternalLiquidity(this.account, args.yieldingBank, resolvedCpiData);
|
|
39
|
+
const oracleAccounts = await this.account.getYieldingBankRefreshAccounts(args.yieldingBank, args.params.newAllocation?.config, externalLiquiditySources);
|
|
40
|
+
const { accounts: remainingAccounts, refs: ixRefs, lookupTables, } = (0, common_1.createCpiRefs)(resolvedCpiData, {
|
|
41
|
+
initialAccounts: [...oracleAccounts, common_1.SYSTEM_PROGRAM_META],
|
|
42
|
+
});
|
|
43
|
+
const preamble = [];
|
|
44
|
+
if (args.params.newAllocation) {
|
|
45
|
+
preamble.push(await new createYieldingBankAllocationBuilder_1.CreateYieldingBankAllocationBuilder(this.context).getIx({
|
|
46
|
+
yieldingBank: args.yieldingBank,
|
|
47
|
+
config: args.params.newAllocation.config,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
const { instructions, postSuccessCacheInvalidations } = await (0, common_1.getCreateAtaInstructions)(this.rpc, manager, remainingAccounts);
|
|
51
|
+
const swapPreInstructions = resolvedCpiData.flatMap((cpi) => cpi.preInstructions ?? []);
|
|
52
|
+
return {
|
|
53
|
+
instructions: [
|
|
54
|
+
...swapPreInstructions,
|
|
55
|
+
...instructions,
|
|
56
|
+
...preamble,
|
|
57
|
+
await this.getIx({
|
|
58
|
+
yieldingBank: args.yieldingBank,
|
|
59
|
+
params: {
|
|
60
|
+
ixRefs,
|
|
61
|
+
remainingAccounts,
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
lookupTables: this.getTxLookupTables(undefined, lookupTables ?? []),
|
|
66
|
+
postSuccessCacheInvalidations: [
|
|
67
|
+
(0, utils_1.getYieldingBankCacheInvalidation)(args.yieldingBank),
|
|
68
|
+
...resolvedCpiData.flatMap((cpi) => cpi.postSuccessCacheInvalidations ?? []),
|
|
69
|
+
...refreshCacheInvalidations,
|
|
70
|
+
...postSuccessCacheInvalidations,
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.RebalanceYieldingBankBuilder = RebalanceYieldingBankBuilder;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Instruction } from "@solana/kit";
|
|
2
|
+
import type { LongYieldCarryTransactionPlan } from "../types";
|
|
3
|
+
import { LongYieldCarryBuilderBase } from "./base";
|
|
4
|
+
import type { RecollateralizeLossIxArgs, RecollateralizeLossTxArgs } from "./args";
|
|
5
|
+
export declare class RecollateralizeLossBuilder extends LongYieldCarryBuilderBase<RecollateralizeLossIxArgs, RecollateralizeLossTxArgs, LongYieldCarryTransactionPlan[]> {
|
|
6
|
+
getIx(args: RecollateralizeLossIxArgs): Promise<Instruction>;
|
|
7
|
+
getTx(args: RecollateralizeLossTxArgs): Promise<LongYieldCarryTransactionPlan[]>;
|
|
8
|
+
private selectRecollateralizationTarget;
|
|
9
|
+
private buildRecollateralizationSwapPlan;
|
|
10
|
+
private buildOptionalDecreaseCarryPhase;
|
|
11
|
+
private buildRecollateralizePhase;
|
|
12
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecollateralizeLossBuilder = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const errors_1 = require("../../errors");
|
|
7
|
+
const decreaseCarryPositionBuilder_1 = require("./decreaseCarryPositionBuilder");
|
|
8
|
+
const common_1 = require("common");
|
|
9
|
+
const lending_platforms_1 = require("lending-platforms");
|
|
10
|
+
const general_1 = require("../../constants/general");
|
|
11
|
+
const carry_1 = require("../../services/carry");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
// Extra repay (bps of the measured deficit) to offset swap costs and oracle
|
|
14
|
+
// drift, which also scale with the swap size. On-chain only requires the
|
|
15
|
+
// deficit to strictly shrink, so an undershoot just leaves a dust residual
|
|
16
|
+
// for the next run; any surplus (carry > debt) must stay within the on-chain
|
|
17
|
+
// RECOLLATERALIZE_LOSS_THRESHOLD_BPS (20 bps of debt) ceiling.
|
|
18
|
+
const RECOLLATERALIZE_LOSS_OVERSHOOT_BUFFER_BPS = BigInt(10);
|
|
19
|
+
class RecollateralizeLossBuilder extends base_1.LongYieldCarryBuilderBase {
|
|
20
|
+
async getIx(args) {
|
|
21
|
+
const tokenData = await this.account.fetchToken(args.token);
|
|
22
|
+
const collateralMint = (0, common_1.fromWeb3Pk)(tokenData.data.collateral.mint);
|
|
23
|
+
const collateralOracle = (0, common_1.fromWeb3Pk)(tokenData.data.collateral.oracle);
|
|
24
|
+
const secondaryCollateralOracle = this.resolveOptionalSecondaryCollateralOracle(tokenData.data.collateral);
|
|
25
|
+
const collateralTokenProgram = (0, common_1.resolveTokenProgram)(tokenData.data.collateral.tokenProgram);
|
|
26
|
+
const collateralTokenAccount = await (0, common_1.getAtaAddress)(collateralMint, args.token, collateralTokenProgram);
|
|
27
|
+
const lpIdx = args.params.lendingPositionIndex;
|
|
28
|
+
const position = tokenData.data.lendingPositions[lpIdx];
|
|
29
|
+
// Position may be missing (out-of-bounds) or inactive (zeroed debt mint).
|
|
30
|
+
// Fall back to an active position so the instruction can reach the on-chain
|
|
31
|
+
// InvalidLendingPosition check rather than failing on account validation.
|
|
32
|
+
const isActive = position && !position.accounting.debt.mint.equals(web3_js_1.PublicKey.default);
|
|
33
|
+
const refPositionEntry = isActive
|
|
34
|
+
? { index: lpIdx, data: position }
|
|
35
|
+
: tokenData.activeLendingPositions[0];
|
|
36
|
+
const refPosition = refPositionEntry?.data ?? tokenData.data.lendingPositions[0];
|
|
37
|
+
const debtMint = (0, common_1.fromWeb3Pk)(refPosition.accounting.debt.mint);
|
|
38
|
+
const debtTokenProgram = (0, common_1.resolveTokenProgram)(refPosition.accounting.debt.tokenProgram);
|
|
39
|
+
const yieldingBank = args.params.yieldingBank ?? args.token;
|
|
40
|
+
const [tokenLpDebtTa, yieldingBankTa] = await Promise.all([
|
|
41
|
+
(0, common_1.getAtaAddress)(debtMint, args.token, debtTokenProgram),
|
|
42
|
+
(0, common_1.getAtaAddress)(debtMint, yieldingBank, debtTokenProgram),
|
|
43
|
+
]);
|
|
44
|
+
// For out-of-bounds indices (position === undefined), use the ref position's
|
|
45
|
+
// accounts so the instruction can be built. The on-chain bounds check fires
|
|
46
|
+
// first and rejects it with InvalidLendingPosition before accounts matter.
|
|
47
|
+
const lpPositionAccountIdx = isActive ? lpIdx : (refPositionEntry?.index ?? 0);
|
|
48
|
+
const builtIx = await this.program.methods
|
|
49
|
+
.recollateralizeLoss({
|
|
50
|
+
prerequisiteCpis: args.params.prerequisiteCpis ?? null,
|
|
51
|
+
ixRefs: args.params.ixRefs,
|
|
52
|
+
lendingPositionIndex: args.params.lendingPositionIndex,
|
|
53
|
+
})
|
|
54
|
+
.accountsStrict({
|
|
55
|
+
manager: this.resolveTokenManager(tokenData.data),
|
|
56
|
+
token: args.token,
|
|
57
|
+
collateralMint,
|
|
58
|
+
collateralTokenAccount,
|
|
59
|
+
collateralOracle,
|
|
60
|
+
secondaryCollateralOracle,
|
|
61
|
+
lpPosition: this.account.getTokenLendingPositionRefreshAccounts(tokenData.data, lpPositionAccountIdx, args.params.lpPosition),
|
|
62
|
+
collateralTokenProgram,
|
|
63
|
+
yieldingBank,
|
|
64
|
+
debtMint,
|
|
65
|
+
tokenLpDebtTa,
|
|
66
|
+
yieldingBankTa,
|
|
67
|
+
debtTokenProgram,
|
|
68
|
+
})
|
|
69
|
+
.remainingAccounts(args.params.remainingAccounts.map(common_1.toWeb3AccountMeta))
|
|
70
|
+
.instruction();
|
|
71
|
+
return (0, common_1.toKitInstruction)(builtIx);
|
|
72
|
+
}
|
|
73
|
+
async getTx(args) {
|
|
74
|
+
const tokenData = await this.account.fetchToken(args.token, { fresh: true });
|
|
75
|
+
const txId = args.params.txId ?? `recollateralize-loss-${Date.now()}`;
|
|
76
|
+
const slippageBps = args.params.swapSlippageBps ?? general_1.DEFAULT_RECOLLATERALIZE_LOSS_SLIPPAGE_BPS;
|
|
77
|
+
const target = await this.selectRecollateralizationTarget(tokenData);
|
|
78
|
+
const swapPlan = await this.buildRecollateralizationSwapPlan(target, slippageBps);
|
|
79
|
+
const dcpPhase = await this.buildOptionalDecreaseCarryPhase(args, target, swapPlan, txId);
|
|
80
|
+
const recollateralizePhase = await this.buildRecollateralizePhase(args, target, swapPlan, txId);
|
|
81
|
+
return dcpPhase ? [dcpPhase, recollateralizePhase] : [recollateralizePhase];
|
|
82
|
+
}
|
|
83
|
+
async selectRecollateralizationTarget(tokenData) {
|
|
84
|
+
const totalDebtUsd = tokenData.activeLendingPositions.reduce((sum, { data: lp }) => sum + (0, common_1.toBigInt)(lp.accounting.debt.tvlUsd), BigInt(0));
|
|
85
|
+
const totalCarryUsd = tokenData.activeCarryPositions.reduce((sum, { data: carry }) => sum + (0, common_1.toBigInt)(carry.tvlUsd), BigInt(0));
|
|
86
|
+
if (totalDebtUsd <= totalCarryUsd) {
|
|
87
|
+
throw new errors_1.NoOpTransactionError("Recollateralization not needed: debt does not exceed carry");
|
|
88
|
+
}
|
|
89
|
+
const bestLp = tokenData.activeLendingPositions.reduce((best, current) => (0, common_1.toBigInt)(current.data.accounting.collateral) > (0, common_1.toBigInt)(best.data.accounting.collateral)
|
|
90
|
+
? current
|
|
91
|
+
: best);
|
|
92
|
+
const bestCarry = tokenData.activeCarryPositions.reduce((best, current) => (0, common_1.toBigInt)(current.data.tvlUsd) > (0, common_1.toBigInt)(best.data.tvlUsd) ? current : best);
|
|
93
|
+
const yieldingBank = await tokenData.deriveYieldingBankAddressForDebtCarryIndex(bestCarry.index, this.pda);
|
|
94
|
+
return {
|
|
95
|
+
tokenData,
|
|
96
|
+
totalDebtUsd,
|
|
97
|
+
totalCarryUsd,
|
|
98
|
+
lendingPositionIndex: bestLp.index,
|
|
99
|
+
position: bestLp.data,
|
|
100
|
+
yieldingBank,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async buildRecollateralizationSwapPlan(target, slippageBps) {
|
|
104
|
+
const { tokenData, position, totalDebtUsd, totalCarryUsd } = target;
|
|
105
|
+
const debtExcessUsd = totalDebtUsd - totalCarryUsd;
|
|
106
|
+
const overshootBuffer = (debtExcessUsd * RECOLLATERALIZE_LOSS_OVERSHOOT_BUFFER_BPS) / BigInt(10000);
|
|
107
|
+
const targetRepayUsd = debtExcessUsd + overshootBuffer;
|
|
108
|
+
const collateralPrice = (0, common_1.toBigInt)(tokenData.data.collateral.price);
|
|
109
|
+
if (collateralPrice === BigInt(0)) {
|
|
110
|
+
throw new Error("Collateral price is zero — refresh the token state first");
|
|
111
|
+
}
|
|
112
|
+
const collateralInputAmount = (0, common_1.tvlUsdToBaseUnits)(targetRepayUsd, collateralPrice, tokenData.data.collateral.decimals);
|
|
113
|
+
if (collateralInputAmount === BigInt(0)) {
|
|
114
|
+
throw new errors_1.NoOpTransactionError("Collateral input rounds to zero — no recollateralization needed");
|
|
115
|
+
}
|
|
116
|
+
const swapQuote = await this.swap.getQuote({
|
|
117
|
+
inputMint: tokenData.collateralMint,
|
|
118
|
+
outputMint: (0, common_1.fromWeb3Pk)(position.accounting.debt.mint),
|
|
119
|
+
amount: Number(collateralInputAmount),
|
|
120
|
+
slippageBps,
|
|
121
|
+
});
|
|
122
|
+
// Minimum guaranteed output after slippage; on-chain repays exactly this amount.
|
|
123
|
+
// Any surplus from the actual swap sits in the debt ATA and gets deposited to the
|
|
124
|
+
// yielding bank by the on-chain handler.
|
|
125
|
+
const repayBaseUnits = (swapQuote.outputAmount * BigInt(10000 - slippageBps)) / BigInt(10000);
|
|
126
|
+
return {
|
|
127
|
+
collateralToWithdrawUi: (0, common_1.toUiAmount)(swapQuote.inputAmount, tokenData.data.collateral.decimals),
|
|
128
|
+
repayUiAmount: (0, common_1.toUiAmount)(repayBaseUnits, position.accounting.debt.decimals),
|
|
129
|
+
repayBaseUnits,
|
|
130
|
+
swapQuote,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
async buildOptionalDecreaseCarryPhase(args, target, swapPlan, txId) {
|
|
134
|
+
const { position, lendingPositionIndex, yieldingBank } = target;
|
|
135
|
+
const lpClient = this.getLendingPlatformClient(position);
|
|
136
|
+
lpClient.ix.clearCacheEntry(lpClient.ix.data.userAccountCatKey, (0, common_1.fromWeb3Pk)(position.protocolUserAcc));
|
|
137
|
+
const lycLendingPositionManager = await carry_1.LycLendingPositionManager.create(lpClient.data, position);
|
|
138
|
+
const postWithdrawalUtilBps = await lycLendingPositionManager.calcPostWithdrawalUtilizationRateBps(swapPlan.collateralToWithdrawUi);
|
|
139
|
+
if (postWithdrawalUtilBps <= position.config.targetUtilizationRateBps) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
const preWithdrawalTargetBps = await lycLendingPositionManager.calcPreWithdrawalTargetUtilizationRateBps(swapPlan.collateralToWithdrawUi);
|
|
143
|
+
return new decreaseCarryPositionBuilder_1.DecreaseCarryPositionBuilder(this.context).buildTx(this.resolveTokenManager(target.tokenData.data), args.token, {
|
|
144
|
+
lendingPositionIndex,
|
|
145
|
+
yieldingBank,
|
|
146
|
+
sourceMint: args.params.sourceMint,
|
|
147
|
+
swapSlippageBps: args.params.swapSlippageBps,
|
|
148
|
+
repaySteering: {
|
|
149
|
+
mode: "explicitTargetUtilization",
|
|
150
|
+
targetUtilizationRateBps: preWithdrawalTargetBps,
|
|
151
|
+
},
|
|
152
|
+
txId,
|
|
153
|
+
}, { includePreInstructions: true });
|
|
154
|
+
}
|
|
155
|
+
async buildRecollateralizePhase(args, target, swapPlan, txId) {
|
|
156
|
+
const { position, lendingPositionIndex } = target;
|
|
157
|
+
const manager = this.resolveTokenManager(target.tokenData.data);
|
|
158
|
+
const lpClient = this.getLendingPlatformClient(position);
|
|
159
|
+
const withdrawCpiData = await this.getLendingOperationCpiData(args.token, manager, position, txId, "withdraw", swapPlan.collateralToWithdrawUi);
|
|
160
|
+
const swapCpiData = await this.swap.getSwapCpiData(swapPlan.swapQuote, args.token, {
|
|
161
|
+
payer: manager,
|
|
162
|
+
});
|
|
163
|
+
const repayCpiData = await this.getLendingOperationCpiData(args.token, manager, position, txId, "repay", swapPlan.repayUiAmount);
|
|
164
|
+
const prerequisiteCpiGroup = [...withdrawCpiData.prerequisiteCpis];
|
|
165
|
+
const executionCpiGroup = [
|
|
166
|
+
...withdrawCpiData.cpis,
|
|
167
|
+
swapCpiData,
|
|
168
|
+
...repayCpiData.prerequisiteCpis,
|
|
169
|
+
...repayCpiData.cpis,
|
|
170
|
+
];
|
|
171
|
+
const { accounts: remainingAccounts, refsGroups, lookupTables, } = (0, common_1.createMultiCpiRefs)(prerequisiteCpiGroup.length ? [prerequisiteCpiGroup, executionCpiGroup] : [executionCpiGroup]);
|
|
172
|
+
const prerequisiteCpis = prerequisiteCpiGroup.length ? refsGroups[0] : undefined;
|
|
173
|
+
const ixRefs = refsGroups[prerequisiteCpiGroup.length ? 1 : 0];
|
|
174
|
+
const preInstructions = await lpClient.ix.getPreInstructions(txId);
|
|
175
|
+
const carryTradeAccounts = await this.account.getCarryTradeAccounts(args.token, target.yieldingBank, lendingPositionIndex);
|
|
176
|
+
const [{ instructions, postSuccessCacheInvalidations }, { instructions: debtAtaInstructions, postSuccessCacheInvalidations: debtAtaInvalidations },] = await Promise.all([
|
|
177
|
+
(0, common_1.getCreateAtaInstructions)(this.rpc, manager, remainingAccounts),
|
|
178
|
+
(0, common_1.getCreateAtaInstructions)(this.rpc, manager, carryTradeAccounts),
|
|
179
|
+
]);
|
|
180
|
+
const recollateralizeIx = await this.getIx({
|
|
181
|
+
token: args.token,
|
|
182
|
+
params: {
|
|
183
|
+
prerequisiteCpis,
|
|
184
|
+
ixRefs,
|
|
185
|
+
lendingPositionIndex,
|
|
186
|
+
remainingAccounts,
|
|
187
|
+
yieldingBank: target.yieldingBank,
|
|
188
|
+
lpPosition: args.params.lpPosition,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
const setupInstructions = [
|
|
192
|
+
...preInstructions,
|
|
193
|
+
...(swapCpiData.preInstructions ?? []),
|
|
194
|
+
...debtAtaInstructions,
|
|
195
|
+
...instructions,
|
|
196
|
+
];
|
|
197
|
+
return {
|
|
198
|
+
instructions: [
|
|
199
|
+
...setupInstructions,
|
|
200
|
+
// The heap frame applies only to this transaction. Keep it with the
|
|
201
|
+
// CPI-heavy instruction while allowing refresh and ATA setup to move
|
|
202
|
+
// into earlier transactions in the same atomic bundle.
|
|
203
|
+
(0, common_1.requestHeapFrameIx)(general_1.MAX_HEAP_FRAME_BYTES),
|
|
204
|
+
recollateralizeIx,
|
|
205
|
+
],
|
|
206
|
+
lookupTables: this.getTxLookupTables(args.token, lookupTables ?? []),
|
|
207
|
+
segmentLengths: [...setupInstructions.map(() => 1), 2],
|
|
208
|
+
postSuccessCacheInvalidations: [
|
|
209
|
+
(0, utils_1.getTokenCacheInvalidation)(args.token),
|
|
210
|
+
(0, lending_platforms_1.getLendingUserAccountCacheInvalidation)((0, common_1.fromWeb3Pk)(position.protocolUserAcc)),
|
|
211
|
+
...postSuccessCacheInvalidations,
|
|
212
|
+
...debtAtaInvalidations,
|
|
213
|
+
...withdrawCpiData.postSuccessCacheInvalidations,
|
|
214
|
+
...repayCpiData.postSuccessCacheInvalidations,
|
|
215
|
+
...(swapCpiData.postSuccessCacheInvalidations ?? []),
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.RecollateralizeLossBuilder = RecollateralizeLossBuilder;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Instruction } from "@solana/kit";
|
|
2
|
+
import type { LongYieldCarryTransactionPlan } from "../types";
|
|
3
|
+
import { LongYieldCarrySingleInstructionBuilderService } from "./base";
|
|
4
|
+
import type { RefreshTokenStateIxArgs } from "./args";
|
|
5
|
+
export declare class RefreshTokenStateBuilder extends LongYieldCarrySingleInstructionBuilderService<RefreshTokenStateIxArgs> {
|
|
6
|
+
getIx(args: RefreshTokenStateIxArgs): Promise<Instruction>;
|
|
7
|
+
getTx(args: RefreshTokenStateIxArgs): Promise<LongYieldCarryTransactionPlan>;
|
|
8
|
+
private getRefreshTokenStateParams;
|
|
9
|
+
}
|