@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,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JupiterSwapClient = void 0;
|
|
4
|
+
const api_1 = require("./api");
|
|
5
|
+
const extract_1 = require("./extract");
|
|
6
|
+
const routePreInstructions_1 = require("./routePreInstructions");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const common_1 = require("common");
|
|
9
|
+
/**
|
|
10
|
+
* Jupiter swap client implementing RoutableSwapClient (see `common`).
|
|
11
|
+
*
|
|
12
|
+
* Provides a simplified API for getting quotes and building swap instructions
|
|
13
|
+
* from Jupiter aggregator for use in CPI calls.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const client = new JupiterSwapClient(rpc);
|
|
18
|
+
*
|
|
19
|
+
* // Get a quote
|
|
20
|
+
* const quote = await client.getQuote({
|
|
21
|
+
* inputMint: USDC_MINT,
|
|
22
|
+
* outputMint: WSOL_MINT,
|
|
23
|
+
* amount: 10_000_000, // 10 USDC
|
|
24
|
+
* slippageBps: 500, // 5%
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Build instruction for CPI
|
|
28
|
+
* const { data, accounts, programId } = await client.getSwapCpiData(
|
|
29
|
+
* quote,
|
|
30
|
+
* swapAuthorityPda
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* // Use in your Anchor program
|
|
34
|
+
* await program.methods
|
|
35
|
+
* .executeSwap(Buffer.from(data))
|
|
36
|
+
* .remainingAccounts(accounts.map(toWeb3AccountMeta))
|
|
37
|
+
* .rpc();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class JupiterSwapClient {
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new Jupiter swap client.
|
|
43
|
+
*
|
|
44
|
+
* @param rpc - Solana RPC client for resolving address lookup tables
|
|
45
|
+
* @param config - Optional default quote policy applied to every Jupiter quote
|
|
46
|
+
*/
|
|
47
|
+
constructor(rpc, config = {}) {
|
|
48
|
+
this.rpc = rpc;
|
|
49
|
+
this.config = config;
|
|
50
|
+
/**
|
|
51
|
+
* Empty lists mean any route for aggregate routing (Jupiter quotes arbitrary
|
|
52
|
+
* pairs via the API).
|
|
53
|
+
*/
|
|
54
|
+
this.inputMints = [];
|
|
55
|
+
this.outputMints = [];
|
|
56
|
+
this.routeAnchorMints = [];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get a swap quote from Jupiter.
|
|
60
|
+
*
|
|
61
|
+
* @param params - Quote parameters
|
|
62
|
+
* @returns Normalized swap quote with Jupiter's QuoteResponse as rawQuote
|
|
63
|
+
*/
|
|
64
|
+
async getQuote(params) {
|
|
65
|
+
const excludeDexes = params.excludeDexes?.length
|
|
66
|
+
? [...new Set([...(this.config.quoteDefaults?.excludeDexes ?? []), ...params.excludeDexes])]
|
|
67
|
+
: undefined;
|
|
68
|
+
const rawQuote = await (0, api_1.getJupiterQuote)({
|
|
69
|
+
...(this.config.quoteDefaults ?? {}),
|
|
70
|
+
inputMint: params.inputMint,
|
|
71
|
+
outputMint: params.outputMint,
|
|
72
|
+
amount: params.amount,
|
|
73
|
+
slippageBps: params.slippageBps,
|
|
74
|
+
...(params.maxAccounts !== undefined ? { maxAccounts: params.maxAccounts } : {}),
|
|
75
|
+
...(params.onlyDirectRoutes !== undefined
|
|
76
|
+
? { onlyDirectRoutes: params.onlyDirectRoutes }
|
|
77
|
+
: {}),
|
|
78
|
+
...(excludeDexes ? { excludeDexes } : {}),
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
inputMint: params.inputMint,
|
|
82
|
+
outputMint: params.outputMint,
|
|
83
|
+
inputAmount: BigInt(rawQuote.inAmount),
|
|
84
|
+
outputAmount: BigInt(rawQuote.outAmount),
|
|
85
|
+
priceImpactPct: Number(rawQuote.priceImpactPct ?? 0),
|
|
86
|
+
rawQuote,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Use Jupiter `ExactOut` quoting: desired output is `minOutputAmount`; reject if implied
|
|
91
|
+
* input exceeds `maxInputAmount`.
|
|
92
|
+
*/
|
|
93
|
+
async getQuoteCoveringMinOutput(params) {
|
|
94
|
+
const need = params.minOutputAmount;
|
|
95
|
+
if (need <= BigInt(0)) {
|
|
96
|
+
throw new Error("getQuoteCoveringMinOutput: minOutputAmount must be positive");
|
|
97
|
+
}
|
|
98
|
+
const maxIn = params.maxInputAmount;
|
|
99
|
+
if (maxIn <= BigInt(0)) {
|
|
100
|
+
throw new Error("getQuoteCoveringMinOutput: maxInputAmount must be positive");
|
|
101
|
+
}
|
|
102
|
+
if (need > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
103
|
+
throw new Error("getQuoteCoveringMinOutput: minOutputAmount exceeds Number.MAX_SAFE_INTEGER");
|
|
104
|
+
}
|
|
105
|
+
const rawQuote = await (0, api_1.getJupiterQuote)({
|
|
106
|
+
...(this.config.quoteDefaults ?? {}),
|
|
107
|
+
inputMint: params.inputMint,
|
|
108
|
+
outputMint: params.outputMint,
|
|
109
|
+
amount: Number(need),
|
|
110
|
+
slippageBps: params.slippageBps,
|
|
111
|
+
swapMode: "ExactOut",
|
|
112
|
+
});
|
|
113
|
+
const inAmt = BigInt(rawQuote.inAmount);
|
|
114
|
+
const outAmt = BigInt(rawQuote.outAmount);
|
|
115
|
+
if (inAmt > maxIn) {
|
|
116
|
+
throw new Error("Jupiter getQuoteCoveringMinOutput: exact-out route needs more input than maxInputAmount");
|
|
117
|
+
}
|
|
118
|
+
if (outAmt < need) {
|
|
119
|
+
throw new Error("Jupiter getQuoteCoveringMinOutput: quoted output is below minOutputAmount");
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
inputMint: params.inputMint,
|
|
123
|
+
outputMint: params.outputMint,
|
|
124
|
+
inputAmount: inAmt,
|
|
125
|
+
outputAmount: outAmt,
|
|
126
|
+
priceImpactPct: Number(rawQuote.priceImpactPct ?? 0),
|
|
127
|
+
rawQuote,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Build Jupiter swap instruction for CPI.
|
|
132
|
+
*
|
|
133
|
+
* This fetches a swap transaction from Jupiter API, decompiles it,
|
|
134
|
+
* and extracts the instruction data and accounts needed for CPI.
|
|
135
|
+
*
|
|
136
|
+
* @param quote - Quote from getQuote()
|
|
137
|
+
* @param userPublicKey - Address executing the swap (typically a PDA)
|
|
138
|
+
* @param options - Swap options
|
|
139
|
+
* @returns Instruction data, accounts, and Jupiter program ID
|
|
140
|
+
*/
|
|
141
|
+
async getSwapCpiData(quote, userPublicKey, options) {
|
|
142
|
+
const transaction = await (0, api_1.buildJupiterSwapTransaction)({
|
|
143
|
+
quote: quote.rawQuote,
|
|
144
|
+
userPublicKey,
|
|
145
|
+
wrapAndUnwrapSol: options?.wrapAndUnwrapSol ?? false,
|
|
146
|
+
});
|
|
147
|
+
const { data, accounts, lookupTables } = await (0, extract_1.extractJupiterInstruction)(transaction, this.rpc);
|
|
148
|
+
// When a `payer` is supplied we provision intermediate-mint ATAs for
|
|
149
|
+
// multi-hop routes; the swap authority `userPublicKey` is typically a PDA
|
|
150
|
+
// and can't pay the rent itself. With no payer we skip pre-instructions
|
|
151
|
+
// (single-hop routes don't need them; multi-hop routes will then fail
|
|
152
|
+
// at the CPI if intermediate ATAs are missing).
|
|
153
|
+
let preInstructions;
|
|
154
|
+
let preInvalidations;
|
|
155
|
+
if (options?.payer) {
|
|
156
|
+
const result = await (0, routePreInstructions_1.getJupiterRoutePreInstructions)(this.rpc, quote.rawQuote, userPublicKey, options.payer);
|
|
157
|
+
if (result.instructions.length) {
|
|
158
|
+
preInstructions = result.instructions;
|
|
159
|
+
preInvalidations = result.postSuccessCacheInvalidations;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
cpiType: common_1.CpiTypes.JUPITER_SWAP,
|
|
164
|
+
data,
|
|
165
|
+
accounts,
|
|
166
|
+
programId: constants_1.JUPITER_V6_PROGRAM_ID,
|
|
167
|
+
lookupTables,
|
|
168
|
+
...(preInstructions ? { preInstructions } : {}),
|
|
169
|
+
...(preInvalidations ? { postSuccessCacheInvalidations: preInvalidations } : {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.JupiterSwapClient = JupiterSwapClient;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Address } from "@solana/kit";
|
|
2
|
+
/**
|
|
3
|
+
* Jupiter V6 Aggregator Program ID
|
|
4
|
+
*/
|
|
5
|
+
export declare const JUPITER_V6_PROGRAM_ID: Address;
|
|
6
|
+
/**
|
|
7
|
+
* Jupiter API base URL
|
|
8
|
+
*/
|
|
9
|
+
export declare const JUPITER_API_URL = "https://lite-api.jup.ag";
|
|
10
|
+
/**
|
|
11
|
+
* Default slippage in basis points (5%)
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_SLIPPAGE_BPS = 500;
|
|
14
|
+
/**
|
|
15
|
+
* Local/Surfpool max account budget for swap instructions.
|
|
16
|
+
* Lower values improve compatibility with local validators.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LOCAL_TEST_MAX_ACCOUNTS = 20;
|
|
19
|
+
/**
|
|
20
|
+
* DEXes to exclude in local/Surfpool tests.
|
|
21
|
+
* Production/testnet deployments should not apply this list by default.
|
|
22
|
+
*/
|
|
23
|
+
export declare const LOCAL_TEST_EXCLUDED_DEXES: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Venues excluded from ALL Jupiter quotes, in every environment. These
|
|
26
|
+
* proprietary market-maker venues rotate their vault token accounts
|
|
27
|
+
* off-chain, so quoted routes intermittently fail at execution with
|
|
28
|
+
* "Token account ... has wrong owner". Not applied when a `dexes`
|
|
29
|
+
* whitelist is set (the whitelist takes full control of routing).
|
|
30
|
+
*
|
|
31
|
+
* TODO(2026-07-06): Riptide was excluded after repeated wrong-owner failures
|
|
32
|
+
* on PYUSD routes. It often quotes the best stable-pair price, so revisit
|
|
33
|
+
* later and give it another chance if their account rotation has stabilized.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ALWAYS_EXCLUDED_DEXES: string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALWAYS_EXCLUDED_DEXES = exports.LOCAL_TEST_EXCLUDED_DEXES = exports.LOCAL_TEST_MAX_ACCOUNTS = exports.DEFAULT_SLIPPAGE_BPS = exports.JUPITER_API_URL = exports.JUPITER_V6_PROGRAM_ID = void 0;
|
|
4
|
+
const kit_1 = require("@solana/kit");
|
|
5
|
+
/**
|
|
6
|
+
* Jupiter V6 Aggregator Program ID
|
|
7
|
+
*/
|
|
8
|
+
exports.JUPITER_V6_PROGRAM_ID = (0, kit_1.address)("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
|
|
9
|
+
/**
|
|
10
|
+
* Jupiter API base URL
|
|
11
|
+
*/
|
|
12
|
+
exports.JUPITER_API_URL = "https://lite-api.jup.ag";
|
|
13
|
+
/**
|
|
14
|
+
* Default slippage in basis points (5%)
|
|
15
|
+
*/
|
|
16
|
+
exports.DEFAULT_SLIPPAGE_BPS = 500;
|
|
17
|
+
/**
|
|
18
|
+
* Local/Surfpool max account budget for swap instructions.
|
|
19
|
+
* Lower values improve compatibility with local validators.
|
|
20
|
+
*/
|
|
21
|
+
exports.LOCAL_TEST_MAX_ACCOUNTS = 20;
|
|
22
|
+
/**
|
|
23
|
+
* DEXes to exclude in local/Surfpool tests.
|
|
24
|
+
* Production/testnet deployments should not apply this list by default.
|
|
25
|
+
*/
|
|
26
|
+
exports.LOCAL_TEST_EXCLUDED_DEXES = ["GoonFi", "HumidiFi", "TesseraV", "1DEX", "Aquifer"];
|
|
27
|
+
/**
|
|
28
|
+
* Venues excluded from ALL Jupiter quotes, in every environment. These
|
|
29
|
+
* proprietary market-maker venues rotate their vault token accounts
|
|
30
|
+
* off-chain, so quoted routes intermittently fail at execution with
|
|
31
|
+
* "Token account ... has wrong owner". Not applied when a `dexes`
|
|
32
|
+
* whitelist is set (the whitelist takes full control of routing).
|
|
33
|
+
*
|
|
34
|
+
* TODO(2026-07-06): Riptide was excluded after repeated wrong-owner failures
|
|
35
|
+
* on PYUSD routes. It often quotes the best stable-pair price, so revisit
|
|
36
|
+
* later and give it another chance if their account rotation has stabilized.
|
|
37
|
+
*/
|
|
38
|
+
exports.ALWAYS_EXCLUDED_DEXES = ["Riptide"];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Address, Rpc, SolanaRpcApi, Transaction } from "@solana/kit";
|
|
2
|
+
import type { ExtractedJupiterInstruction } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Extract Jupiter instruction data and accounts from a Kit transaction.
|
|
5
|
+
*
|
|
6
|
+
* This function decompiles a Jupiter swap transaction, resolves any address lookup tables,
|
|
7
|
+
* and extracts the instruction data and account metas needed for CPI calls.
|
|
8
|
+
*
|
|
9
|
+
* @param transaction - The Kit Transaction from Jupiter API
|
|
10
|
+
* @param rpc - Solana RPC client to resolve lookup tables
|
|
11
|
+
* @param jupiterProgramId - Jupiter program ID (default: JUPITER_V6_PROGRAM_ID)
|
|
12
|
+
* @returns Jupiter instruction data and account metas with writability info
|
|
13
|
+
* @throws Error if Jupiter instruction is not found in transaction
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Get transaction from Jupiter API
|
|
18
|
+
* const jupiterTx = await buildJupiterSwapTransaction({ quote, userPublicKey });
|
|
19
|
+
*
|
|
20
|
+
* // Extract instruction for CPI
|
|
21
|
+
* const { data, accounts } = await extractJupiterInstruction(jupiterTx, rpc);
|
|
22
|
+
*
|
|
23
|
+
* // Use in your program
|
|
24
|
+
* await program.methods
|
|
25
|
+
* .executeSwap({ jupiterSwapData: Array.from(data) })
|
|
26
|
+
* .remainingAccounts(accounts)
|
|
27
|
+
* .rpc();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractJupiterInstruction(transaction: Transaction, rpc: Rpc<SolanaRpcApi>, jupiterProgramId?: Address): Promise<ExtractedJupiterInstruction>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractJupiterInstruction = extractJupiterInstruction;
|
|
4
|
+
const kit_1 = require("@solana/kit");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* Extract Jupiter instruction data and accounts from a Kit transaction.
|
|
8
|
+
*
|
|
9
|
+
* This function decompiles a Jupiter swap transaction, resolves any address lookup tables,
|
|
10
|
+
* and extracts the instruction data and account metas needed for CPI calls.
|
|
11
|
+
*
|
|
12
|
+
* @param transaction - The Kit Transaction from Jupiter API
|
|
13
|
+
* @param rpc - Solana RPC client to resolve lookup tables
|
|
14
|
+
* @param jupiterProgramId - Jupiter program ID (default: JUPITER_V6_PROGRAM_ID)
|
|
15
|
+
* @returns Jupiter instruction data and account metas with writability info
|
|
16
|
+
* @throws Error if Jupiter instruction is not found in transaction
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Get transaction from Jupiter API
|
|
21
|
+
* const jupiterTx = await buildJupiterSwapTransaction({ quote, userPublicKey });
|
|
22
|
+
*
|
|
23
|
+
* // Extract instruction for CPI
|
|
24
|
+
* const { data, accounts } = await extractJupiterInstruction(jupiterTx, rpc);
|
|
25
|
+
*
|
|
26
|
+
* // Use in your program
|
|
27
|
+
* await program.methods
|
|
28
|
+
* .executeSwap({ jupiterSwapData: Array.from(data) })
|
|
29
|
+
* .remainingAccounts(accounts)
|
|
30
|
+
* .rpc();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
async function extractJupiterInstruction(transaction, rpc, jupiterProgramId = constants_1.JUPITER_V6_PROGRAM_ID) {
|
|
34
|
+
// Decode the message bytes to a CompiledTransactionMessage
|
|
35
|
+
const messageDecoder = (0, kit_1.getCompiledTransactionMessageDecoder)();
|
|
36
|
+
const compiledMessage = messageDecoder.decode(transaction.messageBytes);
|
|
37
|
+
// Extract lookup table addresses from the compiled message before decompiling
|
|
38
|
+
const lookupTables = ("addressTableLookups" in compiledMessage ? (compiledMessage.addressTableLookups ?? []) : []).map((lookup) => lookup.lookupTableAddress);
|
|
39
|
+
// Decompile the transaction message, fetching any lookup tables needed
|
|
40
|
+
const decompiledMessage = await (0, kit_1.decompileTransactionMessageFetchingLookupTables)(compiledMessage, rpc);
|
|
41
|
+
// Find the Jupiter instruction
|
|
42
|
+
const jupiterIx = decompiledMessage.instructions.find((ix) => ix.programAddress === jupiterProgramId);
|
|
43
|
+
if (!jupiterIx) {
|
|
44
|
+
throw new Error("Jupiter instruction not found in transaction");
|
|
45
|
+
}
|
|
46
|
+
// Convert instruction accounts to AccountMeta format
|
|
47
|
+
const accounts = (jupiterIx.accounts ?? []).map((account) => ({
|
|
48
|
+
address: account.address,
|
|
49
|
+
role: account.role,
|
|
50
|
+
}));
|
|
51
|
+
// Return instruction data, accounts, and lookup tables
|
|
52
|
+
return {
|
|
53
|
+
data: new Uint8Array(jupiterIx.data ?? []),
|
|
54
|
+
accounts,
|
|
55
|
+
lookupTables,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./client"), exports);
|
|
20
|
+
__exportStar(require("./sizeExactInForMinOutput"), exports);
|
|
21
|
+
__exportStar(require("./routePreInstructions"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Address, Instruction, Rpc, SolanaRpcApi } from "@solana/kit";
|
|
2
|
+
import type { QuoteResponse } from "@jup-ag/api";
|
|
3
|
+
import { type TransactionCacheInvalidation } from "common";
|
|
4
|
+
export interface JupiterRoutePreInstructionsResult {
|
|
5
|
+
instructions: Instruction[];
|
|
6
|
+
postSuccessCacheInvalidations: TransactionCacheInvalidation[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Build idempotent createATA instructions for every intermediate-mint touched
|
|
10
|
+
* by a Jupiter route that the swap authority (`user`) doesn't already have an
|
|
11
|
+
* ATA for. Input/output mints are excluded — the caller is expected to have
|
|
12
|
+
* already provisioned those (e.g. flash-borrow lands the input balance in
|
|
13
|
+
* the user's destDebt ATA).
|
|
14
|
+
*
|
|
15
|
+
* Token programs are resolved via the {@link mints} registry first; unknown
|
|
16
|
+
* mints fall back to an RPC `getMultipleAccounts` lookup that reads each
|
|
17
|
+
* mint's `owner` (the SPL Token vs Token-2022 program).
|
|
18
|
+
*/
|
|
19
|
+
export declare function getJupiterRoutePreInstructions(rpc: Rpc<SolanaRpcApi>, quote: QuoteResponse, user: Address, payer: Address): Promise<JupiterRoutePreInstructionsResult>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getJupiterRoutePreInstructions = getJupiterRoutePreInstructions;
|
|
4
|
+
const common_1 = require("common");
|
|
5
|
+
/**
|
|
6
|
+
* Build idempotent createATA instructions for every intermediate-mint touched
|
|
7
|
+
* by a Jupiter route that the swap authority (`user`) doesn't already have an
|
|
8
|
+
* ATA for. Input/output mints are excluded — the caller is expected to have
|
|
9
|
+
* already provisioned those (e.g. flash-borrow lands the input balance in
|
|
10
|
+
* the user's destDebt ATA).
|
|
11
|
+
*
|
|
12
|
+
* Token programs are resolved via the {@link mints} registry first; unknown
|
|
13
|
+
* mints fall back to an RPC `getMultipleAccounts` lookup that reads each
|
|
14
|
+
* mint's `owner` (the SPL Token vs Token-2022 program).
|
|
15
|
+
*/
|
|
16
|
+
async function getJupiterRoutePreInstructions(rpc, quote, user, payer) {
|
|
17
|
+
const intermediate = new Set();
|
|
18
|
+
for (const step of quote.routePlan ?? []) {
|
|
19
|
+
intermediate.add(step.swapInfo.inputMint);
|
|
20
|
+
intermediate.add(step.swapInfo.outputMint);
|
|
21
|
+
}
|
|
22
|
+
intermediate.delete(quote.inputMint);
|
|
23
|
+
intermediate.delete(quote.outputMint);
|
|
24
|
+
if (!intermediate.size) {
|
|
25
|
+
return { instructions: [], postSuccessCacheInvalidations: [] };
|
|
26
|
+
}
|
|
27
|
+
const tokenProgramByMint = new Map();
|
|
28
|
+
const unknown = [];
|
|
29
|
+
for (const mint of intermediate) {
|
|
30
|
+
const info = common_1.mints.get(mint);
|
|
31
|
+
if (info) {
|
|
32
|
+
tokenProgramByMint.set(mint, info.tokenProgram);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
unknown.push(mint);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (unknown.length) {
|
|
39
|
+
const resp = await rpc
|
|
40
|
+
.getMultipleAccounts(unknown, { encoding: "base64" })
|
|
41
|
+
.send();
|
|
42
|
+
for (let i = 0; i < unknown.length; i += 1) {
|
|
43
|
+
const acct = resp.value[i];
|
|
44
|
+
if (!acct) {
|
|
45
|
+
throw new Error(`getJupiterRoutePreInstructions: route mint ${unknown[i]} not found on-chain`);
|
|
46
|
+
}
|
|
47
|
+
tokenProgramByMint.set(unknown[i], acct.owner);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const instructions = [];
|
|
51
|
+
const postSuccessCacheInvalidations = [];
|
|
52
|
+
for (const mint of intermediate) {
|
|
53
|
+
const tokenProgram = tokenProgramByMint.get(mint);
|
|
54
|
+
const result = await (0, common_1.getCreateAtaIxIfNeeded)(rpc, payer, mint, user, tokenProgram);
|
|
55
|
+
if (result.instruction) {
|
|
56
|
+
instructions.push(result.instruction);
|
|
57
|
+
postSuccessCacheInvalidations.push(...result.postSuccessCacheInvalidations);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { instructions, postSuccessCacheInvalidations };
|
|
61
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Address } from "@solana/kit";
|
|
2
|
+
import type { SwapClient, SwapQuote } from "common";
|
|
3
|
+
export declare class ExactInQuoteExceedsMaxInputError extends Error {
|
|
4
|
+
readonly inputAmount: bigint;
|
|
5
|
+
readonly maxInputAmount: bigint;
|
|
6
|
+
constructor(inputAmount: bigint, maxInputAmount: bigint);
|
|
7
|
+
}
|
|
8
|
+
export interface SizeExactInForMinOutputParams {
|
|
9
|
+
/** Input mint of the swap. */
|
|
10
|
+
inputMint: Address;
|
|
11
|
+
/** Output mint of the swap. */
|
|
12
|
+
outputMint: Address;
|
|
13
|
+
/** Minimum acceptable output amount (smallest units of `outputMint`). */
|
|
14
|
+
minOutputAmount: bigint;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum input amount the caller is willing to spend (smallest units of
|
|
17
|
+
* `inputMint`). Throws if the sized input would exceed this.
|
|
18
|
+
*/
|
|
19
|
+
maxInputAmount: bigint;
|
|
20
|
+
/** Slippage tolerance applied by the swap, in basis points (e.g. 50 = 0.5%). */
|
|
21
|
+
slippageBps: number;
|
|
22
|
+
/**
|
|
23
|
+
* Extra bps of headroom added on top of slippage when sizing the input.
|
|
24
|
+
* The worst-case post-slippage output is pushed above `minOutputAmount`
|
|
25
|
+
* by this much. Defaults to 0 (size to bare minimum).
|
|
26
|
+
*/
|
|
27
|
+
safetyBufferBps?: number;
|
|
28
|
+
/**
|
|
29
|
+
* If true, restrict the quotes to direct routes (no intermediate hops).
|
|
30
|
+
* Useful for CPI flows where intermediate-mint ATAs (e.g. WSOL) wouldn't
|
|
31
|
+
* exist for a PDA caller. Defaults to false.
|
|
32
|
+
*/
|
|
33
|
+
onlyDirectRoutes?: boolean;
|
|
34
|
+
/** Optional route account budget forwarded to backends that support it. */
|
|
35
|
+
maxAccounts?: number;
|
|
36
|
+
/** DEX labels to exclude from routing, forwarded to backends that support it. */
|
|
37
|
+
excludeDexes?: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface SizeExactInForMinOutputResult<TRawQuote = unknown> {
|
|
40
|
+
/** ExactIn quote sized so the worst-case output covers `minOutputAmount`. */
|
|
41
|
+
quote: SwapQuote<TRawQuote>;
|
|
42
|
+
/** The sized input amount in `inputMint` base units (== `quote.inputAmount`). */
|
|
43
|
+
inputAmount: bigint;
|
|
44
|
+
/** The minimum output the caller can rely on after applying slippage. */
|
|
45
|
+
worstCaseOutputAmount: bigint;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Size an ExactIn swap so its **worst-case post-slippage output** covers
|
|
49
|
+
* `minOutputAmount`.
|
|
50
|
+
*
|
|
51
|
+
* The ExactIn route graph is denser than ExactOut on most aggregators
|
|
52
|
+
* (Jupiter included), so this is preferred when ExactOut hits
|
|
53
|
+
* `NO_ROUTES_FOUND`. The trade-off: you over-spend input by the slippage
|
|
54
|
+
* buffer; the unused output excess is the caller's to handle (e.g. sweep
|
|
55
|
+
* to a sink account).
|
|
56
|
+
*
|
|
57
|
+
* Strategy:
|
|
58
|
+
* 1. Probe quote at `minOutputAmount` input — gives us the route's
|
|
59
|
+
* spot rate (`probeOut / probeIn`).
|
|
60
|
+
* 2. Solve for the input `I` such that
|
|
61
|
+
* `I × probeOut/probeIn × (1 − slippageBps/10000) ≥ minOutputAmount × (1 + safetyBufferBps/10000)`.
|
|
62
|
+
* 3. Real ExactIn quote at the sized input.
|
|
63
|
+
* 4. Verify the real quote's worst-case output still covers
|
|
64
|
+
* `minOutputAmount` — guards against price impact at the larger size
|
|
65
|
+
* diverging from the probe's spot rate.
|
|
66
|
+
*
|
|
67
|
+
* Throws if `inputAmount` exceeds `maxInputAmount`, if `slippageBps` is
|
|
68
|
+
* out of range, or if the verification in step 4 fails.
|
|
69
|
+
*/
|
|
70
|
+
export declare function sizeExactInForMinOutput<TRawQuote = unknown>(swap: SwapClient<TRawQuote>, params: SizeExactInForMinOutputParams): Promise<SizeExactInForMinOutputResult<TRawQuote>>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExactInQuoteExceedsMaxInputError = void 0;
|
|
4
|
+
exports.sizeExactInForMinOutput = sizeExactInForMinOutput;
|
|
5
|
+
class ExactInQuoteExceedsMaxInputError extends Error {
|
|
6
|
+
constructor(inputAmount, maxInputAmount) {
|
|
7
|
+
super(`sizeExactInForMinOutput: sized input (${inputAmount}) exceeds maxInputAmount (${maxInputAmount})`);
|
|
8
|
+
this.inputAmount = inputAmount;
|
|
9
|
+
this.maxInputAmount = maxInputAmount;
|
|
10
|
+
this.name = "ExactInQuoteExceedsMaxInputError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ExactInQuoteExceedsMaxInputError = ExactInQuoteExceedsMaxInputError;
|
|
14
|
+
/**
|
|
15
|
+
* Size an ExactIn swap so its **worst-case post-slippage output** covers
|
|
16
|
+
* `minOutputAmount`.
|
|
17
|
+
*
|
|
18
|
+
* The ExactIn route graph is denser than ExactOut on most aggregators
|
|
19
|
+
* (Jupiter included), so this is preferred when ExactOut hits
|
|
20
|
+
* `NO_ROUTES_FOUND`. The trade-off: you over-spend input by the slippage
|
|
21
|
+
* buffer; the unused output excess is the caller's to handle (e.g. sweep
|
|
22
|
+
* to a sink account).
|
|
23
|
+
*
|
|
24
|
+
* Strategy:
|
|
25
|
+
* 1. Probe quote at `minOutputAmount` input — gives us the route's
|
|
26
|
+
* spot rate (`probeOut / probeIn`).
|
|
27
|
+
* 2. Solve for the input `I` such that
|
|
28
|
+
* `I × probeOut/probeIn × (1 − slippageBps/10000) ≥ minOutputAmount × (1 + safetyBufferBps/10000)`.
|
|
29
|
+
* 3. Real ExactIn quote at the sized input.
|
|
30
|
+
* 4. Verify the real quote's worst-case output still covers
|
|
31
|
+
* `minOutputAmount` — guards against price impact at the larger size
|
|
32
|
+
* diverging from the probe's spot rate.
|
|
33
|
+
*
|
|
34
|
+
* Throws if `inputAmount` exceeds `maxInputAmount`, if `slippageBps` is
|
|
35
|
+
* out of range, or if the verification in step 4 fails.
|
|
36
|
+
*/
|
|
37
|
+
async function sizeExactInForMinOutput(swap, params) {
|
|
38
|
+
const { inputMint, outputMint, minOutputAmount, maxInputAmount, slippageBps, safetyBufferBps = 0, onlyDirectRoutes, maxAccounts, excludeDexes, } = params;
|
|
39
|
+
if (minOutputAmount <= 0n) {
|
|
40
|
+
throw new Error("sizeExactInForMinOutput: minOutputAmount must be positive");
|
|
41
|
+
}
|
|
42
|
+
if (maxInputAmount <= 0n) {
|
|
43
|
+
throw new Error("sizeExactInForMinOutput: maxInputAmount must be positive");
|
|
44
|
+
}
|
|
45
|
+
if (slippageBps < 0 || slippageBps >= 10000) {
|
|
46
|
+
throw new Error("sizeExactInForMinOutput: slippageBps must be in [0, 10000)");
|
|
47
|
+
}
|
|
48
|
+
if (safetyBufferBps < 0) {
|
|
49
|
+
throw new Error("sizeExactInForMinOutput: safetyBufferBps must be non-negative");
|
|
50
|
+
}
|
|
51
|
+
if (minOutputAmount > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
52
|
+
throw new Error("sizeExactInForMinOutput: minOutputAmount exceeds Number.MAX_SAFE_INTEGER");
|
|
53
|
+
}
|
|
54
|
+
const probeQuote = await swap.getQuote({
|
|
55
|
+
inputMint,
|
|
56
|
+
outputMint,
|
|
57
|
+
amount: Number(minOutputAmount),
|
|
58
|
+
slippageBps,
|
|
59
|
+
onlyDirectRoutes,
|
|
60
|
+
maxAccounts,
|
|
61
|
+
excludeDexes,
|
|
62
|
+
});
|
|
63
|
+
if (probeQuote.outputAmount <= 0n || probeQuote.inputAmount <= 0n) {
|
|
64
|
+
throw new Error("sizeExactInForMinOutput: probe quote returned non-positive amounts");
|
|
65
|
+
}
|
|
66
|
+
// I = ceil(minOutput × probeIn × (10000 + safetyBufferBps) /
|
|
67
|
+
// (probeOut × (10000 - slippageBps)))
|
|
68
|
+
const slippageBpsBig = BigInt(slippageBps);
|
|
69
|
+
const safetyBpsBig = BigInt(safetyBufferBps);
|
|
70
|
+
const sizingNumer = minOutputAmount * probeQuote.inputAmount * (10000n + safetyBpsBig);
|
|
71
|
+
const sizingDenom = probeQuote.outputAmount * (10000n - slippageBpsBig);
|
|
72
|
+
const inputAmount = (sizingNumer + sizingDenom - 1n) / sizingDenom;
|
|
73
|
+
if (inputAmount > maxInputAmount) {
|
|
74
|
+
throw new ExactInQuoteExceedsMaxInputError(inputAmount, maxInputAmount);
|
|
75
|
+
}
|
|
76
|
+
if (inputAmount > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
77
|
+
throw new Error("sizeExactInForMinOutput: sized input exceeds Number.MAX_SAFE_INTEGER");
|
|
78
|
+
}
|
|
79
|
+
const quote = await swap.getQuote({
|
|
80
|
+
inputMint,
|
|
81
|
+
outputMint,
|
|
82
|
+
amount: Number(inputAmount),
|
|
83
|
+
slippageBps,
|
|
84
|
+
onlyDirectRoutes,
|
|
85
|
+
maxAccounts,
|
|
86
|
+
excludeDexes,
|
|
87
|
+
});
|
|
88
|
+
const worstCaseOutputAmount = (quote.outputAmount * (10000n - slippageBpsBig)) / 10000n;
|
|
89
|
+
if (worstCaseOutputAmount < minOutputAmount) {
|
|
90
|
+
throw new Error(`sizeExactInForMinOutput: real-quote worst-case output (${worstCaseOutputAmount}) ` +
|
|
91
|
+
`does not cover minOutputAmount (${minOutputAmount}) — likely price impact at sized input ` +
|
|
92
|
+
`diverged from probe spot rate; raise safetyBufferBps`);
|
|
93
|
+
}
|
|
94
|
+
return { quote, inputAmount, worstCaseOutputAmount };
|
|
95
|
+
}
|