@kestrelfi/lyc-sdk 1.0.1 → 1.0.3
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/README.md +32 -0
- package/dist/carry-XU3WUD22.mjs +20 -0
- package/dist/carry-XU3WUD22.mjs.map +1 -0
- package/dist/chunk-2T23QQCX.mjs +3707 -0
- package/dist/chunk-2T23QQCX.mjs.map +1 -0
- package/dist/chunk-GOW6CARW.mjs +3969 -0
- package/dist/chunk-GOW6CARW.mjs.map +1 -0
- package/dist/chunk-ZPXXY3QV.mjs +9330 -0
- package/dist/chunk-ZPXXY3QV.mjs.map +1 -0
- package/dist/{sdks/long-yield-carry/src/idl/long_yield_carry.d.ts → core-DP6wfpME.d.mts} +3242 -84
- package/dist/core-DP6wfpME.d.ts +10485 -0
- package/dist/core.d.mts +8 -0
- package/dist/core.d.ts +8 -0
- package/dist/core.js +12348 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +72 -0
- package/dist/core.mjs.map +1 -0
- package/dist/index.d.mts +2537 -0
- package/dist/index.d.ts +2537 -0
- package/dist/index.js +23884 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5898 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -10
- package/.env.example +0 -11
- package/dist/sdks/long-yield-carry/scripts/asyncBurn.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/asyncBurn.js +0 -117
- package/dist/sdks/long-yield-carry/scripts/burnToken.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/burnToken.js +0 -98
- package/dist/sdks/long-yield-carry/scripts/claimIncentives.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/claimIncentives.js +0 -108
- package/dist/sdks/long-yield-carry/scripts/closeCpiPlans.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/closeCpiPlans.js +0 -93
- package/dist/sdks/long-yield-carry/scripts/collectInterest.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/collectInterest.js +0 -164
- package/dist/sdks/long-yield-carry/scripts/collectProtocolFees.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/collectProtocolFees.js +0 -120
- package/dist/sdks/long-yield-carry/scripts/computeOptimalAllocations.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/computeOptimalAllocations.js +0 -84
- package/dist/sdks/long-yield-carry/scripts/createToken.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/createToken.js +0 -76
- package/dist/sdks/long-yield-carry/scripts/createTokenLendingPosition.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/createTokenLendingPosition.js +0 -157
- package/dist/sdks/long-yield-carry/scripts/createYieldingBank.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/createYieldingBank.js +0 -69
- package/dist/sdks/long-yield-carry/scripts/decreaseCarryPositions.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/decreaseCarryPositions.js +0 -247
- package/dist/sdks/long-yield-carry/scripts/depositUnlentCollateral.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/depositUnlentCollateral.js +0 -90
- package/dist/sdks/long-yield-carry/scripts/emergency/deleverageAll.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/emergency/deleverageAll.js +0 -202
- package/dist/sdks/long-yield-carry/scripts/emergency/triggerCircuitBreaker.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/emergency/triggerCircuitBreaker.js +0 -68
- package/dist/sdks/long-yield-carry/scripts/env.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/env.js +0 -8
- package/dist/sdks/long-yield-carry/scripts/findTxs.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/findTxs.js +0 -143
- package/dist/sdks/long-yield-carry/scripts/increaseCarryPositions.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/increaseCarryPositions.js +0 -112
- package/dist/sdks/long-yield-carry/scripts/inspect/format.d.ts +0 -13
- package/dist/sdks/long-yield-carry/scripts/inspect/format.js +0 -363
- package/dist/sdks/long-yield-carry/scripts/inspect.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/inspect.js +0 -108
- package/dist/sdks/long-yield-carry/scripts/localUtils.d.ts +0 -53
- package/dist/sdks/long-yield-carry/scripts/localUtils.js +0 -191
- package/dist/sdks/long-yield-carry/scripts/mintToken.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/mintToken.js +0 -103
- package/dist/sdks/long-yield-carry/scripts/processAsyncBurns.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/processAsyncBurns.js +0 -76
- package/dist/sdks/long-yield-carry/scripts/rebalanceToken.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/rebalanceToken.js +0 -210
- package/dist/sdks/long-yield-carry/scripts/rebalanceYieldingBank.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/rebalanceYieldingBank.js +0 -149
- package/dist/sdks/long-yield-carry/scripts/recollateralizeLoss.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/recollateralizeLoss.js +0 -64
- package/dist/sdks/long-yield-carry/scripts/refresh.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/refresh.js +0 -101
- package/dist/sdks/long-yield-carry/scripts/updateFees.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/updateFees.js +0 -369
- package/dist/sdks/long-yield-carry/scripts/updateGeneralLut.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/updateGeneralLut.js +0 -27
- package/dist/sdks/long-yield-carry/scripts/updateLendingPositionConfig.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/updateLendingPositionConfig.js +0 -127
- package/dist/sdks/long-yield-carry/scripts/updateTokenLuts.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/updateTokenLuts.js +0 -27
- package/dist/sdks/long-yield-carry/scripts/updateTokenMetadata.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/updateTokenMetadata.js +0 -194
- package/dist/sdks/long-yield-carry/scripts/updateYieldingBankConfig.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/updateYieldingBankConfig.js +0 -84
- package/dist/sdks/long-yield-carry/scripts/withdrawUnlentCollateral.d.ts +0 -1
- package/dist/sdks/long-yield-carry/scripts/withdrawUnlentCollateral.js +0 -140
- package/dist/sdks/long-yield-carry/src/client/account.d.ts +0 -152
- package/dist/sdks/long-yield-carry/src/client/account.js +0 -349
- package/dist/sdks/long-yield-carry/src/client/builders/args.d.ts +0 -299
- package/dist/sdks/long-yield-carry/src/client/builders/args.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/builders/asyncBurnBuilder.d.ts +0 -20
- package/dist/sdks/long-yield-carry/src/client/builders/asyncBurnBuilder.js +0 -212
- package/dist/sdks/long-yield-carry/src/client/builders/base.d.ts +0 -77
- package/dist/sdks/long-yield-carry/src/client/builders/base.js +0 -191
- package/dist/sdks/long-yield-carry/src/client/builders/burnTokenBuilder.d.ts +0 -18
- package/dist/sdks/long-yield-carry/src/client/builders/burnTokenBuilder.js +0 -165
- package/dist/sdks/long-yield-carry/src/client/builders/claimIncentivesBuilder.d.ts +0 -9
- package/dist/sdks/long-yield-carry/src/client/builders/claimIncentivesBuilder.js +0 -135
- package/dist/sdks/long-yield-carry/src/client/builders/collectFeesBuilder.d.ts +0 -14
- package/dist/sdks/long-yield-carry/src/client/builders/collectFeesBuilder.js +0 -50
- package/dist/sdks/long-yield-carry/src/client/builders/collectInterestBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/collectInterestBuilder.js +0 -86
- package/dist/sdks/long-yield-carry/src/client/builders/createCpiPlanBuilder.d.ts +0 -6
- package/dist/sdks/long-yield-carry/src/client/builders/createCpiPlanBuilder.js +0 -22
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenBuilder.d.ts +0 -7
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenBuilder.js +0 -64
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenLendingPositionBuilder.d.ts +0 -10
- package/dist/sdks/long-yield-carry/src/client/builders/createTokenLendingPositionBuilder.js +0 -138
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankAllocationBuilder.d.ts +0 -7
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankAllocationBuilder.js +0 -29
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankBuilder.d.ts +0 -7
- package/dist/sdks/long-yield-carry/src/client/builders/createYieldingBankBuilder.js +0 -39
- package/dist/sdks/long-yield-carry/src/client/builders/decreaseCarryPositionBuilder.d.ts +0 -30
- package/dist/sdks/long-yield-carry/src/client/builders/decreaseCarryPositionBuilder.js +0 -99
- package/dist/sdks/long-yield-carry/src/client/builders/depositUnlentCollateralBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/depositUnlentCollateralBuilder.js +0 -64
- package/dist/sdks/long-yield-carry/src/client/builders/increaseCarryPositionBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/increaseCarryPositionBuilder.js +0 -73
- package/dist/sdks/long-yield-carry/src/client/builders/index.d.ts +0 -28
- package/dist/sdks/long-yield-carry/src/client/builders/index.js +0 -62
- package/dist/sdks/long-yield-carry/src/client/builders/mintTokenBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/mintTokenBuilder.js +0 -95
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceTokenBuilder.d.ts +0 -11
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceTokenBuilder.js +0 -255
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceYieldingBankBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/rebalanceYieldingBankBuilder.js +0 -75
- package/dist/sdks/long-yield-carry/src/client/builders/recollateralizeLossBuilder.d.ts +0 -12
- package/dist/sdks/long-yield-carry/src/client/builders/recollateralizeLossBuilder.js +0 -220
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokenStateBuilder.d.ts +0 -9
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokenStateBuilder.js +0 -112
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokensBuilder.d.ts +0 -9
- package/dist/sdks/long-yield-carry/src/client/builders/refreshTokensBuilder.js +0 -59
- package/dist/sdks/long-yield-carry/src/client/builders/refreshYieldingBankBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/refreshYieldingBankBuilder.js +0 -29
- package/dist/sdks/long-yield-carry/src/client/builders/resetTokenBurnRateLimitBuilder.d.ts +0 -7
- package/dist/sdks/long-yield-carry/src/client/builders/resetTokenBurnRateLimitBuilder.js +0 -19
- package/dist/sdks/long-yield-carry/src/client/builders/setTokenCircuitBreakerBuilder.d.ts +0 -11
- package/dist/sdks/long-yield-carry/src/client/builders/setTokenCircuitBreakerBuilder.js +0 -31
- package/dist/sdks/long-yield-carry/src/client/builders/setYieldingBankCircuitBreakerBuilder.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/client/builders/setYieldingBankCircuitBreakerBuilder.js +0 -28
- package/dist/sdks/long-yield-carry/src/client/builders/updateLendingPositionConfigBuilder.d.ts +0 -10
- package/dist/sdks/long-yield-carry/src/client/builders/updateLendingPositionConfigBuilder.js +0 -30
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenConfigurationBuilder.d.ts +0 -11
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenConfigurationBuilder.js +0 -47
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenMetadataBuilder.d.ts +0 -7
- package/dist/sdks/long-yield-carry/src/client/builders/updateTokenMetadataBuilder.js +0 -24
- package/dist/sdks/long-yield-carry/src/client/builders/updateYieldingBankConfigBuilder.d.ts +0 -10
- package/dist/sdks/long-yield-carry/src/client/builders/updateYieldingBankConfigBuilder.js +0 -31
- package/dist/sdks/long-yield-carry/src/client/builders/utils.d.ts +0 -4
- package/dist/sdks/long-yield-carry/src/client/builders/utils.js +0 -20
- package/dist/sdks/long-yield-carry/src/client/client.d.ts +0 -115
- package/dist/sdks/long-yield-carry/src/client/client.js +0 -166
- package/dist/sdks/long-yield-carry/src/client/externalLiquidityResolver.d.ts +0 -13
- package/dist/sdks/long-yield-carry/src/client/externalLiquidityResolver.js +0 -34
- package/dist/sdks/long-yield-carry/src/client/index.d.ts +0 -10
- package/dist/sdks/long-yield-carry/src/client/index.js +0 -33
- package/dist/sdks/long-yield-carry/src/client/lendingPlatformClients.d.ts +0 -19
- package/dist/sdks/long-yield-carry/src/client/lendingPlatformClients.js +0 -33
- package/dist/sdks/long-yield-carry/src/client/pda.d.ts +0 -33
- package/dist/sdks/long-yield-carry/src/client/pda.js +0 -79
- package/dist/sdks/long-yield-carry/src/client/plans/collectInterest.d.ts +0 -24
- package/dist/sdks/long-yield-carry/src/client/plans/collectInterest.js +0 -150
- package/dist/sdks/long-yield-carry/src/client/plans/decreaseCarryPosition.d.ts +0 -12
- package/dist/sdks/long-yield-carry/src/client/plans/decreaseCarryPosition.js +0 -140
- package/dist/sdks/long-yield-carry/src/client/routes/collectInterest.d.ts +0 -13
- package/dist/sdks/long-yield-carry/src/client/routes/collectInterest.js +0 -39
- package/dist/sdks/long-yield-carry/src/client/transaction.d.ts +0 -41
- package/dist/sdks/long-yield-carry/src/client/transaction.js +0 -55
- package/dist/sdks/long-yield-carry/src/client/types/builders.d.ts +0 -18
- package/dist/sdks/long-yield-carry/src/client/types/builders.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/types/enums.d.ts +0 -22
- package/dist/sdks/long-yield-carry/src/client/types/enums.js +0 -48
- package/dist/sdks/long-yield-carry/src/client/types/general.d.ts +0 -98
- package/dist/sdks/long-yield-carry/src/client/types/general.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/types/index.d.ts +0 -6
- package/dist/sdks/long-yield-carry/src/client/types/index.js +0 -22
- package/dist/sdks/long-yield-carry/src/client/types/ix.d.ts +0 -352
- package/dist/sdks/long-yield-carry/src/client/types/ix.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/collectInterest.d.ts +0 -91
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/collectInterest.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/common.d.ts +0 -28
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/common.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/decreaseCarryPosition.d.ts +0 -128
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/decreaseCarryPosition.js +0 -2
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/index.d.ts +0 -3
- package/dist/sdks/long-yield-carry/src/client/types/planTypes/index.js +0 -19
- package/dist/sdks/long-yield-carry/src/client/types/tx.d.ts +0 -339
- package/dist/sdks/long-yield-carry/src/client/types/tx.js +0 -2
- package/dist/sdks/long-yield-carry/src/constants/configs/allocations.d.ts +0 -3
- package/dist/sdks/long-yield-carry/src/constants/configs/allocations.js +0 -23
- package/dist/sdks/long-yield-carry/src/constants/configs/carryTradePresets.d.ts +0 -58
- package/dist/sdks/long-yield-carry/src/constants/configs/carryTradePresets.js +0 -116
- package/dist/sdks/long-yield-carry/src/constants/configs/index.d.ts +0 -2
- package/dist/sdks/long-yield-carry/src/constants/configs/index.js +0 -18
- package/dist/sdks/long-yield-carry/src/constants/general.d.ts +0 -70
- package/dist/sdks/long-yield-carry/src/constants/general.js +0 -107
- package/dist/sdks/long-yield-carry/src/constants/index.d.ts +0 -3
- package/dist/sdks/long-yield-carry/src/constants/index.js +0 -19
- package/dist/sdks/long-yield-carry/src/constants/lycTokenMetadata.d.ts +0 -36
- package/dist/sdks/long-yield-carry/src/constants/lycTokenMetadata.js +0 -41
- package/dist/sdks/long-yield-carry/src/decoders/decodeTransaction.d.ts +0 -86
- package/dist/sdks/long-yield-carry/src/decoders/decodeTransaction.js +0 -230
- package/dist/sdks/long-yield-carry/src/decoders/discriminators.d.ts +0 -8
- package/dist/sdks/long-yield-carry/src/decoders/discriminators.js +0 -11
- package/dist/sdks/long-yield-carry/src/decoders/idlAccounts.d.ts +0 -29
- package/dist/sdks/long-yield-carry/src/decoders/idlAccounts.js +0 -57
- package/dist/sdks/long-yield-carry/src/decoders/index.d.ts +0 -6
- package/dist/sdks/long-yield-carry/src/decoders/index.js +0 -14
- package/dist/sdks/long-yield-carry/src/decoders/innerCpis.d.ts +0 -68
- package/dist/sdks/long-yield-carry/src/decoders/innerCpis.js +0 -225
- package/dist/sdks/long-yield-carry/src/decoders/lycInstructionNames.d.ts +0 -6
- package/dist/sdks/long-yield-carry/src/decoders/lycInstructionNames.js +0 -73
- package/dist/sdks/long-yield-carry/src/decoders/programIds.d.ts +0 -4
- package/dist/sdks/long-yield-carry/src/decoders/programIds.js +0 -11
- package/dist/sdks/long-yield-carry/src/decoders/solana.d.ts +0 -7
- package/dist/sdks/long-yield-carry/src/decoders/solana.js +0 -30
- package/dist/sdks/long-yield-carry/src/decoders/transactionPayload.d.ts +0 -41
- package/dist/sdks/long-yield-carry/src/decoders/transactionPayload.js +0 -6
- package/dist/sdks/long-yield-carry/src/decoders/types.d.ts +0 -58
- package/dist/sdks/long-yield-carry/src/decoders/types.js +0 -2
- package/dist/sdks/long-yield-carry/src/errors.d.ts +0 -69
- package/dist/sdks/long-yield-carry/src/errors.js +0 -183
- package/dist/sdks/long-yield-carry/src/idl/long_yield_carry.js +0 -7323
- package/dist/sdks/long-yield-carry/src/index.d.ts +0 -10
- package/dist/sdks/long-yield-carry/src/index.js +0 -25
- package/dist/sdks/long-yield-carry/src/metrics/index.d.ts +0 -1
- package/dist/sdks/long-yield-carry/src/metrics/index.js +0 -17
- package/dist/sdks/long-yield-carry/src/metrics/protocolMetrics.d.ts +0 -276
- package/dist/sdks/long-yield-carry/src/metrics/protocolMetrics.js +0 -547
- package/dist/sdks/long-yield-carry/src/models/index.d.ts +0 -3
- package/dist/sdks/long-yield-carry/src/models/index.js +0 -7
- package/dist/sdks/long-yield-carry/src/models/lycToken.d.ts +0 -156
- package/dist/sdks/long-yield-carry/src/models/lycToken.js +0 -288
- package/dist/sdks/long-yield-carry/src/models/yieldingBank.d.ts +0 -52
- package/dist/sdks/long-yield-carry/src/models/yieldingBank.js +0 -109
- package/dist/sdks/long-yield-carry/src/services/allocation/allocationService.d.ts +0 -106
- package/dist/sdks/long-yield-carry/src/services/allocation/allocationService.js +0 -589
- package/dist/sdks/long-yield-carry/src/services/allocation/index.d.ts +0 -2
- package/dist/sdks/long-yield-carry/src/services/allocation/index.js +0 -18
- package/dist/sdks/long-yield-carry/src/services/allocation/types.d.ts +0 -25
- package/dist/sdks/long-yield-carry/src/services/allocation/types.js +0 -2
- package/dist/sdks/long-yield-carry/src/services/carry/carryAllocationConfig.d.ts +0 -103
- package/dist/sdks/long-yield-carry/src/services/carry/carryAllocationConfig.js +0 -146
- package/dist/sdks/long-yield-carry/src/services/carry/index.d.ts +0 -2
- package/dist/sdks/long-yield-carry/src/services/carry/index.js +0 -18
- package/dist/sdks/long-yield-carry/src/services/carry/lycLendingPositionManager.d.ts +0 -39
- package/dist/sdks/long-yield-carry/src/services/carry/lycLendingPositionManager.js +0 -100
- package/dist/sdks/long-yield-carry/src/services/index.d.ts +0 -5
- package/dist/sdks/long-yield-carry/src/services/index.js +0 -21
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/index.d.ts +0 -2
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/index.js +0 -5
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/lendingPositionService.d.ts +0 -88
- package/dist/sdks/long-yield-carry/src/services/lendingPosition/lendingPositionService.js +0 -229
- package/dist/sdks/long-yield-carry/src/services/rebalance/index.d.ts +0 -2
- package/dist/sdks/long-yield-carry/src/services/rebalance/index.js +0 -18
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/index.d.ts +0 -1
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/index.js +0 -17
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/tokenRebalanceService.d.ts +0 -51
- package/dist/sdks/long-yield-carry/src/services/rebalance/token/tokenRebalanceService.js +0 -99
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/index.d.ts +0 -3
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/index.js +0 -21
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/planner.d.ts +0 -68
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/planner.js +0 -181
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/strategy.d.ts +0 -26
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/strategy.js +0 -26
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/types.d.ts +0 -40
- package/dist/sdks/long-yield-carry/src/services/rebalance/yieldingBank/types.js +0 -2
- package/dist/sdks/long-yield-carry/src/services/redemption/index.d.ts +0 -2
- package/dist/sdks/long-yield-carry/src/services/redemption/index.js +0 -5
- package/dist/sdks/long-yield-carry/src/services/redemption/redemptionService.d.ts +0 -139
- package/dist/sdks/long-yield-carry/src/services/redemption/redemptionService.js +0 -532
- package/dist/sdks/long-yield-carry/src/types/enriched.d.ts +0 -168
- package/dist/sdks/long-yield-carry/src/types/enriched.js +0 -2
- package/dist/sdks/long-yield-carry/src/types/index.d.ts +0 -1
- package/dist/sdks/long-yield-carry/src/types/index.js +0 -17
- package/dist/sdks/long-yield-carry/src/utils/cache.d.ts +0 -4
- package/dist/sdks/long-yield-carry/src/utils/cache.js +0 -10
- package/dist/sdks/long-yield-carry/src/utils/data.d.ts +0 -12
- package/dist/sdks/long-yield-carry/src/utils/data.js +0 -59
- package/dist/sdks/long-yield-carry/src/utils/enrichment.d.ts +0 -5
- package/dist/sdks/long-yield-carry/src/utils/enrichment.js +0 -244
- package/dist/sdks/long-yield-carry/src/utils/feeDripMetrics.d.ts +0 -36
- package/dist/sdks/long-yield-carry/src/utils/feeDripMetrics.js +0 -93
- package/dist/sdks/long-yield-carry/src/utils/general.d.ts +0 -28
- package/dist/sdks/long-yield-carry/src/utils/general.js +0 -47
- package/dist/sdks/long-yield-carry/src/utils/index.d.ts +0 -13
- package/dist/sdks/long-yield-carry/src/utils/index.js +0 -29
- package/dist/sdks/long-yield-carry/src/utils/ix.d.ts +0 -83
- package/dist/sdks/long-yield-carry/src/utils/ix.js +0 -165
- package/dist/sdks/long-yield-carry/src/utils/lendingPosition.d.ts +0 -68
- package/dist/sdks/long-yield-carry/src/utils/lendingPosition.js +0 -105
- package/dist/sdks/long-yield-carry/src/utils/lookupTables.d.ts +0 -55
- package/dist/sdks/long-yield-carry/src/utils/lookupTables.js +0 -216
- package/dist/sdks/long-yield-carry/src/utils/lycData.d.ts +0 -66
- package/dist/sdks/long-yield-carry/src/utils/lycData.js +0 -211
- package/dist/sdks/long-yield-carry/src/utils/timelock.d.ts +0 -19
- package/dist/sdks/long-yield-carry/src/utils/timelock.js +0 -37
- package/dist/sdks/long-yield-carry/src/utils/tokenFeeMath.d.ts +0 -11
- package/dist/sdks/long-yield-carry/src/utils/tokenFeeMath.js +0 -24
- package/dist/sdks/long-yield-carry/src/utils/transactions.d.ts +0 -20
- package/dist/sdks/long-yield-carry/src/utils/transactions.js +0 -72
- package/dist/sdks/long-yield-carry/src/utils/yieldingBank.d.ts +0 -24
- package/dist/sdks/long-yield-carry/src/utils/yieldingBank.js +0 -36
- package/dist/shared/common/src/constants/accountMetas.d.ts +0 -3
- package/dist/shared/common/src/constants/accountMetas.js +0 -9
- package/dist/shared/common/src/constants/general.d.ts +0 -21
- package/dist/shared/common/src/constants/general.js +0 -30
- package/dist/shared/common/src/constants/generated/cpi.d.ts +0 -23
- package/dist/shared/common/src/constants/generated/cpi.js +0 -28
- package/dist/shared/common/src/constants/generated/index.d.ts +0 -1
- package/dist/shared/common/src/constants/generated/index.js +0 -17
- package/dist/shared/common/src/constants/index.d.ts +0 -3
- package/dist/shared/common/src/constants/index.js +0 -19
- package/dist/shared/common/src/index.d.ts +0 -4
- package/dist/shared/common/src/index.js +0 -20
- package/dist/shared/common/src/services/baseAccountClient.d.ts +0 -22
- package/dist/shared/common/src/services/baseAccountClient.js +0 -38
- package/dist/shared/common/src/services/baseIxBuilderService.d.ts +0 -27
- package/dist/shared/common/src/services/baseIxBuilderService.js +0 -48
- package/dist/shared/common/src/services/dataCache.d.ts +0 -41
- package/dist/shared/common/src/services/dataCache.js +0 -130
- package/dist/shared/common/src/services/index.d.ts +0 -8
- package/dist/shared/common/src/services/index.js +0 -24
- package/dist/shared/common/src/services/lutManager.d.ts +0 -31
- package/dist/shared/common/src/services/lutManager.js +0 -133
- package/dist/shared/common/src/services/mints/defaults.d.ts +0 -2
- package/dist/shared/common/src/services/mints/defaults.js +0 -152
- package/dist/shared/common/src/services/mints/index.d.ts +0 -4
- package/dist/shared/common/src/services/mints/index.js +0 -20
- package/dist/shared/common/src/services/mints/registry.d.ts +0 -70
- package/dist/shared/common/src/services/mints/registry.js +0 -117
- package/dist/shared/common/src/services/mints/symbols.d.ts +0 -6
- package/dist/shared/common/src/services/mints/symbols.js +0 -13
- package/dist/shared/common/src/services/mints/types.d.ts +0 -30
- package/dist/shared/common/src/services/mints/types.js +0 -2
- package/dist/shared/common/src/services/swap/index.d.ts +0 -4
- package/dist/shared/common/src/services/swap/index.js +0 -20
- package/dist/shared/common/src/services/swap/routableSwapClient.d.ts +0 -36
- package/dist/shared/common/src/services/swap/routableSwapClient.js +0 -2
- package/dist/shared/common/src/services/swap/swapClientBase.d.ts +0 -45
- package/dist/shared/common/src/services/swap/swapClientBase.js +0 -2
- package/dist/shared/common/src/services/swap/swapRouting.d.ts +0 -13
- package/dist/shared/common/src/services/swap/swapRouting.js +0 -28
- package/dist/shared/common/src/services/swap/types.d.ts +0 -77
- package/dist/shared/common/src/services/swap/types.js +0 -2
- package/dist/shared/common/src/services/token/index.d.ts +0 -2
- package/dist/shared/common/src/services/token/index.js +0 -18
- package/dist/shared/common/src/services/token/tokenProtocolClientBase.d.ts +0 -51
- package/dist/shared/common/src/services/token/tokenProtocolClientBase.js +0 -2
- package/dist/shared/common/src/services/token/types.d.ts +0 -19
- package/dist/shared/common/src/services/token/types.js +0 -2
- package/dist/shared/common/src/services/transactionSender.d.ts +0 -24
- package/dist/shared/common/src/services/transactionSender.js +0 -30
- package/dist/shared/common/src/types/cpi.d.ts +0 -34
- package/dist/shared/common/src/types/cpi.js +0 -8
- package/dist/shared/common/src/types/enums.d.ts +0 -59
- package/dist/shared/common/src/types/enums.js +0 -122
- package/dist/shared/common/src/types/general.d.ts +0 -38
- package/dist/shared/common/src/types/general.js +0 -2
- package/dist/shared/common/src/types/index.d.ts +0 -4
- package/dist/shared/common/src/types/index.js +0 -20
- package/dist/shared/common/src/types/solana.d.ts +0 -24
- package/dist/shared/common/src/types/solana.js +0 -2
- package/dist/shared/common/src/utils/accounts/index.d.ts +0 -5
- package/dist/shared/common/src/utils/accounts/index.js +0 -21
- package/dist/shared/common/src/utils/accounts/meta.d.ts +0 -21
- package/dist/shared/common/src/utils/accounts/meta.js +0 -27
- package/dist/shared/common/src/utils/accounts/pda.d.ts +0 -2
- package/dist/shared/common/src/utils/accounts/pda.js +0 -17
- package/dist/shared/common/src/utils/accounts/roles.d.ts +0 -26
- package/dist/shared/common/src/utils/accounts/roles.js +0 -54
- package/dist/shared/common/src/utils/accounts/rpc.d.ts +0 -8
- package/dist/shared/common/src/utils/accounts/rpc.js +0 -30
- package/dist/shared/common/src/utils/accounts/splBalances.d.ts +0 -15
- package/dist/shared/common/src/utils/accounts/splBalances.js +0 -52
- package/dist/shared/common/src/utils/anchor.d.ts +0 -17
- package/dist/shared/common/src/utils/anchor.js +0 -29
- package/dist/shared/common/src/utils/asyncConcurrency.d.ts +0 -5
- package/dist/shared/common/src/utils/asyncConcurrency.js +0 -28
- package/dist/shared/common/src/utils/compat.d.ts +0 -46
- package/dist/shared/common/src/utils/compat.js +0 -72
- package/dist/shared/common/src/utils/cpi/args.d.ts +0 -69
- package/dist/shared/common/src/utils/cpi/args.js +0 -100
- package/dist/shared/common/src/utils/cpi/index.d.ts +0 -2
- package/dist/shared/common/src/utils/cpi/index.js +0 -18
- package/dist/shared/common/src/utils/cpi/refs.d.ts +0 -122
- package/dist/shared/common/src/utils/cpi/refs.js +0 -234
- package/dist/shared/common/src/utils/data.d.ts +0 -20
- package/dist/shared/common/src/utils/data.js +0 -27
- package/dist/shared/common/src/utils/general.d.ts +0 -24
- package/dist/shared/common/src/utils/general.js +0 -95
- package/dist/shared/common/src/utils/index.d.ts +0 -22
- package/dist/shared/common/src/utils/index.js +0 -38
- package/dist/shared/common/src/utils/instruction.d.ts +0 -74
- package/dist/shared/common/src/utils/instruction.js +0 -147
- package/dist/shared/common/src/utils/jito.d.ts +0 -113
- package/dist/shared/common/src/utils/jito.js +0 -178
- package/dist/shared/common/src/utils/json.d.ts +0 -5
- package/dist/shared/common/src/utils/json.js +0 -25
- package/dist/shared/common/src/utils/jsonRpcFetch.d.ts +0 -21
- package/dist/shared/common/src/utils/jsonRpcFetch.js +0 -134
- package/dist/shared/common/src/utils/metadata.d.ts +0 -107
- package/dist/shared/common/src/utils/metadata.js +0 -194
- package/dist/shared/common/src/utils/numbers.d.ts +0 -72
- package/dist/shared/common/src/utils/numbers.js +0 -193
- package/dist/shared/common/src/utils/priorityFee.d.ts +0 -18
- package/dist/shared/common/src/utils/priorityFee.js +0 -63
- package/dist/shared/common/src/utils/retry.d.ts +0 -20
- package/dist/shared/common/src/utils/retry.js +0 -69
- package/dist/shared/common/src/utils/rpc.d.ts +0 -40
- package/dist/shared/common/src/utils/rpc.js +0 -130
- package/dist/shared/common/src/utils/solana.d.ts +0 -23
- package/dist/shared/common/src/utils/solana.js +0 -61
- package/dist/shared/common/src/utils/timeSeries.d.ts +0 -18
- package/dist/shared/common/src/utils/timeSeries.js +0 -40
- package/dist/shared/common/src/utils/token.d.ts +0 -33
- package/dist/shared/common/src/utils/token.js +0 -82
- package/dist/shared/common/src/utils/transaction.d.ts +0 -154
- package/dist/shared/common/src/utils/transaction.js +0 -585
- package/dist/shared/common/src/utils/transactionSplitter.d.ts +0 -85
- package/dist/shared/common/src/utils/transactionSplitter.js +0 -127
- package/dist/shared/common/src/utils/txAccountCoverage.d.ts +0 -49
- package/dist/shared/common/src/utils/txAccountCoverage.js +0 -122
- package/dist/shared/jupiter-helpers/src/api.d.ts +0 -59
- package/dist/shared/jupiter-helpers/src/api.js +0 -130
- package/dist/shared/jupiter-helpers/src/client.d.ts +0 -79
- package/dist/shared/jupiter-helpers/src/client.js +0 -173
- package/dist/shared/jupiter-helpers/src/constants.d.ts +0 -35
- package/dist/shared/jupiter-helpers/src/constants.js +0 -38
- package/dist/shared/jupiter-helpers/src/extract.d.ts +0 -30
- package/dist/shared/jupiter-helpers/src/extract.js +0 -57
- package/dist/shared/jupiter-helpers/src/index.d.ts +0 -5
- package/dist/shared/jupiter-helpers/src/index.js +0 -21
- package/dist/shared/jupiter-helpers/src/routePreInstructions.d.ts +0 -19
- package/dist/shared/jupiter-helpers/src/routePreInstructions.js +0 -61
- package/dist/shared/jupiter-helpers/src/sizeExactInForMinOutput.d.ts +0 -70
- package/dist/shared/jupiter-helpers/src/sizeExactInForMinOutput.js +0 -95
- package/dist/shared/jupiter-helpers/src/types.d.ts +0 -66
- package/dist/shared/jupiter-helpers/src/types.js +0 -2
- package/dist/shared/lending-platforms/src/constants/cache.d.ts +0 -8
- package/dist/shared/lending-platforms/src/constants/cache.js +0 -11
- package/dist/shared/lending-platforms/src/constants/index.d.ts +0 -3
- package/dist/shared/lending-platforms/src/constants/index.js +0 -19
- package/dist/shared/lending-platforms/src/constants/kamino.d.ts +0 -7
- package/dist/shared/lending-platforms/src/constants/kamino.js +0 -83
- package/dist/shared/lending-platforms/src/constants/lendingPosition.d.ts +0 -7
- package/dist/shared/lending-platforms/src/constants/lendingPosition.js +0 -10
- package/dist/shared/lending-platforms/src/data/accounts/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/data/accounts/index.js +0 -18
- package/dist/shared/lending-platforms/src/data/accounts/kamino.d.ts +0 -42
- package/dist/shared/lending-platforms/src/data/accounts/kamino.js +0 -104
- package/dist/shared/lending-platforms/src/data/accounts/lpAccountsBase.d.ts +0 -7
- package/dist/shared/lending-platforms/src/data/accounts/lpAccountsBase.js +0 -9
- package/dist/shared/lending-platforms/src/data/incentive/incentiveBase.d.ts +0 -35
- package/dist/shared/lending-platforms/src/data/incentive/incentiveBase.js +0 -26
- package/dist/shared/lending-platforms/src/data/incentive/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/data/incentive/index.js +0 -18
- package/dist/shared/lending-platforms/src/data/incentive/kamino.d.ts +0 -55
- package/dist/shared/lending-platforms/src/data/incentive/kamino.js +0 -101
- package/dist/shared/lending-platforms/src/data/index.d.ts +0 -6
- package/dist/shared/lending-platforms/src/data/index.js +0 -22
- package/dist/shared/lending-platforms/src/data/instructions/index.d.ts +0 -3
- package/dist/shared/lending-platforms/src/data/instructions/index.js +0 -19
- package/dist/shared/lending-platforms/src/data/instructions/kamino.d.ts +0 -55
- package/dist/shared/lending-platforms/src/data/instructions/kamino.js +0 -630
- package/dist/shared/lending-platforms/src/data/instructions/lpInstructionsBase.d.ts +0 -175
- package/dist/shared/lending-platforms/src/data/instructions/lpInstructionsBase.js +0 -192
- package/dist/shared/lending-platforms/src/data/instructions/types.d.ts +0 -7
- package/dist/shared/lending-platforms/src/data/instructions/types.js +0 -2
- package/dist/shared/lending-platforms/src/data/platform/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/data/platform/index.js +0 -18
- package/dist/shared/lending-platforms/src/data/platform/kamino.d.ts +0 -59
- package/dist/shared/lending-platforms/src/data/platform/kamino.js +0 -206
- package/dist/shared/lending-platforms/src/data/platform/lpDataBase.d.ts +0 -35
- package/dist/shared/lending-platforms/src/data/platform/lpDataBase.js +0 -31
- package/dist/shared/lending-platforms/src/data/reserve/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/data/reserve/index.js +0 -18
- package/dist/shared/lending-platforms/src/data/reserve/kamino.d.ts +0 -45
- package/dist/shared/lending-platforms/src/data/reserve/kamino.js +0 -141
- package/dist/shared/lending-platforms/src/data/reserve/reserveBase.d.ts +0 -114
- package/dist/shared/lending-platforms/src/data/reserve/reserveBase.js +0 -125
- package/dist/shared/lending-platforms/src/data/userPosition/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/data/userPosition/index.js +0 -18
- package/dist/shared/lending-platforms/src/data/userPosition/kamino.d.ts +0 -15
- package/dist/shared/lending-platforms/src/data/userPosition/kamino.js +0 -45
- package/dist/shared/lending-platforms/src/data/userPosition/userPositionBase.d.ts +0 -50
- package/dist/shared/lending-platforms/src/data/userPosition/userPositionBase.js +0 -63
- package/dist/shared/lending-platforms/src/index.d.ts +0 -5
- package/dist/shared/lending-platforms/src/index.js +0 -21
- package/dist/shared/lending-platforms/src/services/client/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/services/client/index.js +0 -18
- package/dist/shared/lending-platforms/src/services/client/kamino.d.ts +0 -53
- package/dist/shared/lending-platforms/src/services/client/kamino.js +0 -142
- package/dist/shared/lending-platforms/src/services/client/lpClientBase.d.ts +0 -66
- package/dist/shared/lending-platforms/src/services/client/lpClientBase.js +0 -19
- package/dist/shared/lending-platforms/src/services/flashLoan/flashLoanBase.d.ts +0 -49
- package/dist/shared/lending-platforms/src/services/flashLoan/flashLoanBase.js +0 -16
- package/dist/shared/lending-platforms/src/services/flashLoan/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/services/flashLoan/index.js +0 -18
- package/dist/shared/lending-platforms/src/services/flashLoan/kamino.d.ts +0 -11
- package/dist/shared/lending-platforms/src/services/flashLoan/kamino.js +0 -85
- package/dist/shared/lending-platforms/src/services/index.d.ts +0 -5
- package/dist/shared/lending-platforms/src/services/index.js +0 -21
- package/dist/shared/lending-platforms/src/services/lendingPosition/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/services/lendingPosition/index.js +0 -18
- package/dist/shared/lending-platforms/src/services/lendingPosition/lendingPositionManager.d.ts +0 -117
- package/dist/shared/lending-platforms/src/services/lendingPosition/lendingPositionManager.js +0 -342
- package/dist/shared/lending-platforms/src/services/lendingPosition/types.d.ts +0 -40
- package/dist/shared/lending-platforms/src/services/lendingPosition/types.js +0 -2
- package/dist/shared/lending-platforms/src/services/leverage/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/services/leverage/index.js +0 -18
- package/dist/shared/lending-platforms/src/services/leverage/leverageService.d.ts +0 -104
- package/dist/shared/lending-platforms/src/services/leverage/leverageService.js +0 -437
- package/dist/shared/lending-platforms/src/services/leverage/types.d.ts +0 -261
- package/dist/shared/lending-platforms/src/services/leverage/types.js +0 -2
- package/dist/shared/lending-platforms/src/services/reservesManager.d.ts +0 -53
- package/dist/shared/lending-platforms/src/services/reservesManager.js +0 -112
- package/dist/shared/lending-platforms/src/types/general.d.ts +0 -37
- package/dist/shared/lending-platforms/src/types/general.js +0 -8
- package/dist/shared/lending-platforms/src/types/index.d.ts +0 -2
- package/dist/shared/lending-platforms/src/types/index.js +0 -18
- package/dist/shared/lending-platforms/src/types/kamino.d.ts +0 -10
- package/dist/shared/lending-platforms/src/types/kamino.js +0 -2
- package/dist/shared/lending-platforms/src/utils/accounts.d.ts +0 -16
- package/dist/shared/lending-platforms/src/utils/accounts.js +0 -36
- package/dist/shared/lending-platforms/src/utils/cache.d.ts +0 -3
- package/dist/shared/lending-platforms/src/utils/cache.js +0 -11
- package/dist/shared/lending-platforms/src/utils/index.d.ts +0 -6
- package/dist/shared/lending-platforms/src/utils/index.js +0 -22
- package/dist/shared/lending-platforms/src/utils/kamino.d.ts +0 -87
- package/dist/shared/lending-platforms/src/utils/kamino.js +0 -190
- package/dist/shared/lending-platforms/src/utils/lendingPlatform.d.ts +0 -6
- package/dist/shared/lending-platforms/src/utils/lendingPlatform.js +0 -16
- package/dist/shared/lending-platforms/src/utils/math.d.ts +0 -47
- package/dist/shared/lending-platforms/src/utils/math.js +0 -123
- package/dist/shared/lending-platforms/src/utils/scope.d.ts +0 -38
- package/dist/shared/lending-platforms/src/utils/scope.js +0 -144
- package/dist/shared/oracle-service/src/constants/index.d.ts +0 -3
- package/dist/shared/oracle-service/src/constants/index.js +0 -19
- package/dist/shared/oracle-service/src/constants/pyth.d.ts +0 -7
- package/dist/shared/oracle-service/src/constants/pyth.js +0 -71
- package/dist/shared/oracle-service/src/constants/splStake.d.ts +0 -2
- package/dist/shared/oracle-service/src/constants/splStake.js +0 -6
- package/dist/shared/oracle-service/src/constants/switchboard.d.ts +0 -7
- package/dist/shared/oracle-service/src/constants/switchboard.js +0 -10
- package/dist/shared/oracle-service/src/feeds/custom.d.ts +0 -30
- package/dist/shared/oracle-service/src/feeds/custom.js +0 -56
- package/dist/shared/oracle-service/src/feeds/jupiter.d.ts +0 -7
- package/dist/shared/oracle-service/src/feeds/jupiter.js +0 -43
- package/dist/shared/oracle-service/src/feeds/priceBase.d.ts +0 -13
- package/dist/shared/oracle-service/src/feeds/priceBase.js +0 -25
- package/dist/shared/oracle-service/src/feeds/pyth.d.ts +0 -8
- package/dist/shared/oracle-service/src/feeds/pyth.js +0 -59
- package/dist/shared/oracle-service/src/feeds/splStake.d.ts +0 -26
- package/dist/shared/oracle-service/src/feeds/splStake.js +0 -99
- package/dist/shared/oracle-service/src/feeds/switchboard.d.ts +0 -6
- package/dist/shared/oracle-service/src/feeds/switchboard.js +0 -11
- package/dist/shared/oracle-service/src/index.d.ts +0 -5
- package/dist/shared/oracle-service/src/index.js +0 -26
- package/dist/shared/oracle-service/src/oracle.d.ts +0 -22
- package/dist/shared/oracle-service/src/oracle.js +0 -104
- package/dist/shared/oracle-service/src/types.d.ts +0 -4
- package/dist/shared/oracle-service/src/types.js +0 -2
- package/dist/shared/oracle-service/src/utils/general.d.ts +0 -20
- package/dist/shared/oracle-service/src/utils/general.js +0 -65
- package/dist/shared/oracle-service/src/utils/index.d.ts +0 -1
- package/dist/shared/oracle-service/src/utils/index.js +0 -17
- package/dist/shared/perena-helpers/src/accounts.d.ts +0 -7
- package/dist/shared/perena-helpers/src/accounts.js +0 -12
- package/dist/shared/perena-helpers/src/client.d.ts +0 -299
- package/dist/shared/perena-helpers/src/client.js +0 -680
- package/dist/shared/perena-helpers/src/constants.d.ts +0 -5
- package/dist/shared/perena-helpers/src/constants.js +0 -8
- package/dist/shared/perena-helpers/src/cpi/burn.d.ts +0 -27
- package/dist/shared/perena-helpers/src/cpi/burn.js +0 -22
- package/dist/shared/perena-helpers/src/cpi/index.d.ts +0 -3
- package/dist/shared/perena-helpers/src/cpi/index.js +0 -19
- package/dist/shared/perena-helpers/src/cpi/mint.d.ts +0 -27
- package/dist/shared/perena-helpers/src/cpi/mint.js +0 -22
- package/dist/shared/perena-helpers/src/cpi/requestUnstake.d.ts +0 -19
- package/dist/shared/perena-helpers/src/cpi/requestUnstake.js +0 -16
- package/dist/shared/perena-helpers/src/index.d.ts +0 -5
- package/dist/shared/perena-helpers/src/index.js +0 -21
- package/dist/shared/perena-helpers/src/utils.d.ts +0 -9
- package/dist/shared/perena-helpers/src/utils.js +0 -54
- package/dist/shared/swap-aggregator/src/aggSwapClient.d.ts +0 -71
- package/dist/shared/swap-aggregator/src/aggSwapClient.js +0 -103
- package/dist/shared/swap-aggregator/src/index.d.ts +0 -1
- package/dist/shared/swap-aggregator/src/index.js +0 -17
- package/docs/launchingToken.md +0 -57
- package/scripts/asyncBurn.ts +0 -155
- package/scripts/burnToken.ts +0 -120
- package/scripts/claimIncentives.ts +0 -125
- package/scripts/closeCpiPlans.ts +0 -113
- package/scripts/collectInterest.ts +0 -194
- package/scripts/collectProtocolFees.ts +0 -144
- package/scripts/computeOptimalAllocations.ts +0 -117
- package/scripts/createToken.ts +0 -100
- package/scripts/createTokenLendingPosition.ts +0 -204
- package/scripts/createYieldingBank.ts +0 -91
- package/scripts/decreaseCarryPositions.ts +0 -359
- package/scripts/depositUnlentCollateral.ts +0 -106
- package/scripts/emergency/deleverageAll.ts +0 -287
- package/scripts/emergency/triggerCircuitBreaker.ts +0 -87
- package/scripts/env.ts +0 -4
- package/scripts/findTxs.ts +0 -169
- package/scripts/increaseCarryPositions.ts +0 -134
- package/scripts/inspect/format.ts +0 -576
- package/scripts/inspect.ts +0 -147
- package/scripts/localUtils.ts +0 -249
- package/scripts/mintToken.ts +0 -126
- package/scripts/processAsyncBurns.ts +0 -89
- package/scripts/rebalanceToken.ts +0 -269
- package/scripts/rebalanceYieldingBank.ts +0 -183
- package/scripts/recollateralizeLoss.ts +0 -79
- package/scripts/refresh.ts +0 -156
- package/scripts/updateFees.ts +0 -486
- package/scripts/updateGeneralLut.ts +0 -36
- package/scripts/updateLendingPositionConfig.ts +0 -172
- package/scripts/updateTokenLuts.ts +0 -36
- package/scripts/updateTokenMetadata.ts +0 -199
- package/scripts/updateYieldingBankConfig.ts +0 -100
- package/scripts/withdrawUnlentCollateral.ts +0 -178
- package/src/client/account.ts +0 -503
- package/src/client/builders/args.ts +0 -381
- package/src/client/builders/asyncBurnBuilder.ts +0 -305
- package/src/client/builders/base.ts +0 -303
- package/src/client/builders/burnTokenBuilder.ts +0 -258
- package/src/client/builders/claimIncentivesBuilder.ts +0 -211
- package/src/client/builders/collectFeesBuilder.ts +0 -52
- package/src/client/builders/collectInterestBuilder.ts +0 -165
- package/src/client/builders/createCpiPlanBuilder.ts +0 -21
- package/src/client/builders/createTokenBuilder.ts +0 -73
- package/src/client/builders/createTokenLendingPositionBuilder.ts +0 -219
- package/src/client/builders/createYieldingBankAllocationBuilder.ts +0 -32
- package/src/client/builders/createYieldingBankBuilder.ts +0 -39
- package/src/client/builders/decreaseCarryPositionBuilder.ts +0 -162
- package/src/client/builders/depositUnlentCollateralBuilder.ts +0 -95
- package/src/client/builders/increaseCarryPositionBuilder.ts +0 -105
- package/src/client/builders/index.ts +0 -37
- package/src/client/builders/mintTokenBuilder.ts +0 -137
- package/src/client/builders/rebalanceTokenBuilder.ts +0 -356
- package/src/client/builders/rebalanceYieldingBankBuilder.ts +0 -109
- package/src/client/builders/recollateralizeLossBuilder.ts +0 -367
- package/src/client/builders/refreshTokenStateBuilder.ts +0 -153
- package/src/client/builders/refreshTokensBuilder.ts +0 -82
- package/src/client/builders/refreshYieldingBankBuilder.ts +0 -42
- package/src/client/builders/resetTokenBurnRateLimitBuilder.ts +0 -21
- package/src/client/builders/setTokenCircuitBreakerBuilder.ts +0 -40
- package/src/client/builders/setYieldingBankCircuitBreakerBuilder.ts +0 -37
- package/src/client/builders/updateLendingPositionConfigBuilder.ts +0 -33
- package/src/client/builders/updateTokenConfigurationBuilder.ts +0 -50
- package/src/client/builders/updateTokenMetadataBuilder.ts +0 -24
- package/src/client/builders/updateYieldingBankConfigBuilder.ts +0 -32
- package/src/client/builders/utils.ts +0 -26
- package/src/client/client.ts +0 -264
- package/src/client/externalLiquidityResolver.ts +0 -54
- package/src/client/index.ts +0 -20
- package/src/client/lendingPlatformClients.ts +0 -50
- package/src/client/pda.ts +0 -102
- package/src/client/plans/collectInterest.ts +0 -207
- package/src/client/plans/decreaseCarryPosition.ts +0 -226
- package/src/client/routes/collectInterest.ts +0 -56
- package/src/client/transaction.ts +0 -106
- package/src/client/types/builders.ts +0 -19
- package/src/client/types/enums.ts +0 -47
- package/src/client/types/general.ts +0 -117
- package/src/client/types/index.ts +0 -6
- package/src/client/types/ix.ts +0 -452
- package/src/client/types/planTypes/collectInterest.ts +0 -97
- package/src/client/types/planTypes/common.ts +0 -31
- package/src/client/types/planTypes/decreaseCarryPosition.ts +0 -134
- package/src/client/types/planTypes/index.ts +0 -3
- package/src/client/types/tx.ts +0 -409
- package/src/constants/configs/allocations.ts +0 -30
- package/src/constants/configs/carryTradePresets.ts +0 -164
- package/src/constants/configs/index.ts +0 -2
- package/src/constants/general.ts +0 -141
- package/src/constants/index.ts +0 -3
- package/src/constants/lycTokenMetadata.ts +0 -52
- package/src/decoders/decodeTransaction.ts +0 -319
- package/src/decoders/discriminators.ts +0 -10
- package/src/decoders/idlAccounts.ts +0 -75
- package/src/decoders/index.ts +0 -15
- package/src/decoders/innerCpis.ts +0 -262
- package/src/decoders/lycInstructionNames.ts +0 -73
- package/src/decoders/programIds.ts +0 -12
- package/src/decoders/solana.ts +0 -25
- package/src/decoders/transactionPayload.ts +0 -41
- package/src/decoders/types.ts +0 -60
- package/src/errors.ts +0 -195
- package/src/idl/long_yield_carry.ts +0 -14648
- package/src/index.ts +0 -10
- package/src/metrics/index.ts +0 -1
- package/src/metrics/protocolMetrics.ts +0 -976
- package/src/models/index.ts +0 -9
- package/src/models/lycToken.ts +0 -380
- package/src/models/yieldingBank.ts +0 -127
- package/src/services/allocation/allocationService.ts +0 -823
- package/src/services/allocation/index.ts +0 -2
- package/src/services/allocation/types.ts +0 -27
- package/src/services/carry/carryAllocationConfig.ts +0 -266
- package/src/services/carry/index.ts +0 -2
- package/src/services/carry/lycLendingPositionManager.ts +0 -167
- package/src/services/index.ts +0 -5
- package/src/services/lendingPosition/index.ts +0 -5
- package/src/services/lendingPosition/lendingPositionService.ts +0 -328
- package/src/services/rebalance/index.ts +0 -2
- package/src/services/rebalance/token/index.ts +0 -1
- package/src/services/rebalance/token/tokenRebalanceService.ts +0 -142
- package/src/services/rebalance/yieldingBank/index.ts +0 -3
- package/src/services/rebalance/yieldingBank/planner.ts +0 -215
- package/src/services/rebalance/yieldingBank/strategy.ts +0 -41
- package/src/services/rebalance/yieldingBank/types.ts +0 -41
- package/src/services/redemption/index.ts +0 -9
- package/src/services/redemption/redemptionService.ts +0 -758
- package/src/types/enriched.ts +0 -187
- package/src/types/index.ts +0 -1
- package/src/utils/cache.ts +0 -12
- package/src/utils/data.ts +0 -65
- package/src/utils/enrichment.ts +0 -330
- package/src/utils/feeDripMetrics.ts +0 -146
- package/src/utils/general.ts +0 -54
- package/src/utils/index.ts +0 -13
- package/src/utils/ix.ts +0 -227
- package/src/utils/lendingPosition.ts +0 -221
- package/src/utils/lookupTables.ts +0 -309
- package/src/utils/lycData.ts +0 -321
- package/src/utils/timelock.ts +0 -63
- package/src/utils/tokenFeeMath.ts +0 -25
- package/src/utils/transactions.ts +0 -109
- package/src/utils/yieldingBank.ts +0 -38
- package/tsconfig.json +0 -11
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { RewardInfo } from "@kamino-finance/farms-sdk";
|
|
2
|
-
import { BN } from "@anchor-lang/core";
|
|
3
|
-
import { LendingMarket } from "@kamino-finance/klend-sdk";
|
|
4
|
-
import { Address } from "@solana/kit";
|
|
5
|
-
import { KaminoReserveData } from "../data";
|
|
6
|
-
import { KaminoExtraFarmData } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* Fetches extra farm configurations from Kamino's CDN.
|
|
9
|
-
*/
|
|
10
|
-
export declare function fetchExtraFarms(): Promise<KaminoExtraFarmData[]>;
|
|
11
|
-
/**
|
|
12
|
-
* Fetches all Kamino lending markets from on-chain program accounts.
|
|
13
|
-
* @returns Array of market objects with address, name, and decoded state
|
|
14
|
-
*/
|
|
15
|
-
export declare function getAllKaminoMarkets(rpcUrl: string): Promise<{
|
|
16
|
-
address: Address;
|
|
17
|
-
name: string;
|
|
18
|
-
state: LendingMarket;
|
|
19
|
-
}[]>;
|
|
20
|
-
/**
|
|
21
|
-
* Calculates the APY for a farm reward based on current reward emissions and total staked amount.
|
|
22
|
-
* Converts daily reward rate to annualized percentage yield using compound interest formula.
|
|
23
|
-
*
|
|
24
|
-
* @param reserveMint - The mint address of the reserve's underlying token
|
|
25
|
-
* @param rewardInfo - Farm reward configuration containing emission rate and token info
|
|
26
|
-
* @param totalStakedRaw - Total amount staked in the farm (raw units as string)
|
|
27
|
-
* @param stakedTokenDecimals - Decimal places for the staked token
|
|
28
|
-
* @param exchangeRate - Exchange rate between staked shares and underlying tokens
|
|
29
|
-
* @param rewardMintPrice - USD price of the reward token (used for non-stablecoin rewards)
|
|
30
|
-
* @param requiresPairReserve - If the Kamino incentive requires a pair reserve in order to be eligible
|
|
31
|
-
* @returns Annualized percentage yield as a decimal (e.g., 0.05 = 5% APY)
|
|
32
|
-
*/
|
|
33
|
-
export declare function calculateRewardAPY(reserveMint: Address, rewardInfo: RewardInfo, totalStakedRaw: string, stakedTokenDecimals: number, exchangeRate: number, rewardMintPrice: number, requiresPairReserve: boolean): number;
|
|
34
|
-
/**
|
|
35
|
-
* Converts a liquidity (underlying token) amount to collateral (cToken) amount
|
|
36
|
-
* using the reserve's estimated exchange rate.
|
|
37
|
-
*
|
|
38
|
-
* Kamino's withdraw V2 instruction expects the amount in cTokens, so this
|
|
39
|
-
* conversion is needed when the caller specifies a liquidity amount to withdraw.
|
|
40
|
-
*
|
|
41
|
-
* @param reserveData - The reserve to use for the exchange rate
|
|
42
|
-
* @param liquidityBaseUnits - Amount in liquidity base units (e.g., USDC smallest unit)
|
|
43
|
-
* @returns Amount in collateral base units (cTokens), floored to avoid overdrawing
|
|
44
|
-
*/
|
|
45
|
-
export declare function liquidityToCollateral(reserveData: KaminoReserveData, liquidityBaseUnits: number): number;
|
|
46
|
-
/**
|
|
47
|
-
* Converts a collateral (cToken) amount back to liquidity base units using the
|
|
48
|
-
* same estimated exchange rate as Kamino's reserve math.
|
|
49
|
-
*
|
|
50
|
-
* @param reserveData - The reserve to use for the exchange rate
|
|
51
|
-
* @param collateralBaseUnits - Amount in collateral base units (cTokens)
|
|
52
|
-
* @returns Amount in liquidity base units, floored to preserve withdraw safety
|
|
53
|
-
*/
|
|
54
|
-
export declare function collateralToLiquidity(reserveData: KaminoReserveData, collateralBaseUnits: number): number;
|
|
55
|
-
/**
|
|
56
|
-
* Normalizes a requested liquidity withdraw amount to the actual liquidity that
|
|
57
|
-
* Kamino can redeem after converting through collateral shares.
|
|
58
|
-
*
|
|
59
|
-
* Kamino withdraws collateral shares, not raw liquidity. Because the liquidity
|
|
60
|
-
* -> collateral conversion floors, a requested liquidity amount may redeem
|
|
61
|
-
* slightly less liquidity in practice. Round-tripping through collateral shares
|
|
62
|
-
* lets callers pre-snap to the realizable liquidity amount.
|
|
63
|
-
*
|
|
64
|
-
* @param reserveData - Source reserve used for the withdraw
|
|
65
|
-
* @param liquidityBaseUnits - Requested liquidity amount in base units
|
|
66
|
-
* @returns Realizable liquidity amount after liquidity -> collateral -> liquidity
|
|
67
|
-
*/
|
|
68
|
-
export declare function normalizeLiquidityWithdrawAmount(reserveData: KaminoReserveData, liquidityBaseUnits: BN | number): BN;
|
|
69
|
-
/**
|
|
70
|
-
* Smallest liquidity (underlying) base-unit withdraw request such that, after Kamino's
|
|
71
|
-
* liquidity→collateral→liquidity rounding ({@link normalizeLiquidityWithdrawAmount}),
|
|
72
|
-
* the **realized** liquidity is still at least `minLiquidityOut`.
|
|
73
|
-
*
|
|
74
|
-
* Used for `burn_token` withdraw CPI sizing: the on-chain program credits `unlent_amount`
|
|
75
|
-
* from the actual token balance delta; if the requested withdraw floors below the burn's
|
|
76
|
-
* `collateral_to_user`, the instruction fails with `InsufficientUnlentCollateral`.
|
|
77
|
-
*/
|
|
78
|
-
export declare function minLiquidityWithdrawForPayout(reserveData: KaminoReserveData, minLiquidityOut: BN): BN;
|
|
79
|
-
/**
|
|
80
|
-
* Normalizes a requested UI liquidity withdraw amount to the realizable UI
|
|
81
|
-
* liquidity amount after Kamino rounds through collateral shares.
|
|
82
|
-
*
|
|
83
|
-
* @param reserveData - Source reserve used for the withdraw
|
|
84
|
-
* @param uiAmount - Requested liquidity amount in UI units
|
|
85
|
-
* @returns Realizable liquidity amount in UI units
|
|
86
|
-
*/
|
|
87
|
-
export declare function normalizeLiquidityWithdrawUiAmount(reserveData: KaminoReserveData, uiAmount: number): number;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchExtraFarms = fetchExtraFarms;
|
|
7
|
-
exports.getAllKaminoMarkets = getAllKaminoMarkets;
|
|
8
|
-
exports.calculateRewardAPY = calculateRewardAPY;
|
|
9
|
-
exports.liquidityToCollateral = liquidityToCollateral;
|
|
10
|
-
exports.collateralToLiquidity = collateralToLiquidity;
|
|
11
|
-
exports.normalizeLiquidityWithdrawAmount = normalizeLiquidityWithdrawAmount;
|
|
12
|
-
exports.minLiquidityWithdrawForPayout = minLiquidityWithdrawForPayout;
|
|
13
|
-
exports.normalizeLiquidityWithdrawUiAmount = normalizeLiquidityWithdrawUiAmount;
|
|
14
|
-
const farms_sdk_1 = require("@kamino-finance/farms-sdk");
|
|
15
|
-
const core_1 = require("@anchor-lang/core");
|
|
16
|
-
const klend_sdk_1 = require("@kamino-finance/klend-sdk");
|
|
17
|
-
const common_1 = require("common");
|
|
18
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
19
|
-
/**
|
|
20
|
-
* Fetches extra farm configurations from Kamino's CDN.
|
|
21
|
-
*/
|
|
22
|
-
async function fetchExtraFarms() {
|
|
23
|
-
const cdnRes = await (0, common_1.fetchWithRetry)("https://cdn.kamino.finance/resources.json");
|
|
24
|
-
const allResources = (await cdnRes.json());
|
|
25
|
-
return allResources["mainnet-beta"]["extraFarms"];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Fetches all Kamino lending markets from on-chain program accounts.
|
|
29
|
-
* @returns Array of market objects with address, name, and decoded state
|
|
30
|
-
*/
|
|
31
|
-
async function getAllKaminoMarkets(rpcUrl) {
|
|
32
|
-
const rpc = (0, common_1.createRpcWithRetry)(rpcUrl);
|
|
33
|
-
const accounts = await rpc
|
|
34
|
-
.getProgramAccounts(klend_sdk_1.PROGRAM_ID, {
|
|
35
|
-
filters: [
|
|
36
|
-
{
|
|
37
|
-
dataSize: BigInt(klend_sdk_1.LendingMarket.layout.span + 8), // +8 for discriminator
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
encoding: "base64",
|
|
41
|
-
})
|
|
42
|
-
.send();
|
|
43
|
-
return accounts.map((account) => {
|
|
44
|
-
const market = klend_sdk_1.LendingMarket.decode(Buffer.from(account.account.data[0], "base64"));
|
|
45
|
-
const name = Buffer.from(market.name).toString("utf8").replace(/\0/g, "");
|
|
46
|
-
return {
|
|
47
|
-
address: account.pubkey,
|
|
48
|
-
name,
|
|
49
|
-
state: market,
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Calculates the APY for a farm reward based on current reward emissions and total staked amount.
|
|
55
|
-
* Converts daily reward rate to annualized percentage yield using compound interest formula.
|
|
56
|
-
*
|
|
57
|
-
* @param reserveMint - The mint address of the reserve's underlying token
|
|
58
|
-
* @param rewardInfo - Farm reward configuration containing emission rate and token info
|
|
59
|
-
* @param totalStakedRaw - Total amount staked in the farm (raw units as string)
|
|
60
|
-
* @param stakedTokenDecimals - Decimal places for the staked token
|
|
61
|
-
* @param exchangeRate - Exchange rate between staked shares and underlying tokens
|
|
62
|
-
* @param rewardMintPrice - USD price of the reward token (used for non-stablecoin rewards)
|
|
63
|
-
* @param requiresPairReserve - If the Kamino incentive requires a pair reserve in order to be eligible
|
|
64
|
-
* @returns Annualized percentage yield as a decimal (e.g., 0.05 = 5% APY)
|
|
65
|
-
*/
|
|
66
|
-
function calculateRewardAPY(reserveMint, rewardInfo, totalStakedRaw, stakedTokenDecimals, exchangeRate, rewardMintPrice, requiresPairReserve) {
|
|
67
|
-
let totalStaked = new decimal_js_1.default((0, common_1.toUiAmount)(BigInt(totalStakedRaw), stakedTokenDecimals));
|
|
68
|
-
if (!requiresPairReserve) {
|
|
69
|
-
totalStaked = totalStaked.div(exchangeRate);
|
|
70
|
-
}
|
|
71
|
-
if (totalStaked.isZero())
|
|
72
|
-
return 0;
|
|
73
|
-
const rewardPerTokenPerSecond = (0, farms_sdk_1.calculateCurrentRewardPerToken)(rewardInfo, new decimal_js_1.default((0, common_1.currentUnixSeconds)()));
|
|
74
|
-
if (!rewardPerTokenPerSecond)
|
|
75
|
-
return 0;
|
|
76
|
-
const divisor = new decimal_js_1.default(10)
|
|
77
|
-
.pow(new decimal_js_1.default(rewardInfo.rewardsPerSecondDecimals.toString()))
|
|
78
|
-
.mul(new decimal_js_1.default(10).pow(new decimal_js_1.default(rewardInfo.token.decimals.toString())));
|
|
79
|
-
const adjustedRewardPerToken = new decimal_js_1.default(rewardPerTokenPerSecond).div(divisor);
|
|
80
|
-
let dailyRewards = adjustedRewardPerToken.mul(farms_sdk_1.SECONDS_IN_A_DAY);
|
|
81
|
-
if (common_1.mints.get(rewardInfo.token.mint)?.assetType !== "Stablecoin" &&
|
|
82
|
-
rewardInfo.token.mint !== reserveMint) {
|
|
83
|
-
dailyRewards = dailyRewards.mul(new decimal_js_1.default(rewardMintPrice));
|
|
84
|
-
}
|
|
85
|
-
const dailyRate = dailyRewards.div(totalStaked);
|
|
86
|
-
const apy = decimal_js_1.default.pow(dailyRate.plus(1), common_1.DAYS_PER_YEAR).minus(1);
|
|
87
|
-
return apy.toNumber();
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Converts a liquidity (underlying token) amount to collateral (cToken) amount
|
|
91
|
-
* using the reserve's estimated exchange rate.
|
|
92
|
-
*
|
|
93
|
-
* Kamino's withdraw V2 instruction expects the amount in cTokens, so this
|
|
94
|
-
* conversion is needed when the caller specifies a liquidity amount to withdraw.
|
|
95
|
-
*
|
|
96
|
-
* @param reserveData - The reserve to use for the exchange rate
|
|
97
|
-
* @param liquidityBaseUnits - Amount in liquidity base units (e.g., USDC smallest unit)
|
|
98
|
-
* @returns Amount in collateral base units (cTokens), floored to avoid overdrawing
|
|
99
|
-
*/
|
|
100
|
-
function liquidityToCollateral(reserveData, liquidityBaseUnits) {
|
|
101
|
-
const exchangeRate = reserveData.rawData
|
|
102
|
-
.getEstimatedCollateralExchangeRate(reserveData.slot, 0)
|
|
103
|
-
.toNumber();
|
|
104
|
-
return Math.floor(liquidityBaseUnits * exchangeRate);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Converts a collateral (cToken) amount back to liquidity base units using the
|
|
108
|
-
* same estimated exchange rate as Kamino's reserve math.
|
|
109
|
-
*
|
|
110
|
-
* @param reserveData - The reserve to use for the exchange rate
|
|
111
|
-
* @param collateralBaseUnits - Amount in collateral base units (cTokens)
|
|
112
|
-
* @returns Amount in liquidity base units, floored to preserve withdraw safety
|
|
113
|
-
*/
|
|
114
|
-
function collateralToLiquidity(reserveData, collateralBaseUnits) {
|
|
115
|
-
const exchangeRate = reserveData.rawData
|
|
116
|
-
.getEstimatedCollateralExchangeRate(reserveData.slot, 0)
|
|
117
|
-
.toNumber();
|
|
118
|
-
return Math.floor(collateralBaseUnits / exchangeRate);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Normalizes a requested liquidity withdraw amount to the actual liquidity that
|
|
122
|
-
* Kamino can redeem after converting through collateral shares.
|
|
123
|
-
*
|
|
124
|
-
* Kamino withdraws collateral shares, not raw liquidity. Because the liquidity
|
|
125
|
-
* -> collateral conversion floors, a requested liquidity amount may redeem
|
|
126
|
-
* slightly less liquidity in practice. Round-tripping through collateral shares
|
|
127
|
-
* lets callers pre-snap to the realizable liquidity amount.
|
|
128
|
-
*
|
|
129
|
-
* @param reserveData - Source reserve used for the withdraw
|
|
130
|
-
* @param liquidityBaseUnits - Requested liquidity amount in base units
|
|
131
|
-
* @returns Realizable liquidity amount after liquidity -> collateral -> liquidity
|
|
132
|
-
*/
|
|
133
|
-
function normalizeLiquidityWithdrawAmount(reserveData, liquidityBaseUnits) {
|
|
134
|
-
const requestedBaseUnits = typeof liquidityBaseUnits === "number" ? liquidityBaseUnits : liquidityBaseUnits.toNumber();
|
|
135
|
-
const collateralBaseUnits = liquidityToCollateral(reserveData, requestedBaseUnits);
|
|
136
|
-
return new core_1.BN(collateralToLiquidity(reserveData, collateralBaseUnits));
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Smallest liquidity (underlying) base-unit withdraw request such that, after Kamino's
|
|
140
|
-
* liquidity→collateral→liquidity rounding ({@link normalizeLiquidityWithdrawAmount}),
|
|
141
|
-
* the **realized** liquidity is still at least `minLiquidityOut`.
|
|
142
|
-
*
|
|
143
|
-
* Used for `burn_token` withdraw CPI sizing: the on-chain program credits `unlent_amount`
|
|
144
|
-
* from the actual token balance delta; if the requested withdraw floors below the burn's
|
|
145
|
-
* `collateral_to_user`, the instruction fails with `InsufficientUnlentCollateral`.
|
|
146
|
-
*/
|
|
147
|
-
function minLiquidityWithdrawForPayout(reserveData, minLiquidityOut) {
|
|
148
|
-
const min = new core_1.BN(minLiquidityOut.toString());
|
|
149
|
-
if (normalizeLiquidityWithdrawAmount(reserveData, min).gte(min)) {
|
|
150
|
-
return min;
|
|
151
|
-
}
|
|
152
|
-
let hi = min.clone();
|
|
153
|
-
let expanded = false;
|
|
154
|
-
for (let i = 0; i < 64; i++) {
|
|
155
|
-
hi = hi.muln(2);
|
|
156
|
-
if (normalizeLiquidityWithdrawAmount(reserveData, hi).gte(min)) {
|
|
157
|
-
expanded = true;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (!expanded) {
|
|
162
|
-
throw new Error(`minLiquidityWithdrawForPayout: could not bracket min out ${minLiquidityOut.toString()}`);
|
|
163
|
-
}
|
|
164
|
-
let loBn = min.clone();
|
|
165
|
-
let hiBn = hi.clone();
|
|
166
|
-
while (loBn.lt(hiBn)) {
|
|
167
|
-
const mid = loBn.add(hiBn).shrn(1);
|
|
168
|
-
const realized = normalizeLiquidityWithdrawAmount(reserveData, mid);
|
|
169
|
-
if (realized.gte(min)) {
|
|
170
|
-
hiBn = mid;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
loBn = mid.addn(1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return loBn;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Normalizes a requested UI liquidity withdraw amount to the realizable UI
|
|
180
|
-
* liquidity amount after Kamino rounds through collateral shares.
|
|
181
|
-
*
|
|
182
|
-
* @param reserveData - Source reserve used for the withdraw
|
|
183
|
-
* @param uiAmount - Requested liquidity amount in UI units
|
|
184
|
-
* @returns Realizable liquidity amount in UI units
|
|
185
|
-
*/
|
|
186
|
-
function normalizeLiquidityWithdrawUiAmount(reserveData, uiAmount) {
|
|
187
|
-
const requestedBaseUnits = (0, common_1.fromUiAmount)(uiAmount, reserveData.mint.mintDecimals);
|
|
188
|
-
const normalizedBaseUnits = normalizeLiquidityWithdrawAmount(reserveData, requestedBaseUnits);
|
|
189
|
-
return (0, common_1.toUiAmount)(normalizedBaseUnits, reserveData.mint.mintDecimals);
|
|
190
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LendingPlatform } from "../types";
|
|
2
|
-
import { KaminoClient } from "../services";
|
|
3
|
-
/**
|
|
4
|
-
* Get a lending platform client. Markets are loaded lazily on first use.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getLpClient(lendingPlatform: LendingPlatform, rpcUrl: string, rpcUrls?: string[]): KaminoClient;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLpClient = getLpClient;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
const services_1 = require("../services");
|
|
6
|
-
/**
|
|
7
|
-
* Get a lending platform client. Markets are loaded lazily on first use.
|
|
8
|
-
*/
|
|
9
|
-
function getLpClient(lendingPlatform, rpcUrl, rpcUrls = [rpcUrl]) {
|
|
10
|
-
if (lendingPlatform === types_1.LendingPlatform.Kamino) {
|
|
11
|
-
return new services_1.KaminoClient(rpcUrl, rpcUrls);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
throw new Error("Lending platform not yet supported");
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LTV utilization math (same definition as `ReservesManager.calcLtvUtilizationRateBps` /
|
|
3
|
-
* Kamino `borrowedValueUsd / borrowLimit`):
|
|
4
|
-
*
|
|
5
|
-
* ```
|
|
6
|
-
* ltvUtilization = debtUsd / (collateralUsd × maxLtv)
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* **Assumptions:** debt USD fixed; only collateral USD moves. Liquidation uses a one-collateral sketch
|
|
10
|
-
* (`debt ≤ collateral × liquidationThreshold`). Real obligations are multi-asset.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* If collateral drops X% (positive `drawdownPercent`), what **current** LTV utilization (decimal) stays
|
|
14
|
-
* within the constraint? With `liquidationThreshold`, caps so that after the drop the sketch stays solvent:
|
|
15
|
-
* `target ≤ (1 − drawdown/100) × liquidationThreshold / maxLtv`.
|
|
16
|
-
*
|
|
17
|
-
* Without `liquidationThreshold`, caps so post-drop utilization ≤ `targetMaxBorrowUtilizationAfter` (default 1).
|
|
18
|
-
*/
|
|
19
|
-
export declare function maxLtvUtilBeforeCollDrawdown(params: {
|
|
20
|
-
drawdownPercent: number;
|
|
21
|
-
ltv: number;
|
|
22
|
-
targetMaxBorrowUtilizationAfter?: number;
|
|
23
|
-
liquidationThreshold?: number;
|
|
24
|
-
}): number;
|
|
25
|
-
/**
|
|
26
|
-
* LTV utilization after collateral **USD** moves by `collateralPricePctChg`, with debt USD unchanged.
|
|
27
|
-
*
|
|
28
|
-
* `collateralPricePctChg`: signed percent on collateral price, e.g. `10` = +10% rally, `-30` = −30% crash.
|
|
29
|
-
* Formula: `newUtil = currentUtil / (1 + collateralPricePctChg/100)`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function ltvUtilAfterCollateralPricePctChg(currentLtvUtilization: number, collateralPricePctChg: number): number;
|
|
32
|
-
/**
|
|
33
|
-
* If you sit at **target** utilization and collateral **rallies** `rallyPercentPositive` (e.g. `25` = +25%),
|
|
34
|
-
* utilization falls. This returns how far **below** target it lands — the width of `maxDeviationBelowTarget`
|
|
35
|
-
* that lines up with that rally for carry-style triggers.
|
|
36
|
-
*
|
|
37
|
-
* Equivalent to: `target − ltvUtilAfterCollateralPricePctChg(target, rallyPercentPositive)`.
|
|
38
|
-
*/
|
|
39
|
-
export declare function ltvUtilDeltaBelowTargForRallyPct(targetLtvUtilization: number, rallyPercentPositive: number): number;
|
|
40
|
-
/**
|
|
41
|
-
* If you sit at **target** utilization and collateral **falls** `dropPercentPositive` (e.g. `20` = −20%),
|
|
42
|
-
* utilization rises. This returns how far **above** target it lands — the width of `maxDeviationAboveTarget`
|
|
43
|
-
* that lines up with that drop for carry-style triggers.
|
|
44
|
-
*
|
|
45
|
-
* Equivalent to: `ltvUtilAfterCollateralPricePctChg(target, -dropPercentPositive) − target`.
|
|
46
|
-
*/
|
|
47
|
-
export declare function ltvUtilDeltaAboveTargForDropPct(targetLtvUtilization: number, dropPercentPositive: number): number;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* LTV utilization math (same definition as `ReservesManager.calcLtvUtilizationRateBps` /
|
|
4
|
-
* Kamino `borrowedValueUsd / borrowLimit`):
|
|
5
|
-
*
|
|
6
|
-
* ```
|
|
7
|
-
* ltvUtilization = debtUsd / (collateralUsd × maxLtv)
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* **Assumptions:** debt USD fixed; only collateral USD moves. Liquidation uses a one-collateral sketch
|
|
11
|
-
* (`debt ≤ collateral × liquidationThreshold`). Real obligations are multi-asset.
|
|
12
|
-
*/
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.maxLtvUtilBeforeCollDrawdown = maxLtvUtilBeforeCollDrawdown;
|
|
15
|
-
exports.ltvUtilAfterCollateralPricePctChg = ltvUtilAfterCollateralPricePctChg;
|
|
16
|
-
exports.ltvUtilDeltaBelowTargForRallyPct = ltvUtilDeltaBelowTargForRallyPct;
|
|
17
|
-
exports.ltvUtilDeltaAboveTargForDropPct = ltvUtilDeltaAboveTargForDropPct;
|
|
18
|
-
function clampUnitInterval(x) {
|
|
19
|
-
if (x <= 0)
|
|
20
|
-
return 0;
|
|
21
|
-
if (x >= 1)
|
|
22
|
-
return 1;
|
|
23
|
-
return x;
|
|
24
|
-
}
|
|
25
|
-
function assertLtv(ltv) {
|
|
26
|
-
if (!(ltv > 0) || ltv > 1) {
|
|
27
|
-
throw new RangeError("ltv must be in (0, 1] (e.g. 0.8 for 80% max LTV)");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function assertLiquidationThreshold(t) {
|
|
31
|
-
if (!(t > 0) || t > 1) {
|
|
32
|
-
throw new RangeError("liquidationThreshold must be in (0, 1] (e.g. 0.85)");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function maxLtvUtilBeforeCollUsdMultiplierInternal(params) {
|
|
36
|
-
const { collateralUsdMultiplier: mult, ltv, liquidationThreshold, targetMaxBorrowUtilizationAfter = 1, } = params;
|
|
37
|
-
assertLtv(ltv);
|
|
38
|
-
if (!(mult > 0)) {
|
|
39
|
-
throw new RangeError("collateralUsdMultiplier must be positive");
|
|
40
|
-
}
|
|
41
|
-
if (liquidationThreshold !== undefined) {
|
|
42
|
-
assertLiquidationThreshold(liquidationThreshold);
|
|
43
|
-
return clampUnitInterval((mult * liquidationThreshold) / ltv);
|
|
44
|
-
}
|
|
45
|
-
if (!(targetMaxBorrowUtilizationAfter > 0) || targetMaxBorrowUtilizationAfter > 1) {
|
|
46
|
-
throw new RangeError("targetMaxBorrowUtilizationAfter must be in (0, 1] (1 = 100% of borrow limit)");
|
|
47
|
-
}
|
|
48
|
-
return clampUnitInterval(mult * targetMaxBorrowUtilizationAfter);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* If collateral drops X% (positive `drawdownPercent`), what **current** LTV utilization (decimal) stays
|
|
52
|
-
* within the constraint? With `liquidationThreshold`, caps so that after the drop the sketch stays solvent:
|
|
53
|
-
* `target ≤ (1 − drawdown/100) × liquidationThreshold / maxLtv`.
|
|
54
|
-
*
|
|
55
|
-
* Without `liquidationThreshold`, caps so post-drop utilization ≤ `targetMaxBorrowUtilizationAfter` (default 1).
|
|
56
|
-
*/
|
|
57
|
-
function maxLtvUtilBeforeCollDrawdown(params) {
|
|
58
|
-
if (!(params.drawdownPercent >= 0)) {
|
|
59
|
-
throw new RangeError("drawdownPercent must be non-negative (e.g. 30 for a 30% drop)");
|
|
60
|
-
}
|
|
61
|
-
const collateralUsdMultiplier = 1 - params.drawdownPercent / 100;
|
|
62
|
-
if (!(collateralUsdMultiplier > 0)) {
|
|
63
|
-
throw new RangeError("drawdownPercent must be less than 100 so collateral USD remains positive");
|
|
64
|
-
}
|
|
65
|
-
return maxLtvUtilBeforeCollUsdMultiplierInternal({
|
|
66
|
-
collateralUsdMultiplier,
|
|
67
|
-
ltv: params.ltv,
|
|
68
|
-
targetMaxBorrowUtilizationAfter: params.targetMaxBorrowUtilizationAfter,
|
|
69
|
-
liquidationThreshold: params.liquidationThreshold,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* LTV utilization after collateral **USD** moves by `collateralPricePctChg`, with debt USD unchanged.
|
|
74
|
-
*
|
|
75
|
-
* `collateralPricePctChg`: signed percent on collateral price, e.g. `10` = +10% rally, `-30` = −30% crash.
|
|
76
|
-
* Formula: `newUtil = currentUtil / (1 + collateralPricePctChg/100)`.
|
|
77
|
-
*/
|
|
78
|
-
function ltvUtilAfterCollateralPricePctChg(currentLtvUtilization, collateralPricePctChg) {
|
|
79
|
-
if (!(currentLtvUtilization >= 0) || currentLtvUtilization > 1) {
|
|
80
|
-
throw new RangeError("currentLtvUtilization must be in [0, 1]");
|
|
81
|
-
}
|
|
82
|
-
const mult = 1 + collateralPricePctChg / 100;
|
|
83
|
-
if (!(mult > 0)) {
|
|
84
|
-
throw new RangeError("collateralPricePctChg must be greater than -100 so collateral USD stays positive");
|
|
85
|
-
}
|
|
86
|
-
return currentLtvUtilization / mult;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* If you sit at **target** utilization and collateral **rallies** `rallyPercentPositive` (e.g. `25` = +25%),
|
|
90
|
-
* utilization falls. This returns how far **below** target it lands — the width of `maxDeviationBelowTarget`
|
|
91
|
-
* that lines up with that rally for carry-style triggers.
|
|
92
|
-
*
|
|
93
|
-
* Equivalent to: `target − ltvUtilAfterCollateralPricePctChg(target, rallyPercentPositive)`.
|
|
94
|
-
*/
|
|
95
|
-
function ltvUtilDeltaBelowTargForRallyPct(targetLtvUtilization, rallyPercentPositive) {
|
|
96
|
-
if (!(targetLtvUtilization > 0) || targetLtvUtilization > 1) {
|
|
97
|
-
throw new RangeError("targetLtvUtilization must be in (0, 1]");
|
|
98
|
-
}
|
|
99
|
-
if (!Number.isFinite(rallyPercentPositive) || rallyPercentPositive <= 0) {
|
|
100
|
-
throw new RangeError("rallyPercentPositive must be finite and positive");
|
|
101
|
-
}
|
|
102
|
-
const after = ltvUtilAfterCollateralPricePctChg(targetLtvUtilization, rallyPercentPositive);
|
|
103
|
-
return targetLtvUtilization - after;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* If you sit at **target** utilization and collateral **falls** `dropPercentPositive` (e.g. `20` = −20%),
|
|
107
|
-
* utilization rises. This returns how far **above** target it lands — the width of `maxDeviationAboveTarget`
|
|
108
|
-
* that lines up with that drop for carry-style triggers.
|
|
109
|
-
*
|
|
110
|
-
* Equivalent to: `ltvUtilAfterCollateralPricePctChg(target, -dropPercentPositive) − target`.
|
|
111
|
-
*/
|
|
112
|
-
function ltvUtilDeltaAboveTargForDropPct(targetLtvUtilization, dropPercentPositive) {
|
|
113
|
-
if (!(targetLtvUtilization > 0) || targetLtvUtilization > 1) {
|
|
114
|
-
throw new RangeError("targetLtvUtilization must be in (0, 1]");
|
|
115
|
-
}
|
|
116
|
-
if (!Number.isFinite(dropPercentPositive) ||
|
|
117
|
-
dropPercentPositive <= 0 ||
|
|
118
|
-
dropPercentPositive >= 100) {
|
|
119
|
-
throw new RangeError("dropPercentPositive must be in (0, 100)");
|
|
120
|
-
}
|
|
121
|
-
const after = ltvUtilAfterCollateralPricePctChg(targetLtvUtilization, -dropPercentPositive);
|
|
122
|
-
return after - targetLtvUtilization;
|
|
123
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { OraclePrices } from "@kamino-finance/scope-sdk/dist/@codegen/scope/accounts";
|
|
2
|
-
import { Address, Rpc, SolanaRpcApi } from "@solana/kit";
|
|
3
|
-
import { KaminoReserveData } from "../data/reserve/kamino";
|
|
4
|
-
type OracleMappings = {
|
|
5
|
-
refPrice: number[];
|
|
6
|
-
priceTypes: number[];
|
|
7
|
-
priceInfoAccounts: Address[];
|
|
8
|
-
generic: number[][];
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Recursively collects a token and all its Scope dependency tokens.
|
|
12
|
-
*
|
|
13
|
-
* Handles three dependency mechanisms:
|
|
14
|
-
* - `refPrice`: ScopeTwap and similar read from a single reference index
|
|
15
|
-
* - `generic` (MostRecentOf): stores up to 4 source token indices as u16 LE
|
|
16
|
-
* - `generic` (CappedFloored): stores sourceEntry, capEntry, floorEntry
|
|
17
|
-
*/
|
|
18
|
-
export declare function collectTokenDependencies(token: number, mappings: OracleMappings, result: Set<number>, depth?: number): void;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if a reserve's Scope price chain has any stale entries by comparing
|
|
21
|
-
* each entry's `unixTimestamp` against the reserve's configured max price age.
|
|
22
|
-
* @param reserveData - The reserve to check
|
|
23
|
-
* @param oraclePrices - The fetched Scope OraclePrices account
|
|
24
|
-
* @param bufferSeconds - Lookahead buffer (same semantics as KaminoReserveData.requiresRefresh)
|
|
25
|
-
*/
|
|
26
|
-
export declare function isScopePriceStale(reserveData: KaminoReserveData, oraclePrices: OraclePrices, bufferSeconds?: number): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the external PythPull / PythPullEMA oracle accounts from the Scope
|
|
29
|
-
* dependency tree for the given Kamino reserves. These are the accounts whose
|
|
30
|
-
* data Scope reads during RefreshPriceList — streaming them on a localnet fork
|
|
31
|
-
* keeps Scope prices fresh.
|
|
32
|
-
*
|
|
33
|
-
* Only Pyth accounts are returned. Switchboard and other oracle types are
|
|
34
|
-
* intentionally excluded because their on-chain data format can produce corrupt
|
|
35
|
-
* values when streamed through Surfpool's account mirroring.
|
|
36
|
-
*/
|
|
37
|
-
export declare function getScopePythAccounts(rpc: Rpc<SolanaRpcApi>, reserves: KaminoReserveData[]): Promise<Address[]>;
|
|
38
|
-
export {};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectTokenDependencies = collectTokenDependencies;
|
|
4
|
-
exports.isScopePriceStale = isScopePriceStale;
|
|
5
|
-
exports.getScopePythAccounts = getScopePythAccounts;
|
|
6
|
-
const scope_sdk_1 = require("@kamino-finance/scope-sdk");
|
|
7
|
-
const common_1 = require("common");
|
|
8
|
-
const ORACLE_TYPE_MOST_RECENT_OF = 28;
|
|
9
|
-
const ORACLE_TYPE_CAPPED_FLOORED = 33;
|
|
10
|
-
const MOST_RECENT_OF_UNUSED = 512;
|
|
11
|
-
/**
|
|
12
|
-
* Recursively collects a token and all its Scope dependency tokens.
|
|
13
|
-
*
|
|
14
|
-
* Handles three dependency mechanisms:
|
|
15
|
-
* - `refPrice`: ScopeTwap and similar read from a single reference index
|
|
16
|
-
* - `generic` (MostRecentOf): stores up to 4 source token indices as u16 LE
|
|
17
|
-
* - `generic` (CappedFloored): stores sourceEntry, capEntry, floorEntry
|
|
18
|
-
*/
|
|
19
|
-
function collectTokenDependencies(token, mappings, result, depth = 0) {
|
|
20
|
-
if (result.has(token) || depth > 5)
|
|
21
|
-
return;
|
|
22
|
-
const isValidDep = (dep) => dep !== undefined &&
|
|
23
|
-
dep !== token &&
|
|
24
|
-
dep < mappings.priceInfoAccounts.length &&
|
|
25
|
-
mappings.priceInfoAccounts[dep] !== common_1.DEFAULT_PUBLIC_KEY;
|
|
26
|
-
const recurse = (dep) => collectTokenDependencies(dep, mappings, result, depth + 1);
|
|
27
|
-
if (mappings.priceTypes[token] === ORACLE_TYPE_MOST_RECENT_OF) {
|
|
28
|
-
const raw = mappings.generic[token];
|
|
29
|
-
if (raw?.length >= 8) {
|
|
30
|
-
for (let i = 0; i < 4; i++) {
|
|
31
|
-
const src = raw[i * 2] | (raw[i * 2 + 1] << 8);
|
|
32
|
-
if (src !== MOST_RECENT_OF_UNUSED && isValidDep(src)) {
|
|
33
|
-
recurse(src);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else if (mappings.priceTypes[token] === ORACLE_TYPE_CAPPED_FLOORED) {
|
|
39
|
-
const raw = mappings.generic[token];
|
|
40
|
-
if (raw?.length >= 7) {
|
|
41
|
-
const sourceEntry = raw[0] | (raw[1] << 8);
|
|
42
|
-
if (isValidDep(sourceEntry))
|
|
43
|
-
recurse(sourceEntry);
|
|
44
|
-
// borsh Option<u16>: 1-byte tag (0=None,1=Some) + u16 value
|
|
45
|
-
if (raw[2] === 1) {
|
|
46
|
-
const capEntry = raw[3] | (raw[4] << 8);
|
|
47
|
-
if (isValidDep(capEntry))
|
|
48
|
-
recurse(capEntry);
|
|
49
|
-
}
|
|
50
|
-
const floorOffset = raw[2] === 1 ? 5 : 3;
|
|
51
|
-
if (raw[floorOffset] === 1) {
|
|
52
|
-
const floorEntry = raw[floorOffset + 1] | (raw[floorOffset + 2] << 8);
|
|
53
|
-
if (isValidDep(floorEntry))
|
|
54
|
-
recurse(floorEntry);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const dep = mappings.refPrice[token];
|
|
59
|
-
if (isValidDep(dep)) {
|
|
60
|
-
recurse(dep);
|
|
61
|
-
}
|
|
62
|
-
result.add(token);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Checks if a reserve's Scope price chain has any stale entries by comparing
|
|
66
|
-
* each entry's `unixTimestamp` against the reserve's configured max price age.
|
|
67
|
-
* @param reserveData - The reserve to check
|
|
68
|
-
* @param oraclePrices - The fetched Scope OraclePrices account
|
|
69
|
-
* @param bufferSeconds - Lookahead buffer (same semantics as KaminoReserveData.requiresRefresh)
|
|
70
|
-
*/
|
|
71
|
-
function isScopePriceStale(reserveData, oraclePrices, bufferSeconds = 10) {
|
|
72
|
-
const SCOPE_CHAIN_END = 65535; // U16_MAX — terminates the price chain
|
|
73
|
-
const tokenInfo = reserveData.rawData.state.config.tokenInfo;
|
|
74
|
-
const { priceChain, twapChain } = tokenInfo.scopeConfiguration;
|
|
75
|
-
const isTwapEnabled = tokenInfo.maxTwapDivergenceBps.toNumber() > 0;
|
|
76
|
-
const now = (0, common_1.currentUnixSeconds)();
|
|
77
|
-
const isChainStale = (chain, maxAge) => {
|
|
78
|
-
for (const index of chain) {
|
|
79
|
-
if (index === SCOPE_CHAIN_END)
|
|
80
|
-
break;
|
|
81
|
-
const datedPrice = oraclePrices.prices[index];
|
|
82
|
-
if (!datedPrice || now - datedPrice.unixTimestamp.toNumber() > maxAge - bufferSeconds) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
};
|
|
88
|
-
const spotMaxAge = tokenInfo.maxAgePriceSeconds.toNumber();
|
|
89
|
-
if (isChainStale(priceChain, spotMaxAge))
|
|
90
|
-
return true;
|
|
91
|
-
if (isTwapEnabled) {
|
|
92
|
-
const twapMaxAge = tokenInfo.maxAgeTwapSeconds.toNumber();
|
|
93
|
-
if (isChainStale(twapChain, twapMaxAge))
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
const ORACLE_TYPE_PYTH_PULL = 21;
|
|
99
|
-
const ORACLE_TYPE_PYTH_PULL_EMA = 22;
|
|
100
|
-
const SCOPE_CHAIN_END = 65535;
|
|
101
|
-
/**
|
|
102
|
-
* Returns the external PythPull / PythPullEMA oracle accounts from the Scope
|
|
103
|
-
* dependency tree for the given Kamino reserves. These are the accounts whose
|
|
104
|
-
* data Scope reads during RefreshPriceList — streaming them on a localnet fork
|
|
105
|
-
* keeps Scope prices fresh.
|
|
106
|
-
*
|
|
107
|
-
* Only Pyth accounts are returned. Switchboard and other oracle types are
|
|
108
|
-
* intentionally excluded because their on-chain data format can produce corrupt
|
|
109
|
-
* values when streamed through Surfpool's account mirroring.
|
|
110
|
-
*/
|
|
111
|
-
async function getScopePythAccounts(rpc, reserves) {
|
|
112
|
-
const scope = new scope_sdk_1.Scope("mainnet-beta", rpc);
|
|
113
|
-
const accounts = new Set();
|
|
114
|
-
for (const reserve of reserves) {
|
|
115
|
-
const scopeFeed = reserve.getOracleAccounts().scope;
|
|
116
|
-
if (!scopeFeed)
|
|
117
|
-
continue;
|
|
118
|
-
const [configAddr] = await scope.getSingleFeedConfiguration({ prices: scopeFeed });
|
|
119
|
-
const mappings = await scope.getOracleMappings({ config: configAddr });
|
|
120
|
-
const { priceChain, twapChain } = reserve.rawData.state.config.tokenInfo.scopeConfiguration;
|
|
121
|
-
const chainTokens = new Set();
|
|
122
|
-
for (const chain of [priceChain, twapChain]) {
|
|
123
|
-
for (const index of chain) {
|
|
124
|
-
if (index === SCOPE_CHAIN_END)
|
|
125
|
-
break;
|
|
126
|
-
chainTokens.add(index);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const allTokens = new Set();
|
|
130
|
-
for (const token of chainTokens) {
|
|
131
|
-
collectTokenDependencies(token, mappings, allTokens);
|
|
132
|
-
}
|
|
133
|
-
for (const token of allTokens) {
|
|
134
|
-
const type = mappings.priceTypes[token];
|
|
135
|
-
if (type === ORACLE_TYPE_PYTH_PULL || type === ORACLE_TYPE_PYTH_PULL_EMA) {
|
|
136
|
-
const account = mappings.priceInfoAccounts[token];
|
|
137
|
-
if (account && account !== common_1.DEFAULT_PUBLIC_KEY) {
|
|
138
|
-
accounts.add(account);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return [...accounts];
|
|
144
|
-
}
|