@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,2667 +0,0 @@
|
|
|
1
|
-
// The following methods have breaking changes: ixDepositLiquidity, ixQueueWithdrawal, ixExecuteWithdrawal, ixManagerRefreshSyRate
|
|
2
|
-
// Account names changed: tokenSySrc -> tokenSrc, tokenSyVault -> entryTokenVault
|
|
3
|
-
// New required accounts: exponentPrices
|
|
4
|
-
import {
|
|
5
|
-
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
6
|
-
NATIVE_MINT,
|
|
7
|
-
TOKEN_2022_PROGRAM_ID,
|
|
8
|
-
TOKEN_PROGRAM_ID,
|
|
9
|
-
createAssociatedTokenAccountIdempotentInstruction,
|
|
10
|
-
createSyncNativeInstruction,
|
|
11
|
-
getAccount,
|
|
12
|
-
getAssociatedTokenAddressSync,
|
|
13
|
-
getMint,
|
|
14
|
-
} from "@solana/spl-token"
|
|
15
|
-
import {
|
|
16
|
-
AccountMeta,
|
|
17
|
-
Connection,
|
|
18
|
-
Keypair,
|
|
19
|
-
PublicKey,
|
|
20
|
-
SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
21
|
-
SYSVAR_RENT_PUBKEY,
|
|
22
|
-
SystemProgram,
|
|
23
|
-
TransactionInstruction,
|
|
24
|
-
TransactionMessage,
|
|
25
|
-
VersionedTransaction,
|
|
26
|
-
} from "@solana/web3.js"
|
|
27
|
-
import bs58 from "bs58"
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
ClmmPositionEntry,
|
|
31
|
-
ExponentPrices,
|
|
32
|
-
ExponentVault as ExponentVaultAccountType,
|
|
33
|
-
ExponentVault as ExponentVaultType,
|
|
34
|
-
OrderbookEntry,
|
|
35
|
-
PriceId,
|
|
36
|
-
TokenAccountEntry,
|
|
37
|
-
TokenEntry,
|
|
38
|
-
} from "@exponent-labs/exponent-vaults-fetcher"
|
|
39
|
-
import { PROGRAM_ID as EXPONENT_VAULTS_PROGRAM_ID } from "@exponent-labs/exponent-vaults-idl"
|
|
40
|
-
import { ExponentVaultsPDA, SeedId, SquadsPDA } from "@exponent-labs/exponent-vaults-pda"
|
|
41
|
-
|
|
42
|
-
import { fetchAllMaybeMarketThreeAccounts } from "../client/clmm/accounts/marketThree"
|
|
43
|
-
import * as exponentVaults from "../client/vaults"
|
|
44
|
-
import { Environment, LOCAL_ENV } from "../environment"
|
|
45
|
-
import { emitEventAuthority, uniqueRemainingAccounts } from "../utils"
|
|
46
|
-
import { AumCalculator } from "./aumCalculator"
|
|
47
|
-
import { deserializeExponentStrategyVaultFetcherShape, ExponentVaultsFetcher } from "./fetcher"
|
|
48
|
-
import { getKaminoFarmScopePricesAddress, decodeKaminoFarmState } from "./kamino-farms"
|
|
49
|
-
import { extractPriceIds } from "./pricePathResolver"
|
|
50
|
-
import { SquadsVaultTxnResolver } from "./squadsVaultTxnResolver"
|
|
51
|
-
import { getKaminoFarmsObligationFarm } from "./../../../kamino-lend-standard/src/constants"
|
|
52
|
-
|
|
53
|
-
type Numeric = bigint | number
|
|
54
|
-
|
|
55
|
-
export const SYNTHETIC_USD_MINT = new PublicKey("USD1111111111111111111111111111111111111111")
|
|
56
|
-
export const SYNTHETIC_USD_DECIMALS = 6
|
|
57
|
-
export const SYNTHETIC_USD9_MINT = new PublicKey("USD1111111111111111111111111111111111111119")
|
|
58
|
-
export const SYNTHETIC_USD9_DECIMALS = 9
|
|
59
|
-
const LOCAL_UPDATE_PRICE_DISCRIMINATOR = Buffer.from([7])
|
|
60
|
-
const KAMINO_FARMS_PROGRAM_ID = new PublicKey("FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr")
|
|
61
|
-
|
|
62
|
-
export const getSyntheticMintDecimals = (mint: PublicKey): number | null => {
|
|
63
|
-
if (mint.equals(SYNTHETIC_USD_MINT)) return SYNTHETIC_USD_DECIMALS
|
|
64
|
-
if (mint.equals(SYNTHETIC_USD9_MINT)) return SYNTHETIC_USD9_DECIMALS
|
|
65
|
-
return null
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function unwrapTupleLikeValue(value: unknown): unknown {
|
|
69
|
-
if (Array.isArray(value)) {
|
|
70
|
-
return value[0]
|
|
71
|
-
}
|
|
72
|
-
if (value && typeof value === "object" && "0" in value) {
|
|
73
|
-
return (value as { 0?: unknown })[0]
|
|
74
|
-
}
|
|
75
|
-
return value ?? undefined
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function addTrackedPriceIds(target: Set<number>, priceIdValue: unknown) {
|
|
79
|
-
for (const id of extractPriceIds(priceIdValue)) {
|
|
80
|
-
const numericId = Number(id)
|
|
81
|
-
if (numericId !== 0) {
|
|
82
|
-
target.add(numericId)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function collectTrackedStrategyVaultPriceIds(state: {
|
|
88
|
-
tokenEntries: Array<{ priceId: unknown }>
|
|
89
|
-
strategyPositions: Array<Record<string, unknown>>
|
|
90
|
-
}): Set<number> {
|
|
91
|
-
const allPriceIds = new Set<number>()
|
|
92
|
-
|
|
93
|
-
for (const entry of state.tokenEntries) {
|
|
94
|
-
addTrackedPriceIds(allPriceIds, entry.priceId)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
for (const position of state.strategyPositions) {
|
|
98
|
-
if ("orderbook" in position) {
|
|
99
|
-
const orderbook = unwrapTupleLikeValue(position.orderbook) as { priceIdPt?: unknown } | undefined
|
|
100
|
-
if (orderbook?.priceIdPt) {
|
|
101
|
-
addTrackedPriceIds(allPriceIds, orderbook.priceIdPt)
|
|
102
|
-
}
|
|
103
|
-
continue
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if ("tokenAccount" in position) {
|
|
107
|
-
const tokenAccount = unwrapTupleLikeValue(position.tokenAccount) as {
|
|
108
|
-
balances?: Array<{ priceId?: unknown }>
|
|
109
|
-
} | undefined
|
|
110
|
-
for (const balance of tokenAccount?.balances ?? []) {
|
|
111
|
-
if (balance.priceId) {
|
|
112
|
-
addTrackedPriceIds(allPriceIds, balance.priceId)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
continue
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if ("yieldPosition" in position) {
|
|
119
|
-
const yieldPosition = unwrapTupleLikeValue(position.yieldPosition) as { priceIdPt?: unknown } | undefined
|
|
120
|
-
if (yieldPosition?.priceIdPt) {
|
|
121
|
-
addTrackedPriceIds(allPriceIds, yieldPosition.priceIdPt)
|
|
122
|
-
}
|
|
123
|
-
continue
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if ("clmmPosition" in position) {
|
|
127
|
-
const clmmPosition = unwrapTupleLikeValue(position.clmmPosition) as {
|
|
128
|
-
priceIdPt?: unknown
|
|
129
|
-
priceIdSy?: unknown
|
|
130
|
-
} | undefined
|
|
131
|
-
if (clmmPosition?.priceIdPt) {
|
|
132
|
-
addTrackedPriceIds(allPriceIds, clmmPosition.priceIdPt)
|
|
133
|
-
}
|
|
134
|
-
if (clmmPosition?.priceIdSy) {
|
|
135
|
-
addTrackedPriceIds(allPriceIds, clmmPosition.priceIdSy)
|
|
136
|
-
}
|
|
137
|
-
continue
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if ("obligation" in position) {
|
|
141
|
-
const rawObligation = position.obligation as Record<string, unknown> | Array<unknown>
|
|
142
|
-
const inner = unwrapTupleLikeValue(rawObligation as unknown[] | { 0?: unknown })
|
|
143
|
-
const kaminoVariant =
|
|
144
|
-
inner && typeof inner === "object" && "kaminoObligation" in inner
|
|
145
|
-
? (inner as { kaminoObligation?: unknown }).kaminoObligation
|
|
146
|
-
: inner
|
|
147
|
-
const kaminoEntry = unwrapTupleLikeValue(kaminoVariant) as {
|
|
148
|
-
quotePriceId?: unknown
|
|
149
|
-
reservePriceMappings?: Array<{ reservePriceId?: unknown }>
|
|
150
|
-
} | undefined
|
|
151
|
-
if (kaminoEntry?.quotePriceId) {
|
|
152
|
-
addTrackedPriceIds(allPriceIds, kaminoEntry.quotePriceId)
|
|
153
|
-
}
|
|
154
|
-
for (const mapping of kaminoEntry?.reservePriceMappings ?? []) {
|
|
155
|
-
if (mapping.reservePriceId) {
|
|
156
|
-
addTrackedPriceIds(allPriceIds, mapping.reservePriceId)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return allPriceIds
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const getMintDecimals = async (connection: Connection, mint: PublicKey): Promise<number> => {
|
|
166
|
-
const syntheticDecimals = getSyntheticMintDecimals(mint)
|
|
167
|
-
if (syntheticDecimals !== null) {
|
|
168
|
-
return syntheticDecimals
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const mintInfo = await getMint(connection, mint)
|
|
172
|
-
return mintInfo.decimals
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const pushPriceMintAccount = (remainingAccounts: AccountMeta[], mint: PublicKey) => {
|
|
176
|
-
if (getSyntheticMintDecimals(mint) !== null) return
|
|
177
|
-
remainingAccounts.push({ pubkey: mint, isSigner: false, isWritable: false })
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const isLocalRpcEndpoint = (rpcEndpoint: string): boolean => {
|
|
181
|
-
try {
|
|
182
|
-
const hostname = new URL(rpcEndpoint).hostname
|
|
183
|
-
return hostname === "127.0.0.1" || hostname === "localhost"
|
|
184
|
-
} catch {
|
|
185
|
-
return rpcEndpoint.includes("127.0.0.1") || rpcEndpoint.includes("localhost")
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ============================================================================
|
|
190
|
-
// Policy Types (matching on-chain structures)
|
|
191
|
-
// ============================================================================
|
|
192
|
-
|
|
193
|
-
export type DataOperator =
|
|
194
|
-
| "Equals"
|
|
195
|
-
| "NotEquals"
|
|
196
|
-
| "GreaterThan"
|
|
197
|
-
| "GreaterThanOrEqualTo"
|
|
198
|
-
| "LessThan"
|
|
199
|
-
| "LessThanOrEqualTo"
|
|
200
|
-
|
|
201
|
-
export type DataValue =
|
|
202
|
-
| { u8: number }
|
|
203
|
-
| { u16Le: number }
|
|
204
|
-
| { u32Le: number }
|
|
205
|
-
| { u64Le: bigint }
|
|
206
|
-
| { u128Le: bigint }
|
|
207
|
-
| { u8Slice: number[] }
|
|
208
|
-
|
|
209
|
-
export interface DataConstraint {
|
|
210
|
-
dataOffset: bigint
|
|
211
|
-
dataValue: DataValue
|
|
212
|
-
operator: DataOperator
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export interface AccountConstraint {
|
|
216
|
-
accountIndex: number
|
|
217
|
-
accountKeys?: PublicKey[]
|
|
218
|
-
accountDataConstraints?: DataConstraint[]
|
|
219
|
-
owner?: PublicKey | null
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface InstructionConstraint {
|
|
223
|
-
programId: PublicKey
|
|
224
|
-
accountConstraints: AccountConstraint[]
|
|
225
|
-
dataConstraints: DataConstraint[]
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export type Period = "OneTime" | "Hourly" | "Daily" | "Weekly" | "Monthly" | "Quarterly" | "Yearly"
|
|
229
|
-
|
|
230
|
-
export interface TimeConstraints {
|
|
231
|
-
start: bigint
|
|
232
|
-
expiration: bigint | null
|
|
233
|
-
period: Period
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export interface QuantityConstraints {
|
|
237
|
-
maxPerPeriod: bigint
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export interface SpendingLimit {
|
|
241
|
-
mint: PublicKey
|
|
242
|
-
timeConstraints: TimeConstraints
|
|
243
|
-
quantityConstraints: QuantityConstraints
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export type AllowedSettingsChange = "AddSigner" | "RemoveSigner" | "ChangeThreshold" | "ChangeTimeLock"
|
|
247
|
-
|
|
248
|
-
export type PolicyType =
|
|
249
|
-
| {
|
|
250
|
-
programInteraction: {
|
|
251
|
-
accountIndex: number
|
|
252
|
-
instructionsConstraints: InstructionConstraint[]
|
|
253
|
-
spendingLimits: SpendingLimit[]
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
| {
|
|
257
|
-
internalFundTransfer: {
|
|
258
|
-
sourceAccountMask: number[]
|
|
259
|
-
destinationAccountMask: number[]
|
|
260
|
-
allowedMints: PublicKey[]
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
| {
|
|
264
|
-
settingsChange: {
|
|
265
|
-
allowedActions: AllowedSettingsChange[]
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
| {
|
|
269
|
-
spendingLimit: {
|
|
270
|
-
sourceAccountIndex: number
|
|
271
|
-
destinations: PublicKey[]
|
|
272
|
-
spendingLimit: SpendingLimit
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
277
|
-
export type PolicyExpiration = { timestamp: bigint } | { settingsState: {} }
|
|
278
|
-
|
|
279
|
-
export interface PolicyConfig {
|
|
280
|
-
policyType: PolicyType
|
|
281
|
-
threshold: number
|
|
282
|
-
timeLock: number
|
|
283
|
-
startTimestamp: bigint | null
|
|
284
|
-
expiration: PolicyExpiration | null
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/** Interface type for adapter vaults */
|
|
288
|
-
export type InterfaceType =
|
|
289
|
-
| { generic: Record<string, never> }
|
|
290
|
-
| { kamino: Record<string, never> }
|
|
291
|
-
| { marginfi: Record<string, never> }
|
|
292
|
-
| { jitoRestaking: Record<string, never> }
|
|
293
|
-
| { perena: Record<string, never> }
|
|
294
|
-
|
|
295
|
-
export interface TokenEntryInput {
|
|
296
|
-
mint: PublicKey
|
|
297
|
-
priceId: PriceId
|
|
298
|
-
tokenSquadsAccount: PublicKey
|
|
299
|
-
tokenAccountVault: PublicKey
|
|
300
|
-
tokenEscrow: PublicKey
|
|
301
|
-
shareBp: number
|
|
302
|
-
currentLiquidity: bigint
|
|
303
|
-
mintFlag: number
|
|
304
|
-
interfaceType?: InterfaceType
|
|
305
|
-
/** Force deallocate policy IDs (optional, defaults to empty) */
|
|
306
|
-
forceDeallocatePolicyIds?: bigint[]
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
type TotalAumInfo = {
|
|
310
|
-
aum: bigint
|
|
311
|
-
aumHuman: number
|
|
312
|
-
lpRate: number
|
|
313
|
-
lpSupply: bigint
|
|
314
|
-
lpDecimals: number
|
|
315
|
-
underlyingDecimals: number
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const VAULT_SEED = Buffer.from("vault")
|
|
319
|
-
|
|
320
|
-
const toBigInt = (value: Numeric): bigint => {
|
|
321
|
-
if (typeof value === "bigint") return value
|
|
322
|
-
return BigInt(Math.ceil(value))
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const toCodamaPriceId = (priceId: PriceId): exponentVaults.PriceId => {
|
|
326
|
-
if ("simple" in priceId) {
|
|
327
|
-
return {
|
|
328
|
-
__kind: "Simple",
|
|
329
|
-
priceId: toBigInt(priceId.simple.priceId),
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
if ("multiply" in priceId) {
|
|
333
|
-
return {
|
|
334
|
-
__kind: "Multiply",
|
|
335
|
-
priceIds: priceId.multiply.priceIds.map((id) => toBigInt(id)),
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
throw new Error("Unknown PriceId variant")
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const defaultTokenAccount = (mint: PublicKey, owner: PublicKey, tokenProgram: PublicKey) =>
|
|
342
|
-
getAssociatedTokenAddressSync(mint, owner, true, tokenProgram)
|
|
343
|
-
|
|
344
|
-
const PRICE_INTERFACE_ACCOUNTS_SEED = Buffer.from("price_interface_accounts")
|
|
345
|
-
|
|
346
|
-
const randomPriceInterfaceAccountsSeed = (): Uint8Array =>
|
|
347
|
-
Uint8Array.from(Keypair.generate().publicKey.toBytes().slice(0, 8))
|
|
348
|
-
|
|
349
|
-
const derivePriceInterfaceAccountsAddress = (
|
|
350
|
-
programId: PublicKey,
|
|
351
|
-
exponentPrices: PublicKey,
|
|
352
|
-
seed: Uint8Array,
|
|
353
|
-
): [PublicKey, number] =>
|
|
354
|
-
PublicKey.findProgramAddressSync(
|
|
355
|
-
[PRICE_INTERFACE_ACCOUNTS_SEED, exponentPrices.toBuffer(), Buffer.from(seed)],
|
|
356
|
-
programId,
|
|
357
|
-
)
|
|
358
|
-
|
|
359
|
-
const convertPriceType = (priceType: PriceTypeParam): exponentVaults.PriceType => {
|
|
360
|
-
if ("pyth" in priceType) return exponentVaults.PriceType.Pyth
|
|
361
|
-
if ("pythInverse" in priceType) return exponentVaults.PriceType.PythInverse
|
|
362
|
-
if ("splStakePool" in priceType) return exponentVaults.PriceType.SplStakePool
|
|
363
|
-
if ("one" in priceType) return exponentVaults.PriceType.One
|
|
364
|
-
if ("pt" in priceType) return exponentVaults.PriceType.Pt
|
|
365
|
-
if ("yt" in priceType) return exponentVaults.PriceType.Yt
|
|
366
|
-
if ("solstice" in priceType) return exponentVaults.PriceType.Solstice
|
|
367
|
-
if ("reflect" in priceType) return exponentVaults.PriceType.Reflect
|
|
368
|
-
if ("fragmetric" in priceType) return exponentVaults.PriceType.Fragmetric
|
|
369
|
-
if ("fragmetricSupportedAsset" in priceType) return exponentVaults.PriceType.FragmetricSupportedAsset
|
|
370
|
-
if ("jupiterLend" in priceType) return exponentVaults.PriceType.JupiterLend
|
|
371
|
-
if ("chainlink" in priceType) return exponentVaults.PriceType.Chainlink
|
|
372
|
-
if ("ore" in priceType) return exponentVaults.PriceType.Ore
|
|
373
|
-
if ("hyloLpToken" in priceType) return exponentVaults.PriceType.HyloLpToken
|
|
374
|
-
if ("meteora" in priceType) return exponentVaults.PriceType.Meteora
|
|
375
|
-
if ("kaminoVault" in priceType) return exponentVaults.PriceType.KaminoVault
|
|
376
|
-
throw new Error("Unknown PriceType variant")
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const convertUpdatePriceAction = (
|
|
380
|
-
action: UpdatePriceActionParam,
|
|
381
|
-
programId: PublicKey,
|
|
382
|
-
exponentPrices: PublicKey,
|
|
383
|
-
remainingAccounts: AccountMeta[],
|
|
384
|
-
): exponentVaults.UpdatePriceAction => {
|
|
385
|
-
if ("addPrice" in action) {
|
|
386
|
-
const seed = randomPriceInterfaceAccountsSeed()
|
|
387
|
-
const [priceInterfaceAccounts] = derivePriceInterfaceAccountsAddress(programId, exponentPrices, seed)
|
|
388
|
-
const interfaceAccounts = action.addPrice.interfaceAccounts ?? []
|
|
389
|
-
remainingAccounts.push({
|
|
390
|
-
pubkey: priceInterfaceAccounts,
|
|
391
|
-
isSigner: false,
|
|
392
|
-
isWritable: true,
|
|
393
|
-
})
|
|
394
|
-
pushPriceMintAccount(remainingAccounts, action.addPrice.priceMint)
|
|
395
|
-
pushPriceMintAccount(remainingAccounts, action.addPrice.underlyingMint)
|
|
396
|
-
return {
|
|
397
|
-
__kind: "AddPrice",
|
|
398
|
-
priceType: convertPriceType(action.addPrice.priceType),
|
|
399
|
-
priceMint: action.addPrice.priceMint,
|
|
400
|
-
underlyingMint: action.addPrice.underlyingMint,
|
|
401
|
-
interfaceAccounts,
|
|
402
|
-
priceInterfaceAccountsSeed: seed,
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
if ("removePrice" in action) {
|
|
406
|
-
if (!action.removePrice.priceInterfaceAccounts) {
|
|
407
|
-
throw new Error("removePrice requires priceInterfaceAccounts")
|
|
408
|
-
}
|
|
409
|
-
remainingAccounts.push({
|
|
410
|
-
pubkey: action.removePrice.priceInterfaceAccounts,
|
|
411
|
-
isSigner: false,
|
|
412
|
-
isWritable: true,
|
|
413
|
-
})
|
|
414
|
-
return {
|
|
415
|
-
__kind: "RemovePrice",
|
|
416
|
-
priceId: toBigInt(action.removePrice.priceId),
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
if ("updatePrice" in action) {
|
|
420
|
-
if (!action.updatePrice.priceInterfaceAccounts) {
|
|
421
|
-
throw new Error("updatePrice requires priceInterfaceAccounts")
|
|
422
|
-
}
|
|
423
|
-
remainingAccounts.push({
|
|
424
|
-
pubkey: action.updatePrice.priceInterfaceAccounts,
|
|
425
|
-
isSigner: false,
|
|
426
|
-
isWritable: false,
|
|
427
|
-
})
|
|
428
|
-
return {
|
|
429
|
-
__kind: "UpdatePrice",
|
|
430
|
-
priceId: toBigInt(action.updatePrice.priceId),
|
|
431
|
-
priceType: convertPriceType(action.updatePrice.priceType),
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
if ("addManager" in action) {
|
|
435
|
-
return {
|
|
436
|
-
__kind: "AddManager",
|
|
437
|
-
manager: action.addManager.manager,
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
if ("removeManager" in action) {
|
|
441
|
-
return {
|
|
442
|
-
__kind: "RemoveManager",
|
|
443
|
-
manager: action.removeManager.manager,
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if ("addPtPrice" in action) {
|
|
447
|
-
const seed = randomPriceInterfaceAccountsSeed()
|
|
448
|
-
const [priceInterfaceAccounts] = derivePriceInterfaceAccountsAddress(programId, exponentPrices, seed)
|
|
449
|
-
const interfaceAccounts = action.addPtPrice.interfaceAccounts ?? []
|
|
450
|
-
remainingAccounts.push({
|
|
451
|
-
pubkey: priceInterfaceAccounts,
|
|
452
|
-
isSigner: false,
|
|
453
|
-
isWritable: true,
|
|
454
|
-
})
|
|
455
|
-
pushPriceMintAccount(remainingAccounts, action.addPtPrice.priceMint)
|
|
456
|
-
pushPriceMintAccount(remainingAccounts, action.addPtPrice.underlyingMint)
|
|
457
|
-
return {
|
|
458
|
-
__kind: "AddPtPrice",
|
|
459
|
-
priceMint: action.addPtPrice.priceMint,
|
|
460
|
-
underlyingMint: action.addPtPrice.underlyingMint,
|
|
461
|
-
interfaceAccounts,
|
|
462
|
-
priceInterfaceAccountsSeed: seed,
|
|
463
|
-
impliedApyBps: action.addPtPrice.impliedApyBps,
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
if ("addYtPrice" in action) {
|
|
467
|
-
const seed = randomPriceInterfaceAccountsSeed()
|
|
468
|
-
const [priceInterfaceAccounts] = derivePriceInterfaceAccountsAddress(programId, exponentPrices, seed)
|
|
469
|
-
const interfaceAccounts = action.addYtPrice.interfaceAccounts ?? []
|
|
470
|
-
remainingAccounts.push({
|
|
471
|
-
pubkey: priceInterfaceAccounts,
|
|
472
|
-
isSigner: false,
|
|
473
|
-
isWritable: true,
|
|
474
|
-
})
|
|
475
|
-
pushPriceMintAccount(remainingAccounts, action.addYtPrice.priceMint)
|
|
476
|
-
pushPriceMintAccount(remainingAccounts, action.addYtPrice.underlyingMint)
|
|
477
|
-
return {
|
|
478
|
-
__kind: "AddYtPrice",
|
|
479
|
-
priceMint: action.addYtPrice.priceMint,
|
|
480
|
-
underlyingMint: action.addYtPrice.underlyingMint,
|
|
481
|
-
interfaceAccounts,
|
|
482
|
-
priceInterfaceAccountsSeed: seed,
|
|
483
|
-
impliedApyBps: action.addYtPrice.impliedApyBps,
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
throw new Error("Unknown UpdatePriceAction variant")
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
export interface DepositLiquidityParams {
|
|
490
|
-
depositor: PublicKey
|
|
491
|
-
mint: PublicKey
|
|
492
|
-
tokenAmountIn: Numeric
|
|
493
|
-
minLpOut: Numeric
|
|
494
|
-
tokenSrc?: PublicKey
|
|
495
|
-
/** Defaults to the Squads-controlled token account defined by the vault entry. */
|
|
496
|
-
entryTokenVault?: PublicKey
|
|
497
|
-
tokenLpDst?: PublicKey
|
|
498
|
-
tokenProgram?: PublicKey
|
|
499
|
-
/** Additional remaining accounts (e.g., Kamino obligations) */
|
|
500
|
-
extraRemainingAccounts?: AccountMeta[]
|
|
501
|
-
/**
|
|
502
|
-
* When true, pass token_2022_program (TOKEN_2022_PROGRAM_ID) as the second token program account.
|
|
503
|
-
* Use for compatibility with older deployed programs that expect token_program + token_2022_program
|
|
504
|
-
* instead of token_program + token_program_lp. Required when running against Surfpool/mainnet fork.
|
|
505
|
-
*/
|
|
506
|
-
useLegacyTokenAccounts?: boolean
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
export interface UpdatePriceParams {
|
|
510
|
-
priceInterfaceAccounts?: PublicKey
|
|
511
|
-
pythPriceFeedId?: PublicKey
|
|
512
|
-
remainingAccounts?: PublicKey[]
|
|
513
|
-
priceId: number
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
export interface UpdateStrategyVaultPricesOptions {
|
|
517
|
-
manager?: PublicKey
|
|
518
|
-
priceIds?: Iterable<number>
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
export interface QueueWithdrawalParams {
|
|
522
|
-
depositor: PublicKey
|
|
523
|
-
lpAmount: Numeric
|
|
524
|
-
tokenLpSrc?: PublicKey
|
|
525
|
-
tokenProgram?: PublicKey
|
|
526
|
-
systemProgram?: PublicKey
|
|
527
|
-
tokenLpEscrow?: PublicKey
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
export interface TokenAccountPair {
|
|
531
|
-
/** Source token account (vault's token escrow) */
|
|
532
|
-
tokenSrc: PublicKey
|
|
533
|
-
/** Destination token account (user's token account) */
|
|
534
|
-
tokenDst: PublicKey
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
export interface ExecuteWithdrawalParams {
|
|
538
|
-
owner: PublicKey
|
|
539
|
-
withdrawalAccount: PublicKey
|
|
540
|
-
/** Array of token account pairs matching the withdrawal fills */
|
|
541
|
-
tokenAccountPairs: TokenAccountPair[]
|
|
542
|
-
tokenProgram?: PublicKey
|
|
543
|
-
token2022Program?: PublicKey
|
|
544
|
-
tokenLpEscrow?: PublicKey
|
|
545
|
-
mintLp?: PublicKey
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
export interface ExecuteWithdrawalFromReservesParams {
|
|
549
|
-
owner: PublicKey
|
|
550
|
-
/** Index of the token entry to withdraw */
|
|
551
|
-
entryIdx: number
|
|
552
|
-
/** Amount of LP tokens to burn for withdrawal */
|
|
553
|
-
lpAmount: Numeric
|
|
554
|
-
/** Source token account (owned by squads_vault) */
|
|
555
|
-
tokenSrc: PublicKey
|
|
556
|
-
/** Source token account (owned by vault) */
|
|
557
|
-
tokenVaultSrc: PublicKey
|
|
558
|
-
/** Destination token account (owned by the user) */
|
|
559
|
-
tokenDst: PublicKey
|
|
560
|
-
squadsProgram: PublicKey
|
|
561
|
-
tokenLpSrc?: PublicKey
|
|
562
|
-
tokenProgram?: PublicKey
|
|
563
|
-
token2022Program?: PublicKey
|
|
564
|
-
tokenLpEscrow?: PublicKey
|
|
565
|
-
mintLp?: PublicKey
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
export interface FillWithdrawalFillParam {
|
|
569
|
-
/** Index of the token entry in vault.token_entries */
|
|
570
|
-
tokenEntryIdx: number
|
|
571
|
-
/** Percentage of remaining LP to fill in basis points (10000 = 100%) */
|
|
572
|
-
percentOfTotalLpBp: Numeric
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
export interface FillWithdrawalParams {
|
|
576
|
-
/** Withdrawal account to fill */
|
|
577
|
-
withdrawalAccount: PublicKey
|
|
578
|
-
/** Fill parameters: which token entries and what percentage */
|
|
579
|
-
fills: FillWithdrawalFillParam[]
|
|
580
|
-
/** Token account pairs per fill: [{ tokenSrc (squads), tokenDst (vault escrow), tokenProgram }] */
|
|
581
|
-
tokenAccountTriples: Array<{
|
|
582
|
-
tokenSrc: PublicKey
|
|
583
|
-
tokenDst: PublicKey
|
|
584
|
-
tokenProgram: PublicKey
|
|
585
|
-
}>
|
|
586
|
-
mintLp?: PublicKey
|
|
587
|
-
tokenLpEscrow?: PublicKey
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
export interface WrapperExecuteWithdrawalParams {
|
|
591
|
-
owner: PublicKey
|
|
592
|
-
withdrawalAccount: PublicKey
|
|
593
|
-
/** Array of token account pairs matching the withdrawal fills */
|
|
594
|
-
tokenAccountPairs: TokenAccountPair[]
|
|
595
|
-
/** Index of the token entry for reserves withdrawal */
|
|
596
|
-
entryIdx: number
|
|
597
|
-
/** Source token account for reserves withdrawal (owned by squads_vault) */
|
|
598
|
-
tokenSrc: PublicKey
|
|
599
|
-
/** Source token account for reserves withdrawal (owned by vault) */
|
|
600
|
-
tokenVaultSrc: PublicKey
|
|
601
|
-
/** Destination token account for reserves withdrawal (owned by user) */
|
|
602
|
-
tokenDst: PublicKey
|
|
603
|
-
squadsProgram: PublicKey
|
|
604
|
-
tokenProgram?: PublicKey
|
|
605
|
-
token2022Program?: PublicKey
|
|
606
|
-
tokenLpEscrow?: PublicKey
|
|
607
|
-
mintLp?: PublicKey
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
// ============================================================================
|
|
611
|
-
// Vault Initialization & Policy Management Parameter Types
|
|
612
|
-
// ============================================================================
|
|
613
|
-
|
|
614
|
-
/** Vault type enum */
|
|
615
|
-
export type VaultType = { orderbook: Record<string, never> } | { generic: Record<string, never> }
|
|
616
|
-
|
|
617
|
-
/** Role membership lists for vault governance */
|
|
618
|
-
export interface VaultRoles {
|
|
619
|
-
manager: PublicKey[]
|
|
620
|
-
curator: PublicKey[]
|
|
621
|
-
allocator: PublicKey[]
|
|
622
|
-
sentinel: PublicKey[]
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/** Configuration for proposal voting system */
|
|
626
|
-
export interface ProposalVoteConfig {
|
|
627
|
-
minVotingPeriodSeconds: number
|
|
628
|
-
maxVotingPeriodSeconds: number
|
|
629
|
-
defaultVotingPeriodSeconds: number
|
|
630
|
-
defaultTimelockSeconds: number
|
|
631
|
-
rejectionThresholdBps: bigint
|
|
632
|
-
nextProposalId: bigint
|
|
633
|
-
votingEnabled: boolean
|
|
634
|
-
liveProposalsCount: number
|
|
635
|
-
maxConcurrentLiveProposals: number
|
|
636
|
-
reserved: number[]
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
export interface InitializeVaultParams {
|
|
640
|
-
/** Payer of the transaction (will also be the initial manager) */
|
|
641
|
-
payer: PublicKey
|
|
642
|
-
/** Underlying mint used by vault-level price validation */
|
|
643
|
-
mint: PublicKey
|
|
644
|
-
/** Manager of the vault (can be different from payer) */
|
|
645
|
-
manager: PublicKey
|
|
646
|
-
/** 8-byte seed ID for the vault PDA */
|
|
647
|
-
seedId: SeedId
|
|
648
|
-
/** Fee treasury account */
|
|
649
|
-
feeTreasury: PublicKey
|
|
650
|
-
/** Fee treasury in basis points */
|
|
651
|
-
normalWithdrawalFeeBps: number
|
|
652
|
-
/** Annualized management fee in basis points (1e6 precision) */
|
|
653
|
-
managementFeeBps: bigint
|
|
654
|
-
/** Percentage of vault assets to keep as reserves in basis points (10000 = 100%) */
|
|
655
|
-
reservesShareBp: number
|
|
656
|
-
/** Additional fee charged on fast withdrawals in basis points */
|
|
657
|
-
fastWithdrawalCutBp?: number
|
|
658
|
-
/** Initial token entries for the vault */
|
|
659
|
-
tokenEntries: TokenEntryInput[]
|
|
660
|
-
/** Max LP token supply */
|
|
661
|
-
maxLpSupply: bigint
|
|
662
|
-
/** Initial LP amount to mint */
|
|
663
|
-
initialLpAmount: bigint
|
|
664
|
-
/** LP token decimals */
|
|
665
|
-
lpDecimals: number
|
|
666
|
-
/** Deprecated: ignored by the vaults program */
|
|
667
|
-
vaultType?: VaultType
|
|
668
|
-
/** Role membership lists */
|
|
669
|
-
roles: VaultRoles
|
|
670
|
-
/** Proposal voting configuration (optional) */
|
|
671
|
-
proposalVoteConfig?: ProposalVoteConfig
|
|
672
|
-
/** Address lookup table */
|
|
673
|
-
addressLookupTable: PublicKey
|
|
674
|
-
/** Squads program ID */
|
|
675
|
-
squadsProgram: PublicKey
|
|
676
|
-
/** Squads program config PDA (for creation fee) */
|
|
677
|
-
squadsProgramConfig: PublicKey
|
|
678
|
-
/** Squads treasury (receives creation fee) */
|
|
679
|
-
squadsTreasury: PublicKey
|
|
680
|
-
/** Squads settings account - derived as PDA("smart_account", "settings", index) */
|
|
681
|
-
squadsSettings: PublicKey
|
|
682
|
-
/** Squads vault account - derived as PDA("smart_account", settings_key, "smart_account", 0) */
|
|
683
|
-
squadsVault: PublicKey
|
|
684
|
-
/** Token program (defaults to Token) */
|
|
685
|
-
tokenProgram?: PublicKey
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// ============================================================================
|
|
689
|
-
// Price Management Types
|
|
690
|
-
// ============================================================================
|
|
691
|
-
|
|
692
|
-
/** Price type enum (matches on-chain PriceType) */
|
|
693
|
-
export type PriceTypeParam =
|
|
694
|
-
| { pyth: Record<string, never> }
|
|
695
|
-
| { pythInverse: Record<string, never> }
|
|
696
|
-
| { splStakePool: Record<string, never> }
|
|
697
|
-
| { one: Record<string, never> }
|
|
698
|
-
| { pt: Record<string, never> }
|
|
699
|
-
| { yt: Record<string, never> }
|
|
700
|
-
| { solstice: Record<string, never> }
|
|
701
|
-
| { reflect: Record<string, never> }
|
|
702
|
-
| { fragmetric: Record<string, never> }
|
|
703
|
-
| { fragmetricSupportedAsset: Record<string, never> }
|
|
704
|
-
| { jupiterLend: Record<string, never> }
|
|
705
|
-
| { chainlink: Record<string, never> }
|
|
706
|
-
| { ore: Record<string, never> }
|
|
707
|
-
| { hyloLpToken: Record<string, never> }
|
|
708
|
-
| { meteora: Record<string, never> }
|
|
709
|
-
| { kaminoVault: Record<string, never> }
|
|
710
|
-
|
|
711
|
-
/** Action for managing price entries in ExponentPrices account */
|
|
712
|
-
export type UpdatePriceActionParam =
|
|
713
|
-
| {
|
|
714
|
-
addPrice: {
|
|
715
|
-
priceType: PriceTypeParam
|
|
716
|
-
priceMint: PublicKey
|
|
717
|
-
underlyingMint: PublicKey
|
|
718
|
-
interfaceAccounts?: PublicKey[]
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
| { removePrice: { priceId: bigint; priceInterfaceAccounts?: PublicKey } }
|
|
722
|
-
| { updatePrice: { priceId: bigint; priceType: PriceTypeParam; priceInterfaceAccounts?: PublicKey } }
|
|
723
|
-
| { addManager: { manager: PublicKey } }
|
|
724
|
-
| { removeManager: { manager: PublicKey } }
|
|
725
|
-
| {
|
|
726
|
-
addPtPrice: {
|
|
727
|
-
priceMint: PublicKey
|
|
728
|
-
underlyingMint: PublicKey
|
|
729
|
-
interfaceAccounts?: PublicKey[]
|
|
730
|
-
impliedApyBps: number
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
| {
|
|
734
|
-
addYtPrice: {
|
|
735
|
-
priceMint: PublicKey
|
|
736
|
-
underlyingMint: PublicKey
|
|
737
|
-
interfaceAccounts?: PublicKey[]
|
|
738
|
-
impliedApyBps: number
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
export interface InitializePricesParams {
|
|
743
|
-
/** Manager of the vault (must sign, pays for account creation) */
|
|
744
|
-
manager: PublicKey
|
|
745
|
-
/** Optional override for the exponent_vaults program ID */
|
|
746
|
-
programId?: PublicKey
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
export interface ManagePricesParams {
|
|
750
|
-
/** Manager of the vault (must sign, pays for reallocation) */
|
|
751
|
-
manager: PublicKey
|
|
752
|
-
/** List of price actions to execute */
|
|
753
|
-
actions: UpdatePriceActionParam[]
|
|
754
|
-
/** Optional override for the exponent_vaults program ID */
|
|
755
|
-
programId?: PublicKey
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
export interface AddPolicyParams {
|
|
759
|
-
/** Payer for the transaction */
|
|
760
|
-
payer: PublicKey
|
|
761
|
-
/** Policy configuration to add */
|
|
762
|
-
policyConfig: PolicyConfig
|
|
763
|
-
/** Squads program ID */
|
|
764
|
-
squadsProgram: PublicKey
|
|
765
|
-
/** Next policy seed (get from settings.nextPolicySeed) */
|
|
766
|
-
nextPolicySeed: bigint
|
|
767
|
-
/** Next transaction index (get from settings.transactionIndex + 1) */
|
|
768
|
-
nextTransactionIndex: bigint
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
export interface RemovePolicyParams {
|
|
772
|
-
/** Payer for the transaction */
|
|
773
|
-
payer: PublicKey
|
|
774
|
-
/** Manager of the vault (must sign) */
|
|
775
|
-
manager: PublicKey
|
|
776
|
-
/** Policy seed to remove */
|
|
777
|
-
policySeed: bigint
|
|
778
|
-
/** Squads program ID */
|
|
779
|
-
squadsProgram: PublicKey
|
|
780
|
-
/** Next transaction index (get from settings.transactionIndex + 1) */
|
|
781
|
-
nextTransactionIndex: bigint
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
export interface UpdatePolicyParams {
|
|
785
|
-
payer: PublicKey
|
|
786
|
-
manager: PublicKey
|
|
787
|
-
policyConfig: PolicyConfig
|
|
788
|
-
policySeed: bigint
|
|
789
|
-
squadsProgram: PublicKey
|
|
790
|
-
nextTransactionIndex: bigint
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
export interface WrapperManageVaultSettingsParams {
|
|
794
|
-
manager: PublicKey
|
|
795
|
-
actions: exponentVaults.VaultSettingsAction[]
|
|
796
|
-
remainingAccounts?: AccountMeta[]
|
|
797
|
-
exponentPrices?: PublicKey
|
|
798
|
-
systemProgram?: PublicKey
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
export interface WrapperManagerUpdatePositionParams {
|
|
802
|
-
manager: PublicKey
|
|
803
|
-
update: exponentVaults.PositionUpdate
|
|
804
|
-
remainingAccounts?: AccountMeta[]
|
|
805
|
-
exponentPrices?: PublicKey
|
|
806
|
-
systemProgram?: PublicKey
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
export interface WrapperAddKaminoObligationPositionParams {
|
|
810
|
-
manager: PublicKey
|
|
811
|
-
obligation: PublicKey
|
|
812
|
-
lendingProgramId: PublicKey
|
|
813
|
-
quotePriceId: exponentVaults.PriceId
|
|
814
|
-
reservePriceMappings: exponentVaults.ReservePriceMapping[]
|
|
815
|
-
reserveFarmMappings?: exponentVaults.ReserveFarmMapping[]
|
|
816
|
-
minPriceStatusFlags: number
|
|
817
|
-
remainingAccounts?: AccountMeta[]
|
|
818
|
-
exponentPrices?: PublicKey
|
|
819
|
-
systemProgram?: PublicKey
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
export interface WrapperUpsertKaminoObligationReservePriceMappingsParams {
|
|
823
|
-
manager: PublicKey
|
|
824
|
-
obligation: PublicKey
|
|
825
|
-
reservePriceMappings: exponentVaults.ReservePriceMapping[]
|
|
826
|
-
reserveFarmMappings?: exponentVaults.ReserveFarmMapping[]
|
|
827
|
-
remainingAccounts?: AccountMeta[]
|
|
828
|
-
exponentPrices?: PublicKey
|
|
829
|
-
systemProgram?: PublicKey
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
export type WrapperAddPolicyParams = AddPolicyParams
|
|
833
|
-
|
|
834
|
-
export type WrapperRemovePolicyParams = RemovePolicyParams
|
|
835
|
-
|
|
836
|
-
export type WrapperUpdatePolicyParams = UpdatePolicyParams
|
|
837
|
-
|
|
838
|
-
export interface CancelWithdrawalParams {
|
|
839
|
-
owner: PublicKey
|
|
840
|
-
withdrawalAccount: PublicKey
|
|
841
|
-
tokenLpDst?: PublicKey
|
|
842
|
-
tokenProgram?: PublicKey
|
|
843
|
-
tokenLpEscrow?: PublicKey
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
export interface CollectManagementFeeParams {
|
|
847
|
-
manager: PublicKey
|
|
848
|
-
mintLp?: PublicKey
|
|
849
|
-
feeTreasury?: PublicKey
|
|
850
|
-
tokenProgram?: PublicKey
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
export class ExponentVault {
|
|
854
|
-
public state: ExponentVaultAccountType
|
|
855
|
-
public readonly selfAddress: PublicKey
|
|
856
|
-
public readonly env: Environment
|
|
857
|
-
public connection: Connection
|
|
858
|
-
public readonly programId: PublicKey
|
|
859
|
-
public readonly fetcher: ExponentVaultsFetcher
|
|
860
|
-
public pda: ExponentVaultsPDA
|
|
861
|
-
public aumCalculator: AumCalculator
|
|
862
|
-
private clmmTicksMap: Map<string, PublicKey> = new Map()
|
|
863
|
-
private kaminoFarmAuxAccountsMap: Map<string, AccountMeta[]> = new Map()
|
|
864
|
-
private kaminoObligationFarmUserStates: Set<string> = new Set()
|
|
865
|
-
static squadsVaultTxnResolver = new SquadsVaultTxnResolver()
|
|
866
|
-
|
|
867
|
-
constructor(params: {
|
|
868
|
-
state: ExponentVaultAccountType
|
|
869
|
-
address: PublicKey
|
|
870
|
-
env?: Environment
|
|
871
|
-
connection: Connection
|
|
872
|
-
programId?: PublicKey
|
|
873
|
-
}) {
|
|
874
|
-
this.state = params.state
|
|
875
|
-
this.selfAddress = params.address
|
|
876
|
-
this.env = params.env ?? LOCAL_ENV
|
|
877
|
-
this.connection = params.connection
|
|
878
|
-
this.programId = params.programId ?? this.env.exponentVaultsProgramId ?? new PublicKey(EXPONENT_VAULTS_PROGRAM_ID)
|
|
879
|
-
this.fetcher = new ExponentVaultsFetcher(this.connection, this.programId)
|
|
880
|
-
this.pda = new ExponentVaultsPDA(this.programId)
|
|
881
|
-
this.aumCalculator = new AumCalculator(this.state, this.connection, this.env)
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
static async load(params: { env?: Environment; connection: Connection; address: PublicKey }) {
|
|
885
|
-
const env = params.env ?? LOCAL_ENV
|
|
886
|
-
const fetcher = new ExponentVaultsFetcher(
|
|
887
|
-
params.connection,
|
|
888
|
-
env.exponentVaultsProgramId ?? EXPONENT_VAULTS_PROGRAM_ID,
|
|
889
|
-
)
|
|
890
|
-
const state = await fetcher.fetchVaultDeserialized(params.address)
|
|
891
|
-
const vault = new ExponentVault({
|
|
892
|
-
state,
|
|
893
|
-
address: params.address,
|
|
894
|
-
env,
|
|
895
|
-
connection: params.connection,
|
|
896
|
-
programId: fetcher.programId,
|
|
897
|
-
})
|
|
898
|
-
await Promise.all([
|
|
899
|
-
vault.populateClmmTicksCache(params.connection),
|
|
900
|
-
vault.populateKaminoFarmAuxAccountsCache(params.connection),
|
|
901
|
-
])
|
|
902
|
-
return vault
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
static async loadAll(params: { env?: Environment; connection: Connection }): Promise<ExponentVault[]> {
|
|
906
|
-
const env = params.env ?? LOCAL_ENV
|
|
907
|
-
const fetcher = new ExponentVaultsFetcher(
|
|
908
|
-
params.connection,
|
|
909
|
-
env.exponentVaultsProgramId ?? EXPONENT_VAULTS_PROGRAM_ID,
|
|
910
|
-
)
|
|
911
|
-
const vaults = await fetcher.fetchAllVaultsDeserialized()
|
|
912
|
-
const results = vaults.map(
|
|
913
|
-
({ publicKey, account }) =>
|
|
914
|
-
new ExponentVault({
|
|
915
|
-
state: account,
|
|
916
|
-
address: publicKey,
|
|
917
|
-
env,
|
|
918
|
-
connection: params.connection,
|
|
919
|
-
programId: fetcher.programId,
|
|
920
|
-
}),
|
|
921
|
-
)
|
|
922
|
-
await Promise.all(
|
|
923
|
-
results.flatMap((vault) => [
|
|
924
|
-
vault.populateClmmTicksCache(params.connection),
|
|
925
|
-
vault.populateKaminoFarmAuxAccountsCache(params.connection),
|
|
926
|
-
]),
|
|
927
|
-
)
|
|
928
|
-
return results
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
async reload(connection: Connection = this.connection) {
|
|
932
|
-
const refreshed = await ExponentVault.load({ env: this.env, connection, address: this.selfAddress })
|
|
933
|
-
this.state = refreshed.state
|
|
934
|
-
this.clmmTicksMap = refreshed.clmmTicksMap
|
|
935
|
-
this.kaminoFarmAuxAccountsMap = refreshed.kaminoFarmAuxAccountsMap
|
|
936
|
-
this.kaminoObligationFarmUserStates = refreshed.kaminoObligationFarmUserStates
|
|
937
|
-
this.connection = connection
|
|
938
|
-
this.aumCalculator = new AumCalculator(this.state, this.connection, this.env)
|
|
939
|
-
return refreshed
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
private async populateClmmTicksCache(connection: Connection): Promise<void> {
|
|
943
|
-
this.clmmTicksMap.clear()
|
|
944
|
-
const marketKeys: PublicKey[] = []
|
|
945
|
-
for (const pos of this.state.strategyPositions) {
|
|
946
|
-
if ("clmmPosition" in pos && pos.clmmPosition && typeof pos.clmmPosition === "object") {
|
|
947
|
-
const entry = (pos as { clmmPosition: { 0: ClmmPositionEntry } }).clmmPosition[0]
|
|
948
|
-
const key = entry.market.toBase58()
|
|
949
|
-
if (!this.clmmTicksMap.has(key) && !marketKeys.some((k) => k.equals(entry.market))) {
|
|
950
|
-
marketKeys.push(entry.market)
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
if (marketKeys.length === 0) return
|
|
955
|
-
const markets = await fetchAllMaybeMarketThreeAccounts(connection, marketKeys)
|
|
956
|
-
for (const market of markets) {
|
|
957
|
-
if (market) {
|
|
958
|
-
this.clmmTicksMap.set(market.address.toBase58(), market.data.ticks)
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
private async populateKaminoFarmAuxAccountsCache(connection: Connection): Promise<void> {
|
|
964
|
-
this.kaminoFarmAuxAccountsMap.clear()
|
|
965
|
-
this.kaminoObligationFarmUserStates.clear()
|
|
966
|
-
|
|
967
|
-
const farmStates: PublicKey[] = []
|
|
968
|
-
const delegatedFarmUsers: Array<{ obligation: PublicKey; farmState: PublicKey; userState: PublicKey }> = []
|
|
969
|
-
for (const pos of this.state.strategyPositions) {
|
|
970
|
-
if ("kaminoFarm" in pos && pos.kaminoFarm && typeof pos.kaminoFarm === "object") {
|
|
971
|
-
const entry = (pos as { kaminoFarm: { 0: { farmState: PublicKey } } }).kaminoFarm[0]
|
|
972
|
-
if (!farmStates.some((farmState) => farmState.equals(entry.farmState))) {
|
|
973
|
-
farmStates.push(entry.farmState)
|
|
974
|
-
}
|
|
975
|
-
continue
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
if (!("obligation" in pos) || !pos.obligation || typeof pos.obligation !== "object") {
|
|
979
|
-
continue
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
const rawObligation = pos["obligation"] as Record<string, unknown> | Array<unknown>
|
|
983
|
-
const inner = Array.isArray(rawObligation)
|
|
984
|
-
? (rawObligation[0] as Record<string, unknown> | undefined)
|
|
985
|
-
: rawObligation && typeof rawObligation === "object" && "0" in rawObligation
|
|
986
|
-
? (rawObligation[0] as Record<string, unknown> | undefined)
|
|
987
|
-
: (rawObligation as Record<string, unknown> | undefined)
|
|
988
|
-
const kaminoVariant = inner && "kaminoObligation" in inner ? (inner.kaminoObligation as unknown) : inner
|
|
989
|
-
const entry = Array.isArray(kaminoVariant)
|
|
990
|
-
? (kaminoVariant[0] as
|
|
991
|
-
| {
|
|
992
|
-
obligation?: PublicKey
|
|
993
|
-
reserveFarmMappings?: Array<{ farmState: PublicKey }>
|
|
994
|
-
}
|
|
995
|
-
| undefined)
|
|
996
|
-
: kaminoVariant && typeof kaminoVariant === "object" && "0" in (kaminoVariant as Record<string, unknown>)
|
|
997
|
-
? ((
|
|
998
|
-
kaminoVariant as {
|
|
999
|
-
0?: {
|
|
1000
|
-
obligation?: PublicKey
|
|
1001
|
-
reserveFarmMappings?: Array<{ farmState: PublicKey }>
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
)[0] ?? undefined)
|
|
1005
|
-
: (kaminoVariant as
|
|
1006
|
-
| {
|
|
1007
|
-
obligation?: PublicKey
|
|
1008
|
-
reserveFarmMappings?: Array<{ farmState: PublicKey }>
|
|
1009
|
-
}
|
|
1010
|
-
| undefined)
|
|
1011
|
-
if (!(entry?.obligation instanceof PublicKey)) {
|
|
1012
|
-
continue
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
for (const mapping of entry.reserveFarmMappings ?? []) {
|
|
1016
|
-
if (!farmStates.some((farmState) => farmState.equals(mapping.farmState))) {
|
|
1017
|
-
farmStates.push(mapping.farmState)
|
|
1018
|
-
}
|
|
1019
|
-
delegatedFarmUsers.push({
|
|
1020
|
-
obligation: entry.obligation,
|
|
1021
|
-
farmState: mapping.farmState,
|
|
1022
|
-
userState: getKaminoFarmsObligationFarm(entry.obligation, mapping.farmState, KAMINO_FARMS_PROGRAM_ID),
|
|
1023
|
-
})
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
if (farmStates.length === 0) {
|
|
1028
|
-
return
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
const farmInfos = await connection.getMultipleAccountsInfo(farmStates)
|
|
1032
|
-
for (const [index, farmInfo] of farmInfos.entries()) {
|
|
1033
|
-
const farmState = farmStates[index]
|
|
1034
|
-
if (!farmState || !farmInfo?.data) {
|
|
1035
|
-
if (ExponentVault.debugAum && farmState) {
|
|
1036
|
-
console.log("[VAULT_AUM] kaminoFarmAux: missing farm info", farmState.toBase58())
|
|
1037
|
-
}
|
|
1038
|
-
continue
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
const farm = decodeKaminoFarmState(Buffer.from(farmInfo.data))
|
|
1042
|
-
const auxAccounts: AccountMeta[] = [{ pubkey: farm.globalConfig, isSigner: false, isWritable: false }]
|
|
1043
|
-
const scopePrices = getKaminoFarmScopePricesAddress(farm)
|
|
1044
|
-
if (scopePrices) {
|
|
1045
|
-
auxAccounts.push({ pubkey: scopePrices, isSigner: false, isWritable: false })
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
this.kaminoFarmAuxAccountsMap.set(farmState.toBase58(), auxAccounts)
|
|
1049
|
-
if (ExponentVault.debugAum) {
|
|
1050
|
-
console.log(
|
|
1051
|
-
"[VAULT_AUM] kaminoFarmAux:",
|
|
1052
|
-
farmState.toBase58(),
|
|
1053
|
-
auxAccounts.map((account) => account.pubkey.toBase58()).join(", "),
|
|
1054
|
-
)
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
if (delegatedFarmUsers.length === 0) {
|
|
1059
|
-
return
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
const uniqueUsers = Array.from(
|
|
1063
|
-
new Map(
|
|
1064
|
-
delegatedFarmUsers.map((entry) => [
|
|
1065
|
-
`${entry.obligation.toBase58()}:${entry.farmState.toBase58()}`,
|
|
1066
|
-
entry,
|
|
1067
|
-
]),
|
|
1068
|
-
).values(),
|
|
1069
|
-
)
|
|
1070
|
-
const userInfos = await connection.getMultipleAccountsInfo(uniqueUsers.map((entry) => entry.userState))
|
|
1071
|
-
for (const [index, userInfo] of userInfos.entries()) {
|
|
1072
|
-
if (!userInfo?.data) {
|
|
1073
|
-
continue
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
const entry = uniqueUsers[index]
|
|
1077
|
-
if (!entry) {
|
|
1078
|
-
continue
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
this.kaminoObligationFarmUserStates.add(`${entry.obligation.toBase58()}:${entry.farmState.toBase58()}`)
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
/**
|
|
1086
|
-
* Derive the PDA for a vault using its 8-byte seed identifier.
|
|
1087
|
-
*/
|
|
1088
|
-
static deriveVaultAddress(
|
|
1089
|
-
seedId: Uint8Array | number[],
|
|
1090
|
-
programId: PublicKey = new PublicKey(EXPONENT_VAULTS_PROGRAM_ID),
|
|
1091
|
-
) {
|
|
1092
|
-
if (seedId.length !== 8) {
|
|
1093
|
-
throw new Error(`seedId must contain 8 bytes, received ${seedId.length}`)
|
|
1094
|
-
}
|
|
1095
|
-
const seedBuffer = Buffer.from(seedId)
|
|
1096
|
-
return PublicKey.findProgramAddressSync([VAULT_SEED, seedBuffer], programId)
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
get mintLp() {
|
|
1100
|
-
return this.state.mintLp
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
get tokenLpEscrow() {
|
|
1104
|
-
return this.state.tokenLpEscrow
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
get eventAuthority() {
|
|
1108
|
-
return emitEventAuthority(this.programId)
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
private getTokenEntryOrThrow(mint: PublicKey): TokenEntry {
|
|
1112
|
-
const entry = this.state.tokenEntries.find((e) => e.mint.equals(mint))
|
|
1113
|
-
if (!entry) {
|
|
1114
|
-
throw new Error(`Token entry not found for mint ${mint.toBase58()}`)
|
|
1115
|
-
}
|
|
1116
|
-
return entry
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
async fetchWithdrawalAccount(address: PublicKey) {
|
|
1120
|
-
return this.fetcher.fetchWithdrawalAccountDeserialized(address)
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
async fetchAllActionProposals() {
|
|
1124
|
-
const accounts = await this.connection.getProgramAccounts(this.programId, {
|
|
1125
|
-
filters: [
|
|
1126
|
-
{ memcmp: { offset: 0, bytes: bs58.encode(Buffer.from([144, 192, 194, 210, 241, 173, 240, 41])) } },
|
|
1127
|
-
{ memcmp: { offset: 8, bytes: this.selfAddress.toBase58() } },
|
|
1128
|
-
],
|
|
1129
|
-
})
|
|
1130
|
-
return accounts.map(({ pubkey, account }) => ({
|
|
1131
|
-
address: pubkey,
|
|
1132
|
-
data: exponentVaults.deserializeActionProposalAccount(account.data),
|
|
1133
|
-
}))
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
async fetchLpTokenSupply() {
|
|
1137
|
-
const { supply } = await getMint(this.connection, this.state.mintLp)
|
|
1138
|
-
return supply
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
/** Set DEBUG_VAULT_AUM=1 to log AUM remaining accounts (token entries + strategy positions) for debugging */
|
|
1142
|
-
private static get debugAum(): boolean {
|
|
1143
|
-
return typeof process !== "undefined" && process.env?.DEBUG_VAULT_AUM === "1"
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
private strategyPositionAccountMetas(): AccountMeta[] {
|
|
1147
|
-
const metas: AccountMeta[] = []
|
|
1148
|
-
|
|
1149
|
-
for (const pos of this.state.strategyPositions) {
|
|
1150
|
-
if ("orderbook" in pos && pos.orderbook && typeof pos.orderbook === "object") {
|
|
1151
|
-
const entry: OrderbookEntry = pos["orderbook"][0]
|
|
1152
|
-
metas.push({
|
|
1153
|
-
pubkey: entry.orderbook,
|
|
1154
|
-
isSigner: false,
|
|
1155
|
-
isWritable: false,
|
|
1156
|
-
})
|
|
1157
|
-
if (ExponentVault.debugAum) {
|
|
1158
|
-
console.log("[VAULT_AUM] strategyPosition: Orderbook", entry.orderbook.toBase58())
|
|
1159
|
-
}
|
|
1160
|
-
} else if ("tokenAccount" in pos && pos.tokenAccount && typeof pos.tokenAccount === "object") {
|
|
1161
|
-
const entry: TokenAccountEntry = pos["tokenAccount"][0]
|
|
1162
|
-
for (const balance of entry.balances) {
|
|
1163
|
-
metas.push({
|
|
1164
|
-
pubkey: balance.tokenAccount,
|
|
1165
|
-
isSigner: false,
|
|
1166
|
-
isWritable: false,
|
|
1167
|
-
})
|
|
1168
|
-
if (ExponentVault.debugAum) {
|
|
1169
|
-
console.log("[VAULT_AUM] strategyPosition: TokenAccount balance", balance.tokenAccount.toBase58())
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
} else if ("obligation" in pos && pos.obligation && typeof pos.obligation === "object") {
|
|
1173
|
-
const rawObligation = pos["obligation"] as Record<string, unknown> | Array<unknown>
|
|
1174
|
-
const inner = Array.isArray(rawObligation)
|
|
1175
|
-
? (rawObligation[0] as Record<string, unknown> | undefined)
|
|
1176
|
-
: rawObligation && typeof rawObligation === "object" && "0" in rawObligation
|
|
1177
|
-
? (rawObligation[0] as Record<string, unknown> | undefined)
|
|
1178
|
-
: (rawObligation as Record<string, unknown> | undefined)
|
|
1179
|
-
const kaminoVariant = inner && "kaminoObligation" in inner ? (inner.kaminoObligation as unknown) : inner
|
|
1180
|
-
const entry = Array.isArray(kaminoVariant)
|
|
1181
|
-
? (kaminoVariant[0] as
|
|
1182
|
-
| {
|
|
1183
|
-
obligation?: PublicKey
|
|
1184
|
-
reservePriceMappings?: Array<{ reserve: PublicKey }>
|
|
1185
|
-
reserveFarmMappings?: Array<{ farmState: PublicKey }>
|
|
1186
|
-
}
|
|
1187
|
-
| undefined)
|
|
1188
|
-
: kaminoVariant && typeof kaminoVariant === "object" && "0" in (kaminoVariant as Record<string, unknown>)
|
|
1189
|
-
? ((
|
|
1190
|
-
kaminoVariant as {
|
|
1191
|
-
0?: {
|
|
1192
|
-
obligation?: PublicKey
|
|
1193
|
-
reservePriceMappings?: Array<{ reserve: PublicKey }>
|
|
1194
|
-
reserveFarmMappings?: Array<{ farmState: PublicKey }>
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
)[0] ?? undefined)
|
|
1198
|
-
: (kaminoVariant as
|
|
1199
|
-
| {
|
|
1200
|
-
obligation?: PublicKey
|
|
1201
|
-
reservePriceMappings?: Array<{ reserve: PublicKey }>
|
|
1202
|
-
reserveFarmMappings?: Array<{ farmState: PublicKey }>
|
|
1203
|
-
}
|
|
1204
|
-
| undefined)
|
|
1205
|
-
if (entry?.obligation instanceof PublicKey) {
|
|
1206
|
-
metas.push({
|
|
1207
|
-
pubkey: entry.obligation,
|
|
1208
|
-
isSigner: false,
|
|
1209
|
-
isWritable: false,
|
|
1210
|
-
})
|
|
1211
|
-
for (const mapping of entry.reservePriceMappings ?? []) {
|
|
1212
|
-
metas.push({
|
|
1213
|
-
pubkey: mapping.reserve,
|
|
1214
|
-
isSigner: false,
|
|
1215
|
-
isWritable: false,
|
|
1216
|
-
})
|
|
1217
|
-
}
|
|
1218
|
-
for (const mapping of entry.reserveFarmMappings ?? []) {
|
|
1219
|
-
metas.push({
|
|
1220
|
-
pubkey: mapping.farmState,
|
|
1221
|
-
isSigner: false,
|
|
1222
|
-
isWritable: false,
|
|
1223
|
-
})
|
|
1224
|
-
const obligationFarmUserKey = `${entry.obligation.toBase58()}:${mapping.farmState.toBase58()}`
|
|
1225
|
-
if (this.kaminoObligationFarmUserStates.has(obligationFarmUserKey)) {
|
|
1226
|
-
metas.push({
|
|
1227
|
-
pubkey: getKaminoFarmsObligationFarm(entry.obligation, mapping.farmState, KAMINO_FARMS_PROGRAM_ID),
|
|
1228
|
-
isSigner: false,
|
|
1229
|
-
isWritable: false,
|
|
1230
|
-
})
|
|
1231
|
-
}
|
|
1232
|
-
metas.push(...(this.kaminoFarmAuxAccountsMap.get(mapping.farmState.toBase58()) ?? []))
|
|
1233
|
-
}
|
|
1234
|
-
if (ExponentVault.debugAum) {
|
|
1235
|
-
console.log("[VAULT_AUM] strategyPosition: Obligation", entry.obligation.toBase58())
|
|
1236
|
-
for (const mapping of entry.reservePriceMappings ?? []) {
|
|
1237
|
-
console.log("[VAULT_AUM] strategyPosition: Kamino reserve", mapping.reserve.toBase58())
|
|
1238
|
-
}
|
|
1239
|
-
for (const mapping of entry.reserveFarmMappings ?? []) {
|
|
1240
|
-
console.log("[VAULT_AUM] strategyPosition: Kamino delegated farm", mapping.farmState.toBase58())
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
} else if ("yieldPosition" in pos && pos.yieldPosition && typeof pos.yieldPosition === "object") {
|
|
1245
|
-
const entry = pos["yieldPosition"][0] as { yieldPosition: PublicKey; vault: PublicKey }
|
|
1246
|
-
metas.push({
|
|
1247
|
-
pubkey: entry.yieldPosition,
|
|
1248
|
-
isSigner: false,
|
|
1249
|
-
isWritable: false,
|
|
1250
|
-
})
|
|
1251
|
-
metas.push({
|
|
1252
|
-
pubkey: entry.vault,
|
|
1253
|
-
isSigner: false,
|
|
1254
|
-
isWritable: false,
|
|
1255
|
-
})
|
|
1256
|
-
if (ExponentVault.debugAum) {
|
|
1257
|
-
console.log(
|
|
1258
|
-
"[VAULT_AUM] strategyPosition: YieldPosition",
|
|
1259
|
-
entry.yieldPosition.toBase58(),
|
|
1260
|
-
entry.vault.toBase58(),
|
|
1261
|
-
"(must exist and have exponent_core YieldTokenPosition discriminator)",
|
|
1262
|
-
)
|
|
1263
|
-
}
|
|
1264
|
-
} else if ("clmmPosition" in pos && pos.clmmPosition && typeof pos.clmmPosition === "object") {
|
|
1265
|
-
const entry = (pos as { clmmPosition: { 0: ClmmPositionEntry } }).clmmPosition[0]
|
|
1266
|
-
metas.push({
|
|
1267
|
-
pubkey: entry.lpPosition,
|
|
1268
|
-
isSigner: false,
|
|
1269
|
-
isWritable: false,
|
|
1270
|
-
})
|
|
1271
|
-
metas.push({
|
|
1272
|
-
pubkey: entry.market,
|
|
1273
|
-
isSigner: false,
|
|
1274
|
-
isWritable: false,
|
|
1275
|
-
})
|
|
1276
|
-
const ticksKey = this.clmmTicksMap.get(entry.market.toBase58())
|
|
1277
|
-
if (ticksKey) {
|
|
1278
|
-
metas.push({
|
|
1279
|
-
pubkey: ticksKey,
|
|
1280
|
-
isSigner: false,
|
|
1281
|
-
isWritable: false,
|
|
1282
|
-
})
|
|
1283
|
-
}
|
|
1284
|
-
if (ExponentVault.debugAum) {
|
|
1285
|
-
console.log(
|
|
1286
|
-
"[VAULT_AUM] strategyPosition: ClmmPosition",
|
|
1287
|
-
entry.lpPosition.toBase58(),
|
|
1288
|
-
entry.market.toBase58(),
|
|
1289
|
-
ticksKey ? ticksKey.toBase58() : "(ticks not cached)",
|
|
1290
|
-
)
|
|
1291
|
-
}
|
|
1292
|
-
} else if ("kaminoFarm" in pos && pos.kaminoFarm && typeof pos.kaminoFarm === "object") {
|
|
1293
|
-
const entry = (pos as { kaminoFarm: { 0: { farmState: PublicKey; userState: PublicKey } } }).kaminoFarm[0]
|
|
1294
|
-
metas.push({
|
|
1295
|
-
pubkey: entry.farmState,
|
|
1296
|
-
isSigner: false,
|
|
1297
|
-
isWritable: false,
|
|
1298
|
-
})
|
|
1299
|
-
metas.push({
|
|
1300
|
-
pubkey: entry.userState,
|
|
1301
|
-
isSigner: false,
|
|
1302
|
-
isWritable: false,
|
|
1303
|
-
})
|
|
1304
|
-
const auxAccounts = this.kaminoFarmAuxAccountsMap.get(entry.farmState.toBase58()) ?? []
|
|
1305
|
-
metas.push(...auxAccounts)
|
|
1306
|
-
if (ExponentVault.debugAum) {
|
|
1307
|
-
console.log(
|
|
1308
|
-
"[VAULT_AUM] strategyPosition: KaminoFarm",
|
|
1309
|
-
entry.farmState.toBase58(),
|
|
1310
|
-
entry.userState.toBase58(),
|
|
1311
|
-
)
|
|
1312
|
-
console.log(
|
|
1313
|
-
"[VAULT_AUM] strategyPosition: KaminoFarm aux",
|
|
1314
|
-
auxAccounts.map((account) => account.pubkey.toBase58()).join(", ") || "(none)",
|
|
1315
|
-
)
|
|
1316
|
-
}
|
|
1317
|
-
} else if ("loopscaleStrategy" in pos && pos.loopscaleStrategy && typeof pos.loopscaleStrategy === "object") {
|
|
1318
|
-
const entry = (pos as any).loopscaleStrategy[0]
|
|
1319
|
-
if (entry?.strategy instanceof PublicKey) {
|
|
1320
|
-
metas.push({
|
|
1321
|
-
pubkey: entry.strategy,
|
|
1322
|
-
isSigner: false,
|
|
1323
|
-
isWritable: false,
|
|
1324
|
-
})
|
|
1325
|
-
if (ExponentVault.debugAum) {
|
|
1326
|
-
console.log("[VAULT_AUM] strategyPosition: LoopscaleStrategy", entry.strategy.toBase58())
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
} else if ("loopscaleLoan" in pos && pos.loopscaleLoan && typeof pos.loopscaleLoan === "object") {
|
|
1330
|
-
const entry = (pos as any).loopscaleLoan[0]
|
|
1331
|
-
if (entry?.loan instanceof PublicKey) {
|
|
1332
|
-
metas.push({
|
|
1333
|
-
pubkey: entry.loan,
|
|
1334
|
-
isSigner: false,
|
|
1335
|
-
isWritable: false,
|
|
1336
|
-
})
|
|
1337
|
-
if (ExponentVault.debugAum) {
|
|
1338
|
-
console.log("[VAULT_AUM] strategyPosition: LoopscaleLoan", entry.loan.toBase58())
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
} else if (ExponentVault.debugAum) {
|
|
1342
|
-
console.log("[VAULT_AUM] strategyPosition: UNMATCHED", JSON.stringify(Object.keys(pos)))
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
return metas
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
private tokenEntryAccountMetas(): AccountMeta[] {
|
|
1350
|
-
const metas = this.state.tokenEntries.map((entry) => ({
|
|
1351
|
-
pubkey: entry.tokenSquadsAccount,
|
|
1352
|
-
isSigner: false,
|
|
1353
|
-
isWritable: false,
|
|
1354
|
-
}))
|
|
1355
|
-
if (ExponentVault.debugAum) {
|
|
1356
|
-
metas.forEach((m, i) => {
|
|
1357
|
-
console.log(
|
|
1358
|
-
`[VAULT_AUM] tokenEntry[${i}]:`,
|
|
1359
|
-
m.pubkey.toBase58(),
|
|
1360
|
-
"(vault ATA for mint, must be SPL token account)",
|
|
1361
|
-
)
|
|
1362
|
-
})
|
|
1363
|
-
}
|
|
1364
|
-
return metas
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
private aumRemainingAccounts(): AccountMeta[] {
|
|
1368
|
-
return [...this.tokenEntryAccountMetas(), ...this.strategyPositionAccountMetas()]
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
/**
|
|
1372
|
-
* Returns the readonly account metas required to recalculate the vault's current tracked AUM.
|
|
1373
|
-
* Extra metas can be appended for pending positions or newly introduced Kamino reserves.
|
|
1374
|
-
*/
|
|
1375
|
-
getAumRemainingAccountMetas(extraRemainingAccounts: AccountMeta[] = []): AccountMeta[] {
|
|
1376
|
-
return uniqueRemainingAccounts([...this.aumRemainingAccounts(), ...extraRemainingAccounts])
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
private ixManagePriceUpdates({
|
|
1380
|
-
manager,
|
|
1381
|
-
updates,
|
|
1382
|
-
}: {
|
|
1383
|
-
manager?: PublicKey
|
|
1384
|
-
updates: Array<{
|
|
1385
|
-
priceId: number
|
|
1386
|
-
priceType: exponentVaults.PriceType
|
|
1387
|
-
priceInterfaceAccounts?: PublicKey
|
|
1388
|
-
}>
|
|
1389
|
-
}): TransactionInstruction {
|
|
1390
|
-
if (updates.length === 0) {
|
|
1391
|
-
throw new Error("ixManagePriceUpdates requires at least one update")
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
const resolvedManager = manager ?? this.state.roles.manager[0]
|
|
1395
|
-
if (!resolvedManager) {
|
|
1396
|
-
throw new Error("Vault manager not found")
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
const [exponentPrices] = this.pda.exponentPrices()
|
|
1400
|
-
const remainingAccounts: AccountMeta[] = []
|
|
1401
|
-
const actions: exponentVaults.UpdatePriceAction[] = updates.map((update) => {
|
|
1402
|
-
if (!update.priceInterfaceAccounts) {
|
|
1403
|
-
throw new Error(`priceInterfaceAccounts required for priceId ${update.priceId}`)
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
remainingAccounts.push({ pubkey: update.priceInterfaceAccounts, isSigner: false, isWritable: false })
|
|
1407
|
-
|
|
1408
|
-
return {
|
|
1409
|
-
__kind: "UpdatePrice",
|
|
1410
|
-
priceId: BigInt(update.priceId),
|
|
1411
|
-
priceType: update.priceType,
|
|
1412
|
-
}
|
|
1413
|
-
})
|
|
1414
|
-
|
|
1415
|
-
const ix = exponentVaults.createManagePricesInstruction(
|
|
1416
|
-
{ manager: resolvedManager, exponentPrices, systemProgram: SystemProgram.programId },
|
|
1417
|
-
{ actions },
|
|
1418
|
-
this.programId,
|
|
1419
|
-
)
|
|
1420
|
-
ix.keys.push(...remainingAccounts)
|
|
1421
|
-
return ix
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
ixUpdatePrice({
|
|
1425
|
-
priceInterfaceAccounts,
|
|
1426
|
-
pythPriceFeedId,
|
|
1427
|
-
remainingAccounts = [],
|
|
1428
|
-
priceId,
|
|
1429
|
-
}: UpdatePriceParams): TransactionInstruction {
|
|
1430
|
-
const [exponentPrices] = this.pda.exponentPrices()
|
|
1431
|
-
if (!priceInterfaceAccounts) {
|
|
1432
|
-
throw new Error("ixUpdatePrice requires priceInterfaceAccounts")
|
|
1433
|
-
}
|
|
1434
|
-
const updateRemainingAccounts = [
|
|
1435
|
-
{ pubkey: priceInterfaceAccounts, isSigner: false, isWritable: false },
|
|
1436
|
-
...remainingAccounts.map((pubkey) => ({ pubkey, isSigner: false, isWritable: false })),
|
|
1437
|
-
...(pythPriceFeedId ? [{ pubkey: pythPriceFeedId, isSigner: false, isWritable: false }] : []),
|
|
1438
|
-
]
|
|
1439
|
-
const ix = exponentVaults.createUpdatePriceInstruction(
|
|
1440
|
-
{ exponentPrices },
|
|
1441
|
-
{ updates: [{ priceId: BigInt(priceId), interfaceAccountsIndex: 0 }] },
|
|
1442
|
-
this.programId,
|
|
1443
|
-
)
|
|
1444
|
-
ix.keys.push(...updateRemainingAccounts)
|
|
1445
|
-
if (isLocalRpcEndpoint(this.connection.rpcEndpoint)) {
|
|
1446
|
-
ix.data = Buffer.concat([LOCAL_UPDATE_PRICE_DISCRIMINATOR, ix.data.subarray(1)])
|
|
1447
|
-
}
|
|
1448
|
-
return ix
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
async ixsDepositLiquidity({
|
|
1452
|
-
depositor,
|
|
1453
|
-
mint,
|
|
1454
|
-
tokenAmountIn,
|
|
1455
|
-
minLpOut,
|
|
1456
|
-
tokenSrc,
|
|
1457
|
-
entryTokenVault,
|
|
1458
|
-
tokenLpDst,
|
|
1459
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1460
|
-
extraRemainingAccounts = [],
|
|
1461
|
-
useLegacyTokenAccounts = false,
|
|
1462
|
-
}: DepositLiquidityParams): Promise<TransactionInstruction[]> {
|
|
1463
|
-
const entry = this.getTokenEntryOrThrow(mint)
|
|
1464
|
-
const source = tokenSrc ?? defaultTokenAccount(mint, depositor, tokenProgram)
|
|
1465
|
-
const vault = entryTokenVault ?? entry.tokenSquadsAccount
|
|
1466
|
-
const lpDst = tokenLpDst ?? defaultTokenAccount(this.state.mintLp, depositor, tokenProgram)
|
|
1467
|
-
const exponentPrices = this.pda.exponentPrices()[0]
|
|
1468
|
-
const tokenProgramLp = useLegacyTokenAccounts ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID
|
|
1469
|
-
|
|
1470
|
-
const preIxs: TransactionInstruction[] = []
|
|
1471
|
-
|
|
1472
|
-
// If depositing WSOL, wrap native SOL as needed
|
|
1473
|
-
if (mint.equals(NATIVE_MINT)) {
|
|
1474
|
-
const wsolAta = getAssociatedTokenAddressSync(NATIVE_MINT, depositor, false, tokenProgram)
|
|
1475
|
-
// Create WSOL ATA (idempotent — no-op if already exists)
|
|
1476
|
-
preIxs.push(
|
|
1477
|
-
createAssociatedTokenAccountIdempotentInstruction(depositor, wsolAta, depositor, NATIVE_MINT, tokenProgram),
|
|
1478
|
-
)
|
|
1479
|
-
|
|
1480
|
-
// Check existing WSOL balance
|
|
1481
|
-
let existingWsolBalance = BigInt(0)
|
|
1482
|
-
try {
|
|
1483
|
-
const wsolAccount = await getAccount(this.connection, wsolAta, "confirmed", tokenProgram)
|
|
1484
|
-
existingWsolBalance = wsolAccount.amount
|
|
1485
|
-
} catch {
|
|
1486
|
-
// Account doesn't exist yet — balance is 0
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
const totalNeeded = toBigInt(tokenAmountIn)
|
|
1490
|
-
if (totalNeeded > existingWsolBalance) {
|
|
1491
|
-
const wrapAmount = totalNeeded - existingWsolBalance
|
|
1492
|
-
// Transfer native SOL to the WSOL ATA
|
|
1493
|
-
preIxs.push(
|
|
1494
|
-
SystemProgram.transfer({
|
|
1495
|
-
fromPubkey: depositor,
|
|
1496
|
-
toPubkey: wsolAta,
|
|
1497
|
-
lamports: wrapAmount,
|
|
1498
|
-
}),
|
|
1499
|
-
)
|
|
1500
|
-
// Sync the native balance so the token account reflects the deposited SOL
|
|
1501
|
-
preIxs.push(createSyncNativeInstruction(wsolAta, tokenProgram))
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
const depositorLpAta = getAssociatedTokenAddressSync(this.state.mintLp, depositor)
|
|
1506
|
-
const createLpAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1507
|
-
depositor,
|
|
1508
|
-
depositorLpAta,
|
|
1509
|
-
depositor,
|
|
1510
|
-
this.state.mintLp,
|
|
1511
|
-
)
|
|
1512
|
-
|
|
1513
|
-
const depositIx = exponentVaults.createDepositLiquidityInstruction(
|
|
1514
|
-
{
|
|
1515
|
-
depositor,
|
|
1516
|
-
vault: this.selfAddress,
|
|
1517
|
-
exponentPrices,
|
|
1518
|
-
mint,
|
|
1519
|
-
tokenSrc: source,
|
|
1520
|
-
entryTokenVault: vault,
|
|
1521
|
-
tokenLpDst: lpDst,
|
|
1522
|
-
mintLp: this.state.mintLp,
|
|
1523
|
-
tokenProgram,
|
|
1524
|
-
tokenProgramLp,
|
|
1525
|
-
eventAuthority: this.eventAuthority,
|
|
1526
|
-
program: this.programId,
|
|
1527
|
-
},
|
|
1528
|
-
{ tokenAmountIn: toBigInt(tokenAmountIn), minLpOut: toBigInt(minLpOut) },
|
|
1529
|
-
)
|
|
1530
|
-
|
|
1531
|
-
const remainingAccounts = [...this.aumRemainingAccounts(), ...extraRemainingAccounts]
|
|
1532
|
-
depositIx.keys.push(...remainingAccounts)
|
|
1533
|
-
|
|
1534
|
-
if (ExponentVault.debugAum) {
|
|
1535
|
-
console.log("[VAULT_AUM] ixsDepositLiquidity: total remaining_accounts =", remainingAccounts.length)
|
|
1536
|
-
remainingAccounts.forEach((acc, i) => {
|
|
1537
|
-
console.log(` [${i}] ${acc.pubkey.toBase58()} writable=${acc.isWritable} signer=${acc.isSigner}`)
|
|
1538
|
-
})
|
|
1539
|
-
console.log(
|
|
1540
|
-
"[VAULT_AUM] DepositLiquidity expects: token_entry ATAs (for AUM) + strategy accounts (orderbook, yieldPosition). AccountDiscriminatorNotFound (0xbb9) = wrong account type at one of these.",
|
|
1541
|
-
)
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
return [...preIxs, createLpAtaIx, depositIx]
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
ixQueueWithdrawal({
|
|
1548
|
-
depositor,
|
|
1549
|
-
lpAmount,
|
|
1550
|
-
tokenLpSrc,
|
|
1551
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1552
|
-
systemProgram = SystemProgram.programId,
|
|
1553
|
-
tokenLpEscrow = this.state.tokenLpEscrow,
|
|
1554
|
-
}: QueueWithdrawalParams): { ix: TransactionInstruction; withdrawalKeypair: Keypair } {
|
|
1555
|
-
const withdrawalKeypair = Keypair.generate()
|
|
1556
|
-
const lpSrc = tokenLpSrc ?? defaultTokenAccount(this.state.mintLp, depositor, tokenProgram)
|
|
1557
|
-
|
|
1558
|
-
const ix = exponentVaults.createQueueWithdrawalInstruction(
|
|
1559
|
-
{
|
|
1560
|
-
depositor,
|
|
1561
|
-
vault: this.selfAddress,
|
|
1562
|
-
withdrawalAccount: withdrawalKeypair.publicKey,
|
|
1563
|
-
tokenLpSrc: lpSrc,
|
|
1564
|
-
tokenLpEscrow,
|
|
1565
|
-
tokenProgram,
|
|
1566
|
-
systemProgram,
|
|
1567
|
-
},
|
|
1568
|
-
{
|
|
1569
|
-
lpAmount: toBigInt(lpAmount),
|
|
1570
|
-
},
|
|
1571
|
-
)
|
|
1572
|
-
ix.keys.push(...this.aumRemainingAccounts())
|
|
1573
|
-
return { ix, withdrawalKeypair }
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
ixExecuteWithdrawal({
|
|
1577
|
-
owner,
|
|
1578
|
-
withdrawalAccount,
|
|
1579
|
-
tokenAccountPairs,
|
|
1580
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1581
|
-
token2022Program = TOKEN_2022_PROGRAM_ID,
|
|
1582
|
-
tokenLpEscrow = this.state.tokenLpEscrow,
|
|
1583
|
-
mintLp = this.state.mintLp,
|
|
1584
|
-
}: ExecuteWithdrawalParams): TransactionInstruction {
|
|
1585
|
-
// Flatten token account pairs into remaining accounts: [src1, dst1, src2, dst2, ...]
|
|
1586
|
-
const tokenAccountMetas = tokenAccountPairs.flatMap((pair) => [
|
|
1587
|
-
{ pubkey: pair.tokenSrc, isWritable: true, isSigner: false },
|
|
1588
|
-
{ pubkey: pair.tokenDst, isWritable: true, isSigner: false },
|
|
1589
|
-
])
|
|
1590
|
-
|
|
1591
|
-
const tokenLpSrc = defaultTokenAccount(this.state.mintLp, owner, tokenProgram)
|
|
1592
|
-
|
|
1593
|
-
const ix = exponentVaults.createExecuteWithdrawalInstruction(
|
|
1594
|
-
{
|
|
1595
|
-
vault: this.selfAddress,
|
|
1596
|
-
exponentPrices: this.pda.exponentPrices()[0],
|
|
1597
|
-
owner,
|
|
1598
|
-
withdrawalAccount,
|
|
1599
|
-
tokenLpSrc,
|
|
1600
|
-
tokenLpEscrow,
|
|
1601
|
-
mintLp,
|
|
1602
|
-
tokenProgram,
|
|
1603
|
-
eventAuthority: this.eventAuthority,
|
|
1604
|
-
program: this.programId,
|
|
1605
|
-
token2022Program: token2022Program,
|
|
1606
|
-
},
|
|
1607
|
-
{ tokenTransferAccountsUntil: tokenAccountPairs.length * 2 },
|
|
1608
|
-
)
|
|
1609
|
-
ix.keys.push(...tokenAccountMetas, ...this.aumRemainingAccounts())
|
|
1610
|
-
return ix
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
ixExecuteWithdrawalFromReserves({
|
|
1614
|
-
owner,
|
|
1615
|
-
entryIdx,
|
|
1616
|
-
lpAmount,
|
|
1617
|
-
tokenSrc,
|
|
1618
|
-
tokenVaultSrc,
|
|
1619
|
-
tokenDst,
|
|
1620
|
-
tokenLpSrc,
|
|
1621
|
-
squadsProgram,
|
|
1622
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1623
|
-
token2022Program = TOKEN_2022_PROGRAM_ID,
|
|
1624
|
-
tokenLpEscrow = this.state.tokenLpEscrow,
|
|
1625
|
-
mintLp = this.state.mintLp,
|
|
1626
|
-
}: ExecuteWithdrawalFromReservesParams): TransactionInstruction {
|
|
1627
|
-
const lpSrc = tokenLpSrc ?? defaultTokenAccount(this.state.mintLp, owner, tokenProgram)
|
|
1628
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
1629
|
-
const squadsSettings = this.state.squadsSettings
|
|
1630
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
1631
|
-
settings: squadsSettings,
|
|
1632
|
-
policySeed: 2n, // Policy seed 2 is the vault-authorized transfer policy created at init
|
|
1633
|
-
})
|
|
1634
|
-
|
|
1635
|
-
const ix = exponentVaults.createExecuteWithdrawalFromReservesInstruction(
|
|
1636
|
-
{
|
|
1637
|
-
owner,
|
|
1638
|
-
vault: this.selfAddress,
|
|
1639
|
-
exponentPrices: this.pda.exponentPrices()[0],
|
|
1640
|
-
tokenLpSrc: lpSrc,
|
|
1641
|
-
tokenLpEscrow,
|
|
1642
|
-
tokenVaultSrc,
|
|
1643
|
-
mintLp,
|
|
1644
|
-
tokenSrc,
|
|
1645
|
-
tokenDst,
|
|
1646
|
-
tokenProgram,
|
|
1647
|
-
token2022Program,
|
|
1648
|
-
squadsVault: this.state.squadsVault,
|
|
1649
|
-
squadsPolicy: squadsPolicy,
|
|
1650
|
-
squadsProgram: squadsProgram,
|
|
1651
|
-
},
|
|
1652
|
-
{ entryIdx, lpAmount: toBigInt(lpAmount) },
|
|
1653
|
-
)
|
|
1654
|
-
ix.keys.push(...this.aumRemainingAccounts())
|
|
1655
|
-
return ix
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
ixFillWithdrawal({
|
|
1659
|
-
withdrawalAccount,
|
|
1660
|
-
fills,
|
|
1661
|
-
tokenAccountTriples,
|
|
1662
|
-
mintLp = this.state.mintLp,
|
|
1663
|
-
tokenLpEscrow = this.state.tokenLpEscrow,
|
|
1664
|
-
}: FillWithdrawalParams): TransactionInstruction {
|
|
1665
|
-
const ix = exponentVaults.createFillWithdrawalInstruction(
|
|
1666
|
-
{
|
|
1667
|
-
exponentVaultsProgram: this.programId,
|
|
1668
|
-
squadsVault: this.state.squadsVault,
|
|
1669
|
-
vault: this.selfAddress,
|
|
1670
|
-
exponentPrices: this.pda.exponentPrices()[0],
|
|
1671
|
-
withdrawalAccount,
|
|
1672
|
-
mintLp,
|
|
1673
|
-
tokenLpEscrow,
|
|
1674
|
-
tokenProgramLp: TOKEN_PROGRAM_ID,
|
|
1675
|
-
systemProgram: SystemProgram.programId,
|
|
1676
|
-
},
|
|
1677
|
-
{
|
|
1678
|
-
fills: fills.map((f) => ({
|
|
1679
|
-
tokenEntryIdx: f.tokenEntryIdx,
|
|
1680
|
-
percentOfTotalLpBp: toBigInt(f.percentOfTotalLpBp),
|
|
1681
|
-
})),
|
|
1682
|
-
},
|
|
1683
|
-
)
|
|
1684
|
-
|
|
1685
|
-
// Remaining accounts layout: [aum_accounts..., token_src_0, token_dst_0, token_program_0, ...]
|
|
1686
|
-
const tokenTransferMetas = tokenAccountTriples.flatMap((triple) => [
|
|
1687
|
-
{ pubkey: triple.tokenSrc, isWritable: true, isSigner: false },
|
|
1688
|
-
{ pubkey: triple.tokenDst, isWritable: true, isSigner: false },
|
|
1689
|
-
{ pubkey: triple.tokenProgram, isWritable: false, isSigner: false },
|
|
1690
|
-
])
|
|
1691
|
-
ix.keys.push(...this.aumRemainingAccounts(), ...tokenTransferMetas)
|
|
1692
|
-
return ix
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
ixWrapperExecuteWithdrawal({
|
|
1696
|
-
owner,
|
|
1697
|
-
withdrawalAccount,
|
|
1698
|
-
tokenAccountPairs,
|
|
1699
|
-
entryIdx,
|
|
1700
|
-
tokenSrc,
|
|
1701
|
-
tokenVaultSrc,
|
|
1702
|
-
tokenDst,
|
|
1703
|
-
squadsProgram,
|
|
1704
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1705
|
-
token2022Program = TOKEN_2022_PROGRAM_ID,
|
|
1706
|
-
tokenLpEscrow = this.state.tokenLpEscrow,
|
|
1707
|
-
mintLp = this.state.mintLp,
|
|
1708
|
-
}: WrapperExecuteWithdrawalParams): TransactionInstruction {
|
|
1709
|
-
const tokenLpSrc = defaultTokenAccount(this.state.mintLp, owner, tokenProgram)
|
|
1710
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
1711
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
1712
|
-
settings: this.state.squadsSettings,
|
|
1713
|
-
policySeed: 2n,
|
|
1714
|
-
})
|
|
1715
|
-
|
|
1716
|
-
const tokenAccountMetas = tokenAccountPairs.flatMap((pair) => [
|
|
1717
|
-
{ pubkey: pair.tokenSrc, isWritable: true, isSigner: false },
|
|
1718
|
-
{ pubkey: pair.tokenDst, isWritable: true, isSigner: false },
|
|
1719
|
-
])
|
|
1720
|
-
|
|
1721
|
-
const ix = exponentVaults.createWrapperExecuteWithdrawalInstruction(
|
|
1722
|
-
{
|
|
1723
|
-
vault: this.selfAddress,
|
|
1724
|
-
exponentPrices: this.pda.exponentPrices()[0],
|
|
1725
|
-
owner,
|
|
1726
|
-
withdrawalAccount,
|
|
1727
|
-
tokenLpSrc,
|
|
1728
|
-
tokenLpEscrow,
|
|
1729
|
-
mintLp,
|
|
1730
|
-
tokenProgram,
|
|
1731
|
-
token2022Program,
|
|
1732
|
-
systemProgram: SystemProgram.programId,
|
|
1733
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
1734
|
-
tokenSrc,
|
|
1735
|
-
tokenVaultSrc,
|
|
1736
|
-
tokenDst,
|
|
1737
|
-
squadsVault: this.state.squadsVault,
|
|
1738
|
-
squadsPolicy,
|
|
1739
|
-
squadsProgram,
|
|
1740
|
-
eventAuthority: this.eventAuthority,
|
|
1741
|
-
program: this.programId,
|
|
1742
|
-
},
|
|
1743
|
-
{ tokenTransferAccountsUntil: tokenAccountPairs.length * 2, entryIdx },
|
|
1744
|
-
)
|
|
1745
|
-
ix.keys.push(...tokenAccountMetas, ...this.aumRemainingAccounts())
|
|
1746
|
-
return ix
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
ixCancelWithdrawal({
|
|
1750
|
-
owner,
|
|
1751
|
-
withdrawalAccount,
|
|
1752
|
-
tokenLpDst,
|
|
1753
|
-
tokenProgram = TOKEN_PROGRAM_ID,
|
|
1754
|
-
tokenLpEscrow = this.state.tokenLpEscrow,
|
|
1755
|
-
}: CancelWithdrawalParams) {
|
|
1756
|
-
const lpDst = tokenLpDst ?? defaultTokenAccount(this.state.mintLp, owner, tokenProgram)
|
|
1757
|
-
|
|
1758
|
-
return exponentVaults.createCancelWithdrawalInstruction({
|
|
1759
|
-
owner,
|
|
1760
|
-
vault: this.selfAddress,
|
|
1761
|
-
withdrawalAccount,
|
|
1762
|
-
tokenLpEscrow,
|
|
1763
|
-
tokenLpDst: lpDst,
|
|
1764
|
-
tokenProgram,
|
|
1765
|
-
})
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
// ixCollectManagementFee({
|
|
1769
|
-
// manager,
|
|
1770
|
-
// mintLp = this.state.mintLp,
|
|
1771
|
-
// feeTreasury = this.state.feeTreasury,
|
|
1772
|
-
// tokenProgram = TOKEN_PROGRAM_ID,
|
|
1773
|
-
// }: CollectManagementFeeParams) {
|
|
1774
|
-
// return exponentVaults.createCollectManagementFeeInstruction({
|
|
1775
|
-
// manager,
|
|
1776
|
-
// vault: this.selfAddress,
|
|
1777
|
-
// mintLp,
|
|
1778
|
-
// feeTreasury,
|
|
1779
|
-
// tokenProgram,
|
|
1780
|
-
// })
|
|
1781
|
-
// }
|
|
1782
|
-
|
|
1783
|
-
/**
|
|
1784
|
-
* Create instruction to call wrapper_manage_vault_settings.
|
|
1785
|
-
*/
|
|
1786
|
-
ixWrapperManageVaultSettings({
|
|
1787
|
-
manager,
|
|
1788
|
-
actions,
|
|
1789
|
-
remainingAccounts = [],
|
|
1790
|
-
exponentPrices = this.pda.exponentPrices()[0],
|
|
1791
|
-
systemProgram = SystemProgram.programId,
|
|
1792
|
-
}: WrapperManageVaultSettingsParams): TransactionInstruction {
|
|
1793
|
-
const ix = exponentVaults.createWrapperManageVaultSettingsInstruction(
|
|
1794
|
-
{
|
|
1795
|
-
manager,
|
|
1796
|
-
vault: this.selfAddress,
|
|
1797
|
-
exponentPrices,
|
|
1798
|
-
systemProgram,
|
|
1799
|
-
},
|
|
1800
|
-
{ actions },
|
|
1801
|
-
)
|
|
1802
|
-
ix.keys.push(...remainingAccounts)
|
|
1803
|
-
return ix
|
|
1804
|
-
}
|
|
1805
|
-
|
|
1806
|
-
/**
|
|
1807
|
-
* Create instruction to call wrapper_manager_update_position.
|
|
1808
|
-
*/
|
|
1809
|
-
ixWrapperManagerUpdatePosition({
|
|
1810
|
-
manager,
|
|
1811
|
-
update,
|
|
1812
|
-
remainingAccounts = [],
|
|
1813
|
-
exponentPrices = this.pda.exponentPrices()[0],
|
|
1814
|
-
systemProgram = SystemProgram.programId,
|
|
1815
|
-
}: WrapperManagerUpdatePositionParams): TransactionInstruction {
|
|
1816
|
-
const ix = exponentVaults.createWrapperManagerUpdatePositionInstruction(
|
|
1817
|
-
{
|
|
1818
|
-
manager,
|
|
1819
|
-
vault: this.selfAddress,
|
|
1820
|
-
exponentPrices,
|
|
1821
|
-
systemProgram,
|
|
1822
|
-
},
|
|
1823
|
-
{ update },
|
|
1824
|
-
)
|
|
1825
|
-
ix.keys.push(...remainingAccounts)
|
|
1826
|
-
return ix
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
/**
|
|
1830
|
-
* Convenience wrapper for adding a tracked Kamino obligation position.
|
|
1831
|
-
*/
|
|
1832
|
-
ixWrapperAddKaminoObligationPosition({
|
|
1833
|
-
manager,
|
|
1834
|
-
obligation,
|
|
1835
|
-
lendingProgramId,
|
|
1836
|
-
quotePriceId,
|
|
1837
|
-
reservePriceMappings,
|
|
1838
|
-
reserveFarmMappings = [],
|
|
1839
|
-
minPriceStatusFlags,
|
|
1840
|
-
remainingAccounts = [],
|
|
1841
|
-
exponentPrices = this.pda.exponentPrices()[0],
|
|
1842
|
-
systemProgram = SystemProgram.programId,
|
|
1843
|
-
}: WrapperAddKaminoObligationPositionParams): TransactionInstruction {
|
|
1844
|
-
const obligationEntry: exponentVaults.KaminoObligationEntry = {
|
|
1845
|
-
obligation,
|
|
1846
|
-
lendingProgramId,
|
|
1847
|
-
quotePriceId,
|
|
1848
|
-
reservePriceMappings,
|
|
1849
|
-
reserveFarmMappings,
|
|
1850
|
-
minPriceStatusFlags,
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
return this.ixWrapperManagerUpdatePosition({
|
|
1854
|
-
manager,
|
|
1855
|
-
exponentPrices,
|
|
1856
|
-
systemProgram,
|
|
1857
|
-
remainingAccounts: this.getAumRemainingAccountMetas(remainingAccounts),
|
|
1858
|
-
update: exponentVaults.positionUpdate("AddKaminoObligationEntry", [
|
|
1859
|
-
obligationEntry,
|
|
1860
|
-
] as [exponentVaults.KaminoObligationEntry]),
|
|
1861
|
-
})
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
/**
|
|
1865
|
-
* Convenience wrapper for updating tracked reserve price mappings on a Kamino obligation.
|
|
1866
|
-
*/
|
|
1867
|
-
ixWrapperUpsertKaminoObligationReservePriceMappings({
|
|
1868
|
-
manager,
|
|
1869
|
-
obligation,
|
|
1870
|
-
reservePriceMappings,
|
|
1871
|
-
reserveFarmMappings = [],
|
|
1872
|
-
remainingAccounts = [],
|
|
1873
|
-
exponentPrices = this.pda.exponentPrices()[0],
|
|
1874
|
-
systemProgram = SystemProgram.programId,
|
|
1875
|
-
}: WrapperUpsertKaminoObligationReservePriceMappingsParams): TransactionInstruction {
|
|
1876
|
-
return this.ixWrapperManagerUpdatePosition({
|
|
1877
|
-
manager,
|
|
1878
|
-
exponentPrices,
|
|
1879
|
-
systemProgram,
|
|
1880
|
-
remainingAccounts: this.getAumRemainingAccountMetas(remainingAccounts),
|
|
1881
|
-
update: exponentVaults.positionUpdate("UpsertKaminoObligationReservePriceMappings", {
|
|
1882
|
-
obligation,
|
|
1883
|
-
reservePriceMappings,
|
|
1884
|
-
reserveFarmMappings,
|
|
1885
|
-
}),
|
|
1886
|
-
})
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
// ==========================================================================
|
|
1890
|
-
// Policy Management Methods
|
|
1891
|
-
// ==========================================================================
|
|
1892
|
-
|
|
1893
|
-
/**
|
|
1894
|
-
* Create instruction to add a policy to this vault.
|
|
1895
|
-
* Direct policy management requires an empty vault; live vaults must use proposals.
|
|
1896
|
-
*/
|
|
1897
|
-
ixAddPolicy({ payer, policyConfig, squadsProgram, nextPolicySeed, nextTransactionIndex }: AddPolicyParams) {
|
|
1898
|
-
const squadsSettings = this.state.squadsSettings
|
|
1899
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
1900
|
-
|
|
1901
|
-
// Derive Squads PDAs
|
|
1902
|
-
const [squadsSettingsTransaction] = squadsPda.transaction({
|
|
1903
|
-
settings: squadsSettings,
|
|
1904
|
-
transactionIndex: nextTransactionIndex,
|
|
1905
|
-
})
|
|
1906
|
-
const [squadsProposal] = squadsPda.proposal({
|
|
1907
|
-
settings: squadsSettings,
|
|
1908
|
-
transactionIndex: nextTransactionIndex,
|
|
1909
|
-
})
|
|
1910
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
1911
|
-
settings: squadsSettings,
|
|
1912
|
-
policySeed: nextPolicySeed,
|
|
1913
|
-
})
|
|
1914
|
-
|
|
1915
|
-
return exponentVaults.createAddPolicyInstruction(
|
|
1916
|
-
{
|
|
1917
|
-
payer,
|
|
1918
|
-
vault: this.selfAddress,
|
|
1919
|
-
squadsSettings,
|
|
1920
|
-
squadsSettingsTransaction,
|
|
1921
|
-
squadsProposal,
|
|
1922
|
-
squadsPolicy,
|
|
1923
|
-
squadsProgram,
|
|
1924
|
-
systemProgram: SystemProgram.programId,
|
|
1925
|
-
},
|
|
1926
|
-
{ policyConfig: this.toCodamaPolicyConfig(policyConfig) },
|
|
1927
|
-
)
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
/**
|
|
1931
|
-
* Create instruction to call wrapper_add_policy.
|
|
1932
|
-
* Wrapper uses the same empty-vault guard as direct policy management.
|
|
1933
|
-
*/
|
|
1934
|
-
ixWrapperAddPolicy({
|
|
1935
|
-
payer,
|
|
1936
|
-
policyConfig,
|
|
1937
|
-
squadsProgram,
|
|
1938
|
-
nextPolicySeed,
|
|
1939
|
-
nextTransactionIndex,
|
|
1940
|
-
}: WrapperAddPolicyParams) {
|
|
1941
|
-
const squadsSettings = this.state.squadsSettings
|
|
1942
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
1943
|
-
|
|
1944
|
-
const [squadsSettingsTransaction] = squadsPda.transaction({
|
|
1945
|
-
settings: squadsSettings,
|
|
1946
|
-
transactionIndex: nextTransactionIndex,
|
|
1947
|
-
})
|
|
1948
|
-
const [squadsProposal] = squadsPda.proposal({
|
|
1949
|
-
settings: squadsSettings,
|
|
1950
|
-
transactionIndex: nextTransactionIndex,
|
|
1951
|
-
})
|
|
1952
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
1953
|
-
settings: squadsSettings,
|
|
1954
|
-
policySeed: nextPolicySeed,
|
|
1955
|
-
})
|
|
1956
|
-
|
|
1957
|
-
return exponentVaults.createWrapperAddPolicyInstruction(
|
|
1958
|
-
{
|
|
1959
|
-
payer,
|
|
1960
|
-
vault: this.selfAddress,
|
|
1961
|
-
squadsSettings,
|
|
1962
|
-
squadsSettingsTransaction,
|
|
1963
|
-
squadsProposal,
|
|
1964
|
-
squadsPolicy,
|
|
1965
|
-
squadsProgram,
|
|
1966
|
-
systemProgram: SystemProgram.programId,
|
|
1967
|
-
},
|
|
1968
|
-
{ policyConfig: this.toCodamaPolicyConfig(policyConfig) },
|
|
1969
|
-
)
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
/**
|
|
1973
|
-
* Create instruction to remove a policy from this vault.
|
|
1974
|
-
* Direct policy management requires an empty vault; live vaults must use proposals.
|
|
1975
|
-
*/
|
|
1976
|
-
ixRemovePolicy({ payer, manager, policySeed, squadsProgram, nextTransactionIndex }: RemovePolicyParams) {
|
|
1977
|
-
const squadsSettings = this.state.squadsSettings
|
|
1978
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
1979
|
-
|
|
1980
|
-
// Derive Squads PDAs
|
|
1981
|
-
const [squadsSettingsTransaction] = squadsPda.transaction({
|
|
1982
|
-
settings: squadsSettings,
|
|
1983
|
-
transactionIndex: nextTransactionIndex,
|
|
1984
|
-
})
|
|
1985
|
-
const [squadsProposal] = squadsPda.proposal({
|
|
1986
|
-
settings: squadsSettings,
|
|
1987
|
-
transactionIndex: nextTransactionIndex,
|
|
1988
|
-
})
|
|
1989
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
1990
|
-
settings: squadsSettings,
|
|
1991
|
-
policySeed,
|
|
1992
|
-
})
|
|
1993
|
-
|
|
1994
|
-
return exponentVaults.createRemovePolicyInstruction({
|
|
1995
|
-
payer,
|
|
1996
|
-
vault: this.selfAddress,
|
|
1997
|
-
manager,
|
|
1998
|
-
squadsSettings,
|
|
1999
|
-
squadsSettingsTransaction,
|
|
2000
|
-
squadsProposal,
|
|
2001
|
-
squadsPolicy,
|
|
2002
|
-
squadsProgram,
|
|
2003
|
-
systemProgram: SystemProgram.programId,
|
|
2004
|
-
})
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
/**
|
|
2008
|
-
* Create instruction to call wrapper_remove_policy.
|
|
2009
|
-
* Wrapper uses the same empty-vault guard as direct policy management.
|
|
2010
|
-
*/
|
|
2011
|
-
ixWrapperRemovePolicy({
|
|
2012
|
-
payer,
|
|
2013
|
-
manager,
|
|
2014
|
-
policySeed,
|
|
2015
|
-
squadsProgram,
|
|
2016
|
-
nextTransactionIndex,
|
|
2017
|
-
}: WrapperRemovePolicyParams) {
|
|
2018
|
-
const squadsSettings = this.state.squadsSettings
|
|
2019
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
2020
|
-
|
|
2021
|
-
const [squadsSettingsTransaction] = squadsPda.transaction({
|
|
2022
|
-
settings: squadsSettings,
|
|
2023
|
-
transactionIndex: nextTransactionIndex,
|
|
2024
|
-
})
|
|
2025
|
-
const [squadsProposal] = squadsPda.proposal({
|
|
2026
|
-
settings: squadsSettings,
|
|
2027
|
-
transactionIndex: nextTransactionIndex,
|
|
2028
|
-
})
|
|
2029
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
2030
|
-
settings: squadsSettings,
|
|
2031
|
-
policySeed,
|
|
2032
|
-
})
|
|
2033
|
-
|
|
2034
|
-
return exponentVaults.createWrapperRemovePolicyInstruction({
|
|
2035
|
-
payer,
|
|
2036
|
-
vault: this.selfAddress,
|
|
2037
|
-
manager,
|
|
2038
|
-
squadsSettings,
|
|
2039
|
-
squadsSettingsTransaction,
|
|
2040
|
-
squadsProposal,
|
|
2041
|
-
squadsPolicy,
|
|
2042
|
-
squadsProgram,
|
|
2043
|
-
systemProgram: SystemProgram.programId,
|
|
2044
|
-
})
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
/**
|
|
2048
|
-
* Create instruction to call wrapper_update_policy.
|
|
2049
|
-
* Wrapper uses the same empty-vault guard as direct policy management.
|
|
2050
|
-
*/
|
|
2051
|
-
ixWrapperUpdatePolicy({
|
|
2052
|
-
payer,
|
|
2053
|
-
manager,
|
|
2054
|
-
policyConfig,
|
|
2055
|
-
policySeed,
|
|
2056
|
-
squadsProgram,
|
|
2057
|
-
nextTransactionIndex,
|
|
2058
|
-
}: WrapperUpdatePolicyParams) {
|
|
2059
|
-
const squadsSettings = this.state.squadsSettings
|
|
2060
|
-
const squadsPda = new SquadsPDA(squadsProgram)
|
|
2061
|
-
|
|
2062
|
-
const [squadsSettingsTransaction] = squadsPda.transaction({
|
|
2063
|
-
settings: squadsSettings,
|
|
2064
|
-
transactionIndex: nextTransactionIndex,
|
|
2065
|
-
})
|
|
2066
|
-
const [squadsProposal] = squadsPda.proposal({
|
|
2067
|
-
settings: squadsSettings,
|
|
2068
|
-
transactionIndex: nextTransactionIndex,
|
|
2069
|
-
})
|
|
2070
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
2071
|
-
settings: squadsSettings,
|
|
2072
|
-
policySeed,
|
|
2073
|
-
})
|
|
2074
|
-
|
|
2075
|
-
return exponentVaults.createWrapperUpdatePolicyInstruction(
|
|
2076
|
-
{
|
|
2077
|
-
payer,
|
|
2078
|
-
vault: this.selfAddress,
|
|
2079
|
-
manager,
|
|
2080
|
-
squadsSettings,
|
|
2081
|
-
squadsSettingsTransaction,
|
|
2082
|
-
squadsProposal,
|
|
2083
|
-
squadsPolicy,
|
|
2084
|
-
squadsProgram,
|
|
2085
|
-
systemProgram: SystemProgram.programId,
|
|
2086
|
-
},
|
|
2087
|
-
{ policyConfig: this.toCodamaPolicyConfig(policyConfig) },
|
|
2088
|
-
)
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
// ==========================================================================
|
|
2092
|
-
// Price Management Methods
|
|
2093
|
-
// ==========================================================================
|
|
2094
|
-
|
|
2095
|
-
/**
|
|
2096
|
-
* Derive the ExponentPrices PDA for this vault.
|
|
2097
|
-
*/
|
|
2098
|
-
deriveExponentPricesAddress(): [PublicKey, number] {
|
|
2099
|
-
const vaultsPda = new ExponentVaultsPDA(this.programId)
|
|
2100
|
-
return vaultsPda.exponentPrices()
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
// ==========================================================================
|
|
2104
|
-
// Static Factory Methods
|
|
2105
|
-
// ==========================================================================
|
|
2106
|
-
|
|
2107
|
-
/**
|
|
2108
|
-
* Create instruction to initialize the global ExponentPrices account.
|
|
2109
|
-
* The account is a singleton PDA derived from ["exponent_prices"].
|
|
2110
|
-
*/
|
|
2111
|
-
static ixInitializePrices({ manager, programId: programIdOverride }: InitializePricesParams) {
|
|
2112
|
-
const programId = programIdOverride ?? new PublicKey(EXPONENT_VAULTS_PROGRAM_ID)
|
|
2113
|
-
const [exponentPrices] = new ExponentVaultsPDA(programId).exponentPrices()
|
|
2114
|
-
return exponentVaults.createInitializePricesInstruction(
|
|
2115
|
-
{
|
|
2116
|
-
manager,
|
|
2117
|
-
exponentPrices,
|
|
2118
|
-
systemProgram: SystemProgram.programId,
|
|
2119
|
-
},
|
|
2120
|
-
programId,
|
|
2121
|
-
)
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
/**
|
|
2125
|
-
* Create instruction to manage price entries (add/remove/update) in the ExponentPrices account.
|
|
2126
|
-
* Uses realloc to resize the account as prices are added or removed.
|
|
2127
|
-
*/
|
|
2128
|
-
static ixManagePrices({ manager, actions, programId: programIdOverride }: ManagePricesParams) {
|
|
2129
|
-
const programId = programIdOverride ?? new PublicKey(EXPONENT_VAULTS_PROGRAM_ID)
|
|
2130
|
-
const [exponentPrices] = new ExponentVaultsPDA(programId).exponentPrices()
|
|
2131
|
-
const remainingAccounts: AccountMeta[] = []
|
|
2132
|
-
const codamaActions = actions.map((action) =>
|
|
2133
|
-
convertUpdatePriceAction(action, programId, exponentPrices, remainingAccounts),
|
|
2134
|
-
)
|
|
2135
|
-
const ix = exponentVaults.createManagePricesInstruction(
|
|
2136
|
-
{ manager, exponentPrices, systemProgram: SystemProgram.programId },
|
|
2137
|
-
{ actions: codamaActions },
|
|
2138
|
-
programId,
|
|
2139
|
-
)
|
|
2140
|
-
ix.keys.push(...remainingAccounts)
|
|
2141
|
-
return ix
|
|
2142
|
-
}
|
|
2143
|
-
|
|
2144
|
-
/**
|
|
2145
|
-
* Create instruction to initialize a new vault.
|
|
2146
|
-
* This is a static method since the vault doesn't exist yet.
|
|
2147
|
-
*/
|
|
2148
|
-
static ixInitializeVault(params: InitializeVaultParams, env: Environment) {
|
|
2149
|
-
const programId = env.exponentVaultsProgramId ?? new PublicKey(EXPONENT_VAULTS_PROGRAM_ID)
|
|
2150
|
-
const vaultsPda = new ExponentVaultsPDA(programId)
|
|
2151
|
-
const squadsPda = new SquadsPDA(params.squadsProgram)
|
|
2152
|
-
const tokenProgram = params.tokenProgram ?? TOKEN_PROGRAM_ID
|
|
2153
|
-
|
|
2154
|
-
// Derive vault PDA
|
|
2155
|
-
const [vault] = vaultsPda.vault({ seedId: params.seedId })
|
|
2156
|
-
const [mintLp] = vaultsPda.mintLp({ vault })
|
|
2157
|
-
const [tokenLpEscrow] = vaultsPda.tokenLpEscrow({ vault })
|
|
2158
|
-
|
|
2159
|
-
// Derive LP destination (ATA for payer)
|
|
2160
|
-
const lpDst = getAssociatedTokenAddressSync(mintLp, params.payer, false, tokenProgram)
|
|
2161
|
-
|
|
2162
|
-
// Squads account is created via CPI during initialize_vault
|
|
2163
|
-
// The on-chain program creates the Squads smart account first, so these start at 1
|
|
2164
|
-
const nextTransactionIndex = BigInt(1)
|
|
2165
|
-
const nextPolicySeed = BigInt(1)
|
|
2166
|
-
|
|
2167
|
-
const nextTransactionTransferIndex = BigInt(2)
|
|
2168
|
-
const nextPolicyTransferSeed = BigInt(2)
|
|
2169
|
-
|
|
2170
|
-
// Derive Squads PDAs for the policy that gets created after the Squads account
|
|
2171
|
-
// These all use squadsSettings (the Settings account) as the base key
|
|
2172
|
-
const [squadsSettingsTransaction] = squadsPda.transaction({
|
|
2173
|
-
settings: params.squadsSettings,
|
|
2174
|
-
transactionIndex: nextTransactionIndex,
|
|
2175
|
-
})
|
|
2176
|
-
const [squadsProposal] = squadsPda.proposal({
|
|
2177
|
-
settings: params.squadsSettings,
|
|
2178
|
-
transactionIndex: nextTransactionIndex,
|
|
2179
|
-
})
|
|
2180
|
-
const [squadsPolicy] = squadsPda.policy({
|
|
2181
|
-
settings: params.squadsSettings,
|
|
2182
|
-
policySeed: nextPolicySeed,
|
|
2183
|
-
})
|
|
2184
|
-
|
|
2185
|
-
// Derive Squads PDAs for the transfer accounts
|
|
2186
|
-
const [squadsPolicyTransfer] = squadsPda.policy({
|
|
2187
|
-
settings: params.squadsSettings,
|
|
2188
|
-
policySeed: nextPolicyTransferSeed,
|
|
2189
|
-
})
|
|
2190
|
-
const [squadsSettingsTransactionTransfer] = squadsPda.transaction({
|
|
2191
|
-
settings: params.squadsSettings,
|
|
2192
|
-
transactionIndex: nextTransactionTransferIndex,
|
|
2193
|
-
})
|
|
2194
|
-
const [squadsProposalTransfer] = squadsPda.proposal({
|
|
2195
|
-
settings: params.squadsSettings,
|
|
2196
|
-
transactionIndex: nextTransactionTransferIndex,
|
|
2197
|
-
})
|
|
2198
|
-
|
|
2199
|
-
// Convert token entries to Codama format
|
|
2200
|
-
const codamaTokenEntries: exponentVaults.TokenEntry[] = params.tokenEntries.map((entry) => ({
|
|
2201
|
-
mint: entry.mint,
|
|
2202
|
-
priceId: toCodamaPriceId(entry.priceId),
|
|
2203
|
-
tokenSquadsAccount: entry.tokenSquadsAccount,
|
|
2204
|
-
tokenAccountVault: entry.tokenAccountVault,
|
|
2205
|
-
forceDeallocatePolicyIds: (entry.forceDeallocatePolicyIds ?? []).map((id) => toBigInt(id)),
|
|
2206
|
-
}))
|
|
2207
|
-
|
|
2208
|
-
// Convert seedId to Uint8Array
|
|
2209
|
-
const seedIdArray = new Uint8Array(params.seedId)
|
|
2210
|
-
if (seedIdArray.length !== 8) {
|
|
2211
|
-
throw new Error(`seedId must contain 8 bytes, received ${seedIdArray.length}`)
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
// Convert roles
|
|
2215
|
-
const codamaRoles: exponentVaults.VaultRoles = {
|
|
2216
|
-
manager: params.roles.manager,
|
|
2217
|
-
curator: params.roles.curator,
|
|
2218
|
-
allocator: params.roles.allocator,
|
|
2219
|
-
sentinel: params.roles.sentinel,
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
// Convert proposal vote config if provided
|
|
2223
|
-
const codamaProposalVoteConfig: exponentVaults.ProposalVoteConfig | null = params.proposalVoteConfig
|
|
2224
|
-
? {
|
|
2225
|
-
minVotingPeriodSeconds: params.proposalVoteConfig.minVotingPeriodSeconds,
|
|
2226
|
-
maxVotingPeriodSeconds: params.proposalVoteConfig.maxVotingPeriodSeconds,
|
|
2227
|
-
defaultVotingPeriodSeconds: params.proposalVoteConfig.defaultVotingPeriodSeconds,
|
|
2228
|
-
defaultTimelockSeconds: params.proposalVoteConfig.defaultTimelockSeconds,
|
|
2229
|
-
rejectionThresholdBps: toBigInt(params.proposalVoteConfig.rejectionThresholdBps),
|
|
2230
|
-
nextProposalId: toBigInt(params.proposalVoteConfig.nextProposalId),
|
|
2231
|
-
votingEnabled: params.proposalVoteConfig.votingEnabled,
|
|
2232
|
-
liveProposalsCount: params.proposalVoteConfig.liveProposalsCount,
|
|
2233
|
-
maxConcurrentLiveProposals: params.proposalVoteConfig.maxConcurrentLiveProposals,
|
|
2234
|
-
reserved: new Uint8Array(params.proposalVoteConfig.reserved),
|
|
2235
|
-
}
|
|
2236
|
-
: null
|
|
2237
|
-
|
|
2238
|
-
const [exponentPrices] = new ExponentVaultsPDA(programId).exponentPrices()
|
|
2239
|
-
|
|
2240
|
-
return exponentVaults.createInitializeVaultInstruction(
|
|
2241
|
-
{
|
|
2242
|
-
payer: params.payer,
|
|
2243
|
-
vault,
|
|
2244
|
-
exponentPrices,
|
|
2245
|
-
mint: params.mint,
|
|
2246
|
-
mintLp,
|
|
2247
|
-
tokenLpEscrow,
|
|
2248
|
-
feeTreasury: params.feeTreasury,
|
|
2249
|
-
lpDst,
|
|
2250
|
-
tokenProgram,
|
|
2251
|
-
systemProgram: SystemProgram.programId,
|
|
2252
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
2253
|
-
addressLookupTable: params.addressLookupTable,
|
|
2254
|
-
squadsProgram: params.squadsProgram,
|
|
2255
|
-
squadsProgramConfig: params.squadsProgramConfig,
|
|
2256
|
-
squadsTreasury: params.squadsTreasury,
|
|
2257
|
-
squadsSettings: params.squadsSettings,
|
|
2258
|
-
squadsVault: params.squadsVault,
|
|
2259
|
-
squadsPolicy,
|
|
2260
|
-
squadsSettingsTransaction,
|
|
2261
|
-
squadsProposal,
|
|
2262
|
-
squadsPolicyTransfer,
|
|
2263
|
-
squadsSettingsTransactionTransfer,
|
|
2264
|
-
squadsProposalTransfer,
|
|
2265
|
-
},
|
|
2266
|
-
{
|
|
2267
|
-
manager: params.manager,
|
|
2268
|
-
feeTreasuryLpBps: params.normalWithdrawalFeeBps,
|
|
2269
|
-
managementFeeBps: toBigInt(params.managementFeeBps),
|
|
2270
|
-
reservesShareBp: params.reservesShareBp,
|
|
2271
|
-
fastWithdrawalCutBp: params.fastWithdrawalCutBp ?? 0,
|
|
2272
|
-
tokenEntries: codamaTokenEntries,
|
|
2273
|
-
maxLpSupply: toBigInt(params.maxLpSupply),
|
|
2274
|
-
seedId: seedIdArray,
|
|
2275
|
-
initialLpAmount: toBigInt(params.initialLpAmount),
|
|
2276
|
-
lpDecimals: params.lpDecimals,
|
|
2277
|
-
roles: codamaRoles,
|
|
2278
|
-
proposalVoteConfig: codamaProposalVoteConfig,
|
|
2279
|
-
},
|
|
2280
|
-
)
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
async fetchTotalAumInfo(pricesAccount: ExponentPrices, jitoBundleRpc?: string): Promise<TotalAumInfo> {
|
|
2284
|
-
const aum = await this.getTotalAumViaJitoBundle(pricesAccount, jitoBundleRpc)
|
|
2285
|
-
|
|
2286
|
-
const { supply: lpSupply, decimals: lpDecimals } = await getMint(this.connection, this.state.mintLp)
|
|
2287
|
-
const underlyingDecimals = await getMintDecimals(this.connection, this.state.underlyingMint)
|
|
2288
|
-
|
|
2289
|
-
if (lpSupply === 0n) {
|
|
2290
|
-
return {
|
|
2291
|
-
aum,
|
|
2292
|
-
aumHuman: 0,
|
|
2293
|
-
lpRate: 0,
|
|
2294
|
-
lpSupply,
|
|
2295
|
-
lpDecimals,
|
|
2296
|
-
underlyingDecimals,
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
const lpHuman = Number(lpSupply.toString()) / 10 ** lpDecimals
|
|
2301
|
-
const aumHuman = Number(aum.toString()) / 10 ** underlyingDecimals
|
|
2302
|
-
const lpRate = aumHuman / lpHuman
|
|
2303
|
-
|
|
2304
|
-
return {
|
|
2305
|
-
aum,
|
|
2306
|
-
aumHuman,
|
|
2307
|
-
lpRate,
|
|
2308
|
-
lpSupply,
|
|
2309
|
-
lpDecimals,
|
|
2310
|
-
underlyingDecimals,
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
|
-
/**
|
|
2315
|
-
* LP token price: AUM / LP supply.
|
|
2316
|
-
* Returns 0 when LP supply is zero.
|
|
2317
|
-
*/
|
|
2318
|
-
async getLpPrice(): Promise<number> {
|
|
2319
|
-
const aum = this.getTotalAum()
|
|
2320
|
-
const lpSupply = await this.fetchLpTokenSupply()
|
|
2321
|
-
const quoteDecimals = await getMintDecimals(this.connection, this.state.underlyingMint)
|
|
2322
|
-
|
|
2323
|
-
const lpSupplyNum = parseInt(lpSupply.toString())
|
|
2324
|
-
if (lpSupplyNum === 0) return 0
|
|
2325
|
-
|
|
2326
|
-
const aumHuman = parseInt(aum.toString()) / 10 ** quoteDecimals
|
|
2327
|
-
const lpMintInfo = await getMint(this.connection, this.state.mintLp)
|
|
2328
|
-
return aumHuman / (lpSupplyNum / 10 ** lpMintInfo.decimals)
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
/**
|
|
2332
|
-
* Total AUM: on-chain tracked base value + value held in strategy positions.
|
|
2333
|
-
*/
|
|
2334
|
-
getTotalAum(): bigint {
|
|
2335
|
-
return this.aumCalculator.getTotalAum()
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2338
|
-
/**
|
|
2339
|
-
* Calculates total AUM by simulating a bundle that updates prices and deposits liquidity.
|
|
2340
|
-
* Requires an RPC endpoint that supports the `simulateBundle` method (e.g., Jito, Helius).
|
|
2341
|
-
*/
|
|
2342
|
-
async getTotalAumViaJitoBundle(pricesAccount: ExponentPrices, jitoBundleRpc?: string): Promise<bigint> {
|
|
2343
|
-
try {
|
|
2344
|
-
const rpcUrl = jitoBundleRpc ?? this.connection.rpcEndpoint
|
|
2345
|
-
|
|
2346
|
-
const depositor = this.state.roles.manager[0]
|
|
2347
|
-
if (!depositor) {
|
|
2348
|
-
throw new Error("Vault manager not found")
|
|
2349
|
-
}
|
|
2350
|
-
|
|
2351
|
-
const depositMint = this.state.tokenEntries[0]?.mint
|
|
2352
|
-
if (!depositMint) {
|
|
2353
|
-
throw new Error("Deposit token not found")
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2356
|
-
const [updatePriceIxs, depositIxs] = await Promise.all([
|
|
2357
|
-
this.ixsUpdateStrategyVaultPrices(pricesAccount),
|
|
2358
|
-
this.ixsDepositLiquidity({
|
|
2359
|
-
depositor,
|
|
2360
|
-
mint: depositMint,
|
|
2361
|
-
tokenAmountIn: 1,
|
|
2362
|
-
minLpOut: 0,
|
|
2363
|
-
}),
|
|
2364
|
-
])
|
|
2365
|
-
|
|
2366
|
-
// Use a dummy blockhash - Jito will replace it with replaceRecentBlockhash
|
|
2367
|
-
const blockhash = "11111111111111111111111111111111"
|
|
2368
|
-
|
|
2369
|
-
const encodedTransactions: string[] = []
|
|
2370
|
-
|
|
2371
|
-
if (updatePriceIxs.length > 0) {
|
|
2372
|
-
const priceMsg = new TransactionMessage({
|
|
2373
|
-
payerKey: depositor,
|
|
2374
|
-
recentBlockhash: blockhash,
|
|
2375
|
-
instructions: updatePriceIxs,
|
|
2376
|
-
}).compileToV0Message()
|
|
2377
|
-
encodedTransactions.push(Buffer.from(new VersionedTransaction(priceMsg).serialize()).toString("base64"))
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
const depositMsg = new TransactionMessage({
|
|
2381
|
-
payerKey: depositor,
|
|
2382
|
-
recentBlockhash: blockhash,
|
|
2383
|
-
instructions: depositIxs,
|
|
2384
|
-
}).compileToV0Message()
|
|
2385
|
-
encodedTransactions.push(Buffer.from(new VersionedTransaction(depositMsg).serialize()).toString("base64"))
|
|
2386
|
-
|
|
2387
|
-
const rpcResponse = await fetch(rpcUrl, {
|
|
2388
|
-
method: "POST",
|
|
2389
|
-
headers: { "Content-Type": "application/json" },
|
|
2390
|
-
body: JSON.stringify({
|
|
2391
|
-
jsonrpc: "2.0",
|
|
2392
|
-
id: "1",
|
|
2393
|
-
method: "simulateBundle",
|
|
2394
|
-
params: [
|
|
2395
|
-
{ encodedTransactions },
|
|
2396
|
-
{
|
|
2397
|
-
preExecutionAccountsConfigs: [
|
|
2398
|
-
null,
|
|
2399
|
-
null,
|
|
2400
|
-
// {
|
|
2401
|
-
// addresses: [this.state.selfAddress.toBase58()],
|
|
2402
|
-
// encoding: "base64",
|
|
2403
|
-
// },
|
|
2404
|
-
],
|
|
2405
|
-
postExecutionAccountsConfigs: [
|
|
2406
|
-
null,
|
|
2407
|
-
{
|
|
2408
|
-
addresses: [this.state.selfAddress.toBase58()],
|
|
2409
|
-
encoding: "base64",
|
|
2410
|
-
},
|
|
2411
|
-
],
|
|
2412
|
-
transactionEncoding: "base64",
|
|
2413
|
-
skipSigVerify: true,
|
|
2414
|
-
replaceRecentBlockhash: true,
|
|
2415
|
-
simulationBank: { commitment: { commitment: "processed" } },
|
|
2416
|
-
},
|
|
2417
|
-
],
|
|
2418
|
-
}),
|
|
2419
|
-
cache: "no-store",
|
|
2420
|
-
})
|
|
2421
|
-
|
|
2422
|
-
type HeliusSimulationTransactionResult = {
|
|
2423
|
-
err?: unknown
|
|
2424
|
-
logs?: string[] | null
|
|
2425
|
-
unitsConsumed?: number | null
|
|
2426
|
-
preExecutionAccounts?: Array<{ data: [string, string] } | null> | null
|
|
2427
|
-
postExecutionAccounts?: Array<{ data: [string, string] } | null> | null
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
type HeliusSimulationResponse = {
|
|
2431
|
-
result?: {
|
|
2432
|
-
value?: {
|
|
2433
|
-
summary?: unknown
|
|
2434
|
-
transactionResults?: HeliusSimulationTransactionResult[]
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
error?: unknown
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
const responseBody = (await rpcResponse.json().catch(() => null)) as HeliusSimulationResponse | null
|
|
2441
|
-
const txnResults = responseBody?.result?.value?.transactionResults || []
|
|
2442
|
-
|
|
2443
|
-
if (!rpcResponse.ok || responseBody?.error) {
|
|
2444
|
-
throw new Error("Jito bundle simulation failed")
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
const depositFailed = !!txnResults[1].err
|
|
2448
|
-
if (depositFailed) {
|
|
2449
|
-
throw new Error("Jito bundle simulation failed")
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
const postVaultAccountData = txnResults[1]?.postExecutionAccounts?.[0]?.data?.[0]
|
|
2453
|
-
|
|
2454
|
-
if (!postVaultAccountData) {
|
|
2455
|
-
throw new Error("Jito bundle simulation failed")
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
const vaultStateAfterSimulations = deserializeExponentStrategyVaultFetcherShape(
|
|
2459
|
-
Buffer.from(postVaultAccountData, "base64"),
|
|
2460
|
-
) as ExponentVaultType
|
|
2461
|
-
const aum =
|
|
2462
|
-
vaultStateAfterSimulations.financials.aumInBase + vaultStateAfterSimulations.financials.aumInBaseInPositions
|
|
2463
|
-
|
|
2464
|
-
return aum
|
|
2465
|
-
} catch {
|
|
2466
|
-
console.warn("Unable to calculate AUM via simulation. Using AUM from vault.state")
|
|
2467
|
-
return this.getTotalAum()
|
|
2468
|
-
}
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
|
-
async ixsUpdateStrategyVaultPrices(
|
|
2472
|
-
pricesAccount: ExponentPrices,
|
|
2473
|
-
options: UpdateStrategyVaultPricesOptions = {},
|
|
2474
|
-
): Promise<TransactionInstruction[]> {
|
|
2475
|
-
const trackedPriceIds =
|
|
2476
|
-
options.priceIds ??
|
|
2477
|
-
collectTrackedStrategyVaultPriceIds({
|
|
2478
|
-
tokenEntries: this.state.tokenEntries,
|
|
2479
|
-
strategyPositions: this.state.strategyPositions,
|
|
2480
|
-
})
|
|
2481
|
-
|
|
2482
|
-
const priceIds = [...trackedPriceIds].sort((a, b) => a - b)
|
|
2483
|
-
if (priceIds.length === 0) {
|
|
2484
|
-
return []
|
|
2485
|
-
}
|
|
2486
|
-
|
|
2487
|
-
return priceIds.map((priceId) => {
|
|
2488
|
-
const priceEntry = pricesAccount.prices[priceId]
|
|
2489
|
-
|
|
2490
|
-
if (!priceEntry) {
|
|
2491
|
-
throw new Error(`Price entry not found for priceId ${priceId}`)
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
return this.ixUpdatePrice({
|
|
2495
|
-
priceId,
|
|
2496
|
-
priceInterfaceAccounts: priceEntry.priceInterfaceAccounts,
|
|
2497
|
-
remainingAccounts: priceEntry.interfaceAccounts,
|
|
2498
|
-
})
|
|
2499
|
-
})
|
|
2500
|
-
}
|
|
2501
|
-
|
|
2502
|
-
// ==========================================================================
|
|
2503
|
-
// Helper Methods — Codama type conversions
|
|
2504
|
-
// ==========================================================================
|
|
2505
|
-
|
|
2506
|
-
/**
|
|
2507
|
-
* Converts vault `PolicyConfig` (policyType shape from policy builders) to the Codama/client codec shape
|
|
2508
|
-
* required by the proposal action codecs used by staged proposal creation.
|
|
2509
|
-
*/
|
|
2510
|
-
public toCodamaPolicyConfig(config: PolicyConfig): exponentVaults.PolicyConfig {
|
|
2511
|
-
return {
|
|
2512
|
-
payload: this.toCodamaPolicyPayload(config.policyType),
|
|
2513
|
-
threshold: config.threshold,
|
|
2514
|
-
timeLock: config.timeLock,
|
|
2515
|
-
startTimestamp: config.startTimestamp,
|
|
2516
|
-
expiration: config.expiration ? this.toCodamaPolicyExpiration(config.expiration) : null,
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
private toCodamaPolicyPayload(policyType: PolicyType): exponentVaults.PolicyCreationPayload {
|
|
2521
|
-
if ("programInteraction" in policyType) {
|
|
2522
|
-
const pi = policyType.programInteraction
|
|
2523
|
-
// Post-hook for interaction validation (matches initialize_vault.rs).
|
|
2524
|
-
// num_extra_accounts: 7 (vault, exponent_prices, mint_lp, payer,
|
|
2525
|
-
// system_program, instructions_sysvar, squads_policy).
|
|
2526
|
-
// program_id is separate, so total = 8 accounts.
|
|
2527
|
-
const validateInteractionPostHook = {
|
|
2528
|
-
numExtraAccounts: 7,
|
|
2529
|
-
accountConstraints: [],
|
|
2530
|
-
instructionData: new Uint8Array([21]), // validate_interaction_hook discriminator
|
|
2531
|
-
programId: this.programId,
|
|
2532
|
-
passInnerInstructions: true,
|
|
2533
|
-
}
|
|
2534
|
-
const payload: exponentVaults.ProgramInteractionPolicyCreationPayload = {
|
|
2535
|
-
accountIndex: pi.accountIndex,
|
|
2536
|
-
instructionsConstraints: pi.instructionsConstraints.map((ic) => ({
|
|
2537
|
-
programId: ic.programId,
|
|
2538
|
-
accountConstraints: ic.accountConstraints.map((ac) => ({
|
|
2539
|
-
accountIndex: ac.accountIndex,
|
|
2540
|
-
accountConstraint:
|
|
2541
|
-
ac.accountDataConstraints && ac.accountDataConstraints.length > 0
|
|
2542
|
-
? {
|
|
2543
|
-
__kind: "AccountData" as const,
|
|
2544
|
-
fields: [ac.accountDataConstraints.map((dc) => this.toCodamaDataConstraint(dc))],
|
|
2545
|
-
}
|
|
2546
|
-
: { __kind: "Pubkey" as const, fields: [ac.accountKeys ?? []] },
|
|
2547
|
-
owner: ac.owner ?? null,
|
|
2548
|
-
})),
|
|
2549
|
-
dataConstraints: ic.dataConstraints.map((dc) => this.toCodamaDataConstraint(dc)),
|
|
2550
|
-
})),
|
|
2551
|
-
preHook: null,
|
|
2552
|
-
postHook: validateInteractionPostHook,
|
|
2553
|
-
spendingLimits: pi.spendingLimits.map((sl) => ({
|
|
2554
|
-
mint: sl.mint,
|
|
2555
|
-
timeConstraints: {
|
|
2556
|
-
start: sl.timeConstraints.start,
|
|
2557
|
-
expiration: sl.timeConstraints.expiration,
|
|
2558
|
-
period: this.toCodamaPeriod(sl.timeConstraints.period),
|
|
2559
|
-
},
|
|
2560
|
-
quantityConstraints: { maxPerPeriod: sl.quantityConstraints.maxPerPeriod },
|
|
2561
|
-
})),
|
|
2562
|
-
}
|
|
2563
|
-
return { __kind: "ProgramInteraction", fields: [payload] }
|
|
2564
|
-
}
|
|
2565
|
-
if ("internalFundTransfer" in policyType) {
|
|
2566
|
-
const ift = policyType.internalFundTransfer
|
|
2567
|
-
const payload: exponentVaults.InternalFundTransferPolicyCreationPayload = {
|
|
2568
|
-
sourceAccountIndices: new Uint8Array(ift.sourceAccountMask),
|
|
2569
|
-
destinationAccountIndices: new Uint8Array(ift.destinationAccountMask),
|
|
2570
|
-
allowedMints: ift.allowedMints,
|
|
2571
|
-
}
|
|
2572
|
-
return { __kind: "InternalFundTransfer", fields: [payload] }
|
|
2573
|
-
}
|
|
2574
|
-
if ("settingsChange" in policyType) {
|
|
2575
|
-
const sc = policyType.settingsChange
|
|
2576
|
-
const payload: exponentVaults.SettingsChangePolicyCreationPayload = {
|
|
2577
|
-
actions: sc.allowedActions.map((a) => this.toCodamaAllowedSettingsChange(a)),
|
|
2578
|
-
}
|
|
2579
|
-
return { __kind: "SettingsChange", fields: [payload] }
|
|
2580
|
-
}
|
|
2581
|
-
if ("spendingLimit" in policyType) {
|
|
2582
|
-
const spl = policyType.spendingLimit
|
|
2583
|
-
const payload: exponentVaults.SpendingLimitPolicyCreationPayload = {
|
|
2584
|
-
mint: spl.spendingLimit.mint,
|
|
2585
|
-
sourceAccountIndex: spl.sourceAccountIndex,
|
|
2586
|
-
timeConstraints: {
|
|
2587
|
-
start: spl.spendingLimit.timeConstraints.start,
|
|
2588
|
-
expiration: spl.spendingLimit.timeConstraints.expiration,
|
|
2589
|
-
period: this.toCodamaPeriod(spl.spendingLimit.timeConstraints.period),
|
|
2590
|
-
accumulateUnused: false,
|
|
2591
|
-
},
|
|
2592
|
-
quantityConstraints: {
|
|
2593
|
-
maxPerPeriod: spl.spendingLimit.quantityConstraints.maxPerPeriod,
|
|
2594
|
-
maxPerUse: 0n,
|
|
2595
|
-
enforceExactQuantity: false,
|
|
2596
|
-
},
|
|
2597
|
-
usageState: null,
|
|
2598
|
-
destinations: spl.destinations,
|
|
2599
|
-
}
|
|
2600
|
-
return { __kind: "SpendingLimit", fields: [payload] }
|
|
2601
|
-
}
|
|
2602
|
-
throw new Error("Unsupported policy type for Codama migration")
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2605
|
-
private toCodamaDataConstraint(constraint: DataConstraint): exponentVaults.DataConstraint {
|
|
2606
|
-
return {
|
|
2607
|
-
dataOffset: constraint.dataOffset,
|
|
2608
|
-
dataValue: this.toCodamaDataValue(constraint.dataValue),
|
|
2609
|
-
operator: this.toCodamaDataOperator(constraint.operator),
|
|
2610
|
-
}
|
|
2611
|
-
}
|
|
2612
|
-
|
|
2613
|
-
private toCodamaDataValue(value: DataValue): exponentVaults.DataValue {
|
|
2614
|
-
if ("u8" in value) return { __kind: "U8", fields: [value.u8] }
|
|
2615
|
-
if ("u16Le" in value) return { __kind: "U16Le", fields: [value.u16Le] }
|
|
2616
|
-
if ("u32Le" in value) return { __kind: "U32Le", fields: [value.u32Le] }
|
|
2617
|
-
if ("u64Le" in value) return { __kind: "U64Le", fields: [value.u64Le] }
|
|
2618
|
-
if ("u128Le" in value) return { __kind: "U128Le", fields: [value.u128Le] }
|
|
2619
|
-
if ("u8Slice" in value) return { __kind: "U8Slice", fields: [new Uint8Array(value.u8Slice)] }
|
|
2620
|
-
throw new Error("Unknown data value type")
|
|
2621
|
-
}
|
|
2622
|
-
|
|
2623
|
-
private toCodamaDataOperator(op: DataOperator): exponentVaults.DataOperator {
|
|
2624
|
-
const map: Record<DataOperator, exponentVaults.DataOperator> = {
|
|
2625
|
-
Equals: exponentVaults.DataOperator.Equals,
|
|
2626
|
-
NotEquals: exponentVaults.DataOperator.NotEquals,
|
|
2627
|
-
GreaterThan: exponentVaults.DataOperator.GreaterThan,
|
|
2628
|
-
GreaterThanOrEqualTo: exponentVaults.DataOperator.GreaterThanOrEqualTo,
|
|
2629
|
-
LessThan: exponentVaults.DataOperator.LessThan,
|
|
2630
|
-
LessThanOrEqualTo: exponentVaults.DataOperator.LessThanOrEqualTo,
|
|
2631
|
-
}
|
|
2632
|
-
return map[op]
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
private toCodamaPeriod(period: Period): exponentVaults.PeriodV2 {
|
|
2636
|
-
const map: Record<string, exponentVaults.PeriodV2> = {
|
|
2637
|
-
OneTime: { __kind: "OneTime" },
|
|
2638
|
-
Daily: { __kind: "Daily" },
|
|
2639
|
-
Weekly: { __kind: "Weekly" },
|
|
2640
|
-
Monthly: { __kind: "Monthly" },
|
|
2641
|
-
}
|
|
2642
|
-
const result = map[period]
|
|
2643
|
-
if (!result) throw new Error(`Unsupported period: ${period}`)
|
|
2644
|
-
return result
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2647
|
-
private toCodamaPolicyExpiration(expiration: PolicyExpiration): exponentVaults.PolicyExpirationArgs {
|
|
2648
|
-
if ("timestamp" in expiration) return { __kind: "Timestamp", fields: [expiration.timestamp] }
|
|
2649
|
-
if ("settingsState" in expiration) return { __kind: "SettingsState" }
|
|
2650
|
-
throw new Error("Unknown expiration type")
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
|
-
private toCodamaAllowedSettingsChange(change: AllowedSettingsChange): exponentVaults.AllowedSettingsChange {
|
|
2654
|
-
switch (change) {
|
|
2655
|
-
case "AddSigner":
|
|
2656
|
-
return { __kind: "AddSigner", newSigner: null, newSignerPermissions: null }
|
|
2657
|
-
case "RemoveSigner":
|
|
2658
|
-
return { __kind: "RemoveSigner", oldSigner: null }
|
|
2659
|
-
case "ChangeThreshold":
|
|
2660
|
-
return { __kind: "ChangeThreshold" }
|
|
2661
|
-
case "ChangeTimeLock":
|
|
2662
|
-
return { __kind: "ChangeTimeLock", newTimeLock: null }
|
|
2663
|
-
default:
|
|
2664
|
-
throw new Error(`Unsupported settings change: ${change}`)
|
|
2665
|
-
}
|
|
2666
|
-
}
|
|
2667
|
-
}
|