@exponent-labs/exponent-sdk 0.9.1 → 0.9.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/build/addressLookupTableUtil.d.ts +13 -13
- package/build/addressLookupTableUtil.js +5 -5
- package/build/addressLookupTableUtil.js.map +1 -1
- package/build/client/clmm/accounts/lpPosition.js +5 -6
- package/build/client/clmm/accounts/lpPosition.js.map +1 -1
- package/build/client/clmm/accounts/marketThree.js +5 -6
- package/build/client/clmm/accounts/marketThree.js.map +1 -1
- package/build/client/clmm/accounts/vault.js +5 -6
- package/build/client/clmm/accounts/vault.js.map +1 -1
- package/build/client/clmm/index.d.ts +1 -2
- package/build/client/clmm/instructions/addFarm.js +1 -2
- package/build/client/clmm/instructions/addFarm.js.map +1 -1
- package/build/client/clmm/instructions/addLiquidity.js +1 -2
- package/build/client/clmm/instructions/addLiquidity.js.map +1 -1
- package/build/client/clmm/instructions/addMarketEmission.js +1 -2
- package/build/client/clmm/instructions/addMarketEmission.js.map +1 -1
- package/build/client/clmm/instructions/buyPt.js +1 -2
- package/build/client/clmm/instructions/buyPt.js.map +1 -1
- package/build/client/clmm/instructions/buyYt.js +1 -2
- package/build/client/clmm/instructions/buyYt.js.map +1 -1
- package/build/client/clmm/instructions/claimFarmEmission.js +1 -2
- package/build/client/clmm/instructions/claimFarmEmission.js.map +1 -1
- package/build/client/clmm/instructions/closeMarket.js +1 -2
- package/build/client/clmm/instructions/closeMarket.js.map +1 -1
- package/build/client/clmm/instructions/depositLiquidity.js +1 -2
- package/build/client/clmm/instructions/depositLiquidity.js.map +1 -1
- package/build/client/clmm/instructions/initializeMarket.js +1 -2
- package/build/client/clmm/instructions/initializeMarket.js.map +1 -1
- package/build/client/clmm/instructions/marketAccrueEmission.js +1 -2
- package/build/client/clmm/instructions/marketAccrueEmission.js.map +1 -1
- package/build/client/clmm/instructions/marketCollectEmission.js +1 -2
- package/build/client/clmm/instructions/marketCollectEmission.js.map +1 -1
- package/build/client/clmm/instructions/modifyFarm.js +1 -2
- package/build/client/clmm/instructions/modifyFarm.js.map +1 -1
- package/build/client/clmm/instructions/modifyMarketSetting.js +1 -2
- package/build/client/clmm/instructions/modifyMarketSetting.js.map +1 -1
- package/build/client/clmm/instructions/sellPt.js +1 -2
- package/build/client/clmm/instructions/sellPt.js.map +1 -1
- package/build/client/clmm/instructions/sellYt.js +1 -2
- package/build/client/clmm/instructions/sellYt.js.map +1 -1
- package/build/client/clmm/instructions/tradePt.js +1 -2
- package/build/client/clmm/instructions/tradePt.js.map +1 -1
- package/build/client/clmm/instructions/tradePtExactOut.js +1 -2
- package/build/client/clmm/instructions/tradePtExactOut.js.map +1 -1
- package/build/client/clmm/instructions/withdrawLiquidity.js +1 -2
- package/build/client/clmm/instructions/withdrawLiquidity.js.map +1 -1
- package/build/client/clmm/instructions/wrapperBuyYt.js +1 -2
- package/build/client/clmm/instructions/wrapperBuyYt.js.map +1 -1
- package/build/client/clmm/instructions/wrapperProvideLiquidity.js +1 -2
- package/build/client/clmm/instructions/wrapperProvideLiquidity.js.map +1 -1
- package/build/client/clmm/instructions/wrapperProvideLiquidityBase.js +1 -2
- package/build/client/clmm/instructions/wrapperProvideLiquidityBase.js.map +1 -1
- package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.js +1 -2
- package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.js.map +1 -1
- package/build/client/clmm/instructions/wrapperSellYt.js +1 -2
- package/build/client/clmm/instructions/wrapperSellYt.js.map +1 -1
- package/build/client/clmm/instructions/wrapperWithdrawLiquidity.js +1 -2
- package/build/client/clmm/instructions/wrapperWithdrawLiquidity.js.map +1 -1
- package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.js +1 -2
- package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.js.map +1 -1
- package/build/client/clmm/types/addFarmEvent.d.ts +1 -25
- package/build/client/clmm/types/amount.d.ts +1 -19
- package/build/client/clmm/types/amount.js +3 -3
- package/build/client/clmm/types/amount.js.map +1 -1
- package/build/client/clmm/types/buyPtEvent.d.ts +1 -16
- package/build/client/clmm/types/buyYtEvent.d.ts +1 -40
- package/build/client/clmm/types/claimFarmEmissionsEvent.d.ts +1 -149
- package/build/client/clmm/types/claimLimits.d.ts +1 -16
- package/build/client/clmm/types/closeMarketEvent.d.ts +1 -16
- package/build/client/clmm/types/configurationOptions.d.ts +1 -25
- package/build/client/clmm/types/cpiAccounts.d.ts +1 -99
- package/build/client/clmm/types/cpiCoreAccounts.d.ts +1 -42
- package/build/client/clmm/types/cpiInterfaceContext.d.ts +1 -13
- package/build/client/clmm/types/crossingSplit.d.ts +1 -109
- package/build/client/clmm/types/depositLiquidityEvent.d.ts +1 -149
- package/build/client/clmm/types/depositLiquidityReturnData.d.ts +1 -49
- package/build/client/clmm/types/emissionInfo.d.ts +1 -25
- package/build/client/clmm/types/farmEmission.d.ts +1 -16
- package/build/client/clmm/types/liquidityNetBalanceLimits.d.ts +1 -19
- package/build/client/clmm/types/lpFarm.d.ts +1 -30
- package/build/client/clmm/types/marketAccrueEmissionEvent.d.ts +1 -134
- package/build/client/clmm/types/marketAdminAction.d.ts +1 -306
- package/build/client/clmm/types/marketAdminAction.js +3 -3
- package/build/client/clmm/types/marketAdminAction.js.map +1 -1
- package/build/client/clmm/types/marketCollectEmissionEvent.d.ts +1 -143
- package/build/client/clmm/types/marketEmission.d.ts +1 -13
- package/build/client/clmm/types/marketEmissions.d.ts +1 -23
- package/build/client/clmm/types/marketFinancials.d.ts +1 -19
- package/build/client/clmm/types/marketThreeInitEvent.d.ts +1 -52
- package/build/client/clmm/types/mergeEvent.d.ts +1 -61
- package/build/client/clmm/types/modifiedTick.d.ts +1 -13
- package/build/client/clmm/types/modifiedTicks.d.ts +1 -35
- package/build/client/clmm/types/modifyFarmEvent.d.ts +1 -31
- package/build/client/clmm/types/number.d.ts +1 -1
- package/build/client/clmm/types/personalYieldTracker.d.ts +1 -10
- package/build/client/clmm/types/personalYieldTrackers.d.ts +1 -19
- package/build/client/clmm/types/principalShare.d.ts +1 -42
- package/build/client/clmm/types/principalShareTrackers.d.ts +1 -59
- package/build/client/clmm/types/sellPtEvent.d.ts +1 -16
- package/build/client/clmm/types/sellYtEvent.d.ts +1 -34
- package/build/client/clmm/types/stripEvent.d.ts +1 -61
- package/build/client/clmm/types/swapDirection.d.ts +1 -1
- package/build/client/clmm/types/tradePtEvent.d.ts +1 -90
- package/build/client/clmm/types/withdrawLiquidityEvent.d.ts +1 -158
- package/build/client/clmm/types/withdrawLiquidityReturnData.d.ts +1 -34
- package/build/client/clmm/types/wrapperBuyYtEvent.d.ts +1 -16
- package/build/client/clmm/types/wrapperProvideLiquidityBaseEvent.d.ts +1 -40
- package/build/client/clmm/types/wrapperProvideLiquidityClassicEvent.d.ts +1 -37
- package/build/client/clmm/types/wrapperProvideLiquidityEvent.d.ts +1 -40
- package/build/client/clmm/types/wrapperSellYtEvent.d.ts +1 -16
- package/build/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.d.ts +1 -43
- package/build/client/clmm/types/wrapperWithdrawLiquidityEvent.d.ts +1 -43
- package/build/client/core/accounts/admin.js +5 -6
- package/build/client/core/accounts/admin.js.map +1 -1
- package/build/client/core/accounts/lpPosition.js +5 -6
- package/build/client/core/accounts/lpPosition.js.map +1 -1
- package/build/client/core/accounts/marketTwo.js +5 -6
- package/build/client/core/accounts/marketTwo.js.map +1 -1
- package/build/client/core/accounts/vault.js +5 -6
- package/build/client/core/accounts/vault.js.map +1 -1
- package/build/client/core/accounts/yieldTokenPosition.js +5 -6
- package/build/client/core/accounts/yieldTokenPosition.js.map +1 -1
- package/build/client/core/index.d.ts +1 -2
- package/build/client/core/instructions/addEmission.js +1 -2
- package/build/client/core/instructions/addEmission.js.map +1 -1
- package/build/client/core/instructions/addFarm.js +1 -2
- package/build/client/core/instructions/addFarm.js.map +1 -1
- package/build/client/core/instructions/addLpTokensMetadata.js +1 -2
- package/build/client/core/instructions/addLpTokensMetadata.js.map +1 -1
- package/build/client/core/instructions/addMarketEmission.js +1 -2
- package/build/client/core/instructions/addMarketEmission.js.map +1 -1
- package/build/client/core/instructions/buyYt.js +1 -2
- package/build/client/core/instructions/buyYt.js.map +1 -1
- package/build/client/core/instructions/claimFarmEmissions.js +1 -2
- package/build/client/core/instructions/claimFarmEmissions.js.map +1 -1
- package/build/client/core/instructions/collectEmission.js +1 -2
- package/build/client/core/instructions/collectEmission.js.map +1 -1
- package/build/client/core/instructions/collectInterest.js +1 -2
- package/build/client/core/instructions/collectInterest.js.map +1 -1
- package/build/client/core/instructions/collectTreasuryEmission.js +1 -2
- package/build/client/core/instructions/collectTreasuryEmission.js.map +1 -1
- package/build/client/core/instructions/collectTreasuryInterest.js +1 -2
- package/build/client/core/instructions/collectTreasuryInterest.js.map +1 -1
- package/build/client/core/instructions/depositYt.js +1 -2
- package/build/client/core/instructions/depositYt.js.map +1 -1
- package/build/client/core/instructions/initLpPosition.js +1 -2
- package/build/client/core/instructions/initLpPosition.js.map +1 -1
- package/build/client/core/instructions/initMarketTwo.js +1 -2
- package/build/client/core/instructions/initMarketTwo.js.map +1 -1
- package/build/client/core/instructions/initializeVault.js +1 -2
- package/build/client/core/instructions/initializeVault.js.map +1 -1
- package/build/client/core/instructions/initializeYieldPosition.js +1 -2
- package/build/client/core/instructions/initializeYieldPosition.js.map +1 -1
- package/build/client/core/instructions/marketCollectEmission.js +1 -2
- package/build/client/core/instructions/marketCollectEmission.js.map +1 -1
- package/build/client/core/instructions/marketDepositLp.js +1 -2
- package/build/client/core/instructions/marketDepositLp.js.map +1 -1
- package/build/client/core/instructions/marketTwoDepositLiquidity.js +1 -2
- package/build/client/core/instructions/marketTwoDepositLiquidity.js.map +1 -1
- package/build/client/core/instructions/marketTwoWithdrawLiquidity.js +1 -2
- package/build/client/core/instructions/marketTwoWithdrawLiquidity.js.map +1 -1
- package/build/client/core/instructions/marketWithdrawLp.js +1 -2
- package/build/client/core/instructions/marketWithdrawLp.js.map +1 -1
- package/build/client/core/instructions/merge.js +1 -2
- package/build/client/core/instructions/merge.js.map +1 -1
- package/build/client/core/instructions/modifyFarm.js +1 -2
- package/build/client/core/instructions/modifyFarm.js.map +1 -1
- package/build/client/core/instructions/modifyMarketSetting.js +1 -2
- package/build/client/core/instructions/modifyMarketSetting.js.map +1 -1
- package/build/client/core/instructions/modifyVaultSetting.js +1 -2
- package/build/client/core/instructions/modifyVaultSetting.js.map +1 -1
- package/build/client/core/instructions/reallocMarket.js +1 -2
- package/build/client/core/instructions/reallocMarket.js.map +1 -1
- package/build/client/core/instructions/sellYt.js +1 -2
- package/build/client/core/instructions/sellYt.js.map +1 -1
- package/build/client/core/instructions/stageYtYield.js +1 -2
- package/build/client/core/instructions/stageYtYield.js.map +1 -1
- package/build/client/core/instructions/strip.js +1 -2
- package/build/client/core/instructions/strip.js.map +1 -1
- package/build/client/core/instructions/tradePt.js +1 -2
- package/build/client/core/instructions/tradePt.js.map +1 -1
- package/build/client/core/instructions/withdrawYt.js +1 -2
- package/build/client/core/instructions/withdrawYt.js.map +1 -1
- package/build/client/core/instructions/wrapperBuyPt.js +1 -2
- package/build/client/core/instructions/wrapperBuyPt.js.map +1 -1
- package/build/client/core/instructions/wrapperBuyYt.js +1 -2
- package/build/client/core/instructions/wrapperBuyYt.js.map +1 -1
- package/build/client/core/instructions/wrapperCollectInterest.js +1 -2
- package/build/client/core/instructions/wrapperCollectInterest.js.map +1 -1
- package/build/client/core/instructions/wrapperMerge.js +1 -2
- package/build/client/core/instructions/wrapperMerge.js.map +1 -1
- package/build/client/core/instructions/wrapperProvideLiquidity.js +1 -2
- package/build/client/core/instructions/wrapperProvideLiquidity.js.map +1 -1
- package/build/client/core/instructions/wrapperProvideLiquidityBase.js +1 -2
- package/build/client/core/instructions/wrapperProvideLiquidityBase.js.map +1 -1
- package/build/client/core/instructions/wrapperProvideLiquidityClassic.js +1 -2
- package/build/client/core/instructions/wrapperProvideLiquidityClassic.js.map +1 -1
- package/build/client/core/instructions/wrapperSellPt.js +1 -2
- package/build/client/core/instructions/wrapperSellPt.js.map +1 -1
- package/build/client/core/instructions/wrapperSellYt.js +1 -2
- package/build/client/core/instructions/wrapperSellYt.js.map +1 -1
- package/build/client/core/instructions/wrapperStrip.js +1 -2
- package/build/client/core/instructions/wrapperStrip.js.map +1 -1
- package/build/client/core/instructions/wrapperWithdrawLiquidity.js +1 -2
- package/build/client/core/instructions/wrapperWithdrawLiquidity.js.map +1 -1
- package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.js +1 -2
- package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.js.map +1 -1
- package/build/client/core/types/adminAction.d.ts +1 -269
- package/build/client/core/types/adminAction.js +3 -3
- package/build/client/core/types/adminAction.js.map +1 -1
- package/build/client/core/types/amount.d.ts +1 -19
- package/build/client/core/types/amount.js +3 -3
- package/build/client/core/types/amount.js.map +1 -1
- package/build/client/core/types/buyPtEvent.d.ts +1 -19
- package/build/client/core/types/buyYtEvent.d.ts +1 -49
- package/build/client/core/types/claimFarmEmissionsEvent.d.ts +1 -31
- package/build/client/core/types/claimFarmEmissionsEventV2.d.ts +1 -83
- package/build/client/core/types/claimLimits.d.ts +1 -16
- package/build/client/core/types/collectEmissionEvent.d.ts +1 -25
- package/build/client/core/types/collectEmissionEventV2.d.ts +1 -55
- package/build/client/core/types/collectInterestEvent.d.ts +1 -22
- package/build/client/core/types/collectInterestEventV2.d.ts +1 -52
- package/build/client/core/types/collectTreasuryEmissionKind.d.ts +1 -1
- package/build/client/core/types/collectTreasuryInterestKind.d.ts +1 -1
- package/build/client/core/types/cpiAccounts.d.ts +1 -99
- package/build/client/core/types/cpiInterfaceContext.d.ts +1 -13
- package/build/client/core/types/depositLiquidityEvent.d.ts +1 -49
- package/build/client/core/types/depositLpEvent.d.ts +1 -31
- package/build/client/core/types/depositLpEventV2.d.ts +1 -83
- package/build/client/core/types/depositYtEvent.d.ts +1 -40
- package/build/client/core/types/depositYtEventV2.d.ts +1 -70
- package/build/client/core/types/emissionInfo.d.ts +1 -25
- package/build/client/core/types/farmEmission.d.ts +1 -16
- package/build/client/core/types/initLpPositionEvent.d.ts +1 -25
- package/build/client/core/types/initializeYieldPositionEvent.d.ts +1 -16
- package/build/client/core/types/liquidityNetBalanceLimits.d.ts +1 -19
- package/build/client/core/types/lpFarm.d.ts +1 -30
- package/build/client/core/types/marketAdminAction.d.ts +1 -239
- package/build/client/core/types/marketAdminAction.js +3 -3
- package/build/client/core/types/marketAdminAction.js.map +1 -1
- package/build/client/core/types/marketCollectEmissionEvent.d.ts +1 -28
- package/build/client/core/types/marketCollectEmissionEventV2.d.ts +1 -80
- package/build/client/core/types/marketEmission.d.ts +1 -13
- package/build/client/core/types/marketEmissions.d.ts +1 -23
- package/build/client/core/types/marketFinancials.d.ts +1 -22
- package/build/client/core/types/mergeEvent.d.ts +1 -61
- package/build/client/core/types/number.d.ts +1 -1
- package/build/client/core/types/personalYieldTracker.d.ts +1 -10
- package/build/client/core/types/personalYieldTrackers.d.ts +1 -19
- package/build/client/core/types/principleDetails.d.ts +1 -7
- package/build/client/core/types/principles.d.ts +1 -70
- package/build/client/core/types/sellPtEvent.d.ts +1 -19
- package/build/client/core/types/sellYtEvent.d.ts +1 -43
- package/build/client/core/types/stageYieldEvent.d.ts +1 -31
- package/build/client/core/types/stageYieldEventV2.d.ts +1 -58
- package/build/client/core/types/stripEvent.d.ts +1 -61
- package/build/client/core/types/tradePtEvent.d.ts +1 -37
- package/build/client/core/types/withdrawLiquidityEvent.d.ts +1 -43
- package/build/client/core/types/withdrawLpEvent.d.ts +1 -31
- package/build/client/core/types/withdrawLpEventV2.d.ts +1 -83
- package/build/client/core/types/withdrawYtEvent.d.ts +1 -40
- package/build/client/core/types/withdrawYtEventV2.d.ts +1 -70
- package/build/client/core/types/wrapperBuyYtEvent.d.ts +1 -19
- package/build/client/core/types/wrapperCollectInterestEvent.d.ts +1 -16
- package/build/client/core/types/wrapperMergeEvent.d.ts +1 -19
- package/build/client/core/types/wrapperProvideLiquidityBaseEvent.d.ts +1 -25
- package/build/client/core/types/wrapperProvideLiquidityClassicEvent.d.ts +1 -22
- package/build/client/core/types/wrapperProvideLiquidityEvent.d.ts +1 -22
- package/build/client/core/types/wrapperSellYtEvent.d.ts +1 -19
- package/build/client/core/types/wrapperStripEvent.d.ts +1 -19
- package/build/client/core/types/wrapperWithdrawLiquidityClassicEvent.d.ts +1 -22
- package/build/client/core/types/wrapperWithdrawLiquidityEvent.d.ts +1 -19
- package/build/client/core/types/yieldTokenTracker.d.ts +1 -10
- package/build/client/orderbook/accounts/cpiAccountsOrderbook.js +5 -6
- package/build/client/orderbook/accounts/cpiAccountsOrderbook.js.map +1 -1
- package/build/client/orderbook/accounts/vault.js +5 -6
- package/build/client/orderbook/accounts/vault.js.map +1 -1
- package/build/client/orderbook/index.d.ts +1 -2
- package/build/client/orderbook/instructions/collectAdminEmission.js +1 -2
- package/build/client/orderbook/instructions/collectAdminEmission.js.map +1 -1
- package/build/client/orderbook/instructions/collectAdminFee.js +1 -2
- package/build/client/orderbook/instructions/collectAdminFee.js.map +1 -1
- package/build/client/orderbook/instructions/collectInterest.js +1 -2
- package/build/client/orderbook/instructions/collectInterest.js.map +1 -1
- package/build/client/orderbook/instructions/initializeOrderbook.js +1 -2
- package/build/client/orderbook/instructions/initializeOrderbook.js.map +1 -1
- package/build/client/orderbook/instructions/marketOffer.js +1 -2
- package/build/client/orderbook/instructions/marketOffer.js.map +1 -1
- package/build/client/orderbook/instructions/postOffer.js +1 -2
- package/build/client/orderbook/instructions/postOffer.js.map +1 -1
- package/build/client/orderbook/instructions/reallocOrderbookAccount.js +1 -2
- package/build/client/orderbook/instructions/reallocOrderbookAccount.js.map +1 -1
- package/build/client/orderbook/instructions/removeExpiredOffers.js +1 -2
- package/build/client/orderbook/instructions/removeExpiredOffers.js.map +1 -1
- package/build/client/orderbook/instructions/removeOffer.js +1 -2
- package/build/client/orderbook/instructions/removeOffer.js.map +1 -1
- package/build/client/orderbook/instructions/setConfigurationOptions.js +1 -2
- package/build/client/orderbook/instructions/setConfigurationOptions.js.map +1 -1
- package/build/client/orderbook/instructions/withdrawFunds.js +1 -2
- package/build/client/orderbook/instructions/withdrawFunds.js.map +1 -1
- package/build/client/orderbook/instructions/wrapperCollectAdminFee.js +1 -2
- package/build/client/orderbook/instructions/wrapperCollectAdminFee.js.map +1 -1
- package/build/client/orderbook/instructions/wrapperCollectInterest.js +1 -2
- package/build/client/orderbook/instructions/wrapperCollectInterest.js.map +1 -1
- package/build/client/orderbook/instructions/wrapperMarketOffer.js +1 -2
- package/build/client/orderbook/instructions/wrapperMarketOffer.js.map +1 -1
- package/build/client/orderbook/instructions/wrapperPostOffer.js +1 -2
- package/build/client/orderbook/instructions/wrapperPostOffer.js.map +1 -1
- package/build/client/orderbook/instructions/wrapperRemoveOffer.js +1 -2
- package/build/client/orderbook/instructions/wrapperRemoveOffer.js.map +1 -1
- package/build/client/orderbook/instructions/wrapperWithdrawFunds.js +1 -2
- package/build/client/orderbook/instructions/wrapperWithdrawFunds.js.map +1 -1
- package/build/client/orderbook/types/amount.d.ts +1 -19
- package/build/client/orderbook/types/amount.js +3 -3
- package/build/client/orderbook/types/amount.js.map +1 -1
- package/build/client/orderbook/types/claimLimits.d.ts +1 -16
- package/build/client/orderbook/types/collectAdminEmissionEvent.d.ts +1 -19
- package/build/client/orderbook/types/collectAdminFeeEvent.d.ts +1 -19
- package/build/client/orderbook/types/collectEmissionEventV2.d.ts +1 -55
- package/build/client/orderbook/types/collectInterestEventV2.d.ts +1 -52
- package/build/client/orderbook/types/collectUserInterestEvent.d.ts +1 -16
- package/build/client/orderbook/types/cpiAccounts.d.ts +1 -99
- package/build/client/orderbook/types/cpiInterfaceContext.d.ts +1 -13
- package/build/client/orderbook/types/emissionInfo.d.ts +1 -25
- package/build/client/orderbook/types/exponentCoreCpiAccounts.d.ts +1 -99
- package/build/client/orderbook/types/filledOffersEvent.d.ts +1 -22
- package/build/client/orderbook/types/marketOfferEvent.d.ts +1 -74
- package/build/client/orderbook/types/mergeEvent.d.ts +1 -61
- package/build/client/orderbook/types/number.d.ts +1 -1
- package/build/client/orderbook/types/offerOptions.d.ts +1 -13
- package/build/client/orderbook/types/offerOptions.js +3 -3
- package/build/client/orderbook/types/offerOptions.js.map +1 -1
- package/build/client/orderbook/types/offerType.d.ts +1 -1
- package/build/client/orderbook/types/orderbookInitEvent.d.ts +1 -28
- package/build/client/orderbook/types/postOfferEvent.d.ts +1 -96
- package/build/client/orderbook/types/removeOfferEvent.d.ts +1 -28
- package/build/client/orderbook/types/setConfigurationOptionsEnum.d.ts +1 -49
- package/build/client/orderbook/types/setConfigurationOptionsEnum.js +3 -3
- package/build/client/orderbook/types/setConfigurationOptionsEnum.js.map +1 -1
- package/build/client/orderbook/types/stripEvent.d.ts +1 -61
- package/build/client/orderbook/types/withdrawFundsEvent.d.ts +1 -28
- package/build/client/orderbook/types/wrapperCollectAdminFeeEvent.d.ts +1 -13
- package/build/client/orderbook/types/wrapperCollectInterestEvent.d.ts +1 -10
- package/build/client/orderbook/types/wrapperMarketOfferEvent.d.ts +1 -13
- package/build/client/orderbook/types/wrapperPostOfferEvent.d.ts +1 -28
- package/build/client/orderbook/types/wrapperRemoveOfferEvent.d.ts +1 -10
- package/build/client/orderbook/types/wrapperWithdrawFundsEvent.d.ts +1 -19
- package/build/client/orderbook/types/yieldTokenTracker.d.ts +1 -10
- package/build/client/vaults/accounts/actionProposal.js +5 -6
- package/build/client/vaults/accounts/actionProposal.js.map +1 -1
- package/build/client/vaults/accounts/exponentStrategyVault.js +5 -6
- package/build/client/vaults/accounts/exponentStrategyVault.js.map +1 -1
- package/build/client/vaults/accounts/programConfig.js +5 -6
- package/build/client/vaults/accounts/programConfig.js.map +1 -1
- package/build/client/vaults/accounts/voteAccount.js +5 -6
- package/build/client/vaults/accounts/voteAccount.js.map +1 -1
- package/build/client/vaults/accounts/withdrawalAccount.js +5 -6
- package/build/client/vaults/accounts/withdrawalAccount.js.map +1 -1
- package/build/client/vaults/eventRegistry.d.ts +8 -2
- package/build/client/vaults/eventRegistry.js +6 -0
- package/build/client/vaults/eventRegistry.js.map +1 -1
- package/build/client/vaults/index.d.ts +4 -2
- package/build/client/vaults/index.js +3 -0
- package/build/client/vaults/index.js.map +1 -1
- package/build/client/vaults/instructions/activateProposal.d.ts +2 -0
- package/build/client/vaults/instructions/activateProposal.js +3 -2
- package/build/client/vaults/instructions/activateProposal.js.map +1 -1
- package/build/client/vaults/instructions/addPolicy.js +1 -2
- package/build/client/vaults/instructions/addPolicy.js.map +1 -1
- package/build/client/vaults/instructions/appendProposalActions.js +1 -2
- package/build/client/vaults/instructions/appendProposalActions.js.map +1 -1
- package/build/client/vaults/instructions/cancelProposal.d.ts +2 -0
- package/build/client/vaults/instructions/cancelProposal.js +3 -2
- package/build/client/vaults/instructions/cancelProposal.js.map +1 -1
- package/build/client/vaults/instructions/cancelWithdrawal.d.ts +2 -0
- package/build/client/vaults/instructions/cancelWithdrawal.js +3 -2
- package/build/client/vaults/instructions/cancelWithdrawal.js.map +1 -1
- package/build/client/vaults/instructions/collectManagementFee.js +1 -2
- package/build/client/vaults/instructions/collectManagementFee.js.map +1 -1
- package/build/client/vaults/instructions/depositLiquidity.js +1 -2
- package/build/client/vaults/instructions/depositLiquidity.js.map +1 -1
- package/build/client/vaults/instructions/executeProposal.d.ts +2 -0
- package/build/client/vaults/instructions/executeProposal.js +3 -2
- package/build/client/vaults/instructions/executeProposal.js.map +1 -1
- package/build/client/vaults/instructions/executeWithdrawal.js +1 -2
- package/build/client/vaults/instructions/executeWithdrawal.js.map +1 -1
- package/build/client/vaults/instructions/executeWithdrawalFromReserves.d.ts +2 -0
- package/build/client/vaults/instructions/executeWithdrawalFromReserves.js +3 -2
- package/build/client/vaults/instructions/executeWithdrawalFromReserves.js.map +1 -1
- package/build/client/vaults/instructions/fillWithdrawal.js +1 -2
- package/build/client/vaults/instructions/fillWithdrawal.js.map +1 -1
- package/build/client/vaults/instructions/finalizeProposal.d.ts +2 -0
- package/build/client/vaults/instructions/finalizeProposal.js +3 -2
- package/build/client/vaults/instructions/finalizeProposal.js.map +1 -1
- package/build/client/vaults/instructions/initProposal.js +1 -2
- package/build/client/vaults/instructions/initProposal.js.map +1 -1
- package/build/client/vaults/instructions/initializePrices.js +1 -2
- package/build/client/vaults/instructions/initializePrices.js.map +1 -1
- package/build/client/vaults/instructions/initializeVault.js +1 -2
- package/build/client/vaults/instructions/initializeVault.js.map +1 -1
- package/build/client/vaults/instructions/makeSentienelManager.js +1 -2
- package/build/client/vaults/instructions/makeSentienelManager.js.map +1 -1
- package/build/client/vaults/instructions/managePrices.js +1 -2
- package/build/client/vaults/instructions/managePrices.js.map +1 -1
- package/build/client/vaults/instructions/manageVaultSettings.js +1 -2
- package/build/client/vaults/instructions/manageVaultSettings.js.map +1 -1
- package/build/client/vaults/instructions/managerUpdatePosition.js +1 -2
- package/build/client/vaults/instructions/managerUpdatePosition.js.map +1 -1
- package/build/client/vaults/instructions/queueWithdrawal.d.ts +2 -0
- package/build/client/vaults/instructions/queueWithdrawal.js +3 -2
- package/build/client/vaults/instructions/queueWithdrawal.js.map +1 -1
- package/build/client/vaults/instructions/removePolicy.js +1 -2
- package/build/client/vaults/instructions/removePolicy.js.map +1 -1
- package/build/client/vaults/instructions/sentinelSetVaultFlags.d.ts +2 -0
- package/build/client/vaults/instructions/sentinelSetVaultFlags.js +3 -2
- package/build/client/vaults/instructions/sentinelSetVaultFlags.js.map +1 -1
- package/build/client/vaults/instructions/stakeVote.d.ts +2 -0
- package/build/client/vaults/instructions/stakeVote.js +3 -2
- package/build/client/vaults/instructions/stakeVote.js.map +1 -1
- package/build/client/vaults/instructions/unstakeVote.js +1 -2
- package/build/client/vaults/instructions/unstakeVote.js.map +1 -1
- package/build/client/vaults/instructions/updatePolicy.js +1 -2
- package/build/client/vaults/instructions/updatePolicy.js.map +1 -1
- package/build/client/vaults/instructions/updatePolicyManager.js +1 -2
- package/build/client/vaults/instructions/updatePolicyManager.js.map +1 -1
- package/build/client/vaults/instructions/updatePrice.js +1 -2
- package/build/client/vaults/instructions/updatePrice.js.map +1 -1
- package/build/client/vaults/instructions/validateInteractionHook.js +1 -2
- package/build/client/vaults/instructions/validateInteractionHook.js.map +1 -1
- package/build/client/vaults/instructions/wrapperAddPolicy.js +1 -2
- package/build/client/vaults/instructions/wrapperAddPolicy.js.map +1 -1
- package/build/client/vaults/instructions/wrapperExecuteWithdrawal.js +1 -2
- package/build/client/vaults/instructions/wrapperExecuteWithdrawal.js.map +1 -1
- package/build/client/vaults/instructions/wrapperManageVaultSettings.js +1 -2
- package/build/client/vaults/instructions/wrapperManageVaultSettings.js.map +1 -1
- package/build/client/vaults/instructions/wrapperManagerUpdatePosition.js +1 -2
- package/build/client/vaults/instructions/wrapperManagerUpdatePosition.js.map +1 -1
- package/build/client/vaults/instructions/wrapperRemovePolicy.js +1 -2
- package/build/client/vaults/instructions/wrapperRemovePolicy.js.map +1 -1
- package/build/client/vaults/instructions/wrapperUpdatePolicy.js +1 -2
- package/build/client/vaults/instructions/wrapperUpdatePolicy.js.map +1 -1
- package/build/client/vaults/types/accountConstraint.d.ts +1 -13
- package/build/client/vaults/types/accountConstraintType.d.ts +1 -1
- package/build/client/vaults/types/accountConstraintType.js +3 -3
- package/build/client/vaults/types/accountConstraintType.js.map +1 -1
- package/build/client/vaults/types/allowedSettingsChange.d.ts +1 -54
- package/build/client/vaults/types/allowedSettingsChange.js +3 -3
- package/build/client/vaults/types/allowedSettingsChange.js.map +1 -1
- package/build/client/vaults/types/cancelProposalEvent.d.ts +1 -19
- package/build/client/vaults/types/cancelWithdrawalEvent.d.ts +12 -0
- package/build/client/vaults/types/cancelWithdrawalEvent.js +29 -0
- package/build/client/vaults/types/cancelWithdrawalEvent.js.map +1 -0
- package/build/client/vaults/types/clmmPositionEntry.d.ts +1 -80
- package/build/client/vaults/types/dataConstraint.d.ts +1 -109
- package/build/client/vaults/types/dataOperator.d.ts +1 -1
- package/build/client/vaults/types/dataValue.d.ts +1 -73
- package/build/client/vaults/types/dataValue.js +3 -3
- package/build/client/vaults/types/dataValue.js.map +1 -1
- package/build/client/vaults/types/depositLiquidityEvent.d.ts +1 -40
- package/build/client/vaults/types/executeProposalEvent.d.ts +1 -19
- package/build/client/vaults/types/executeWithdrawalEvent.d.ts +8 -10
- package/build/client/vaults/types/executeWithdrawalEvent.js +19 -0
- package/build/client/vaults/types/executeWithdrawalEvent.js.map +1 -1
- package/build/client/vaults/types/executeWithdrawalFromReservesEvent.d.ts +19 -0
- package/build/client/vaults/types/executeWithdrawalFromReservesEvent.js +48 -0
- package/build/client/vaults/types/executeWithdrawalFromReservesEvent.js.map +1 -0
- package/build/client/vaults/types/fillParam.d.ts +1 -10
- package/build/client/vaults/types/finalizeProposalEvent.d.ts +1 -34
- package/build/client/vaults/types/hook.d.ts +1 -35
- package/build/client/vaults/types/hookCompiledInstruction.d.ts +1 -13
- package/build/client/vaults/types/index.d.ts +3 -0
- package/build/client/vaults/types/index.js +3 -0
- package/build/client/vaults/types/index.js.map +1 -1
- package/build/client/vaults/types/instructionConstraint.d.ts +1 -165
- package/build/client/vaults/types/internalFundTransferPolicyCreationPayload.d.ts +1 -13
- package/build/client/vaults/types/kaminoFarmEntry.d.ts +1 -10
- package/build/client/vaults/types/kaminoObligationEntry.d.ts +1 -122
- package/build/client/vaults/types/limitedQuantityConstraints.d.ts +1 -7
- package/build/client/vaults/types/limitedSpendingLimit.d.ts +1 -97
- package/build/client/vaults/types/limitedTimeConstraints.d.ts +1 -61
- package/build/client/vaults/types/loopscaleLoanEntry.d.ts +1 -7
- package/build/client/vaults/types/loopscaleStrategyEntry.d.ts +1 -7
- package/build/client/vaults/types/number.d.ts +1 -1
- package/build/client/vaults/types/obligationType.js +3 -3
- package/build/client/vaults/types/obligationType.js.map +1 -1
- package/build/client/vaults/types/orderbookEntry.d.ts +1 -54
- package/build/client/vaults/types/periodV2.d.ts +1 -37
- package/build/client/vaults/types/periodV2.js +3 -3
- package/build/client/vaults/types/periodV2.js.map +1 -1
- package/build/client/vaults/types/permissions.d.ts +1 -7
- package/build/client/vaults/types/policyAction.d.ts +1 -40
- package/build/client/vaults/types/policyAction.js +3 -3
- package/build/client/vaults/types/policyAction.js.map +1 -1
- package/build/client/vaults/types/policyCreationPayload.d.ts +1 -260
- package/build/client/vaults/types/policyCreationPayload.js +3 -3
- package/build/client/vaults/types/policyCreationPayload.js.map +1 -1
- package/build/client/vaults/types/policyExpirationArgs.d.ts +1 -19
- package/build/client/vaults/types/policyExpirationArgs.js +3 -3
- package/build/client/vaults/types/policyExpirationArgs.js.map +1 -1
- package/build/client/vaults/types/positionUpdate.js +3 -3
- package/build/client/vaults/types/positionUpdate.js.map +1 -1
- package/build/client/vaults/types/priceId.d.ts +1 -25
- package/build/client/vaults/types/priceId.js +3 -3
- package/build/client/vaults/types/priceId.js.map +1 -1
- package/build/client/vaults/types/priceType.d.ts +1 -1
- package/build/client/vaults/types/proposalAction.d.ts +2 -204
- package/build/client/vaults/types/proposalAction.js +6 -3
- package/build/client/vaults/types/proposalAction.js.map +1 -1
- package/build/client/vaults/types/proposalActionKind.d.ts +1 -1
- package/build/client/vaults/types/proposalStatus.d.ts +1 -1
- package/build/client/vaults/types/proposalVoteConfig.d.ts +1 -34
- package/build/client/vaults/types/proposeActionEvent.d.ts +1 -34
- package/build/client/vaults/types/quantityConstraints.d.ts +1 -13
- package/build/client/vaults/types/queueWithdrawalEvent.d.ts +11 -0
- package/build/client/vaults/types/queueWithdrawalEvent.js +31 -0
- package/build/client/vaults/types/queueWithdrawalEvent.js.map +1 -0
- package/build/client/vaults/types/reserveFarmMapping.d.ts +1 -13
- package/build/client/vaults/types/reservePriceMapping.d.ts +1 -42
- package/build/client/vaults/types/settingsChangePolicyCreationPayload.d.ts +1 -77
- package/build/client/vaults/types/spendingLimitPolicyCreationPayload.d.ts +1 -130
- package/build/client/vaults/types/stakeVoteEvent.d.ts +1 -28
- package/build/client/vaults/types/strategyPosition.js +3 -3
- package/build/client/vaults/types/strategyPosition.js.map +1 -1
- package/build/client/vaults/types/timeConstraints.d.ts +1 -64
- package/build/client/vaults/types/tokenAccountBalance.d.ts +1 -45
- package/build/client/vaults/types/tokenAccountEntry.d.ts +1 -66
- package/build/client/vaults/types/tokenEntry.d.ts +1 -51
- package/build/client/vaults/types/unstakeVoteEvent.d.ts +1 -25
- package/build/client/vaults/types/updatePriceAction.d.ts +1 -124
- package/build/client/vaults/types/updatePriceAction.js +3 -3
- package/build/client/vaults/types/updatePriceAction.js.map +1 -1
- package/build/client/vaults/types/updatePriceInput.d.ts +1 -10
- package/build/client/vaults/types/usageState.d.ts +1 -10
- package/build/client/vaults/types/vaultConfig.d.ts +1 -74
- package/build/client/vaults/types/vaultFinancials.d.ts +1 -43
- package/build/client/vaults/types/vaultFlagAction.d.ts +1 -37
- package/build/client/vaults/types/vaultFlagAction.js +3 -3
- package/build/client/vaults/types/vaultFlagAction.js.map +1 -1
- package/build/client/vaults/types/vaultFlagsUpdatedEvent.d.ts +1 -16
- package/build/client/vaults/types/vaultRoleKind.d.ts +1 -1
- package/build/client/vaults/types/vaultRoles.d.ts +1 -16
- package/build/client/vaults/types/vaultSettingsAction.js +3 -3
- package/build/client/vaults/types/vaultSettingsAction.js.map +1 -1
- package/build/client/vaults/types/voteChoice.d.ts +1 -1
- package/build/client/vaults/types/withdrawalPeriodSettings.d.ts +1 -31
- package/build/client/vaults/types/withdrawalPeriodSettings.js +3 -3
- package/build/client/vaults/types/withdrawalPeriodSettings.js.map +1 -1
- package/build/client/vaults/types/withdrawalTokenFill.d.ts +1 -13
- package/build/client/vaults/types/yieldPositionEntry.d.ts +1 -45
- package/build/clmm/codamaEvents.d.ts +1 -2
- package/build/codamaEvents.d.ts +1 -2
- package/build/exponentVaults/aumCalculator.d.ts +0 -2
- package/build/exponentVaults/aumCalculator.js +20 -10
- package/build/exponentVaults/aumCalculator.js.map +1 -1
- package/build/exponentVaults/events.d.ts +1 -2
- package/build/exponentVaults/fetcher.js +4 -4
- package/build/exponentVaults/fetcher.js.map +1 -1
- package/build/exponentVaults/index.d.ts +1 -1
- package/build/exponentVaults/index.js +20 -9
- package/build/exponentVaults/index.js.map +1 -1
- package/build/exponentVaults/kamino-farms.d.ts +0 -2
- package/build/exponentVaults/kamino-farms.js +14 -14
- package/build/exponentVaults/kamino-farms.js.map +1 -1
- package/build/exponentVaults/kamino-markets.d.ts +394 -394
- package/build/exponentVaults/kamino-markets.js +2 -2
- package/build/exponentVaults/kamino-markets.js.map +1 -1
- package/build/exponentVaults/loopscale/helpers.js +6 -7
- package/build/exponentVaults/loopscale/helpers.js.map +1 -1
- package/build/exponentVaults/loopscale/prepared-transactions.js +1 -2
- package/build/exponentVaults/loopscale/prepared-transactions.js.map +1 -1
- package/build/exponentVaults/policyBuilders.d.ts +73 -75
- package/build/exponentVaults/policyBuilders.js +26 -27
- package/build/exponentVaults/policyBuilders.js.map +1 -1
- package/build/exponentVaults/policyMatcher.js +6 -7
- package/build/exponentVaults/policyMatcher.js.map +1 -1
- package/build/exponentVaults/pricePathResolver.js +7 -8
- package/build/exponentVaults/pricePathResolver.js.map +1 -1
- package/build/exponentVaults/scope-refresh.js +1 -2
- package/build/exponentVaults/scope-refresh.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/helpers.js +6 -7
- package/build/exponentVaults/squadsVaultTxnResolver/helpers.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.js +5 -6
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.js +1 -2
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.js +1 -2
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.js +1 -2
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.js +1 -2
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.js.map +1 -1
- package/build/exponentVaults/squadsVaultTxnResolver/utils.d.ts +1 -3
- package/build/exponentVaults/squadsVaultTxnResolver/utils.js +1 -2
- package/build/exponentVaults/squadsVaultTxnResolver/utils.js.map +1 -1
- package/build/exponentVaults/syncTransaction.d.ts +1 -1
- package/build/exponentVaults/syncTransaction.js +4 -4
- package/build/exponentVaults/syncTransaction.js.map +1 -1
- package/build/exponentVaults/titan-quote.js +1 -2
- package/build/exponentVaults/titan-quote.js.map +1 -1
- package/build/exponentVaults/vault-instruction-types.d.ts +1 -1
- package/build/exponentVaults/vault-interaction.d.ts +58 -2576
- package/build/exponentVaults/vault-interaction.js +325 -75
- package/build/exponentVaults/vault-interaction.js.map +1 -1
- package/build/exponentVaults/vault.d.ts +9 -25
- package/build/exponentVaults/vault.js +28 -12
- package/build/exponentVaults/vault.js.map +1 -1
- package/build/exponentVaults/vaultTransactionBuilder.js +35 -30
- package/build/exponentVaults/vaultTransactionBuilder.js.map +1 -1
- package/build/flavors.js +19 -20
- package/build/flavors.js.map +1 -1
- package/build/index.js +17 -7
- package/build/index.js.map +1 -1
- package/build/market.d.ts +31 -31
- package/build/market.js +17 -7
- package/build/market.js.map +1 -1
- package/build/marketThree.d.ts +42 -48
- package/build/marketThree.js +20 -8
- package/build/marketThree.js.map +1 -1
- package/build/orderbook/codamaEvents.d.ts +1 -2
- package/build/orderbook/index.js +17 -7
- package/build/orderbook/index.js.map +1 -1
- package/build/orderbook/math.d.ts +4 -4
- package/build/orderbook/math.js +13 -13
- package/build/orderbook/math.js.map +1 -1
- package/build/orderbook/orderbook.d.ts +19 -21
- package/build/orderbook/orderbook.js +17 -7
- package/build/orderbook/orderbook.js.map +1 -1
- package/build/orderbook/types.js +17 -7
- package/build/orderbook/types.js.map +1 -1
- package/build/orderbook/utils.js +6 -7
- package/build/orderbook/utils.js.map +1 -1
- package/build/syPosition.js +3 -4
- package/build/syPosition.js.map +1 -1
- package/build/tokenUtil.js +2 -3
- package/build/tokenUtil.js.map +1 -1
- package/build/utils/altUtil.js +2 -3
- package/build/utils/altUtil.js.map +1 -1
- package/build/utils/binSolver.js +1 -2
- package/build/utils/binSolver.js.map +1 -1
- package/build/utils/index.d.ts +2 -2
- package/build/utils/index.js +3 -4
- package/build/utils/index.js.map +1 -1
- package/build/vault.d.ts +11 -12
- package/build/vault.js +20 -10
- package/build/vault.js.map +1 -1
- package/build/ytPosition.d.ts +7 -7
- package/build/ytPosition.js +17 -7
- package/build/ytPosition.js.map +1 -1
- package/package.json +36 -32
- package/build/client/vaults/instructions/proposeAction.d.ts +0 -16
- package/build/client/vaults/instructions/proposeAction.js +0 -29
- package/build/client/vaults/instructions/proposeAction.js.map +0 -1
- package/build/exponentVaults/loopscale/client.test.d.ts +0 -1
- package/build/exponentVaults/loopscale/client.test.js +0 -183
- package/build/exponentVaults/loopscale/client.test.js.map +0 -1
- package/build/exponentVaults/loopscale/prepared-transactions.test.d.ts +0 -1
- package/build/exponentVaults/loopscale/prepared-transactions.test.js +0 -400
- package/build/exponentVaults/loopscale/prepared-transactions.test.js.map +0 -1
- package/build/exponentVaults/loopscale/response-plan.d.ts +0 -69
- package/build/exponentVaults/loopscale/response-plan.js +0 -141
- package/build/exponentVaults/loopscale/response-plan.js.map +0 -1
- package/build/exponentVaults/loopscale/response-plan.test.d.ts +0 -1
- package/build/exponentVaults/loopscale/response-plan.test.js +0 -139
- package/build/exponentVaults/loopscale/response-plan.test.js.map +0 -1
- package/build/exponentVaults/loopscale/send-plan.d.ts +0 -75
- package/build/exponentVaults/loopscale/send-plan.js +0 -235
- package/build/exponentVaults/loopscale/send-plan.js.map +0 -1
- package/build/exponentVaults/loopscale-client.d.ts +0 -130
- package/build/exponentVaults/loopscale-client.js +0 -489
- package/build/exponentVaults/loopscale-client.js.map +0 -1
- package/build/exponentVaults/loopscale-client.test.d.ts +0 -1
- package/build/exponentVaults/loopscale-client.test.js +0 -162
- package/build/exponentVaults/loopscale-client.test.js.map +0 -1
- package/build/exponentVaults/loopscale-client.types.d.ts +0 -425
- package/build/exponentVaults/loopscale-client.types.js +0 -3
- package/build/exponentVaults/loopscale-client.types.js.map +0 -1
- package/build/exponentVaults/loopscale-execution.d.ts +0 -125
- package/build/exponentVaults/loopscale-execution.js +0 -341
- package/build/exponentVaults/loopscale-execution.js.map +0 -1
- package/build/exponentVaults/loopscale-execution.test.d.ts +0 -1
- package/build/exponentVaults/loopscale-execution.test.js +0 -139
- package/build/exponentVaults/loopscale-execution.test.js.map +0 -1
- package/build/exponentVaults/loopscale-vault.d.ts +0 -115
- package/build/exponentVaults/loopscale-vault.js +0 -275
- package/build/exponentVaults/loopscale-vault.js.map +0 -1
- package/build/exponentVaults/loopscale-vault.test.d.ts +0 -1
- package/build/exponentVaults/loopscale-vault.test.js +0 -102
- package/build/exponentVaults/loopscale-vault.test.js.map +0 -1
- package/build/exponentVaults/pricePathResolver.test.d.ts +0 -1
- package/build/exponentVaults/pricePathResolver.test.js +0 -369
- package/build/exponentVaults/pricePathResolver.test.js.map +0 -1
- package/build/exponentVaults/vaultTransactionBuilder.test.d.ts +0 -1
- package/build/exponentVaults/vaultTransactionBuilder.test.js +0 -214
- package/build/exponentVaults/vaultTransactionBuilder.test.js.map +0 -1
- package/build/marketThree.test.d.ts +0 -1
- package/build/marketThree.test.js +0 -166
- package/build/marketThree.test.js.map +0 -1
- package/build/utils/binSolver.test.d.ts +0 -1
- package/build/utils/binSolver.test.js +0 -16
- package/build/utils/binSolver.test.js.map +0 -1
- package/jest.config.js +0 -5
- package/src/CodamaEventDecoder.ts +0 -151
- package/src/addressLookupTableUtil.ts +0 -110
- package/src/client/clmm/accounts/lpPosition.ts +0 -143
- package/src/client/clmm/accounts/marketThree.ts +0 -274
- package/src/client/clmm/accounts/vault.ts +0 -234
- package/src/client/clmm/eventRegistry.ts +0 -92
- package/src/client/clmm/index.ts +0 -82
- package/src/client/clmm/instructions/addFarm.ts +0 -57
- package/src/client/clmm/instructions/addLiquidity.ts +0 -78
- package/src/client/clmm/instructions/addMarketEmission.ts +0 -50
- package/src/client/clmm/instructions/buyPt.ts +0 -73
- package/src/client/clmm/instructions/buyYt.ts +0 -80
- package/src/client/clmm/instructions/claimFarmEmission.ts +0 -56
- package/src/client/clmm/instructions/closeMarket.ts +0 -47
- package/src/client/clmm/instructions/depositLiquidity.ts +0 -71
- package/src/client/clmm/instructions/initializeMarket.ts +0 -127
- package/src/client/clmm/instructions/marketAccrueEmission.ts +0 -39
- package/src/client/clmm/instructions/marketCollectEmission.ts +0 -57
- package/src/client/clmm/instructions/modifyFarm.ts +0 -55
- package/src/client/clmm/instructions/modifyMarketSetting.ts +0 -45
- package/src/client/clmm/instructions/sellPt.ts +0 -73
- package/src/client/clmm/instructions/sellYt.ts +0 -80
- package/src/client/clmm/instructions/tradePt.ts +0 -73
- package/src/client/clmm/instructions/tradePtExactOut.ts +0 -75
- package/src/client/clmm/instructions/withdrawLiquidity.ts +0 -67
- package/src/client/clmm/instructions/wrapperBuyYt.ts +0 -85
- package/src/client/clmm/instructions/wrapperProvideLiquidity.ts +0 -100
- package/src/client/clmm/instructions/wrapperProvideLiquidityBase.ts +0 -98
- package/src/client/clmm/instructions/wrapperProvideLiquidityClassic.ts +0 -86
- package/src/client/clmm/instructions/wrapperSellYt.ts +0 -83
- package/src/client/clmm/instructions/wrapperWithdrawLiquidity.ts +0 -75
- package/src/client/clmm/instructions/wrapperWithdrawLiquidityClassic.ts +0 -69
- package/src/client/clmm/types/addFarmEvent.ts +0 -51
- package/src/client/clmm/types/amount.ts +0 -51
- package/src/client/clmm/types/buyPtEvent.ts +0 -36
- package/src/client/clmm/types/buyYtEvent.ts +0 -74
- package/src/client/clmm/types/claimFarmEmissionsEvent.ts +0 -94
- package/src/client/clmm/types/claimLimits.ts +0 -15
- package/src/client/clmm/types/closeMarketEvent.ts +0 -36
- package/src/client/clmm/types/configurationOptions.ts +0 -29
- package/src/client/clmm/types/cpiAccounts.ts +0 -21
- package/src/client/clmm/types/cpiCoreAccounts.ts +0 -15
- package/src/client/clmm/types/cpiInterfaceContext.ts +0 -13
- package/src/client/clmm/types/crossingSplit.ts +0 -40
- package/src/client/clmm/types/depositLiquidityEvent.ts +0 -93
- package/src/client/clmm/types/depositLiquidityReturnData.ts +0 -81
- package/src/client/clmm/types/emissionInfo.ts +0 -44
- package/src/client/clmm/types/farmEmission.ts +0 -31
- package/src/client/clmm/types/index.ts +0 -48
- package/src/client/clmm/types/liquidityNetBalanceLimits.ts +0 -22
- package/src/client/clmm/types/lpFarm.ts +0 -12
- package/src/client/clmm/types/marketAccrueEmissionEvent.ts +0 -69
- package/src/client/clmm/types/marketAdminAction.ts +0 -239
- package/src/client/clmm/types/marketCollectEmissionEvent.ts +0 -83
- package/src/client/clmm/types/marketEmission.ts +0 -28
- package/src/client/clmm/types/marketEmissions.ts +0 -10
- package/src/client/clmm/types/marketFinancials.ts +0 -17
- package/src/client/clmm/types/marketThreeInitEvent.ts +0 -92
- package/src/client/clmm/types/mergeEvent.ts +0 -118
- package/src/client/clmm/types/modifiedTick.ts +0 -13
- package/src/client/clmm/types/modifiedTicks.ts +0 -18
- package/src/client/clmm/types/modifyFarmEvent.ts +0 -56
- package/src/client/clmm/types/number.ts +0 -7
- package/src/client/clmm/types/personalYieldTracker.ts +0 -12
- package/src/client/clmm/types/personalYieldTrackers.ts +0 -13
- package/src/client/clmm/types/principalShare.ts +0 -22
- package/src/client/clmm/types/principalShareTrackers.ts +0 -10
- package/src/client/clmm/types/sellPtEvent.ts +0 -36
- package/src/client/clmm/types/sellYtEvent.ts +0 -69
- package/src/client/clmm/types/stripEvent.ts +0 -124
- package/src/client/clmm/types/swapDirection.ts +0 -8
- package/src/client/clmm/types/tradePtEvent.ts +0 -76
- package/src/client/clmm/types/withdrawLiquidityEvent.ts +0 -99
- package/src/client/clmm/types/withdrawLiquidityReturnData.ts +0 -27
- package/src/client/clmm/types/wrapperBuyYtEvent.ts +0 -36
- package/src/client/clmm/types/wrapperProvideLiquidityBaseEvent.ts +0 -60
- package/src/client/clmm/types/wrapperProvideLiquidityClassicEvent.ts +0 -58
- package/src/client/clmm/types/wrapperProvideLiquidityEvent.ts +0 -60
- package/src/client/clmm/types/wrapperSellYtEvent.ts +0 -36
- package/src/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.ts +0 -62
- package/src/client/clmm/types/wrapperWithdrawLiquidityEvent.ts +0 -62
- package/src/client/core/accounts/admin.ts +0 -112
- package/src/client/core/accounts/lpPosition.ts +0 -122
- package/src/client/core/accounts/marketTwo.ts +0 -234
- package/src/client/core/accounts/vault.ts +0 -234
- package/src/client/core/accounts/yieldTokenPosition.ts +0 -126
- package/src/client/core/eventRegistry.ts +0 -134
- package/src/client/core/index.ts +0 -113
- package/src/client/core/instructions/addEmission.ts +0 -62
- package/src/client/core/instructions/addFarm.ts +0 -53
- package/src/client/core/instructions/addLpTokensMetadata.ts +0 -62
- package/src/client/core/instructions/addMarketEmission.ts +0 -52
- package/src/client/core/instructions/buyYt.ts +0 -79
- package/src/client/core/instructions/claimFarmEmissions.ts +0 -54
- package/src/client/core/instructions/collectEmission.ts +0 -66
- package/src/client/core/instructions/collectInterest.ts +0 -64
- package/src/client/core/instructions/collectTreasuryEmission.ts +0 -64
- package/src/client/core/instructions/collectTreasuryInterest.ts +0 -62
- package/src/client/core/instructions/depositYt.ts +0 -59
- package/src/client/core/instructions/initLpPosition.ts +0 -35
- package/src/client/core/instructions/initMarketTwo.ts +0 -103
- package/src/client/core/instructions/initializeVault.ts +0 -107
- package/src/client/core/instructions/initializeYieldPosition.ts +0 -33
- package/src/client/core/instructions/marketCollectEmission.ts +0 -55
- package/src/client/core/instructions/marketDepositLp.ts +0 -59
- package/src/client/core/instructions/marketTwoDepositLiquidity.ts +0 -65
- package/src/client/core/instructions/marketTwoWithdrawLiquidity.ts +0 -65
- package/src/client/core/instructions/marketWithdrawLp.ts +0 -59
- package/src/client/core/instructions/merge.ts +0 -61
- package/src/client/core/instructions/modifyFarm.ts +0 -51
- package/src/client/core/instructions/modifyMarketSetting.ts +0 -47
- package/src/client/core/instructions/modifyVaultSetting.ts +0 -44
- package/src/client/core/instructions/reallocMarket.ts +0 -45
- package/src/client/core/instructions/sellYt.ts +0 -79
- package/src/client/core/instructions/stageYtYield.ts +0 -39
- package/src/client/core/instructions/strip.ts +0 -61
- package/src/client/core/instructions/tradePt.ts +0 -59
- package/src/client/core/instructions/withdrawYt.ts +0 -61
- package/src/client/core/instructions/wrapperBuyPt.ts +0 -63
- package/src/client/core/instructions/wrapperBuyYt.ts +0 -93
- package/src/client/core/instructions/wrapperCollectInterest.ts +0 -63
- package/src/client/core/instructions/wrapperMerge.ts +0 -77
- package/src/client/core/instructions/wrapperProvideLiquidity.ts +0 -103
- package/src/client/core/instructions/wrapperProvideLiquidityBase.ts +0 -81
- package/src/client/core/instructions/wrapperProvideLiquidityClassic.ts +0 -77
- package/src/client/core/instructions/wrapperSellPt.ts +0 -63
- package/src/client/core/instructions/wrapperSellYt.ts +0 -87
- package/src/client/core/instructions/wrapperStrip.ts +0 -81
- package/src/client/core/instructions/wrapperWithdrawLiquidity.ts +0 -77
- package/src/client/core/instructions/wrapperWithdrawLiquidityClassic.ts +0 -73
- package/src/client/core/types/adminAction.ts +0 -255
- package/src/client/core/types/amount.ts +0 -51
- package/src/client/core/types/buyPtEvent.ts +0 -39
- package/src/client/core/types/buyYtEvent.ts +0 -95
- package/src/client/core/types/claimFarmEmissionsEvent.ts +0 -75
- package/src/client/core/types/claimFarmEmissionsEventV2.ts +0 -83
- package/src/client/core/types/claimLimits.ts +0 -15
- package/src/client/core/types/collectEmissionEvent.ts +0 -51
- package/src/client/core/types/collectEmissionEventV2.ts +0 -60
- package/src/client/core/types/collectInterestEvent.ts +0 -48
- package/src/client/core/types/collectInterestEventV2.ts +0 -57
- package/src/client/core/types/collectTreasuryEmissionKind.ts +0 -8
- package/src/client/core/types/collectTreasuryInterestKind.ts +0 -8
- package/src/client/core/types/cpiAccounts.ts +0 -21
- package/src/client/core/types/cpiInterfaceContext.ts +0 -13
- package/src/client/core/types/depositLiquidityEvent.ts +0 -101
- package/src/client/core/types/depositLpEvent.ts +0 -75
- package/src/client/core/types/depositLpEventV2.ts +0 -83
- package/src/client/core/types/depositYtEvent.ts +0 -82
- package/src/client/core/types/depositYtEventV2.ts +0 -91
- package/src/client/core/types/emissionInfo.ts +0 -44
- package/src/client/core/types/farmEmission.ts +0 -31
- package/src/client/core/types/index.ts +0 -60
- package/src/client/core/types/initLpPositionEvent.ts +0 -57
- package/src/client/core/types/initializeYieldPositionEvent.ts +0 -43
- package/src/client/core/types/liquidityNetBalanceLimits.ts +0 -22
- package/src/client/core/types/lpFarm.ts +0 -12
- package/src/client/core/types/marketAdminAction.ts +0 -212
- package/src/client/core/types/marketCollectEmissionEvent.ts +0 -67
- package/src/client/core/types/marketCollectEmissionEventV2.ts +0 -75
- package/src/client/core/types/marketEmission.ts +0 -28
- package/src/client/core/types/marketEmissions.ts +0 -10
- package/src/client/core/types/marketFinancials.ts +0 -19
- package/src/client/core/types/mergeEvent.ts +0 -118
- package/src/client/core/types/number.ts +0 -7
- package/src/client/core/types/personalYieldTracker.ts +0 -12
- package/src/client/core/types/personalYieldTrackers.ts +0 -13
- package/src/client/core/types/principleDetails.ts +0 -25
- package/src/client/core/types/principles.ts +0 -23
- package/src/client/core/types/sellPtEvent.ts +0 -39
- package/src/client/core/types/sellYtEvent.ts +0 -90
- package/src/client/core/types/stageYieldEvent.ts +0 -63
- package/src/client/core/types/stageYieldEventV2.ts +0 -69
- package/src/client/core/types/stripEvent.ts +0 -124
- package/src/client/core/types/tradePtEvent.ts +0 -80
- package/src/client/core/types/withdrawLiquidityEvent.ts +0 -97
- package/src/client/core/types/withdrawLpEvent.ts +0 -75
- package/src/client/core/types/withdrawLpEventV2.ts +0 -83
- package/src/client/core/types/withdrawYtEvent.ts +0 -82
- package/src/client/core/types/withdrawYtEventV2.ts +0 -91
- package/src/client/core/types/wrapperBuyYtEvent.ts +0 -39
- package/src/client/core/types/wrapperCollectInterestEvent.ts +0 -37
- package/src/client/core/types/wrapperMergeEvent.ts +0 -38
- package/src/client/core/types/wrapperProvideLiquidityBaseEvent.ts +0 -43
- package/src/client/core/types/wrapperProvideLiquidityClassicEvent.ts +0 -41
- package/src/client/core/types/wrapperProvideLiquidityEvent.ts +0 -41
- package/src/client/core/types/wrapperSellYtEvent.ts +0 -39
- package/src/client/core/types/wrapperStripEvent.ts +0 -38
- package/src/client/core/types/wrapperWithdrawLiquidityClassicEvent.ts +0 -41
- package/src/client/core/types/wrapperWithdrawLiquidityEvent.ts +0 -39
- package/src/client/core/types/yieldTokenTracker.ts +0 -12
- package/src/client/orderbook/accounts/cpiAccountsOrderbook.ts +0 -101
- package/src/client/orderbook/accounts/vault.ts +0 -234
- package/src/client/orderbook/eventRegistry.ts +0 -71
- package/src/client/orderbook/index.ts +0 -55
- package/src/client/orderbook/instructions/collectAdminEmission.ts +0 -48
- package/src/client/orderbook/instructions/collectAdminFee.ts +0 -59
- package/src/client/orderbook/instructions/collectInterest.ts +0 -66
- package/src/client/orderbook/instructions/initializeOrderbook.ts +0 -104
- package/src/client/orderbook/instructions/marketOffer.ts +0 -89
- package/src/client/orderbook/instructions/postOffer.ts +0 -96
- package/src/client/orderbook/instructions/reallocOrderbookAccount.ts +0 -45
- package/src/client/orderbook/instructions/removeExpiredOffers.ts +0 -37
- package/src/client/orderbook/instructions/removeOffer.ts +0 -73
- package/src/client/orderbook/instructions/setConfigurationOptions.ts +0 -43
- package/src/client/orderbook/instructions/withdrawFunds.ts +0 -78
- package/src/client/orderbook/instructions/wrapperCollectAdminFee.ts +0 -73
- package/src/client/orderbook/instructions/wrapperCollectInterest.ts +0 -65
- package/src/client/orderbook/instructions/wrapperMarketOffer.ts +0 -94
- package/src/client/orderbook/instructions/wrapperPostOffer.ts +0 -99
- package/src/client/orderbook/instructions/wrapperRemoveOffer.ts +0 -75
- package/src/client/orderbook/instructions/wrapperWithdrawFunds.ts +0 -80
- package/src/client/orderbook/types/amount.ts +0 -51
- package/src/client/orderbook/types/claimLimits.ts +0 -15
- package/src/client/orderbook/types/collectAdminEmissionEvent.ts +0 -39
- package/src/client/orderbook/types/collectAdminFeeEvent.ts +0 -17
- package/src/client/orderbook/types/collectEmissionEventV2.ts +0 -60
- package/src/client/orderbook/types/collectInterestEventV2.ts +0 -57
- package/src/client/orderbook/types/collectUserInterestEvent.ts +0 -36
- package/src/client/orderbook/types/cpiAccounts.ts +0 -21
- package/src/client/orderbook/types/cpiInterfaceContext.ts +0 -13
- package/src/client/orderbook/types/emissionInfo.ts +0 -44
- package/src/client/orderbook/types/exponentCoreCpiAccounts.ts +0 -21
- package/src/client/orderbook/types/filledOffersEvent.ts +0 -19
- package/src/client/orderbook/types/index.ts +0 -30
- package/src/client/orderbook/types/marketOfferEvent.ts +0 -72
- package/src/client/orderbook/types/mergeEvent.ts +0 -118
- package/src/client/orderbook/types/number.ts +0 -7
- package/src/client/orderbook/types/offerOptions.ts +0 -56
- package/src/client/orderbook/types/offerType.ts +0 -8
- package/src/client/orderbook/types/orderbookInitEvent.ts +0 -54
- package/src/client/orderbook/types/postOfferEvent.ts +0 -78
- package/src/client/orderbook/types/removeOfferEvent.ts +0 -67
- package/src/client/orderbook/types/setConfigurationOptionsEnum.ts +0 -116
- package/src/client/orderbook/types/stripEvent.ts +0 -124
- package/src/client/orderbook/types/withdrawFundsEvent.ts +0 -65
- package/src/client/orderbook/types/wrapperCollectAdminFeeEvent.ts +0 -13
- package/src/client/orderbook/types/wrapperCollectInterestEvent.ts +0 -25
- package/src/client/orderbook/types/wrapperMarketOfferEvent.ts +0 -27
- package/src/client/orderbook/types/wrapperPostOfferEvent.ts +0 -72
- package/src/client/orderbook/types/wrapperRemoveOfferEvent.ts +0 -25
- package/src/client/orderbook/types/wrapperWithdrawFundsEvent.ts +0 -38
- package/src/client/orderbook/types/yieldTokenTracker.ts +0 -12
- package/src/client/vaults/accounts/actionProposal.ts +0 -144
- package/src/client/vaults/accounts/exponentStrategyVault.ts +0 -211
- package/src/client/vaults/accounts/programConfig.ts +0 -123
- package/src/client/vaults/accounts/voteAccount.ts +0 -132
- package/src/client/vaults/accounts/withdrawalAccount.ts +0 -132
- package/src/client/vaults/eventRegistry.ts +0 -45
- package/src/client/vaults/index.ts +0 -113
- package/src/client/vaults/instructions/activateProposal.ts +0 -46
- package/src/client/vaults/instructions/addPolicy.ts +0 -57
- package/src/client/vaults/instructions/appendProposalActions.ts +0 -47
- package/src/client/vaults/instructions/cancelProposal.ts +0 -28
- package/src/client/vaults/instructions/cancelWithdrawal.ts +0 -34
- package/src/client/vaults/instructions/collectManagementFee.ts +0 -32
- package/src/client/vaults/instructions/depositLiquidity.ts +0 -62
- package/src/client/vaults/instructions/executeProposal.ts +0 -36
- package/src/client/vaults/instructions/executeWithdrawal.ts +0 -58
- package/src/client/vaults/instructions/executeWithdrawalFromReserves.ts +0 -66
- package/src/client/vaults/instructions/fillWithdrawal.ts +0 -59
- package/src/client/vaults/instructions/finalizeProposal.ts +0 -28
- package/src/client/vaults/instructions/initProposal.ts +0 -46
- package/src/client/vaults/instructions/initializePrices.ts +0 -28
- package/src/client/vaults/instructions/initializeVault.ts +0 -148
- package/src/client/vaults/instructions/makeSentienelManager.ts +0 -28
- package/src/client/vaults/instructions/managePrices.ts +0 -46
- package/src/client/vaults/instructions/manageVaultSettings.ts +0 -48
- package/src/client/vaults/instructions/managerUpdatePosition.ts +0 -45
- package/src/client/vaults/instructions/queueWithdrawal.ts +0 -50
- package/src/client/vaults/instructions/removePolicy.ts +0 -44
- package/src/client/vaults/instructions/sentinelSetVaultFlags.ts +0 -44
- package/src/client/vaults/instructions/stakeVote.ts +0 -57
- package/src/client/vaults/instructions/unstakeVote.ts +0 -42
- package/src/client/vaults/instructions/updatePolicy.ts +0 -59
- package/src/client/vaults/instructions/updatePolicyManager.ts +0 -44
- package/src/client/vaults/instructions/updatePrice.ts +0 -42
- package/src/client/vaults/instructions/validateInteractionHook.ts +0 -60
- package/src/client/vaults/instructions/wrapperAddPolicy.ts +0 -57
- package/src/client/vaults/instructions/wrapperExecuteWithdrawal.ts +0 -76
- package/src/client/vaults/instructions/wrapperManageVaultSettings.ts +0 -48
- package/src/client/vaults/instructions/wrapperManagerUpdatePosition.ts +0 -45
- package/src/client/vaults/instructions/wrapperRemovePolicy.ts +0 -44
- package/src/client/vaults/instructions/wrapperUpdatePolicy.ts +0 -59
- package/src/client/vaults/types/accountConstraint.ts +0 -35
- package/src/client/vaults/types/accountConstraintType.ts +0 -93
- package/src/client/vaults/types/allowedSettingsChange.ts +0 -136
- package/src/client/vaults/types/cancelProposalEvent.ts +0 -47
- package/src/client/vaults/types/clmmPositionEntry.ts +0 -37
- package/src/client/vaults/types/dataConstraint.ts +0 -16
- package/src/client/vaults/types/dataOperator.ts +0 -13
- package/src/client/vaults/types/dataValue.ts +0 -119
- package/src/client/vaults/types/depositLiquidityEvent.ts +0 -89
- package/src/client/vaults/types/executeProposalEvent.ts +0 -47
- package/src/client/vaults/types/executeWithdrawalEvent.ts +0 -12
- package/src/client/vaults/types/fillParam.ts +0 -12
- package/src/client/vaults/types/finalizeProposalEvent.ts +0 -51
- package/src/client/vaults/types/hook.ts +0 -40
- package/src/client/vaults/types/hookCompiledInstruction.ts +0 -20
- package/src/client/vaults/types/index.ts +0 -68
- package/src/client/vaults/types/instructionConstraint.ts +0 -33
- package/src/client/vaults/types/internalFundTransferPolicyCreationPayload.ts +0 -35
- package/src/client/vaults/types/kaminoFarmEntry.ts +0 -32
- package/src/client/vaults/types/kaminoObligationEntry.ts +0 -51
- package/src/client/vaults/types/limitedQuantityConstraints.ts +0 -10
- package/src/client/vaults/types/limitedSpendingLimit.ts +0 -35
- package/src/client/vaults/types/limitedTimeConstraints.ts +0 -15
- package/src/client/vaults/types/loopscaleLoanEntry.ts +0 -23
- package/src/client/vaults/types/loopscaleStrategyEntry.ts +0 -23
- package/src/client/vaults/types/number.ts +0 -8
- package/src/client/vaults/types/obligationType.ts +0 -63
- package/src/client/vaults/types/orderbookEntry.ts +0 -50
- package/src/client/vaults/types/periodV2.ts +0 -76
- package/src/client/vaults/types/permissions.ts +0 -8
- package/src/client/vaults/types/policyAction.ts +0 -74
- package/src/client/vaults/types/policyConfig.ts +0 -32
- package/src/client/vaults/types/policyCreationPayload.ts +0 -147
- package/src/client/vaults/types/policyExpirationArgs.ts +0 -67
- package/src/client/vaults/types/positionUpdate.ts +0 -313
- package/src/client/vaults/types/priceId.ts +0 -57
- package/src/client/vaults/types/priceType.ts +0 -23
- package/src/client/vaults/types/programInteractionPolicyCreationPayload.ts +0 -32
- package/src/client/vaults/types/proposalAction.ts +0 -97
- package/src/client/vaults/types/proposalActionKind.ts +0 -11
- package/src/client/vaults/types/proposalStatus.ts +0 -13
- package/src/client/vaults/types/proposalVoteConfig.ts +0 -36
- package/src/client/vaults/types/proposeActionEvent.ts +0 -62
- package/src/client/vaults/types/quantityConstraints.ts +0 -14
- package/src/client/vaults/types/reserveFarmMapping.ts +0 -35
- package/src/client/vaults/types/reservePriceMapping.ts +0 -26
- package/src/client/vaults/types/settingsChangePolicyCreationPayload.ts +0 -14
- package/src/client/vaults/types/spendingLimitPolicyCreationPayload.ts +0 -54
- package/src/client/vaults/types/stakeVoteEvent.ts +0 -54
- package/src/client/vaults/types/strategyPosition.ts +0 -178
- package/src/client/vaults/types/timeConstraints.ts +0 -22
- package/src/client/vaults/types/tokenAccountBalance.ts +0 -35
- package/src/client/vaults/types/tokenAccountEntry.ts +0 -30
- package/src/client/vaults/types/tokenEntry.ts +0 -48
- package/src/client/vaults/types/unstakeVoteEvent.ts +0 -53
- package/src/client/vaults/types/updatePriceAction.ts +0 -268
- package/src/client/vaults/types/updatePriceInput.ts +0 -12
- package/src/client/vaults/types/usageState.ts +0 -12
- package/src/client/vaults/types/vaultConfig.ts +0 -38
- package/src/client/vaults/types/vaultFinancials.ts +0 -40
- package/src/client/vaults/types/vaultFlagAction.ts +0 -75
- package/src/client/vaults/types/vaultFlagsUpdatedEvent.ts +0 -37
- package/src/client/vaults/types/vaultRoleKind.ts +0 -11
- package/src/client/vaults/types/vaultRoles.ts +0 -59
- package/src/client/vaults/types/vaultSettingsAction.ts +0 -533
- package/src/client/vaults/types/voteChoice.ts +0 -9
- package/src/client/vaults/types/withdrawalPeriodSettings.ts +0 -83
- package/src/client/vaults/types/withdrawalTokenFill.ts +0 -35
- package/src/client/vaults/types/yieldPositionEntry.ts +0 -35
- package/src/clmm/codamaEvents.ts +0 -34
- package/src/clmm/index.ts +0 -1
- package/src/codamaEvents.ts +0 -27
- package/src/environment.ts +0 -21
- package/src/exponentVaults/aumCalculator.ts +0 -1350
- package/src/exponentVaults/events.ts +0 -15
- package/src/exponentVaults/fetcher.ts +0 -257
- package/src/exponentVaults/index.ts +0 -322
- package/src/exponentVaults/kamino-farms.ts +0 -538
- package/src/exponentVaults/kamino-markets.ts +0 -363
- package/src/exponentVaults/loopscale/client.ts +0 -808
- package/src/exponentVaults/loopscale/helpers.ts +0 -172
- package/src/exponentVaults/loopscale/index.ts +0 -57
- package/src/exponentVaults/loopscale/prepared-transactions.ts +0 -435
- package/src/exponentVaults/loopscale/prepared-types.ts +0 -73
- package/src/exponentVaults/loopscale/types.ts +0 -466
- package/src/exponentVaults/policyBuilders.ts +0 -1729
- package/src/exponentVaults/policyMatcher.ts +0 -895
- package/src/exponentVaults/pricePathResolver.test.ts +0 -466
- package/src/exponentVaults/pricePathResolver.ts +0 -273
- package/src/exponentVaults/scope-refresh.ts +0 -169
- package/src/exponentVaults/squadsVaultTxnResolver/constants.ts +0 -59
- package/src/exponentVaults/squadsVaultTxnResolver/helpers.ts +0 -355
- package/src/exponentVaults/squadsVaultTxnResolver/index.ts +0 -16
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.ts +0 -472
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.ts +0 -33
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/index.ts +0 -38
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.ts +0 -83
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.ts +0 -94
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/titan.ts +0 -41
- package/src/exponentVaults/squadsVaultTxnResolver/squadsVaultTxnResolver.ts +0 -91
- package/src/exponentVaults/squadsVaultTxnResolver/types.ts +0 -171
- package/src/exponentVaults/squadsVaultTxnResolver/utils.ts +0 -3
- package/src/exponentVaults/syncTransaction.ts +0 -500
- package/src/exponentVaults/titan-quote.ts +0 -446
- package/src/exponentVaults/vault-instruction-types.ts +0 -493
- package/src/exponentVaults/vault-interaction.ts +0 -5070
- package/src/exponentVaults/vault.ts +0 -2667
- package/src/exponentVaults/vaultTransactionBuilder.test.ts +0 -256
- package/src/exponentVaults/vaultTransactionBuilder.ts +0 -927
- package/src/flavors.ts +0 -841
- package/src/index.ts +0 -26
- package/src/lpPosition.ts +0 -155
- package/src/market.ts +0 -2432
- package/src/marketThree.test.ts +0 -210
- package/src/marketThree.ts +0 -2861
- package/src/orderbook/codamaEvents.ts +0 -28
- package/src/orderbook/index.ts +0 -13
- package/src/orderbook/math.ts +0 -138
- package/src/orderbook/orderbook.ts +0 -1354
- package/src/orderbook/types.ts +0 -40
- package/src/orderbook/utils.ts +0 -66
- package/src/router.ts +0 -810
- package/src/syPosition.ts +0 -182
- package/src/tokenUtil.ts +0 -23
- package/src/utils/altUtil.ts +0 -52
- package/src/utils/binSolver.test.ts +0 -17
- package/src/utils/binSolver.ts +0 -44
- package/src/utils/index.ts +0 -33
- package/src/utils/ix.ts +0 -7
- package/src/vault.ts +0 -1033
- package/src/ytPosition.ts +0 -319
- package/tsconfig.json +0 -46
|
@@ -1,1350 +0,0 @@
|
|
|
1
|
-
import { MintLayout } from "@solana/spl-token"
|
|
2
|
-
import { Connection, PublicKey } from "@solana/web3.js"
|
|
3
|
-
import BN from "bn.js"
|
|
4
|
-
import Decimal from "decimal.js"
|
|
5
|
-
|
|
6
|
-
import { ExponentFetcher } from "@exponent-labs/exponent-fetcher"
|
|
7
|
-
import { ExponentPDA } from "@exponent-labs/exponent-pda"
|
|
8
|
-
import type {
|
|
9
|
-
ExponentPrice,
|
|
10
|
-
ExponentPrices,
|
|
11
|
-
ExponentVault as ExponentVaultAccountType,
|
|
12
|
-
PriceId,
|
|
13
|
-
StrategyPosition,
|
|
14
|
-
} from "@exponent-labs/exponent-vaults-fetcher"
|
|
15
|
-
import { Fraction, Obligation, Reserve } from "@exponent-labs/kamino-reserve-deserializer"
|
|
16
|
-
import { Loan as LoopscaleLoan, Strategy as LoopscaleStrategy } from "@exponent-labs/loopscale-deserializer"
|
|
17
|
-
|
|
18
|
-
import { Environment, LOCAL_ENV } from "../environment"
|
|
19
|
-
import {
|
|
20
|
-
KAMINO_FARM_ACCOUNT_DISCRIMINATOR_LEN,
|
|
21
|
-
KAMINO_FARM_GLOBAL_CONFIG_TREASURY_FEE_BPS_OFFSET,
|
|
22
|
-
applyKaminoFarmTreasuryFee,
|
|
23
|
-
calculateKaminoFarmPrincipalAmount,
|
|
24
|
-
decodeKaminoFarmState,
|
|
25
|
-
decodeKaminoFarmUserState,
|
|
26
|
-
decodeKaminoScopeDatedPrice,
|
|
27
|
-
getKaminoFarmScopePricesAddress,
|
|
28
|
-
projectKaminoFarmGlobalRewards,
|
|
29
|
-
projectKaminoFarmUserRewards,
|
|
30
|
-
} from "./kamino-farms"
|
|
31
|
-
import { getKaminoFarmsObligationFarm, KAMINO_FARMS_PROGRAM_ID } from "./../../../kamino-lend-standard/src/constants"
|
|
32
|
-
|
|
33
|
-
// ============================================================================
|
|
34
|
-
// Types
|
|
35
|
-
// ============================================================================
|
|
36
|
-
|
|
37
|
-
export enum PositionType {
|
|
38
|
-
Reserves = "reserves",
|
|
39
|
-
TokenAccount = "tokenAccount",
|
|
40
|
-
Orderbook = "orderbook",
|
|
41
|
-
YieldPosition = "yieldPosition",
|
|
42
|
-
KaminoObligation = "kaminoObligation",
|
|
43
|
-
ClmmPosition = "clmmPosition",
|
|
44
|
-
LoopscaleLoan = "loopscaleLoan",
|
|
45
|
-
LoopscaleStrategy = "loopscaleStrategy",
|
|
46
|
-
KaminoFarm = "kaminoFarm",
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type AumResult = {
|
|
50
|
-
positionType: PositionType
|
|
51
|
-
mint: string
|
|
52
|
-
aum: bigint
|
|
53
|
-
/** Exists only for PositionType.KaminoObligation */
|
|
54
|
-
kaminoObligationExposure?: Array<{
|
|
55
|
-
mint: string
|
|
56
|
-
amount: bigint // negative for borrowed, positive for supplied; value is in raw base units like `aum`
|
|
57
|
-
}>
|
|
58
|
-
/** Exists only for PositionType.LoopscaleLoan */
|
|
59
|
-
loopscaleLoanExposure?: Array<{
|
|
60
|
-
mint: string
|
|
61
|
-
amount: bigint // negative for debt, positive for collateral; value is in raw base units like `aum`
|
|
62
|
-
}>
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
type TokenAccountEntryTyped = {
|
|
66
|
-
tokenMint: PublicKey
|
|
67
|
-
balances: Array<{ tokenAccount: PublicKey; priceId: PriceId }>
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type OrderbookEntryTyped = {
|
|
71
|
-
orderbook: PublicKey
|
|
72
|
-
mint: PublicKey
|
|
73
|
-
offerIdxVec: number[]
|
|
74
|
-
priceIdPt: PriceId
|
|
75
|
-
baseMint: PublicKey
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type YieldPositionEntryTyped = {
|
|
79
|
-
yieldPosition: PublicKey
|
|
80
|
-
vault: PublicKey
|
|
81
|
-
priceIdPt: PriceId
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
type ObligationEntryTyped = {
|
|
85
|
-
obligation: PublicKey
|
|
86
|
-
lendingProgramId: PublicKey
|
|
87
|
-
quotePriceId: PriceId
|
|
88
|
-
reservePriceMappings: Array<{ reserve: PublicKey; reservePriceId: PriceId }>
|
|
89
|
-
reserveFarmMappings: Array<{
|
|
90
|
-
reserve: PublicKey
|
|
91
|
-
farmKind: number
|
|
92
|
-
farmState: PublicKey
|
|
93
|
-
}>
|
|
94
|
-
minPriceStatusFlags: number
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
type ClmmPositionEntryTyped = {
|
|
98
|
-
lpPosition: PublicKey
|
|
99
|
-
market: PublicKey
|
|
100
|
-
priceIdPt: PriceId
|
|
101
|
-
priceIdSy: PriceId
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
type LoopscaleLoanEntryTyped = {
|
|
105
|
-
loan: PublicKey
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
type LoopscaleStrategyEntryTyped = {
|
|
109
|
-
strategy: PublicKey
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
type KaminoFarmEntryTyped = {
|
|
113
|
-
farmState: PublicKey
|
|
114
|
-
userState: PublicKey
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
type TokenEntryTyped = {
|
|
118
|
-
mint: PublicKey
|
|
119
|
-
priceId: PriceId
|
|
120
|
-
tokenSquadsAccount: PublicKey
|
|
121
|
-
tokenAccountVault: PublicKey
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
type ValuationClock = {
|
|
125
|
-
currentSlot: bigint
|
|
126
|
-
currentUnixTimestamp: bigint
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// ============================================================================
|
|
130
|
-
// Constants
|
|
131
|
-
// ============================================================================
|
|
132
|
-
|
|
133
|
-
const PRECISE_NUMBER_DECIMALS = 12
|
|
134
|
-
const PRECISE_NUMBER_SCALE = new Decimal(10).pow(PRECISE_NUMBER_DECIMALS)
|
|
135
|
-
const DEFAULT_PUBLIC_KEY = PublicKey.default
|
|
136
|
-
const KAMINO_RESERVE_FARM_KIND_COLLATERAL = 0
|
|
137
|
-
const KAMINO_RESERVE_FARM_KIND_DEBT = 1
|
|
138
|
-
|
|
139
|
-
// ============================================================================
|
|
140
|
-
// AumCalculator
|
|
141
|
-
// ============================================================================
|
|
142
|
-
|
|
143
|
-
export class AumCalculator {
|
|
144
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
-
private clmmMarketCache = new Map<string, Promise<any>>()
|
|
146
|
-
private mintDecimalsCache = new Map<string, Promise<number>>()
|
|
147
|
-
|
|
148
|
-
constructor(
|
|
149
|
-
private state: ExponentVaultAccountType,
|
|
150
|
-
private connection: Connection,
|
|
151
|
-
private env: Environment = LOCAL_ENV,
|
|
152
|
-
) {}
|
|
153
|
-
|
|
154
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
|
-
private async loadClmmMarket(market: PublicKey): Promise<any> {
|
|
156
|
-
const key = market.toBase58()
|
|
157
|
-
let cached = this.clmmMarketCache.get(key)
|
|
158
|
-
if (!cached) {
|
|
159
|
-
cached = (async () => {
|
|
160
|
-
const { MarketThree } = await import("../marketThree")
|
|
161
|
-
return MarketThree.load(this.env, this.connection, market)
|
|
162
|
-
})()
|
|
163
|
-
this.clmmMarketCache.set(key, cached)
|
|
164
|
-
}
|
|
165
|
-
return cached
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Total AUM: on-chain tracked base value + value held in strategy positions.
|
|
170
|
-
*/
|
|
171
|
-
getTotalAum(): bigint {
|
|
172
|
-
return (
|
|
173
|
-
BigInt(this.state.financials.aumInBase.toString()) + BigInt(this.state.financials.aumInBaseInPositions.toString())
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// ==========================================================================
|
|
178
|
-
// Price resolution
|
|
179
|
-
// ==========================================================================
|
|
180
|
-
|
|
181
|
-
static priceEntryToDecimal(entry: ExponentPrice): Decimal {
|
|
182
|
-
const [n0, n1, n2, n3] = entry.price[0]
|
|
183
|
-
const raw =
|
|
184
|
-
BigInt(n0.toString()) +
|
|
185
|
-
(BigInt(n1.toString()) << BigInt(64)) +
|
|
186
|
-
(BigInt(n2.toString()) << BigInt(128)) +
|
|
187
|
-
(BigInt(n3.toString()) << BigInt(192))
|
|
188
|
-
return new Decimal(raw.toString()).div(PRECISE_NUMBER_SCALE)
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
static resolvePrice(priceId: PriceId, prices: ExponentPrices): Decimal {
|
|
192
|
-
const getPrice = (id: bigint): Decimal => {
|
|
193
|
-
const entry = prices.prices[Number(id)]
|
|
194
|
-
if (!entry) {
|
|
195
|
-
throw new Error(`Price not found for id ${id}`)
|
|
196
|
-
}
|
|
197
|
-
return AumCalculator.priceEntryToDecimal(entry)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if ("simple" in priceId) {
|
|
201
|
-
return getPrice(priceId.simple.priceId)
|
|
202
|
-
}
|
|
203
|
-
if ("multiply" in priceId) {
|
|
204
|
-
const ids = priceId.multiply.priceIds
|
|
205
|
-
if (ids.length === 0) {
|
|
206
|
-
throw new Error("Multiply priceIds cannot be empty")
|
|
207
|
-
}
|
|
208
|
-
let acc = getPrice(ids[0])
|
|
209
|
-
for (const id of ids.slice(1)) {
|
|
210
|
-
acc = acc.mul(getPrice(id))
|
|
211
|
-
}
|
|
212
|
-
return acc
|
|
213
|
-
}
|
|
214
|
-
throw new Error("Unknown PriceId variant")
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
static decimalFloorToBigInt(value: Decimal | bigint | number | string): bigint {
|
|
218
|
-
const decimalValue = value instanceof Decimal ? value : new Decimal(value.toString())
|
|
219
|
-
return BigInt(decimalValue.floor().toFixed(0))
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
static getPriceIds(priceId: PriceId): bigint[] {
|
|
223
|
-
if ("simple" in priceId) {
|
|
224
|
-
return [priceId.simple.priceId]
|
|
225
|
-
}
|
|
226
|
-
if ("multiply" in priceId) {
|
|
227
|
-
const ids = priceId.multiply.priceIds
|
|
228
|
-
if (ids.length === 0) {
|
|
229
|
-
throw new Error("Multiply priceIds cannot be empty")
|
|
230
|
-
}
|
|
231
|
-
return ids
|
|
232
|
-
}
|
|
233
|
-
throw new Error("Unknown PriceId variant")
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
static projectYieldPositionClaimableInterestAfterFee(
|
|
237
|
-
yieldPosition: { ytBalance: bigint; interest: { staged: bigint; lastSeenIndex: number } },
|
|
238
|
-
coreVault: { finalSyExchangeRate: number; lastSeenSyExchangeRate: number; interestBpsFee: number },
|
|
239
|
-
): bigint {
|
|
240
|
-
const projectedUnstagedInterest = AumCalculator.scaleSyToCurrentRate(
|
|
241
|
-
AumCalculator.calcEarnedSy(
|
|
242
|
-
yieldPosition.ytBalance,
|
|
243
|
-
yieldPosition.interest.lastSeenIndex,
|
|
244
|
-
coreVault.finalSyExchangeRate,
|
|
245
|
-
),
|
|
246
|
-
coreVault.finalSyExchangeRate,
|
|
247
|
-
coreVault.lastSeenSyExchangeRate,
|
|
248
|
-
)
|
|
249
|
-
const grossClaimableInterest = yieldPosition.interest.staged + projectedUnstagedInterest
|
|
250
|
-
const treasuryAmount = (grossClaimableInterest * BigInt(coreVault.interestBpsFee) + BigInt(9_999)) / BigInt(10_000)
|
|
251
|
-
return grossClaimableInterest - treasuryAmount
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
static calcEarnedSy(ytBalance: bigint, lastSeenRate: number, currentRate: number): bigint {
|
|
255
|
-
if (ytBalance === BigInt(0) || lastSeenRate >= currentRate || lastSeenRate === 0) {
|
|
256
|
-
return BigInt(0)
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const delta = new Decimal(1).div(lastSeenRate).sub(new Decimal(1).div(currentRate))
|
|
260
|
-
return AumCalculator.decimalFloorToBigInt(delta.mul(ytBalance.toString()))
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
static scaleSyToCurrentRate(syAmount: bigint, finalRate: number, currentRate: number): bigint {
|
|
264
|
-
if (syAmount === BigInt(0) || currentRate <= finalRate) {
|
|
265
|
-
return syAmount
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return AumCalculator.decimalFloorToBigInt(new Decimal(syAmount.toString()).mul(finalRate).div(currentRate))
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
private async loadMintDecimals(mint: PublicKey): Promise<number> {
|
|
272
|
-
const key = mint.toBase58()
|
|
273
|
-
let cached = this.mintDecimalsCache.get(key)
|
|
274
|
-
if (!cached) {
|
|
275
|
-
cached = (async () => {
|
|
276
|
-
const mintInfo = await this.connection.getAccountInfo(mint)
|
|
277
|
-
if (!mintInfo?.data) {
|
|
278
|
-
throw new Error(`Mint not found: ${mint.toBase58()}`)
|
|
279
|
-
}
|
|
280
|
-
return MintLayout.decode(Buffer.from(mintInfo.data)).decimals
|
|
281
|
-
})()
|
|
282
|
-
this.mintDecimalsCache.set(key, cached)
|
|
283
|
-
}
|
|
284
|
-
return cached
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
private async getCurrentValuationClock(): Promise<ValuationClock> {
|
|
288
|
-
const currentSlot = BigInt(await this.connection.getSlot("confirmed"))
|
|
289
|
-
const blockTime = await this.connection.getBlockTime(Number(currentSlot))
|
|
290
|
-
return {
|
|
291
|
-
currentSlot,
|
|
292
|
-
currentUnixTimestamp: BigInt(blockTime ?? Math.floor(Date.now() / 1000)),
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
private getPriceInputMint(priceId: PriceId, prices: ExponentPrices): PublicKey {
|
|
297
|
-
const ids = AumCalculator.getPriceIds(priceId)
|
|
298
|
-
const lastEntry = prices.prices[Number(ids[ids.length - 1])]
|
|
299
|
-
if (!lastEntry) {
|
|
300
|
-
throw new Error(`Price not found for id ${ids[ids.length - 1]}`)
|
|
301
|
-
}
|
|
302
|
-
return lastEntry.priceMint
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private async resolveInputAmountScale(priceId: PriceId, prices: ExponentPrices): Promise<Decimal> {
|
|
306
|
-
const inputMint = this.getPriceInputMint(priceId, prices)
|
|
307
|
-
const inputDecimals = await this.loadMintDecimals(inputMint)
|
|
308
|
-
return new Decimal(10).pow(inputDecimals)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// ==========================================================================
|
|
312
|
-
// Token account balance parsing
|
|
313
|
-
// ==========================================================================
|
|
314
|
-
|
|
315
|
-
/** Read SPL token amount from account data (offset 64 = after mint(32) + owner(32)) */
|
|
316
|
-
static parseTokenAccountAmount(data: Buffer | Uint8Array): bigint {
|
|
317
|
-
const u8 = data instanceof Uint8Array ? data : new Uint8Array(data)
|
|
318
|
-
if (u8.byteLength < 72) {
|
|
319
|
-
throw new Error("SPL token account data too short")
|
|
320
|
-
}
|
|
321
|
-
return new DataView(u8.buffer, u8.byteOffset, u8.byteLength).getBigUint64(64, true)
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
static parseU128LE(data: Buffer, offset: number): bigint {
|
|
325
|
-
const lo = data.readBigUInt64LE(offset)
|
|
326
|
-
const hi = data.readBigUInt64LE(offset + 8)
|
|
327
|
-
return lo + (hi << 64n)
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ==========================================================================
|
|
331
|
-
// AUM calculation per position type
|
|
332
|
-
// ==========================================================================
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* TokenAccount position AUM.
|
|
336
|
-
* Fetches each token account balance and multiplies by resolved price.
|
|
337
|
-
*/
|
|
338
|
-
async calculateTokenAccountAum(entry: TokenAccountEntryTyped, prices: ExponentPrices): Promise<AumResult[]> {
|
|
339
|
-
const results: AumResult[] = []
|
|
340
|
-
|
|
341
|
-
if (entry.balances.length === 0) {
|
|
342
|
-
return results
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const accountKeys = entry.balances.map((b) => b.tokenAccount)
|
|
346
|
-
const accountInfos = await this.connection.getMultipleAccountsInfo(accountKeys)
|
|
347
|
-
|
|
348
|
-
let totalAum = BigInt(0)
|
|
349
|
-
for (let i = 0; i < entry.balances.length; i++) {
|
|
350
|
-
const balance = entry.balances[i]
|
|
351
|
-
const info = accountInfos[i]
|
|
352
|
-
if (!info?.data) {
|
|
353
|
-
continue
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
try {
|
|
357
|
-
const tokenAmount = AumCalculator.parseTokenAccountAmount(Buffer.from(info.data))
|
|
358
|
-
const price = AumCalculator.resolvePrice(balance.priceId, prices)
|
|
359
|
-
const valueInBase = new Decimal(tokenAmount.toString()).mul(price)
|
|
360
|
-
totalAum += AumCalculator.decimalFloorToBigInt(valueInBase)
|
|
361
|
-
} catch {
|
|
362
|
-
// Skip if price resolution fails
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
results.push({ positionType: PositionType.TokenAccount, mint: entry.tokenMint.toBase58(), aum: totalAum })
|
|
367
|
-
return results
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Orderbook position AUM.
|
|
372
|
-
* Reads SY exchange rate from raw bytes, iterates tracked offers,
|
|
373
|
-
* and calculates SY value per offer following the Rust logic.
|
|
374
|
-
*/
|
|
375
|
-
async calculateOrderbookAum(entry: OrderbookEntryTyped, prices: ExponentPrices): Promise<AumResult[]> {
|
|
376
|
-
try {
|
|
377
|
-
const fetcher = new ExponentFetcher({ connection: this.connection })
|
|
378
|
-
const orderbook = await fetcher.fetchOrderbook(entry.orderbook)
|
|
379
|
-
|
|
380
|
-
const syPrice = new Decimal(orderbook.lastSyExchangeRate.toString()).div(PRECISE_NUMBER_SCALE)
|
|
381
|
-
const ptPrice = AumCalculator.resolvePrice(entry.priceIdPt, prices)
|
|
382
|
-
const ytPrice = Decimal.max(new Decimal(1).sub(ptPrice), new Decimal(0))
|
|
383
|
-
const mintPt = new ExponentPDA().mintPt({ vault: orderbook.vault }).toBase58()
|
|
384
|
-
const mintYt = new ExponentPDA().mintYt({ vault: orderbook.vault }).toBase58()
|
|
385
|
-
|
|
386
|
-
// Find vault's user escrow indices by matching squadsVault address
|
|
387
|
-
const vaultEscrowIndices = new Set<number>()
|
|
388
|
-
for (let i = 0; i < orderbook.userEscrows.length; i++) {
|
|
389
|
-
if (orderbook.userEscrows[i].user.equals(this.state.squadsVault)) {
|
|
390
|
-
vaultEscrowIndices.add(i + 1)
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const aumByMint = new Map<string, Decimal>()
|
|
395
|
-
|
|
396
|
-
for (const offerIdx of entry.offerIdxVec) {
|
|
397
|
-
const offer = orderbook.offers.find((o) => o.offerIndex === offerIdx)
|
|
398
|
-
if (!offer) {
|
|
399
|
-
continue
|
|
400
|
-
}
|
|
401
|
-
if (!vaultEscrowIndices.has(offer.userVaultPointer)) {
|
|
402
|
-
continue
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
const offerMint = entry.mint.toBase58()
|
|
406
|
-
|
|
407
|
-
const syInOffer = AumCalculator.getSyInOffer(offer, ptPrice, syPrice)
|
|
408
|
-
const valueInBase = syInOffer.mul(syPrice)
|
|
409
|
-
aumByMint.set(offerMint, (aumByMint.get(offerMint) ?? new Decimal(0)).add(valueInBase))
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
const userEscrow = orderbook.userEscrows.find((escrow) => escrow.user.equals(this.state.squadsVault))
|
|
413
|
-
if (userEscrow) {
|
|
414
|
-
const stagedSy = AumCalculator.projectOrderbookStagedSy(userEscrow, syPrice)
|
|
415
|
-
AumCalculator.addOrderbookEscrowValue(aumByMint, entry.mint.toBase58(), userEscrow.syAmount + stagedSy, syPrice)
|
|
416
|
-
AumCalculator.addOrderbookEscrowValue(aumByMint, mintPt, userEscrow.ptAmount, ptPrice)
|
|
417
|
-
AumCalculator.addOrderbookEscrowValue(aumByMint, mintYt, userEscrow.ytAmount, ytPrice)
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return Array.from(aumByMint.entries()).map(([mint, aum]) => ({
|
|
421
|
-
positionType: PositionType.Orderbook,
|
|
422
|
-
mint,
|
|
423
|
-
aum: AumCalculator.decimalFloorToBigInt(aum),
|
|
424
|
-
}))
|
|
425
|
-
} catch (e) {
|
|
426
|
-
console.warn("Failed to calculate orderbook AUM:", e)
|
|
427
|
-
return []
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
private static addOrderbookEscrowValue(
|
|
432
|
-
aumByMint: Map<string, Decimal>,
|
|
433
|
-
mint: string,
|
|
434
|
-
amount: bigint,
|
|
435
|
-
price: Decimal,
|
|
436
|
-
): void {
|
|
437
|
-
if (amount <= BigInt(0) || price.lte(0)) {
|
|
438
|
-
return
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
const valueInBase = new Decimal(amount.toString()).mul(price)
|
|
442
|
-
aumByMint.set(mint, (aumByMint.get(mint) ?? new Decimal(0)).add(valueInBase))
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
private static projectOrderbookStagedSy(
|
|
446
|
-
userEscrow: {
|
|
447
|
-
staged: bigint
|
|
448
|
-
stakedYtAmount: bigint
|
|
449
|
-
yieldIndex: number
|
|
450
|
-
},
|
|
451
|
-
currentSyRate: Decimal,
|
|
452
|
-
): bigint {
|
|
453
|
-
if (userEscrow.staged < BigInt(0)) {
|
|
454
|
-
return BigInt(0)
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
const lastSeenSyRate = userEscrow.yieldIndex
|
|
458
|
-
if (lastSeenSyRate <= 0) {
|
|
459
|
-
return userEscrow.staged
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
const currentSyRateNumber = currentSyRate.toNumber()
|
|
463
|
-
if (currentSyRateNumber <= lastSeenSyRate) {
|
|
464
|
-
return userEscrow.staged
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const rateDelta = 1 / lastSeenSyRate - 1 / currentSyRateNumber
|
|
468
|
-
const interestEarned = Math.floor(rateDelta * Number(userEscrow.stakedYtAmount))
|
|
469
|
-
return userEscrow.staged + BigInt(Math.max(interestEarned, 0))
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Calculate the SY-equivalent amount in an offer.
|
|
474
|
-
* Mirrors Rust get_sy_in_offer() logic.
|
|
475
|
-
*/
|
|
476
|
-
static getSyInOffer(
|
|
477
|
-
offer: { amount: bigint; virtualOffer: boolean; orderTypeFlag: number },
|
|
478
|
-
ptPrice: Decimal,
|
|
479
|
-
syExchangeRate: Decimal,
|
|
480
|
-
): Decimal {
|
|
481
|
-
const amount = new Decimal(offer.amount.toString())
|
|
482
|
-
const isBuyYt = offer.orderTypeFlag === 2
|
|
483
|
-
|
|
484
|
-
if (offer.virtualOffer) {
|
|
485
|
-
if (isBuyYt) {
|
|
486
|
-
// PT in offer -> convert to SY
|
|
487
|
-
return amount.mul(ptPrice).div(syExchangeRate)
|
|
488
|
-
} else {
|
|
489
|
-
// SY in offer directly
|
|
490
|
-
return amount
|
|
491
|
-
}
|
|
492
|
-
} else {
|
|
493
|
-
if (isBuyYt) {
|
|
494
|
-
// SY in offer directly
|
|
495
|
-
return amount
|
|
496
|
-
} else {
|
|
497
|
-
// YT in offer -> convert to SY
|
|
498
|
-
const ytToSyRate = new Decimal(1).sub(ptPrice).div(syExchangeRate)
|
|
499
|
-
return amount.mul(ytToSyRate)
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* YieldPosition AUM (Exponent core YT).
|
|
506
|
-
* YT value = yt_balance * (1 - pt_price)
|
|
507
|
-
*/
|
|
508
|
-
async calculateYieldPositionAum(entry: YieldPositionEntryTyped, prices: ExponentPrices): Promise<AumResult> {
|
|
509
|
-
const ytMint = new ExponentPDA().mintYt({ vault: entry.vault }).toBase58()
|
|
510
|
-
|
|
511
|
-
try {
|
|
512
|
-
const fetcher = new ExponentFetcher({ connection: this.connection })
|
|
513
|
-
const [yieldPosition, coreVault] = await Promise.all([
|
|
514
|
-
fetcher.fetchYtPosition(entry.yieldPosition),
|
|
515
|
-
fetcher.fetchVault(entry.vault),
|
|
516
|
-
])
|
|
517
|
-
|
|
518
|
-
if (!yieldPosition) {
|
|
519
|
-
return { positionType: PositionType.YieldPosition, mint: ytMint, aum: BigInt(0) }
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const ptPrice = AumCalculator.resolvePrice(entry.priceIdPt, prices)
|
|
523
|
-
const ytValueFactor = new Decimal(1).sub(ptPrice)
|
|
524
|
-
let valueInBase = new Decimal(0)
|
|
525
|
-
|
|
526
|
-
if (ytValueFactor.gt(0)) {
|
|
527
|
-
valueInBase = valueInBase.add(new Decimal(yieldPosition.ytBalance.toString()).mul(ytValueFactor))
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (yieldPosition.ytBalance > BigInt(0) || yieldPosition.interest.staged > BigInt(0)) {
|
|
531
|
-
const netClaimableInterest = AumCalculator.projectYieldPositionClaimableInterestAfterFee(
|
|
532
|
-
yieldPosition,
|
|
533
|
-
coreVault,
|
|
534
|
-
)
|
|
535
|
-
valueInBase = valueInBase.add(
|
|
536
|
-
new Decimal(netClaimableInterest.toString()).mul(new Decimal(coreVault.lastSeenSyExchangeRate.toString())),
|
|
537
|
-
)
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
return { positionType: PositionType.YieldPosition, mint: ytMint, aum: AumCalculator.decimalFloorToBigInt(valueInBase) }
|
|
541
|
-
} catch (e) {
|
|
542
|
-
console.warn("Failed to calculate yield position AUM:", e)
|
|
543
|
-
return { positionType: PositionType.YieldPosition, mint: ytMint, aum: BigInt(0) }
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Kamino obligation position AUM.
|
|
549
|
-
* AUM = sum(collateral market values in base) - sum(debt market values in base).
|
|
550
|
-
*
|
|
551
|
-
* In practice, obligation marketValueSf values are stale for our use case, so
|
|
552
|
-
* we derive each side directly from the current Kamino Reserve accounts.
|
|
553
|
-
*/
|
|
554
|
-
async calculateObligationAum(
|
|
555
|
-
entry: ObligationEntryTyped,
|
|
556
|
-
prices: ExponentPrices,
|
|
557
|
-
valuationClock: ValuationClock,
|
|
558
|
-
): Promise<AumResult> {
|
|
559
|
-
try {
|
|
560
|
-
const obligation = await Obligation.fetch(this.connection, entry.obligation, entry.lendingProgramId)
|
|
561
|
-
if (!obligation) {
|
|
562
|
-
return {
|
|
563
|
-
positionType: PositionType.KaminoObligation,
|
|
564
|
-
mint: this.state.underlyingMint.toBase58(),
|
|
565
|
-
aum: BigInt(0),
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
const defaultKey = PublicKey.default
|
|
570
|
-
|
|
571
|
-
// Filter active deposits (collateral)
|
|
572
|
-
const collateralValues = obligation.deposits
|
|
573
|
-
.filter((d) => !d.depositReserve.equals(defaultKey) && !d.depositedAmount.isZero())
|
|
574
|
-
.map((d) => ({
|
|
575
|
-
reserve: d.depositReserve,
|
|
576
|
-
rawAmount: d.depositedAmount,
|
|
577
|
-
isDeposit: true as const,
|
|
578
|
-
}))
|
|
579
|
-
|
|
580
|
-
// Filter active borrows (debt)
|
|
581
|
-
const debtValues = obligation.borrows
|
|
582
|
-
.filter((b) => !b.borrowReserve.equals(defaultKey) && !b.borrowedAmountSf.isZero())
|
|
583
|
-
.map((b) => ({
|
|
584
|
-
reserve: b.borrowReserve,
|
|
585
|
-
rawAmount: b.borrowedAmountSf,
|
|
586
|
-
isDeposit: false as const,
|
|
587
|
-
}))
|
|
588
|
-
|
|
589
|
-
const allValues = [...collateralValues, ...debtValues]
|
|
590
|
-
let reserveMap: Map<string, Reserve> | undefined
|
|
591
|
-
const reserveKeysToFetch = new Set<string>()
|
|
592
|
-
for (const value of allValues) {
|
|
593
|
-
reserveKeysToFetch.add(value.reserve.toBase58())
|
|
594
|
-
}
|
|
595
|
-
for (const mapping of entry.reservePriceMappings) {
|
|
596
|
-
reserveKeysToFetch.add(mapping.reserve.toBase58())
|
|
597
|
-
}
|
|
598
|
-
for (const reserveFarmMapping of entry.reserveFarmMappings ?? []) {
|
|
599
|
-
reserveKeysToFetch.add(reserveFarmMapping.reserve.toBase58())
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (reserveKeysToFetch.size > 0) {
|
|
603
|
-
const uniqueReserves = Array.from(reserveKeysToFetch)
|
|
604
|
-
const reserveKeys = uniqueReserves.map((k) => new PublicKey(k))
|
|
605
|
-
const reserves = await Reserve.fetchMultiple(this.connection, reserveKeys, entry.lendingProgramId)
|
|
606
|
-
reserveMap = new Map()
|
|
607
|
-
for (let i = 0; i < reserveKeys.length; i++) {
|
|
608
|
-
if (reserves[i]) {
|
|
609
|
-
reserveMap.set(reserveKeys[i].toBase58(), reserves[i]!)
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
const kaminoObligationExposure = await this.buildKaminoObligationExposure(
|
|
615
|
-
obligation.deposits,
|
|
616
|
-
obligation.borrows,
|
|
617
|
-
entry,
|
|
618
|
-
prices,
|
|
619
|
-
reserveMap,
|
|
620
|
-
)
|
|
621
|
-
const collateralBase = await this.calculateSideInBase(collateralValues, entry, prices, reserveMap)
|
|
622
|
-
const debtBase = await this.calculateSideInBase(debtValues, entry, prices, reserveMap)
|
|
623
|
-
const delegatedRewardBase = await this.calculateDelegatedFarmRewardAumInBase(
|
|
624
|
-
entry,
|
|
625
|
-
obligation,
|
|
626
|
-
prices,
|
|
627
|
-
reserveMap,
|
|
628
|
-
valuationClock,
|
|
629
|
-
)
|
|
630
|
-
|
|
631
|
-
const aumDecimal = Decimal.max(collateralBase.sub(debtBase).add(delegatedRewardBase), new Decimal(0))
|
|
632
|
-
|
|
633
|
-
return {
|
|
634
|
-
positionType: PositionType.KaminoObligation,
|
|
635
|
-
mint: this.state.underlyingMint.toBase58(),
|
|
636
|
-
aum: AumCalculator.decimalFloorToBigInt(aumDecimal),
|
|
637
|
-
kaminoObligationExposure,
|
|
638
|
-
}
|
|
639
|
-
} catch (e) {
|
|
640
|
-
console.warn("Failed to calculate obligation AUM:", e)
|
|
641
|
-
return {
|
|
642
|
-
positionType: PositionType.KaminoObligation,
|
|
643
|
-
mint: this.state.underlyingMint.toBase58(),
|
|
644
|
-
aum: BigInt(0),
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
private async buildKaminoObligationExposure(
|
|
650
|
-
deposits: Obligation["deposits"],
|
|
651
|
-
borrows: Obligation["borrows"],
|
|
652
|
-
entry: ObligationEntryTyped,
|
|
653
|
-
prices: ExponentPrices,
|
|
654
|
-
reserveMap?: Map<string, Reserve>,
|
|
655
|
-
): Promise<Array<{ mint: string; amount: bigint }>> {
|
|
656
|
-
const exposureByMint = new Map<string, bigint>()
|
|
657
|
-
const defaultKey = PublicKey.default
|
|
658
|
-
const quotePrice = AumCalculator.resolvePrice(entry.quotePriceId, prices)
|
|
659
|
-
const quoteInputMint = this.getPriceInputMint(entry.quotePriceId, prices)
|
|
660
|
-
|
|
661
|
-
for (const deposit of deposits) {
|
|
662
|
-
if (deposit.depositReserve.equals(defaultKey) || deposit.depositedAmount.isZero()) {
|
|
663
|
-
continue
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
const reserve = reserveMap?.get(deposit.depositReserve.toBase58())
|
|
667
|
-
if (!reserve) {
|
|
668
|
-
continue
|
|
669
|
-
}
|
|
670
|
-
const mapping = entry.reservePriceMappings.find((candidate) => candidate.reserve.equals(deposit.depositReserve))
|
|
671
|
-
if (!mapping) {
|
|
672
|
-
continue
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
const mint = reserve.liquidity.mintPubkey.toBase58()
|
|
676
|
-
const amount = BigInt(
|
|
677
|
-
this.calculateReserveAmountInBase(
|
|
678
|
-
reserve,
|
|
679
|
-
deposit.depositedAmount,
|
|
680
|
-
true,
|
|
681
|
-
mapping,
|
|
682
|
-
prices,
|
|
683
|
-
quotePrice,
|
|
684
|
-
quoteInputMint,
|
|
685
|
-
)
|
|
686
|
-
.floor()
|
|
687
|
-
.toString(),
|
|
688
|
-
)
|
|
689
|
-
exposureByMint.set(mint, (exposureByMint.get(mint) ?? BigInt(0)) + amount)
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
for (const borrow of borrows) {
|
|
693
|
-
if (borrow.borrowReserve.equals(defaultKey) || borrow.borrowedAmountSf.isZero()) {
|
|
694
|
-
continue
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
const reserve = reserveMap?.get(borrow.borrowReserve.toBase58())
|
|
698
|
-
if (!reserve) {
|
|
699
|
-
continue
|
|
700
|
-
}
|
|
701
|
-
const mapping = entry.reservePriceMappings.find((candidate) => candidate.reserve.equals(borrow.borrowReserve))
|
|
702
|
-
if (!mapping) {
|
|
703
|
-
continue
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
const mint = reserve.liquidity.mintPubkey.toBase58()
|
|
707
|
-
const amount = BigInt(
|
|
708
|
-
this.calculateReserveAmountInBase(
|
|
709
|
-
reserve,
|
|
710
|
-
borrow.borrowedAmountSf,
|
|
711
|
-
false,
|
|
712
|
-
mapping,
|
|
713
|
-
prices,
|
|
714
|
-
quotePrice,
|
|
715
|
-
quoteInputMint,
|
|
716
|
-
)
|
|
717
|
-
.floor()
|
|
718
|
-
.toString(),
|
|
719
|
-
)
|
|
720
|
-
exposureByMint.set(mint, (exposureByMint.get(mint) ?? BigInt(0)) - amount)
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
return Array.from(exposureByMint.entries()).map(([mint, amount]) => ({ mint, amount }))
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
private calculateKaminoFarmRewardValueInBase(params: {
|
|
727
|
-
farm: ReturnType<typeof decodeKaminoFarmState>
|
|
728
|
-
user: ReturnType<typeof decodeKaminoFarmUserState>
|
|
729
|
-
globalConfigData: Buffer
|
|
730
|
-
scopePriceData?: Buffer | null
|
|
731
|
-
prices: ExponentPrices
|
|
732
|
-
valuationClock: ValuationClock
|
|
733
|
-
}): Decimal {
|
|
734
|
-
const treasuryFeeBps = params.globalConfigData.readBigUInt64LE(
|
|
735
|
-
KAMINO_FARM_ACCOUNT_DISCRIMINATOR_LEN + KAMINO_FARM_GLOBAL_CONFIG_TREASURY_FEE_BPS_OFFSET,
|
|
736
|
-
)
|
|
737
|
-
const scopePrice = params.scopePriceData
|
|
738
|
-
? decodeKaminoScopeDatedPrice(params.scopePriceData, params.farm.scopeOraclePriceId)
|
|
739
|
-
: null
|
|
740
|
-
const projectedRewards = projectKaminoFarmUserRewards(
|
|
741
|
-
params.farm,
|
|
742
|
-
params.user,
|
|
743
|
-
projectKaminoFarmGlobalRewards(params.farm, scopePrice, params.valuationClock),
|
|
744
|
-
)
|
|
745
|
-
|
|
746
|
-
let rewardValueInBase = new Decimal(0)
|
|
747
|
-
for (let rewardIndex = 0; rewardIndex < params.farm.numRewardTokens; rewardIndex += 1) {
|
|
748
|
-
const rewardMint = projectedRewards.projectedRewardInfos[rewardIndex].rewardMint
|
|
749
|
-
const rewardPriceId = this.resolveTrackedMintPriceId(rewardMint)
|
|
750
|
-
if (!rewardPriceId) {
|
|
751
|
-
throw new Error(`Missing Exponent price for Kamino farm reward mint ${rewardMint.toBase58()}`)
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
const netRewardAmount = applyKaminoFarmTreasuryFee(
|
|
755
|
-
projectedRewards.projectedRewardsIssuedUnclaimed[rewardIndex],
|
|
756
|
-
treasuryFeeBps,
|
|
757
|
-
)
|
|
758
|
-
rewardValueInBase = rewardValueInBase.add(
|
|
759
|
-
new Decimal(netRewardAmount.toString()).mul(AumCalculator.resolvePrice(rewardPriceId, params.prices)),
|
|
760
|
-
)
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
return rewardValueInBase
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
private async calculateDelegatedFarmRewardAumInBase(
|
|
767
|
-
entry: ObligationEntryTyped,
|
|
768
|
-
obligation: Obligation,
|
|
769
|
-
prices: ExponentPrices,
|
|
770
|
-
reserveMap: Map<string, Reserve> | undefined,
|
|
771
|
-
valuationClock: ValuationClock,
|
|
772
|
-
): Promise<Decimal> {
|
|
773
|
-
if ((entry.reserveFarmMappings?.length ?? 0) === 0) {
|
|
774
|
-
return new Decimal(0)
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
const accountKeys = new Map<string, PublicKey>()
|
|
778
|
-
for (const reserveFarmMapping of entry.reserveFarmMappings) {
|
|
779
|
-
accountKeys.set(reserveFarmMapping.farmState.toBase58(), reserveFarmMapping.farmState)
|
|
780
|
-
const userState = getKaminoFarmsObligationFarm(
|
|
781
|
-
entry.obligation,
|
|
782
|
-
reserveFarmMapping.farmState,
|
|
783
|
-
KAMINO_FARMS_PROGRAM_ID,
|
|
784
|
-
)
|
|
785
|
-
accountKeys.set(userState.toBase58(), userState)
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
const uniqueAccountKeys = [...accountKeys.values()]
|
|
789
|
-
const accountInfos = uniqueAccountKeys.length > 0
|
|
790
|
-
? await this.connection.getMultipleAccountsInfo(uniqueAccountKeys)
|
|
791
|
-
: []
|
|
792
|
-
const accountInfoMap = new Map<string, Buffer | null>()
|
|
793
|
-
for (let index = 0; index < uniqueAccountKeys.length; index += 1) {
|
|
794
|
-
accountInfoMap.set(uniqueAccountKeys[index].toBase58(), accountInfos[index]?.data ? Buffer.from(accountInfos[index]!.data) : null)
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
let totalRewardValueInBase = new Decimal(0)
|
|
798
|
-
for (const reserveFarmMapping of entry.reserveFarmMappings) {
|
|
799
|
-
let reserve = reserveMap?.get(reserveFarmMapping.reserve.toBase58())
|
|
800
|
-
if (!reserve) {
|
|
801
|
-
reserve = await Reserve.fetch(this.connection, reserveFarmMapping.reserve, entry.lendingProgramId) ?? undefined
|
|
802
|
-
if (reserve) {
|
|
803
|
-
reserveMap?.set(reserveFarmMapping.reserve.toBase58(), reserve)
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
if (!reserve) {
|
|
807
|
-
throw new Error(`Missing tracked Kamino reserve ${reserveFarmMapping.reserve.toBase58()}`)
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
const expectedFarmState = reserveFarmMapping.farmKind === KAMINO_RESERVE_FARM_KIND_COLLATERAL
|
|
811
|
-
? reserve.farmCollateral
|
|
812
|
-
: reserveFarmMapping.farmKind === KAMINO_RESERVE_FARM_KIND_DEBT
|
|
813
|
-
? reserve.farmDebt
|
|
814
|
-
: null
|
|
815
|
-
if (!expectedFarmState?.equals(reserveFarmMapping.farmState)) {
|
|
816
|
-
throw new Error(`Stored reserve farm mapping is stale for reserve ${reserveFarmMapping.reserve.toBase58()}`)
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
const farmData = accountInfoMap.get(reserveFarmMapping.farmState.toBase58())
|
|
820
|
-
if (!farmData) {
|
|
821
|
-
throw new Error(`Missing delegated farm account ${reserveFarmMapping.farmState.toBase58()}`)
|
|
822
|
-
}
|
|
823
|
-
const farm = decodeKaminoFarmState(farmData)
|
|
824
|
-
if (!farm.isDelegated) {
|
|
825
|
-
throw new Error(`Stored farm ${reserveFarmMapping.farmState.toBase58()} is not delegated`)
|
|
826
|
-
}
|
|
827
|
-
const userState = getKaminoFarmsObligationFarm(
|
|
828
|
-
entry.obligation,
|
|
829
|
-
reserveFarmMapping.farmState,
|
|
830
|
-
KAMINO_FARMS_PROGRAM_ID,
|
|
831
|
-
)
|
|
832
|
-
|
|
833
|
-
const additionalAccounts = [farm.globalConfig]
|
|
834
|
-
const scopePrices = getKaminoFarmScopePricesAddress(farm)
|
|
835
|
-
if (scopePrices) {
|
|
836
|
-
additionalAccounts.push(scopePrices)
|
|
837
|
-
}
|
|
838
|
-
const [globalConfigInfo, scopeInfo] = await this.connection.getMultipleAccountsInfo(additionalAccounts)
|
|
839
|
-
if (!globalConfigInfo?.data) {
|
|
840
|
-
throw new Error(`Missing delegated farm global config ${farm.globalConfig.toBase58()}`)
|
|
841
|
-
}
|
|
842
|
-
const globalConfigData = Buffer.from(globalConfigInfo.data)
|
|
843
|
-
|
|
844
|
-
const userData = accountInfoMap.get(userState.toBase58())
|
|
845
|
-
if (!userData) {
|
|
846
|
-
continue
|
|
847
|
-
}
|
|
848
|
-
const user = decodeKaminoFarmUserState(userData)
|
|
849
|
-
if (!user.delegatee.equals(entry.obligation)) {
|
|
850
|
-
throw new Error(`Delegated farm user ${userState.toBase58()} does not delegate to obligation`)
|
|
851
|
-
}
|
|
852
|
-
if (!user.owner.equals(obligation.owner)) {
|
|
853
|
-
throw new Error(`Delegated farm user ${userState.toBase58()} owner mismatch`)
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
const scopePriceData = scopePrices ? Buffer.from(scopeInfo?.data ?? []) : null
|
|
857
|
-
if (scopePrices && !scopeInfo?.data) {
|
|
858
|
-
throw new Error(`Missing delegated farm scope prices ${scopePrices.toBase58()}`)
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
totalRewardValueInBase = totalRewardValueInBase.add(this.calculateKaminoFarmRewardValueInBase({
|
|
862
|
-
farm,
|
|
863
|
-
user,
|
|
864
|
-
globalConfigData,
|
|
865
|
-
scopePriceData,
|
|
866
|
-
prices,
|
|
867
|
-
valuationClock,
|
|
868
|
-
}))
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
return totalRewardValueInBase
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* CLMM position AUM.
|
|
876
|
-
* Uses MarketThree.getPtAndSyOnWithdrawLiquidity to keep parity with
|
|
877
|
-
* existing frontend CLMM valuation logic, plus uncollected fees.
|
|
878
|
-
*/
|
|
879
|
-
async calculateClmmPositionAum(entry: ClmmPositionEntryTyped, prices: ExponentPrices): Promise<AumResult> {
|
|
880
|
-
const zeroResult: AumResult = {
|
|
881
|
-
positionType: PositionType.ClmmPosition,
|
|
882
|
-
mint: this.state.underlyingMint.toBase58(),
|
|
883
|
-
aum: BigInt(0),
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
try {
|
|
887
|
-
const fetcher = new ExponentFetcher({ connection: this.connection })
|
|
888
|
-
|
|
889
|
-
const [lpPosition, marketThree] = await Promise.all([
|
|
890
|
-
fetcher.fetchLpPositionCLMM(entry.lpPosition),
|
|
891
|
-
this.loadClmmMarket(entry.market),
|
|
892
|
-
])
|
|
893
|
-
|
|
894
|
-
if (!lpPosition.market.equals(entry.market)) {
|
|
895
|
-
return zeroResult
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
if (lpPosition.lpBalance === BigInt(0)) {
|
|
899
|
-
return zeroResult
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
const { totalPtOut, totalSyOut } = marketThree.getPtAndSyOnWithdrawLiquidity(lpPosition)
|
|
903
|
-
|
|
904
|
-
// Add uncollected fees
|
|
905
|
-
const finalPt = totalPtOut + lpPosition.tokensOwedPt
|
|
906
|
-
const finalSy = totalSyOut + lpPosition.tokensOwedSy
|
|
907
|
-
|
|
908
|
-
const ptPrice = AumCalculator.resolvePrice(entry.priceIdPt, prices)
|
|
909
|
-
const syPrice = AumCalculator.resolvePrice(entry.priceIdSy, prices)
|
|
910
|
-
|
|
911
|
-
const ptValue = new Decimal(finalPt.toString()).mul(ptPrice)
|
|
912
|
-
const syValue = new Decimal(finalSy.toString()).mul(syPrice)
|
|
913
|
-
const totalValue = ptValue.add(syValue)
|
|
914
|
-
|
|
915
|
-
return {
|
|
916
|
-
positionType: PositionType.ClmmPosition,
|
|
917
|
-
mint: this.state.underlyingMint.toBase58(),
|
|
918
|
-
aum: AumCalculator.decimalFloorToBigInt(totalValue),
|
|
919
|
-
}
|
|
920
|
-
} catch (e) {
|
|
921
|
-
console.warn("Failed to calculate CLMM position AUM:", e)
|
|
922
|
-
return zeroResult
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
async calculateKaminoFarmAum(
|
|
927
|
-
entry: KaminoFarmEntryTyped,
|
|
928
|
-
prices: ExponentPrices,
|
|
929
|
-
valuationClock: ValuationClock,
|
|
930
|
-
): Promise<AumResult> {
|
|
931
|
-
const zeroResult: AumResult = {
|
|
932
|
-
positionType: PositionType.KaminoFarm,
|
|
933
|
-
mint: this.state.underlyingMint.toBase58(),
|
|
934
|
-
aum: 0n,
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
const [farmInfo, userInfo] = await this.connection.getMultipleAccountsInfo([entry.farmState, entry.userState])
|
|
938
|
-
if (!farmInfo?.data || !userInfo?.data) {
|
|
939
|
-
return zeroResult
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
const farm = decodeKaminoFarmState(Buffer.from(farmInfo.data))
|
|
943
|
-
if (farm.isDelegated) {
|
|
944
|
-
return zeroResult
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
const user = decodeKaminoFarmUserState(Buffer.from(userInfo.data))
|
|
948
|
-
|
|
949
|
-
const principalAmount = calculateKaminoFarmPrincipalAmount(farm, user)
|
|
950
|
-
const principalPriceId = this.resolveTrackedMintPriceId(farm.underlyingMint)
|
|
951
|
-
if (!principalPriceId) {
|
|
952
|
-
throw new Error(`Missing Exponent price for Kamino farm underlying mint ${farm.underlyingMint.toBase58()}`)
|
|
953
|
-
}
|
|
954
|
-
const principalValueInBase = new Decimal(principalAmount.toString()).mul(
|
|
955
|
-
AumCalculator.resolvePrice(principalPriceId, prices),
|
|
956
|
-
)
|
|
957
|
-
|
|
958
|
-
if (farm.numRewardTokens === 0) {
|
|
959
|
-
return {
|
|
960
|
-
positionType: PositionType.KaminoFarm,
|
|
961
|
-
mint: farm.underlyingMint.toBase58(),
|
|
962
|
-
aum: AumCalculator.decimalFloorToBigInt(principalValueInBase),
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
const additionalAccounts = [farm.globalConfig]
|
|
967
|
-
const scopePricesAddress = getKaminoFarmScopePricesAddress(farm)
|
|
968
|
-
if (scopePricesAddress) {
|
|
969
|
-
additionalAccounts.push(scopePricesAddress)
|
|
970
|
-
}
|
|
971
|
-
const additionalInfos = await this.connection.getMultipleAccountsInfo(additionalAccounts)
|
|
972
|
-
const globalConfigInfo = additionalInfos[0]
|
|
973
|
-
if (!globalConfigInfo?.data) {
|
|
974
|
-
throw new Error(`Missing Kamino farm global config ${farm.globalConfig.toBase58()}`)
|
|
975
|
-
}
|
|
976
|
-
const scopeInfo = scopePricesAddress ? additionalInfos[1] : null
|
|
977
|
-
if (scopePricesAddress && !scopeInfo?.data) {
|
|
978
|
-
throw new Error(`Missing scope prices account ${scopePricesAddress.toBase58()}`)
|
|
979
|
-
}
|
|
980
|
-
const rewardValueInBase = this.calculateKaminoFarmRewardValueInBase({
|
|
981
|
-
farm,
|
|
982
|
-
user,
|
|
983
|
-
globalConfigData: Buffer.from(globalConfigInfo.data),
|
|
984
|
-
scopePriceData: scopeInfo?.data ? Buffer.from(scopeInfo.data) : null,
|
|
985
|
-
prices,
|
|
986
|
-
valuationClock,
|
|
987
|
-
})
|
|
988
|
-
|
|
989
|
-
return {
|
|
990
|
-
positionType: PositionType.KaminoFarm,
|
|
991
|
-
mint: farm.underlyingMint.toBase58(),
|
|
992
|
-
aum: AumCalculator.decimalFloorToBigInt(principalValueInBase.add(rewardValueInBase)),
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
/**
|
|
997
|
-
* Calculate one side (collateral or debt) of a Kamino obligation in base units.
|
|
998
|
-
* For SDK-side valuation we derive the current reserve value directly from
|
|
999
|
-
* Kamino Reserve accounts and convert the resulting human base amount into raw
|
|
1000
|
-
* base units at the end.
|
|
1001
|
-
*/
|
|
1002
|
-
private async calculateSideInBase(
|
|
1003
|
-
reserveValues: Array<{ reserve: PublicKey; rawAmount: BN; isDeposit: boolean }>,
|
|
1004
|
-
entry: ObligationEntryTyped,
|
|
1005
|
-
prices: ExponentPrices,
|
|
1006
|
-
reserveMap?: Map<string, Reserve>,
|
|
1007
|
-
): Promise<Decimal> {
|
|
1008
|
-
if (reserveValues.length === 0) {
|
|
1009
|
-
return new Decimal(0)
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const quotePrice = AumCalculator.resolvePrice(entry.quotePriceId, prices)
|
|
1013
|
-
const quoteInputMint = this.getPriceInputMint(entry.quotePriceId, prices)
|
|
1014
|
-
|
|
1015
|
-
let aggregateBaseValue = new Decimal(0)
|
|
1016
|
-
for (const rv of reserveValues) {
|
|
1017
|
-
const mapping = entry.reservePriceMappings.find((candidate) => candidate.reserve.equals(rv.reserve))
|
|
1018
|
-
if (!mapping) {
|
|
1019
|
-
throw new Error(`Missing Kamino reserve mapping for ${rv.reserve.toBase58()}`)
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
const reserve = reserveMap?.get(rv.reserve.toBase58())
|
|
1023
|
-
if (!reserve) {
|
|
1024
|
-
throw new Error(`Reserve not found for ${rv.reserve.toBase58()}, cannot compute market value`)
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
aggregateBaseValue = aggregateBaseValue.add(
|
|
1028
|
-
this.calculateReserveAmountInBase(
|
|
1029
|
-
reserve,
|
|
1030
|
-
rv.rawAmount,
|
|
1031
|
-
rv.isDeposit,
|
|
1032
|
-
mapping,
|
|
1033
|
-
prices,
|
|
1034
|
-
quotePrice,
|
|
1035
|
-
quoteInputMint,
|
|
1036
|
-
),
|
|
1037
|
-
)
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
return aggregateBaseValue
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
private calculateReserveAmountInBase(
|
|
1044
|
-
reserve: Reserve,
|
|
1045
|
-
rawAmount: BN,
|
|
1046
|
-
isDeposit: boolean,
|
|
1047
|
-
mapping: { reservePriceId: PriceId },
|
|
1048
|
-
prices: ExponentPrices,
|
|
1049
|
-
quotePrice: Decimal,
|
|
1050
|
-
quoteInputMint: PublicKey,
|
|
1051
|
-
): Decimal {
|
|
1052
|
-
let liquidityAmountRaw: Decimal
|
|
1053
|
-
if (isDeposit) {
|
|
1054
|
-
// cTokens -> liquidity token raw amount via collateral exchange rate
|
|
1055
|
-
liquidityAmountRaw = new Decimal(rawAmount.toString()).mul(reserve.getCollateralExchangeRate())
|
|
1056
|
-
} else {
|
|
1057
|
-
// borrowedAmountSf decodes into liquidity token raw amount
|
|
1058
|
-
liquidityAmountRaw = new Fraction(rawAmount).toDecimal()
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
if (reserve.liquidity.mintPubkey.equals(quoteInputMint)) {
|
|
1062
|
-
return liquidityAmountRaw.mul(quotePrice)
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
const reservePriceId = mapping.reservePriceId
|
|
1066
|
-
if (!reservePriceId || ("simple" in reservePriceId && reservePriceId.simple.priceId === 0n)) {
|
|
1067
|
-
// Passthrough — no price conversion, treat as 1:1
|
|
1068
|
-
return liquidityAmountRaw.mul(quotePrice)
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
return liquidityAmountRaw.mul(AumCalculator.resolvePrice(reservePriceId, prices)).mul(quotePrice)
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
/**
|
|
1075
|
-
* Loopscale Loan AUM (BORROWER side).
|
|
1076
|
-
* AUM = sum(collateral_value) - sum(outstanding_debt).
|
|
1077
|
-
*/
|
|
1078
|
-
async calculateLoopscaleLoanAum(entry: LoopscaleLoanEntryTyped, prices: ExponentPrices): Promise<AumResult> {
|
|
1079
|
-
const mint = this.state.underlyingMint.toBase58()
|
|
1080
|
-
|
|
1081
|
-
try {
|
|
1082
|
-
const loan = await LoopscaleLoan.fetch(this.connection, entry.loan)
|
|
1083
|
-
if (!loan) {
|
|
1084
|
-
return { positionType: PositionType.LoopscaleLoan, mint, aum: BigInt(0) }
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
const tokenEntries = this.state.tokenEntries as unknown as TokenEntryTyped[]
|
|
1088
|
-
const mintPriceMap = new Map<string, PriceId>()
|
|
1089
|
-
for (const te of tokenEntries) {
|
|
1090
|
-
mintPriceMap.set(te.mint.toBase58(), te.priceId)
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
const exposureByMint = new Map<string, bigint>()
|
|
1094
|
-
|
|
1095
|
-
let collateralValue = new Decimal(0)
|
|
1096
|
-
for (const collateral of loan.collateral) {
|
|
1097
|
-
const assetMint = collateral.assetMint.toBase58()
|
|
1098
|
-
const amount = BigInt(collateral.amount.toString())
|
|
1099
|
-
if (collateral.assetMint.equals(PublicKey.default) || amount === BigInt(0)) {
|
|
1100
|
-
continue
|
|
1101
|
-
}
|
|
1102
|
-
const priceId = mintPriceMap.get(assetMint)
|
|
1103
|
-
if (!priceId) {
|
|
1104
|
-
continue
|
|
1105
|
-
}
|
|
1106
|
-
const price = AumCalculator.resolvePrice(priceId, prices)
|
|
1107
|
-
const valueInBase = BigInt(new Decimal(amount.toString()).mul(price).floor().toString())
|
|
1108
|
-
collateralValue = collateralValue.add(new Decimal(amount.toString()).mul(price))
|
|
1109
|
-
exposureByMint.set(assetMint, (exposureByMint.get(assetMint) ?? BigInt(0)) + valueInBase)
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
let debtValue = new Decimal(0)
|
|
1113
|
-
for (const ledger of loan.ledgers) {
|
|
1114
|
-
const principalDue = BigInt(ledger.principalDue.toString())
|
|
1115
|
-
const principalRepaid = BigInt(ledger.principalRepaid.toString())
|
|
1116
|
-
const interestOutstanding = BigInt(ledger.interestOutstanding.toString())
|
|
1117
|
-
const outstanding = principalDue - principalRepaid + interestOutstanding
|
|
1118
|
-
if (outstanding <= BigInt(0)) {
|
|
1119
|
-
continue
|
|
1120
|
-
}
|
|
1121
|
-
const ledgerMint = ledger.principalMint.toBase58()
|
|
1122
|
-
const priceId = mintPriceMap.get(ledgerMint)
|
|
1123
|
-
if (!priceId) {
|
|
1124
|
-
continue
|
|
1125
|
-
}
|
|
1126
|
-
const price = AumCalculator.resolvePrice(priceId, prices)
|
|
1127
|
-
const valueInBase = BigInt(new Decimal(outstanding.toString()).mul(price).floor().toString())
|
|
1128
|
-
debtValue = debtValue.add(new Decimal(outstanding.toString()).mul(price))
|
|
1129
|
-
exposureByMint.set(ledgerMint, (exposureByMint.get(ledgerMint) ?? BigInt(0)) - valueInBase)
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
const loopscaleLoanExposure = Array.from(exposureByMint.entries()).map(([m, amount]) => ({ mint: m, amount }))
|
|
1133
|
-
const aum = Decimal.max(collateralValue.sub(debtValue), new Decimal(0))
|
|
1134
|
-
return {
|
|
1135
|
-
positionType: PositionType.LoopscaleLoan,
|
|
1136
|
-
mint,
|
|
1137
|
-
aum: BigInt(aum.floor().toString()),
|
|
1138
|
-
loopscaleLoanExposure,
|
|
1139
|
-
}
|
|
1140
|
-
} catch (e) {
|
|
1141
|
-
console.warn("Failed to calculate Loopscale loan AUM:", e)
|
|
1142
|
-
return { positionType: PositionType.LoopscaleLoan, mint, aum: BigInt(0) }
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
/**
|
|
1147
|
-
* Loopscale Strategy AUM (LENDER side).
|
|
1148
|
-
* AUM = (tokenBalance + currentDeployedAmount + outstandingInterestAmount) × price.
|
|
1149
|
-
*/
|
|
1150
|
-
async calculateLoopscaleStrategyAum(entry: LoopscaleStrategyEntryTyped, prices: ExponentPrices): Promise<AumResult> {
|
|
1151
|
-
const underlyingMint = this.state.underlyingMint.toBase58()
|
|
1152
|
-
|
|
1153
|
-
try {
|
|
1154
|
-
const strategy = await LoopscaleStrategy.fetch(this.connection, entry.strategy)
|
|
1155
|
-
if (!strategy) {
|
|
1156
|
-
return { positionType: PositionType.LoopscaleStrategy, mint: underlyingMint, aum: BigInt(0) }
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
const principalMint = strategy.principalMint.toBase58()
|
|
1160
|
-
|
|
1161
|
-
const tokenBalance = BigInt(strategy.tokenBalance.toString())
|
|
1162
|
-
const currentDeployedAmount = BigInt(strategy.currentDeployedAmount.toString())
|
|
1163
|
-
const outstandingInterestAmount = BigInt(strategy.outstandingInterestAmount.toString())
|
|
1164
|
-
const totalValue = tokenBalance + currentDeployedAmount + outstandingInterestAmount
|
|
1165
|
-
|
|
1166
|
-
if (totalValue === BigInt(0)) {
|
|
1167
|
-
return { positionType: PositionType.LoopscaleStrategy, mint: principalMint, aum: BigInt(0) }
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
const tokenEntries = this.state.tokenEntries as unknown as TokenEntryTyped[]
|
|
1171
|
-
const priceId = tokenEntries.find((te) => te.mint.toBase58() === principalMint)?.priceId
|
|
1172
|
-
if (!priceId) {
|
|
1173
|
-
return { positionType: PositionType.LoopscaleStrategy, mint: principalMint, aum: BigInt(0) }
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
const price = AumCalculator.resolvePrice(priceId, prices)
|
|
1177
|
-
const aum = new Decimal(totalValue.toString()).mul(price)
|
|
1178
|
-
const amount = BigInt(aum.floor().toString())
|
|
1179
|
-
return {
|
|
1180
|
-
positionType: PositionType.LoopscaleStrategy,
|
|
1181
|
-
mint: principalMint,
|
|
1182
|
-
aum: amount,
|
|
1183
|
-
loopscaleLoanExposure: [{ mint: principalMint, amount }],
|
|
1184
|
-
}
|
|
1185
|
-
} catch (e) {
|
|
1186
|
-
console.warn("Failed to calculate Loopscale strategy AUM:", e)
|
|
1187
|
-
return { positionType: PositionType.LoopscaleStrategy, mint: underlyingMint, aum: BigInt(0) }
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Reserve tokens AUM (funds in vault token accounts - "Instant Liquidity").
|
|
1193
|
-
*/
|
|
1194
|
-
async calculateReserveTokensAum(prices: ExponentPrices): Promise<AumResult[]> {
|
|
1195
|
-
const tokenEntries = this.state.tokenEntries as unknown as TokenEntryTyped[]
|
|
1196
|
-
const results: AumResult[] = []
|
|
1197
|
-
|
|
1198
|
-
const allAccounts = tokenEntries.map((e) => e.tokenSquadsAccount)
|
|
1199
|
-
const accountInfos = await this.connection.getMultipleAccountsInfo(allAccounts)
|
|
1200
|
-
|
|
1201
|
-
for (let i = 0; i < tokenEntries.length; i++) {
|
|
1202
|
-
const entry = tokenEntries[i]
|
|
1203
|
-
const squadsInfo = accountInfos[i * 2]
|
|
1204
|
-
const vaultInfo = accountInfos[i * 2 + 1]
|
|
1205
|
-
|
|
1206
|
-
let balance = BigInt(0)
|
|
1207
|
-
if (squadsInfo?.data) {
|
|
1208
|
-
balance += AumCalculator.parseTokenAccountAmount(Buffer.from(squadsInfo.data))
|
|
1209
|
-
}
|
|
1210
|
-
if (vaultInfo?.data) {
|
|
1211
|
-
balance += AumCalculator.parseTokenAccountAmount(Buffer.from(vaultInfo.data))
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
if (balance === BigInt(0)) {
|
|
1215
|
-
continue
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
try {
|
|
1219
|
-
const price = AumCalculator.resolvePrice(entry.priceId, prices)
|
|
1220
|
-
const valueInBase = new Decimal(balance.toString()).mul(price)
|
|
1221
|
-
results.push({
|
|
1222
|
-
positionType: PositionType.Reserves,
|
|
1223
|
-
mint: entry.mint.toBase58(),
|
|
1224
|
-
aum: AumCalculator.decimalFloorToBigInt(valueInBase),
|
|
1225
|
-
})
|
|
1226
|
-
} catch {
|
|
1227
|
-
// Skip if price resolution fails
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
return results
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
// ==========================================================================
|
|
1235
|
-
// Convenience: calculate all position AUMs
|
|
1236
|
-
// ==========================================================================
|
|
1237
|
-
|
|
1238
|
-
/**
|
|
1239
|
-
* Calculate AUM for a single strategy position.
|
|
1240
|
-
* Returns array of AumResults (may be multiple for tokenAccount positions).
|
|
1241
|
-
*/
|
|
1242
|
-
async calculatePositionAum(
|
|
1243
|
-
position: StrategyPosition,
|
|
1244
|
-
prices: ExponentPrices,
|
|
1245
|
-
valuationClock?: ValuationClock,
|
|
1246
|
-
): Promise<AumResult[]> {
|
|
1247
|
-
if ("tokenAccount" in position) {
|
|
1248
|
-
const entry = (position as { tokenAccount: { 0: TokenAccountEntryTyped } }).tokenAccount[0]
|
|
1249
|
-
return this.calculateTokenAccountAum(entry, prices)
|
|
1250
|
-
}
|
|
1251
|
-
if ("orderbook" in position) {
|
|
1252
|
-
const entry = (position as { orderbook: { 0: OrderbookEntryTyped } }).orderbook[0]
|
|
1253
|
-
const result = await this.calculateOrderbookAum(entry, prices)
|
|
1254
|
-
return result
|
|
1255
|
-
}
|
|
1256
|
-
if ("yieldPosition" in position) {
|
|
1257
|
-
const entry = (position as { yieldPosition: { 0: YieldPositionEntryTyped } }).yieldPosition[0]
|
|
1258
|
-
const result = await this.calculateYieldPositionAum(entry, prices)
|
|
1259
|
-
return [result]
|
|
1260
|
-
}
|
|
1261
|
-
if ("obligation" in position) {
|
|
1262
|
-
const inner = (position as { obligation: { 0: Record<string, unknown> } }).obligation[0]
|
|
1263
|
-
if (inner && "kaminoObligation" in inner) {
|
|
1264
|
-
const kaminoVariant = inner.kaminoObligation as unknown
|
|
1265
|
-
const entry = Array.isArray(kaminoVariant)
|
|
1266
|
-
? (kaminoVariant[0] as ObligationEntryTyped | undefined)
|
|
1267
|
-
: kaminoVariant && typeof kaminoVariant === "object" && "0" in (kaminoVariant as Record<string, unknown>)
|
|
1268
|
-
? ((kaminoVariant as { 0?: ObligationEntryTyped })[0] ?? undefined)
|
|
1269
|
-
: (kaminoVariant as ObligationEntryTyped | undefined)
|
|
1270
|
-
if (entry) {
|
|
1271
|
-
const result = await this.calculateObligationAum(
|
|
1272
|
-
entry,
|
|
1273
|
-
prices,
|
|
1274
|
-
valuationClock ?? await this.getCurrentValuationClock(),
|
|
1275
|
-
)
|
|
1276
|
-
return [result]
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
if ("clmmPosition" in position) {
|
|
1281
|
-
const entry = (position as { clmmPosition: { 0: ClmmPositionEntryTyped } }).clmmPosition[0]
|
|
1282
|
-
const result = await this.calculateClmmPositionAum(entry, prices)
|
|
1283
|
-
return [result]
|
|
1284
|
-
}
|
|
1285
|
-
if ("loopscaleLoan" in position) {
|
|
1286
|
-
const entry = (position as { loopscaleLoan: { 0: LoopscaleLoanEntryTyped } }).loopscaleLoan[0]
|
|
1287
|
-
const result = await this.calculateLoopscaleLoanAum(entry, prices)
|
|
1288
|
-
return [result]
|
|
1289
|
-
}
|
|
1290
|
-
if ("loopscaleStrategy" in position) {
|
|
1291
|
-
const entry = (position as { loopscaleStrategy: { 0: LoopscaleStrategyEntryTyped } }).loopscaleStrategy[0]
|
|
1292
|
-
const result = await this.calculateLoopscaleStrategyAum(entry, prices)
|
|
1293
|
-
return [result]
|
|
1294
|
-
}
|
|
1295
|
-
if ("kaminoFarm" in position) {
|
|
1296
|
-
const entry = (position as { kaminoFarm: { 0: KaminoFarmEntryTyped } }).kaminoFarm[0]
|
|
1297
|
-
const result = await this.calculateKaminoFarmAum(
|
|
1298
|
-
entry,
|
|
1299
|
-
prices,
|
|
1300
|
-
valuationClock ?? await this.getCurrentValuationClock(),
|
|
1301
|
-
)
|
|
1302
|
-
return [result]
|
|
1303
|
-
}
|
|
1304
|
-
return []
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
/**
|
|
1308
|
-
* Calculate AUM for all positions: reserve tokens + strategy positions.
|
|
1309
|
-
*/
|
|
1310
|
-
async calculatePositionsAum(prices: ExponentPrices): Promise<AumResult[]> {
|
|
1311
|
-
const valuationClock = await this.getCurrentValuationClock()
|
|
1312
|
-
const [reserveResults, ...positionResults] = await Promise.all([
|
|
1313
|
-
this.calculateReserveTokensAum(prices),
|
|
1314
|
-
...this.state.strategyPositions.map((position) => this.calculatePositionAum(position, prices, valuationClock)),
|
|
1315
|
-
])
|
|
1316
|
-
return [reserveResults, ...positionResults].flat()
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
get strategyPositions(): StrategyPosition[] {
|
|
1320
|
-
return this.state.strategyPositions
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
private resolveTrackedMintPriceId(mint: PublicKey): PriceId | null {
|
|
1324
|
-
const tokenEntry = (this.state.tokenEntries as unknown as TokenEntryTyped[]).find((entry) => entry.mint.equals(mint))
|
|
1325
|
-
if (tokenEntry) {
|
|
1326
|
-
return tokenEntry.priceId
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
for (const position of this.state.strategyPositions) {
|
|
1330
|
-
if ("tokenAccount" in position) {
|
|
1331
|
-
const entry = (position as { tokenAccount: { 0: TokenAccountEntryTyped } }).tokenAccount[0]
|
|
1332
|
-
if (entry.tokenMint.equals(mint) && entry.balances.length > 0) {
|
|
1333
|
-
return entry.balances[0].priceId
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
return null
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
private static convertKaminoStakeToAmount(stake: bigint, totalStake: bigint, totalAmount: bigint): bigint {
|
|
1342
|
-
if (stake === 0n) {
|
|
1343
|
-
return 0n
|
|
1344
|
-
}
|
|
1345
|
-
if (totalStake === 0n) {
|
|
1346
|
-
return totalAmount
|
|
1347
|
-
}
|
|
1348
|
-
return (stake * totalAmount) / totalStake
|
|
1349
|
-
}
|
|
1350
|
-
}
|