@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
package/src/marketThree.ts
DELETED
|
@@ -1,2861 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TOKEN_PROGRAM_ID,
|
|
3
|
-
createAssociatedTokenAccountIdempotentInstruction,
|
|
4
|
-
getAccount,
|
|
5
|
-
getAssociatedTokenAddressSync,
|
|
6
|
-
} from "@solana/spl-token"
|
|
7
|
-
import bs58 from "bs58"
|
|
8
|
-
import Decimal from "decimal.js"
|
|
9
|
-
|
|
10
|
-
import { ExponentCLMMPDA } from "@exponent-labs/exponent-clmm-pda"
|
|
11
|
-
import {
|
|
12
|
-
ExponentFetcher,
|
|
13
|
-
LiquidityNetBalanceLimits,
|
|
14
|
-
LpFarm,
|
|
15
|
-
LpPositionCLMM,
|
|
16
|
-
MarketConfigurationOptions,
|
|
17
|
-
MarketThreeFinancials,
|
|
18
|
-
Ticks,
|
|
19
|
-
} from "@exponent-labs/exponent-fetcher"
|
|
20
|
-
import { ExponentPDA } from "@exponent-labs/exponent-pda"
|
|
21
|
-
import {
|
|
22
|
-
AnchorizedPNum,
|
|
23
|
-
CpiAccountsRaw,
|
|
24
|
-
ExponentCoreCpiAccountsRaw,
|
|
25
|
-
Flavor,
|
|
26
|
-
SyPosition,
|
|
27
|
-
} from "@exponent-labs/exponent-types"
|
|
28
|
-
import { LiquidityAdd } from "@exponent-labs/market-math"
|
|
29
|
-
import {
|
|
30
|
-
EffSnap,
|
|
31
|
-
calcDepositSyAndPtFromBaseAmount,
|
|
32
|
-
calcPtPriceInAsset,
|
|
33
|
-
computeLiquidityTargetAndTokenNeeds,
|
|
34
|
-
getPtAndSyOnWithdrawLiquidity,
|
|
35
|
-
normalizedTimeRemaining,
|
|
36
|
-
} from "@exponent-labs/market-three-math"
|
|
37
|
-
|
|
38
|
-
import {
|
|
39
|
-
fetchAddressLookupTable,
|
|
40
|
-
makeCpiAccountMetaLists,
|
|
41
|
-
makeMarketCoreCpiAccountMetaLists,
|
|
42
|
-
} from "./addressLookupTableUtil"
|
|
43
|
-
import { Environment } from "./environment"
|
|
44
|
-
import {
|
|
45
|
-
makeFlavorGenericSync,
|
|
46
|
-
makeFlavorJitoRestakingSync,
|
|
47
|
-
makeFlavorKaminoSync,
|
|
48
|
-
makeFlavorMarginfiSync,
|
|
49
|
-
makeFlavorPerenaSync,
|
|
50
|
-
} from "./flavors"
|
|
51
|
-
import { makeSyPosition } from "./syPosition"
|
|
52
|
-
import { emitEventAuthority, uniqueRemainingAccounts } from "./utils"
|
|
53
|
-
import { Vault } from "./vault"
|
|
54
|
-
import { Connection, Keypair, PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, SystemProgram, TransactionInstruction } from "@solana/web3.js"
|
|
55
|
-
import * as exponentClmm from './client/clmm'
|
|
56
|
-
import { SwapDirection } from './client/clmm'
|
|
57
|
-
import * as exponentCore from './client/core'
|
|
58
|
-
|
|
59
|
-
export { LiquidityAdd }
|
|
60
|
-
|
|
61
|
-
const SECONDS_PER_YEAR = 365 * 24 * 60 * 60
|
|
62
|
-
|
|
63
|
-
interface Emission {
|
|
64
|
-
/** Token account that holds emission tokens */
|
|
65
|
-
escrowAccountAddress: PublicKey
|
|
66
|
-
|
|
67
|
-
/** Mint for the emission token */
|
|
68
|
-
mint: PublicKey
|
|
69
|
-
|
|
70
|
-
/** Token program ID for the emission token */
|
|
71
|
-
tokenProgramAddress: PublicKey
|
|
72
|
-
|
|
73
|
-
/** How many emissions have been claimed by SY holders */
|
|
74
|
-
totalClaimed: bigint
|
|
75
|
-
|
|
76
|
-
/** How many emissions have been earned by the SY robot over its lifetime */
|
|
77
|
-
lastSeenTotalAccruedEmissions: bigint
|
|
78
|
-
|
|
79
|
-
/** Global index for sharing out rewards to SY holders */
|
|
80
|
-
index: AnchorizedPNum
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export type MarketAdminAction = exponentClmm.MarketAdminAction
|
|
84
|
-
|
|
85
|
-
export { SwapDirection } from './client/clmm'
|
|
86
|
-
|
|
87
|
-
interface MarketThreeLoadOptions {
|
|
88
|
-
syConfig?: {
|
|
89
|
-
skipWrap?: boolean
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
type MarketThreeArgs = {
|
|
94
|
-
admin: PublicKey
|
|
95
|
-
addressLookupTable: PublicKey
|
|
96
|
-
mintPt: PublicKey
|
|
97
|
-
mintYt: PublicKey
|
|
98
|
-
mintSy: PublicKey
|
|
99
|
-
vault: Vault
|
|
100
|
-
tokenPtEscrow: PublicKey
|
|
101
|
-
tokenSyEscrow: PublicKey
|
|
102
|
-
tokenYtEscrow: PublicKey
|
|
103
|
-
tokenFeeTreasurySy: PublicKey
|
|
104
|
-
tokenFeeTreasuryPt: PublicKey
|
|
105
|
-
syProgram: PublicKey
|
|
106
|
-
selfAddress: PublicKey
|
|
107
|
-
statusFlags: number
|
|
108
|
-
configurationOptions: MarketConfigurationOptions
|
|
109
|
-
financials: MarketThreeFinancials
|
|
110
|
-
cpiSyAccounts: CpiAccountsRaw
|
|
111
|
-
cpiCoreAccounts: ExponentCoreCpiAccountsRaw
|
|
112
|
-
isCurrentFlashSwap: boolean
|
|
113
|
-
lpFarm: LpFarm
|
|
114
|
-
flavor: Flavor
|
|
115
|
-
emissions: {
|
|
116
|
-
trackers: {
|
|
117
|
-
tokenEscrow: PublicKey
|
|
118
|
-
lpShareIndex: number
|
|
119
|
-
lastSeenStaged: number
|
|
120
|
-
}[]
|
|
121
|
-
}
|
|
122
|
-
liquidityNetBalanceLimits: LiquidityNetBalanceLimits
|
|
123
|
-
ticksAccount: PublicKey
|
|
124
|
-
ticks: Ticks
|
|
125
|
-
syPosition: SyPosition
|
|
126
|
-
treasuryFeeOwner: PublicKey
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* CLMM (Concentrated Liquidity Market Maker) market client for the Exponent protocol.
|
|
131
|
-
*
|
|
132
|
-
* Provides instruction builders for trading PT/YT tokens, managing concentrated liquidity positions,
|
|
133
|
-
* and administering market settings. Each `ix*` method returns one or more Solana `TransactionInstruction`s
|
|
134
|
-
* ready to be included in a transaction.
|
|
135
|
-
*
|
|
136
|
-
* "Wrapper" methods (e.g. `ixWrapperBuyPt`) combine a base-asset mint/redeem step with the
|
|
137
|
-
* underlying trade so the caller can operate directly with the base asset rather than SY.
|
|
138
|
-
*/
|
|
139
|
-
export class MarketThree {
|
|
140
|
-
xponPda: ExponentPDA
|
|
141
|
-
pda: ExponentCLMMPDA
|
|
142
|
-
|
|
143
|
-
constructor(
|
|
144
|
-
public state: MarketThreeArgs,
|
|
145
|
-
public selfAddress: PublicKey,
|
|
146
|
-
public env: Environment,
|
|
147
|
-
public connection: Connection,
|
|
148
|
-
) {
|
|
149
|
-
this.xponPda = new ExponentPDA(env.coreProgramId)
|
|
150
|
-
this.pda = new ExponentCLMMPDA()
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Build the modify_market_setting instruction without loading the full market.
|
|
154
|
-
* Use this when the market's ALT is invalid/unset (e.g. repair flow) to avoid fetching the ALT.
|
|
155
|
-
*/
|
|
156
|
-
static buildModifyMarketSettingIx(
|
|
157
|
-
connection: Connection,
|
|
158
|
-
marketAddress: PublicKey,
|
|
159
|
-
{ signer, adminAction }: { signer: PublicKey; adminAction: MarketAdminAction },
|
|
160
|
-
): TransactionInstruction {
|
|
161
|
-
return exponentClmm
|
|
162
|
-
.createModifyMarketSettingInstruction(
|
|
163
|
-
{
|
|
164
|
-
market: marketAddress,
|
|
165
|
-
signer,
|
|
166
|
-
systemProgram: SystemProgram.programId,
|
|
167
|
-
},
|
|
168
|
-
{'action': adminAction}
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Load a MarketThree instance from on-chain state.
|
|
173
|
-
*
|
|
174
|
-
* Fetches the market account, its address lookup table, vault, and ticks data in parallel.
|
|
175
|
-
* Pre-loaded vault/ticks can be passed to avoid redundant fetches.
|
|
176
|
-
*
|
|
177
|
-
* @param env - Environment configuration (program IDs, cluster)
|
|
178
|
-
* @param connection - Solana RPC connection
|
|
179
|
-
* @param address - On-chain address of the market account
|
|
180
|
-
* @param vault - Optional pre-loaded vault (fetched automatically if omitted)
|
|
181
|
-
* @param ticks - Optional pre-loaded ticks data (fetched automatically if omitted)
|
|
182
|
-
* @param options - Optional load options (e.g. SY config overrides)
|
|
183
|
-
*/
|
|
184
|
-
static async load(
|
|
185
|
-
env: Environment,
|
|
186
|
-
connection: Connection,
|
|
187
|
-
address: PublicKey,
|
|
188
|
-
vault?: Vault,
|
|
189
|
-
ticks?: Ticks,
|
|
190
|
-
options: MarketThreeLoadOptions = {},
|
|
191
|
-
): Promise<MarketThree> {
|
|
192
|
-
const fetcher = new ExponentFetcher({ connection })
|
|
193
|
-
const fetchedMarket = await fetcher.fetchMarketThree(address)
|
|
194
|
-
const [alt, loadedVault, loadedTicks] = await Promise.all([
|
|
195
|
-
fetchAddressLookupTable(connection, fetchedMarket.addressLookupTable),
|
|
196
|
-
vault || Vault.load(env, connection, fetchedMarket.vault, options),
|
|
197
|
-
ticks || fetcher.fetchMarketThreeTicks(fetchedMarket.ticks),
|
|
198
|
-
])
|
|
199
|
-
const cpiSyAccounts = makeCpiAccountMetaLists(alt, fetchedMarket.cpiSyAccounts)
|
|
200
|
-
const cpiCoreAccounts = makeMarketCoreCpiAccountMetaLists(alt, fetchedMarket.cpiCoreAccounts)
|
|
201
|
-
|
|
202
|
-
const flavor = (() => {
|
|
203
|
-
switch (loadedVault.flavor.flavor) {
|
|
204
|
-
case "marginfi":
|
|
205
|
-
return makeFlavorMarginfiSync(loadedVault.flavor)
|
|
206
|
-
case "kamino":
|
|
207
|
-
return makeFlavorKaminoSync(loadedVault.flavor)
|
|
208
|
-
case "jitoRestaking":
|
|
209
|
-
return makeFlavorJitoRestakingSync(loadedVault.flavor)
|
|
210
|
-
case "perena":
|
|
211
|
-
return makeFlavorPerenaSync(loadedVault.flavor)
|
|
212
|
-
case "generic":
|
|
213
|
-
return makeFlavorGenericSync(loadedVault.flavor, options.syConfig)
|
|
214
|
-
default:
|
|
215
|
-
throw new Error(`Unknown flavor: ${loadedVault.flavor}`)
|
|
216
|
-
}
|
|
217
|
-
})()
|
|
218
|
-
|
|
219
|
-
const syPosition = await makeSyPosition(fetcher, flavor, fetchedMarket.syProgram, address)
|
|
220
|
-
|
|
221
|
-
//? Assuming that the owner is the same for both accounts feeAccounts
|
|
222
|
-
const treasuryFeeOwner = await MarketThree.fetchTreasuryFeeOwner(fetchedMarket.tokenFeeTreasuryPt, connection)
|
|
223
|
-
|
|
224
|
-
const state: MarketThreeArgs = {
|
|
225
|
-
...fetchedMarket,
|
|
226
|
-
vault: loadedVault,
|
|
227
|
-
flavor,
|
|
228
|
-
ticks: loadedTicks,
|
|
229
|
-
syPosition,
|
|
230
|
-
cpiSyAccounts,
|
|
231
|
-
cpiCoreAccounts,
|
|
232
|
-
ticksAccount: fetchedMarket.ticks,
|
|
233
|
-
treasuryFeeOwner,
|
|
234
|
-
}
|
|
235
|
-
return new MarketThree(state, address, env, connection)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async reload(connection: Connection = this.connection) {
|
|
239
|
-
const market = await MarketThree.load(this.env, connection, this.selfAddress)
|
|
240
|
-
this.state = market.state
|
|
241
|
-
return market
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
get vault() {
|
|
245
|
-
return this.state.vault
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
get flavor() {
|
|
249
|
-
return this.state.flavor
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
get lpBalance() {
|
|
253
|
-
return this.state.financials.liquidityBalance
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
get syBalance() {
|
|
257
|
-
return this.state.financials.syBalance
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
get ptBalance() {
|
|
261
|
-
return this.state.financials.ptBalance
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
get mintSy() {
|
|
265
|
-
return this.state.mintSy
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
get mintPt() {
|
|
269
|
-
return this.state.mintPt
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
get statusFlags() {
|
|
273
|
-
return this.state.statusFlags
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
get mintYt() {
|
|
277
|
-
return this.state.mintYt
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
get addressLookupTable() {
|
|
281
|
-
return this.state.addressLookupTable
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
get syProgram() {
|
|
285
|
-
return this.state.syProgram
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
get cpiSyAccounts() {
|
|
289
|
-
return this.state.cpiSyAccounts
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
get cpiCoreAccounts() {
|
|
293
|
-
return this.state.cpiCoreAccounts
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
get marketEmissions() {
|
|
297
|
-
return this.state.emissions
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
get ticksKey() {
|
|
301
|
-
return this.state.ticksAccount
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
get corePda() {
|
|
305
|
-
return new ExponentPDA()
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
get coreEventAuthority() {
|
|
309
|
-
return emitEventAuthority(exponentCore.EXPONENTCORE_PROGRAM_ID)
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
get emissions(): Emission[] {
|
|
313
|
-
if (this.flavor.flavor === "marginfi") {
|
|
314
|
-
return this.flavor.mfiSyState.account.emissions.map((e) => ({
|
|
315
|
-
escrowAccountAddress: e.escrowAccount,
|
|
316
|
-
mint: e.mint,
|
|
317
|
-
tokenProgramAddress: e.tokenProgram,
|
|
318
|
-
totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
|
|
319
|
-
lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
|
|
320
|
-
index: e.index,
|
|
321
|
-
}))
|
|
322
|
-
}
|
|
323
|
-
if (this.flavor.flavor === "kamino") {
|
|
324
|
-
return this.flavor.kaminoSyState.account.emissions.map((e) => ({
|
|
325
|
-
escrowAccountAddress: e.escrowAccount,
|
|
326
|
-
mint: e.mint,
|
|
327
|
-
tokenProgramAddress: e.tokenProgram,
|
|
328
|
-
totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
|
|
329
|
-
lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
|
|
330
|
-
index: e.index,
|
|
331
|
-
}))
|
|
332
|
-
}
|
|
333
|
-
if (this.flavor.flavor === "jitoRestaking") {
|
|
334
|
-
return this.flavor.jitoSyState.account.emissions.map((e) => ({
|
|
335
|
-
escrowAccountAddress: e.escrowAccount,
|
|
336
|
-
mint: e.mint,
|
|
337
|
-
tokenProgramAddress: e.tokenProgram,
|
|
338
|
-
totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
|
|
339
|
-
lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
|
|
340
|
-
index: e.index,
|
|
341
|
-
}))
|
|
342
|
-
}
|
|
343
|
-
if (this.flavor.flavor === "perena") {
|
|
344
|
-
return this.flavor.perenaSyState.account.emissions.map((e) => ({
|
|
345
|
-
escrowAccountAddress: e.escrowAccount,
|
|
346
|
-
mint: e.mint,
|
|
347
|
-
tokenProgramAddress: e.tokenProgram,
|
|
348
|
-
totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
|
|
349
|
-
lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
|
|
350
|
-
index: e.index,
|
|
351
|
-
}))
|
|
352
|
-
}
|
|
353
|
-
if (this.flavor.flavor === "generic") {
|
|
354
|
-
return this.flavor.genericSyState.account.emissions.map((e) => ({
|
|
355
|
-
escrowAccountAddress: e.escrowAccount,
|
|
356
|
-
mint: e.mint,
|
|
357
|
-
tokenProgramAddress: e.tokenProgram,
|
|
358
|
-
totalClaimed: BigInt(e.totalClaimedEmissions.toString()),
|
|
359
|
-
lastSeenTotalAccruedEmissions: BigInt(e.lastSeenTotalAccruedEmissions.toString()),
|
|
360
|
-
index: e.index,
|
|
361
|
-
}))
|
|
362
|
-
}
|
|
363
|
-
throw new Error("Unknown flavor")
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/** Get the escrow token account addresses for the emissions, in order */
|
|
367
|
-
get emissionTokenAccounts(): PublicKey[] {
|
|
368
|
-
return this.emissions.map((e) => e.escrowAccountAddress)
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/** Pass-through SY account owned by the market */
|
|
372
|
-
get tokenSyEscrow(): PublicKey {
|
|
373
|
-
return this.state.tokenSyEscrow
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/** Pass-through YT account owned by the market */
|
|
377
|
-
get tokenYtEscrow(): PublicKey {
|
|
378
|
-
return this.state.tokenYtEscrow
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** SY account that holds treasury SY fees from PT trading */
|
|
382
|
-
get tokenFeeTreasurySy(): PublicKey {
|
|
383
|
-
return this.state.tokenFeeTreasurySy
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/** PT account that holds treasury PT fees from PT trading */
|
|
387
|
-
get tokenFeeTreasuryPt(): PublicKey {
|
|
388
|
-
return this.state.tokenFeeTreasuryPt
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/** Market liquidity for PT */
|
|
392
|
-
get tokenPtEscrow(): PublicKey {
|
|
393
|
-
return this.state.tokenPtEscrow
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
get currentSyExchangeRate(): number {
|
|
397
|
-
return this.flavor.currentSyExchangeRate
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/** Special account for event emit self-cpi */
|
|
401
|
-
get eventAuthority(): PublicKey {
|
|
402
|
-
return emitEventAuthority(exponentClmm.EXPONENTCLMM_PROGRAM_ID)
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
get secondsRemaining(): number {
|
|
406
|
-
const timeNow = Date.now() / 1000
|
|
407
|
-
return Math.max(0, Math.round(Number(this.state.financials.expirationTs) - timeNow))
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/** Annualize a rate given the number of seconds remaining until maturity */
|
|
411
|
-
static annualize(rate: number, secondsRemaining: number) {
|
|
412
|
-
return (rate * SECONDS_PER_YEAR) / secondsRemaining
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
static annualizeApy(rate: number, secondsRemaining: number) {
|
|
416
|
-
return (1 + rate) ** (SECONDS_PER_YEAR / secondsRemaining) - 1
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/** The fee rate taken off of trade fees (typically around 20%) expressed as a BPS number */
|
|
420
|
-
get feeTreasuryBps(): number {
|
|
421
|
-
return this.state.configurationOptions.treasuryFeeBps
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/** The fee rate taken off of trade fees (typically around 20%) expressed as a rational number */
|
|
425
|
-
get feeTreasuryRate(): number {
|
|
426
|
-
return this.feeTreasuryBps / 10_000
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/** Get the owner of the treasury fee accounts: tokenFeeTreasuryPt & tokenFeeTreasurySy */
|
|
430
|
-
static async fetchTreasuryFeeOwner(
|
|
431
|
-
tokenFeeTreasury: PublicKey,
|
|
432
|
-
connection: Connection,
|
|
433
|
-
): Promise<PublicKey> {
|
|
434
|
-
const { owner } = await getAccount(connection, tokenFeeTreasury)
|
|
435
|
-
return owner
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/** Deposit a pair of tokens as liquidity to the market
|
|
439
|
-
* Adds PT & SY from the `depositor` to the market
|
|
440
|
-
*
|
|
441
|
-
* Due to unforeseeable slippage, the PT & SY amounts intended are effectively the maximum amounts
|
|
442
|
-
* The minimum LP tokens to receive is specified by `minLpOut`
|
|
443
|
-
*
|
|
444
|
-
* The token accounts themselves are optional, and will be derived from the depositor's wallet if not provided
|
|
445
|
-
*/
|
|
446
|
-
ixDepositLiquidity({
|
|
447
|
-
ptInIntent,
|
|
448
|
-
syInIntent,
|
|
449
|
-
depositor,
|
|
450
|
-
lowerTickKey,
|
|
451
|
-
upperTickKey,
|
|
452
|
-
ptSrc: ptSrcParam,
|
|
453
|
-
sySrc: sySrcParam,
|
|
454
|
-
lpPosition: lpPositionParam,
|
|
455
|
-
}: {
|
|
456
|
-
/** Intended (maximum) amount of PT in */
|
|
457
|
-
ptInIntent: bigint
|
|
458
|
-
/** Intended (maximum) amount of SY in */
|
|
459
|
-
syInIntent: bigint
|
|
460
|
-
/** Lower tick key */
|
|
461
|
-
lowerTickKey: number
|
|
462
|
-
/** Upper tick key */
|
|
463
|
-
upperTickKey: number
|
|
464
|
-
depositor: PublicKey
|
|
465
|
-
ptSrc?: PublicKey
|
|
466
|
-
sySrc?: PublicKey
|
|
467
|
-
lpPosition?: Keypair
|
|
468
|
-
}) {
|
|
469
|
-
const sySrc = sySrcParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
|
|
470
|
-
const ptSrc = ptSrcParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
|
|
471
|
-
|
|
472
|
-
const lpPosition = lpPositionParam || Keypair.generate()
|
|
473
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
474
|
-
...this.cpiSyAccounts.depositSy,
|
|
475
|
-
...this.cpiSyAccounts.getPositionState,
|
|
476
|
-
])
|
|
477
|
-
|
|
478
|
-
const ix = exponentClmm.createDepositLiquidityInstruction(
|
|
479
|
-
{
|
|
480
|
-
depositor,
|
|
481
|
-
market: this.selfAddress,
|
|
482
|
-
ticks: this.ticksKey,
|
|
483
|
-
lpPosition: lpPosition.publicKey,
|
|
484
|
-
tokenPtSrc: ptSrc,
|
|
485
|
-
tokenSySrc: sySrc,
|
|
486
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
487
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
488
|
-
addressLookupTable: this.addressLookupTable,
|
|
489
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
490
|
-
syProgram: this.syProgram,
|
|
491
|
-
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
492
|
-
systemProgram: SystemProgram.programId,
|
|
493
|
-
eventAuthority: this.eventAuthority,
|
|
494
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
lowerTickKey: convertApyToApyBp(lowerTickKey),
|
|
498
|
-
upperTickKey: convertApyToApyBp(upperTickKey),
|
|
499
|
-
maxPtIn: ptInIntent,
|
|
500
|
-
maxSyIn: syInIntent,
|
|
501
|
-
},
|
|
502
|
-
)
|
|
503
|
-
ix.keys.push(...remainingAccounts)
|
|
504
|
-
|
|
505
|
-
return {
|
|
506
|
-
ix,
|
|
507
|
-
signers: lpPosition,
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Redeem LP tokens for PT & SY (liquidity removal)
|
|
513
|
-
*
|
|
514
|
-
* The lpIn is exactly the amount of LP tokens to burn
|
|
515
|
-
* The minimum PT & SY out are specified by minPtOut & minSyOut
|
|
516
|
-
* The transaction may fail due to unforeseeable slippage on the redemption rate
|
|
517
|
-
*
|
|
518
|
-
* The token accounts themselves are optional, and will be derived from the withdrawer's wallet if not provided
|
|
519
|
-
*/
|
|
520
|
-
ixWithdrawLiquidity({
|
|
521
|
-
lpIn,
|
|
522
|
-
withdrawer,
|
|
523
|
-
lpPosition,
|
|
524
|
-
minPtOut,
|
|
525
|
-
minSyOut,
|
|
526
|
-
ptDst: ptDstParam,
|
|
527
|
-
syDst: syDstParam,
|
|
528
|
-
}: {
|
|
529
|
-
lpIn: bigint
|
|
530
|
-
withdrawer: PublicKey
|
|
531
|
-
lpPosition: PublicKey
|
|
532
|
-
minPtOut: bigint
|
|
533
|
-
minSyOut: bigint
|
|
534
|
-
ptDst?: PublicKey
|
|
535
|
-
syDst?: PublicKey
|
|
536
|
-
lnImpliedApyLimit?: number
|
|
537
|
-
}) {
|
|
538
|
-
const ptDst = ptDstParam || getAssociatedTokenAddressSync(this.mintPt, withdrawer, true, TOKEN_PROGRAM_ID)
|
|
539
|
-
const syDst = syDstParam || getAssociatedTokenAddressSync(this.mintSy, withdrawer, true, TOKEN_PROGRAM_ID)
|
|
540
|
-
const ptDstAtaIx = createAssociatedTokenAccountIdempotentInstruction(withdrawer, ptDst, withdrawer, this.mintPt)
|
|
541
|
-
const syDstAtaIx = createAssociatedTokenAccountIdempotentInstruction(withdrawer, syDst, withdrawer, this.mintSy)
|
|
542
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
543
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
544
|
-
...this.cpiSyAccounts.getPositionState,
|
|
545
|
-
])
|
|
546
|
-
|
|
547
|
-
const ix = exponentClmm.createWithdrawLiquidityInstruction(
|
|
548
|
-
{
|
|
549
|
-
owner: withdrawer,
|
|
550
|
-
market: this.selfAddress,
|
|
551
|
-
lpPosition,
|
|
552
|
-
ticks: this.ticksKey,
|
|
553
|
-
tokenPtDst: ptDst,
|
|
554
|
-
tokenSyDst: syDst,
|
|
555
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
556
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
557
|
-
addressLookupTable: this.addressLookupTable,
|
|
558
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
559
|
-
syProgram: this.syProgram,
|
|
560
|
-
systemProgram: SystemProgram.programId,
|
|
561
|
-
eventAuthority: this.eventAuthority,
|
|
562
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
liquidityToRemove: lpIn,
|
|
566
|
-
minPtOut,
|
|
567
|
-
minSyOut,
|
|
568
|
-
},
|
|
569
|
-
)
|
|
570
|
-
ix.keys.push(...remainingAccounts)
|
|
571
|
-
|
|
572
|
-
return { ixs: [ix], setupIxs: [ptDstAtaIx, syDstAtaIx] }
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Swap PT <-> SY on the CLMM.
|
|
577
|
-
*
|
|
578
|
-
* Low-level instruction — prefer {@link ixBuyPt} / {@link ixSellPt} for directional trades.
|
|
579
|
-
*
|
|
580
|
-
* @param trader - Wallet signing the transaction
|
|
581
|
-
* @param traderAmount - Amount of the input token
|
|
582
|
-
* @param outConstraint - Minimum output amount (slippage protection)
|
|
583
|
-
* @param swapDirection - `SwapDirection.SyToPt` or `SwapDirection.PtToSy`
|
|
584
|
-
* @param lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
585
|
-
*/
|
|
586
|
-
ixTradePt({
|
|
587
|
-
trader,
|
|
588
|
-
traderAmount,
|
|
589
|
-
outConstraint,
|
|
590
|
-
swapDirection,
|
|
591
|
-
tokenPt: tokenPtParam,
|
|
592
|
-
tokenSy: tokenSyParam,
|
|
593
|
-
lnImpliedApyLimit,
|
|
594
|
-
}: {
|
|
595
|
-
trader: PublicKey
|
|
596
|
-
traderAmount: bigint
|
|
597
|
-
outConstraint: bigint
|
|
598
|
-
swapDirection: SwapDirection
|
|
599
|
-
tokenPt?: PublicKey
|
|
600
|
-
tokenSy?: PublicKey
|
|
601
|
-
lnImpliedApyLimit?: number
|
|
602
|
-
}) {
|
|
603
|
-
const tokenPt = tokenPtParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
|
|
604
|
-
const tokenSy = tokenSyParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
|
|
605
|
-
|
|
606
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, tokenSy, trader, this.mintSy)
|
|
607
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, tokenPt, trader, this.mintPt)
|
|
608
|
-
|
|
609
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
610
|
-
...this.cpiSyAccounts.getSyState,
|
|
611
|
-
...this.cpiSyAccounts.getPositionState,
|
|
612
|
-
...this.cpiSyAccounts.depositSy,
|
|
613
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
614
|
-
])
|
|
615
|
-
|
|
616
|
-
const ix = exponentClmm.createTradePtInstruction(
|
|
617
|
-
{
|
|
618
|
-
trader,
|
|
619
|
-
market: this.selfAddress,
|
|
620
|
-
ticks: this.ticksKey,
|
|
621
|
-
tokenSyTrader: tokenSy,
|
|
622
|
-
tokenPtTrader: tokenPt,
|
|
623
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
624
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
625
|
-
addressLookupTable: this.addressLookupTable,
|
|
626
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
627
|
-
syProgram: this.syProgram,
|
|
628
|
-
tokenFeeTreasurySy: this.tokenFeeTreasurySy,
|
|
629
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
630
|
-
eventAuthority: this.eventAuthority,
|
|
631
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
632
|
-
},
|
|
633
|
-
{
|
|
634
|
-
amountIn: traderAmount,
|
|
635
|
-
swapDirection,
|
|
636
|
-
amountOutConstraint: outConstraint || null,
|
|
637
|
-
priceSpotLimit: lnImpliedApyLimit ?? null,
|
|
638
|
-
},
|
|
639
|
-
)
|
|
640
|
-
ix.keys.push(...remainingAccounts)
|
|
641
|
-
|
|
642
|
-
return { ixs: [ix], setupIxs: [tokenPtAtaIx, tokenSyAtaIx] }
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Swap PT <-> SY specifying the exact output amount.
|
|
647
|
-
*
|
|
648
|
-
* Inverse of {@link ixTradePt} — the caller specifies how much they want to *receive*
|
|
649
|
-
* rather than how much they want to *spend*.
|
|
650
|
-
*
|
|
651
|
-
* @param trader - Wallet signing the transaction
|
|
652
|
-
* @param amountOut - Exact amount of the output token to receive
|
|
653
|
-
* @param swapDirection - `SwapDirection.SyToPt` or `SwapDirection.PtToSy`
|
|
654
|
-
* @param amountInConstraint - Maximum input amount (slippage protection)
|
|
655
|
-
* @param lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
656
|
-
*/
|
|
657
|
-
ixTradePtExactOut({
|
|
658
|
-
trader,
|
|
659
|
-
amountOut,
|
|
660
|
-
swapDirection,
|
|
661
|
-
amountInConstraint,
|
|
662
|
-
tokenPt: tokenPtParam,
|
|
663
|
-
tokenSy: tokenSyParam,
|
|
664
|
-
lnImpliedApyLimit,
|
|
665
|
-
}: {
|
|
666
|
-
trader: PublicKey
|
|
667
|
-
amountOut: bigint
|
|
668
|
-
swapDirection: SwapDirection
|
|
669
|
-
amountInConstraint?: bigint
|
|
670
|
-
tokenPt?: PublicKey
|
|
671
|
-
tokenSy?: PublicKey
|
|
672
|
-
lnImpliedApyLimit?: number
|
|
673
|
-
}) {
|
|
674
|
-
const tokenPt = tokenPtParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
|
|
675
|
-
const tokenSy = tokenSyParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
|
|
676
|
-
|
|
677
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, tokenSy, trader, this.mintSy)
|
|
678
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(trader, tokenPt, trader, this.mintPt)
|
|
679
|
-
|
|
680
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
681
|
-
...this.cpiSyAccounts.getSyState,
|
|
682
|
-
...this.cpiSyAccounts.getPositionState,
|
|
683
|
-
...this.cpiSyAccounts.depositSy,
|
|
684
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
685
|
-
])
|
|
686
|
-
|
|
687
|
-
const ix = exponentClmm.createTradePtExactOutInstruction(
|
|
688
|
-
{
|
|
689
|
-
trader,
|
|
690
|
-
market: this.selfAddress,
|
|
691
|
-
ticks: this.ticksKey,
|
|
692
|
-
tokenSyTrader: tokenSy,
|
|
693
|
-
tokenPtTrader: tokenPt,
|
|
694
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
695
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
696
|
-
addressLookupTable: this.addressLookupTable,
|
|
697
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
698
|
-
syProgram: this.syProgram,
|
|
699
|
-
tokenFeeTreasurySy: this.tokenFeeTreasurySy,
|
|
700
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
701
|
-
eventAuthority: this.eventAuthority,
|
|
702
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
amountOut,
|
|
706
|
-
swapDirection,
|
|
707
|
-
amountInConstraint: amountInConstraint ?? null,
|
|
708
|
-
priceSpotLimit: lnImpliedApyLimit ?? null,
|
|
709
|
-
},
|
|
710
|
-
)
|
|
711
|
-
ix.keys.push(...remainingAccounts)
|
|
712
|
-
|
|
713
|
-
return { ixs: [ix], setupIxs: [tokenPtAtaIx, tokenSyAtaIx] }
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
/** Buy PT with SY
|
|
717
|
-
*
|
|
718
|
-
* The trader is the account that sends the SY
|
|
719
|
-
* The amountPt is the exact amount of PT the trader intends to buy
|
|
720
|
-
* The syConstraint is the maximum amount of SY the trader is willing to spend
|
|
721
|
-
*
|
|
722
|
-
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
723
|
-
*/
|
|
724
|
-
ixBuyPt({
|
|
725
|
-
trader,
|
|
726
|
-
amountSy,
|
|
727
|
-
outConstraint,
|
|
728
|
-
tokenPt,
|
|
729
|
-
tokenSy,
|
|
730
|
-
lnImpliedApyLimit,
|
|
731
|
-
}: {
|
|
732
|
-
trader: PublicKey
|
|
733
|
-
amountSy: bigint
|
|
734
|
-
outConstraint: bigint
|
|
735
|
-
tokenPt?: PublicKey
|
|
736
|
-
tokenSy?: PublicKey
|
|
737
|
-
lnImpliedApyLimit?: number
|
|
738
|
-
}) {
|
|
739
|
-
return this.ixTradePt({
|
|
740
|
-
trader,
|
|
741
|
-
traderAmount: amountSy,
|
|
742
|
-
outConstraint: outConstraint,
|
|
743
|
-
swapDirection: SwapDirection.SyToPt,
|
|
744
|
-
tokenPt,
|
|
745
|
-
tokenSy,
|
|
746
|
-
lnImpliedApyLimit,
|
|
747
|
-
})
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* Sell PT for SY
|
|
752
|
-
* The trader is the account that sends the PT
|
|
753
|
-
* The amountPt is the exact amount of PT the trader intends to sell
|
|
754
|
-
* The minSyReceive is the minimum amount of SY the trader is willing to receive
|
|
755
|
-
*
|
|
756
|
-
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
757
|
-
*/
|
|
758
|
-
ixSellPt({
|
|
759
|
-
trader,
|
|
760
|
-
amountPt,
|
|
761
|
-
outConstraint,
|
|
762
|
-
tokenPt,
|
|
763
|
-
tokenSy,
|
|
764
|
-
lnImpliedApyLimit,
|
|
765
|
-
}: {
|
|
766
|
-
trader: PublicKey
|
|
767
|
-
amountPt: bigint
|
|
768
|
-
outConstraint: bigint
|
|
769
|
-
tokenPt?: PublicKey
|
|
770
|
-
tokenSy?: PublicKey
|
|
771
|
-
lnImpliedApyLimit?: number
|
|
772
|
-
}) {
|
|
773
|
-
return this.ixTradePt({
|
|
774
|
-
trader,
|
|
775
|
-
traderAmount: amountPt,
|
|
776
|
-
outConstraint: outConstraint,
|
|
777
|
-
swapDirection: SwapDirection.PtToSy,
|
|
778
|
-
tokenPt,
|
|
779
|
-
tokenSy,
|
|
780
|
-
lnImpliedApyLimit,
|
|
781
|
-
})
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* Buy exact amount of PT with SY
|
|
786
|
-
*
|
|
787
|
-
* The trader specifies the exact amount of PT they want to receive
|
|
788
|
-
* The maxSyIn is the maximum amount of SY the trader is willing to spend
|
|
789
|
-
*/
|
|
790
|
-
ixBuyPtExactOut({
|
|
791
|
-
trader,
|
|
792
|
-
amountPt,
|
|
793
|
-
maxSyIn,
|
|
794
|
-
tokenPt,
|
|
795
|
-
tokenSy,
|
|
796
|
-
lnImpliedApyLimit,
|
|
797
|
-
}: {
|
|
798
|
-
trader: PublicKey
|
|
799
|
-
amountPt: bigint
|
|
800
|
-
maxSyIn?: bigint
|
|
801
|
-
tokenPt?: PublicKey
|
|
802
|
-
tokenSy?: PublicKey
|
|
803
|
-
lnImpliedApyLimit?: number
|
|
804
|
-
}) {
|
|
805
|
-
return this.ixTradePtExactOut({
|
|
806
|
-
trader,
|
|
807
|
-
amountOut: amountPt,
|
|
808
|
-
amountInConstraint: maxSyIn,
|
|
809
|
-
swapDirection: SwapDirection.SyToPt,
|
|
810
|
-
tokenPt,
|
|
811
|
-
tokenSy,
|
|
812
|
-
lnImpliedApyLimit,
|
|
813
|
-
})
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* Sell PT for exact amount of SY
|
|
818
|
-
*
|
|
819
|
-
* The trader specifies the exact amount of SY they want to receive
|
|
820
|
-
* The maxPtIn is the maximum amount of PT the trader is willing to spend
|
|
821
|
-
*/
|
|
822
|
-
ixSellPtExactOut({
|
|
823
|
-
trader,
|
|
824
|
-
amountSy,
|
|
825
|
-
maxPtIn,
|
|
826
|
-
tokenPt,
|
|
827
|
-
tokenSy,
|
|
828
|
-
lnImpliedApyLimit,
|
|
829
|
-
}: {
|
|
830
|
-
trader: PublicKey
|
|
831
|
-
amountSy: bigint
|
|
832
|
-
maxPtIn?: bigint
|
|
833
|
-
tokenPt?: PublicKey
|
|
834
|
-
tokenSy?: PublicKey
|
|
835
|
-
lnImpliedApyLimit?: number
|
|
836
|
-
}) {
|
|
837
|
-
return this.ixTradePtExactOut({
|
|
838
|
-
trader,
|
|
839
|
-
amountOut: amountSy,
|
|
840
|
-
amountInConstraint: maxPtIn,
|
|
841
|
-
swapDirection: SwapDirection.PtToSy,
|
|
842
|
-
tokenPt,
|
|
843
|
-
tokenSy,
|
|
844
|
-
lnImpliedApyLimit,
|
|
845
|
-
})
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
/** Buy YT with SY
|
|
849
|
-
*
|
|
850
|
-
* The trader is the account that sends the SY
|
|
851
|
-
*
|
|
852
|
-
* The ytOut is the exact amount of YT the trader intends to buy
|
|
853
|
-
*
|
|
854
|
-
* The maxSyIn is the maximum amount of SY the trader is willing to spend
|
|
855
|
-
*
|
|
856
|
-
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
857
|
-
*/
|
|
858
|
-
ixBuyYt({
|
|
859
|
-
trader,
|
|
860
|
-
payer,
|
|
861
|
-
ytOut,
|
|
862
|
-
maxSyIn,
|
|
863
|
-
ytTrader: ytTraderParam,
|
|
864
|
-
ptTrader: ptTraderParam,
|
|
865
|
-
syTrader: syTraderParam,
|
|
866
|
-
lnImpliedApyLimit,
|
|
867
|
-
}: {
|
|
868
|
-
trader: PublicKey
|
|
869
|
-
/** Payer for ATA creation instructions. Defaults to trader. */
|
|
870
|
-
payer?: PublicKey
|
|
871
|
-
ytOut: bigint
|
|
872
|
-
maxSyIn: bigint
|
|
873
|
-
ytTrader?: PublicKey
|
|
874
|
-
ptTrader?: PublicKey
|
|
875
|
-
syTrader?: PublicKey
|
|
876
|
-
lnImpliedApyLimit?: number
|
|
877
|
-
}) {
|
|
878
|
-
const ataPayer = payer ?? trader
|
|
879
|
-
const syTrader = syTraderParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
|
|
880
|
-
const ptTrader = ptTraderParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
|
|
881
|
-
const ytTrader = ytTraderParam || getAssociatedTokenAddressSync(this.mintYt, trader, true, TOKEN_PROGRAM_ID)
|
|
882
|
-
|
|
883
|
-
const syTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(ataPayer, syTrader, trader, this.mintSy)
|
|
884
|
-
const ptTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(ataPayer, ptTrader, trader, this.mintPt)
|
|
885
|
-
const ytTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(ataPayer, ytTrader, trader, this.mintYt)
|
|
886
|
-
|
|
887
|
-
const stripAccounts = this.cpiCoreAccounts.stripSy
|
|
888
|
-
|
|
889
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
890
|
-
...this.cpiSyAccounts.getSyState,
|
|
891
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
892
|
-
...this.cpiSyAccounts.depositSy,
|
|
893
|
-
...stripAccounts,
|
|
894
|
-
])
|
|
895
|
-
|
|
896
|
-
const ix = exponentClmm.createBuyYtInstruction(
|
|
897
|
-
{
|
|
898
|
-
trader,
|
|
899
|
-
market: this.selfAddress,
|
|
900
|
-
ticks: this.ticksKey,
|
|
901
|
-
tokenSyTrader: syTrader,
|
|
902
|
-
tokenYtTrader: ytTrader,
|
|
903
|
-
tokenPtTrader: ptTrader,
|
|
904
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
905
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
906
|
-
tokenYtEscrow: this.tokenYtEscrow,
|
|
907
|
-
tokenFeeTreasurySy: this.tokenFeeTreasurySy,
|
|
908
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
909
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
910
|
-
addressLookupTable: this.addressLookupTable,
|
|
911
|
-
syProgram: this.syProgram,
|
|
912
|
-
exponentCoreProgram: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
913
|
-
eventAuthority: this.eventAuthority,
|
|
914
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
915
|
-
},
|
|
916
|
-
{
|
|
917
|
-
syIn: maxSyIn,
|
|
918
|
-
minYtOut: ytOut,
|
|
919
|
-
priceSpotLimit: lnImpliedApyLimit ?? null,
|
|
920
|
-
},
|
|
921
|
-
)
|
|
922
|
-
ix.keys.push(...remainingAccounts)
|
|
923
|
-
|
|
924
|
-
return { ixs: [ix], setupIxs: [syTraderAtaIx, ptTraderAtaIx, ytTraderAtaIx] }
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
/** Sell YT for SY
|
|
928
|
-
*
|
|
929
|
-
* The trader is the account that sends the YT
|
|
930
|
-
*
|
|
931
|
-
* The amountYt is the exact amount of YT the trader intends to sell
|
|
932
|
-
*
|
|
933
|
-
* The minSyOut is the minimum amount of SY the trader is willing to receive
|
|
934
|
-
*
|
|
935
|
-
* The token accounts themselves are optional, and will be derived from the trader's wallet if not provided
|
|
936
|
-
*/
|
|
937
|
-
ixSellYt({
|
|
938
|
-
trader,
|
|
939
|
-
payer,
|
|
940
|
-
ytIn,
|
|
941
|
-
minSyOut,
|
|
942
|
-
ytSrc: ytSrcParam,
|
|
943
|
-
ptSrc: ptSrcParam,
|
|
944
|
-
syDst: syDstParam,
|
|
945
|
-
lnImpliedApyLimit,
|
|
946
|
-
}: {
|
|
947
|
-
trader: PublicKey
|
|
948
|
-
/** Payer for ATA creation instructions. Defaults to trader. */
|
|
949
|
-
payer?: PublicKey
|
|
950
|
-
ytIn: bigint
|
|
951
|
-
minSyOut: bigint
|
|
952
|
-
ytSrc?: PublicKey
|
|
953
|
-
ptSrc?: PublicKey
|
|
954
|
-
syDst?: PublicKey
|
|
955
|
-
lnImpliedApyLimit?: number
|
|
956
|
-
}) {
|
|
957
|
-
const ataPayer = payer ?? trader
|
|
958
|
-
const syDst = syDstParam || getAssociatedTokenAddressSync(this.mintSy, trader, true, TOKEN_PROGRAM_ID)
|
|
959
|
-
const ptSrc = ptSrcParam || getAssociatedTokenAddressSync(this.mintPt, trader, true, TOKEN_PROGRAM_ID)
|
|
960
|
-
const ytSrc = ytSrcParam || getAssociatedTokenAddressSync(this.mintYt, trader, true, TOKEN_PROGRAM_ID)
|
|
961
|
-
|
|
962
|
-
const syDstAtaIxs = createAssociatedTokenAccountIdempotentInstruction(ataPayer, syDst, trader, this.mintSy)
|
|
963
|
-
const ptSrcAtaIxs = createAssociatedTokenAccountIdempotentInstruction(ataPayer, ptSrc, trader, this.mintPt)
|
|
964
|
-
const ytSrcAtaIxs = createAssociatedTokenAccountIdempotentInstruction(ataPayer, ytSrc, trader, this.mintYt)
|
|
965
|
-
|
|
966
|
-
const mergeAccounts = this.cpiCoreAccounts.mergeSy
|
|
967
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
968
|
-
...this.cpiSyAccounts.getSyState,
|
|
969
|
-
...this.cpiSyAccounts.getPositionState,
|
|
970
|
-
...this.cpiSyAccounts.depositSy,
|
|
971
|
-
...mergeAccounts,
|
|
972
|
-
])
|
|
973
|
-
|
|
974
|
-
const ix = exponentClmm.createSellYtInstruction(
|
|
975
|
-
{
|
|
976
|
-
trader,
|
|
977
|
-
market: this.selfAddress,
|
|
978
|
-
ticks: this.ticksKey,
|
|
979
|
-
tokenYtTrader: ytSrc,
|
|
980
|
-
tokenPtTrader: ptSrc,
|
|
981
|
-
tokenSyTrader: syDst,
|
|
982
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
983
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
984
|
-
tokenYtEscrow: this.tokenYtEscrow,
|
|
985
|
-
addressLookupTable: this.addressLookupTable,
|
|
986
|
-
tokenFeeTreasurySy: this.tokenFeeTreasurySy,
|
|
987
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
988
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
989
|
-
syProgram: this.syProgram,
|
|
990
|
-
exponentCoreProgram: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
991
|
-
eventAuthority: this.eventAuthority,
|
|
992
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
ytIn,
|
|
996
|
-
minSyOut,
|
|
997
|
-
priceSpotLimit: lnImpliedApyLimit ?? null,
|
|
998
|
-
},
|
|
999
|
-
)
|
|
1000
|
-
ix.keys.push(...remainingAccounts)
|
|
1001
|
-
|
|
1002
|
-
return { ixs: [ix], setupIxs: [syDstAtaIxs, ptSrcAtaIxs, ytSrcAtaIxs] }
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
/** Apply an admin action to the market (e.g. change status, fees, tick spacing). */
|
|
1006
|
-
ixModifyMarketSetting({ signer, adminAction }: { signer: PublicKey; adminAction: MarketAdminAction }) {
|
|
1007
|
-
return exponentClmm.createModifyMarketSettingInstruction(
|
|
1008
|
-
{
|
|
1009
|
-
market: this.selfAddress,
|
|
1010
|
-
signer,
|
|
1011
|
-
systemProgram: SystemProgram.programId,
|
|
1012
|
-
},
|
|
1013
|
-
{ action: adminAction },
|
|
1014
|
-
)
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
/**
|
|
1018
|
-
* Add a new farm to the market to distribute rewards to LP holders
|
|
1019
|
-
*
|
|
1020
|
-
* @param signer - The admin address that signs the transaction
|
|
1021
|
-
* @param farmMint - The mint address of the farm reward token
|
|
1022
|
-
* @param farmTokenProgram - The token program for the farm reward token
|
|
1023
|
-
* @param emissionsRate - The rate of emissions per second (in token smallest units)
|
|
1024
|
-
* @param untilTimestamp - Unix timestamp when the farm emissions should end
|
|
1025
|
-
* @param farmTokenSrc - Optional source token account for the farm rewards (derived from signer if not provided)
|
|
1026
|
-
* @param feePayer - Optional fee payer for account reallocation (defaults to signer)
|
|
1027
|
-
*/
|
|
1028
|
-
ixAddFarm({
|
|
1029
|
-
signer,
|
|
1030
|
-
farmMint,
|
|
1031
|
-
farmTokenProgram,
|
|
1032
|
-
emissionsRate,
|
|
1033
|
-
untilTimestamp,
|
|
1034
|
-
farmTokenSrc: farmTokenSrcParam,
|
|
1035
|
-
feePayer: feePayerParam,
|
|
1036
|
-
}: {
|
|
1037
|
-
signer: PublicKey
|
|
1038
|
-
farmMint: PublicKey
|
|
1039
|
-
farmTokenProgram: PublicKey
|
|
1040
|
-
emissionsRate: bigint
|
|
1041
|
-
untilTimestamp: number
|
|
1042
|
-
farmTokenSrc?: PublicKey
|
|
1043
|
-
feePayer?: PublicKey
|
|
1044
|
-
}) {
|
|
1045
|
-
const feePayer = feePayerParam || signer
|
|
1046
|
-
const farmTokenEscrow = getAssociatedTokenAddressSync(farmMint, this.selfAddress, true, farmTokenProgram)
|
|
1047
|
-
const farmTokenSrc = farmTokenSrcParam || getAssociatedTokenAddressSync(farmMint, signer, true, farmTokenProgram)
|
|
1048
|
-
|
|
1049
|
-
const farmTokenEscrowAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1050
|
-
feePayer,
|
|
1051
|
-
farmTokenEscrow,
|
|
1052
|
-
this.selfAddress,
|
|
1053
|
-
farmMint,
|
|
1054
|
-
farmTokenProgram,
|
|
1055
|
-
)
|
|
1056
|
-
|
|
1057
|
-
const ix = exponentClmm.createAddFarmInstruction(
|
|
1058
|
-
{
|
|
1059
|
-
market: this.selfAddress,
|
|
1060
|
-
ticks: this.ticksKey,
|
|
1061
|
-
signer,
|
|
1062
|
-
feePayer,
|
|
1063
|
-
mintNew: farmMint,
|
|
1064
|
-
tokenSource: farmTokenSrc,
|
|
1065
|
-
tokenFarm: farmTokenEscrow,
|
|
1066
|
-
tokenProgram: farmTokenProgram,
|
|
1067
|
-
systemProgram: SystemProgram.programId,
|
|
1068
|
-
eventAuthority: this.eventAuthority,
|
|
1069
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1070
|
-
},
|
|
1071
|
-
{
|
|
1072
|
-
tokenRate: emissionsRate,
|
|
1073
|
-
untilTimestamp,
|
|
1074
|
-
},
|
|
1075
|
-
)
|
|
1076
|
-
|
|
1077
|
-
return {
|
|
1078
|
-
ixs: [ix],
|
|
1079
|
-
setupIxs: [farmTokenEscrowAtaIx],
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* Modify an existing farm's emissions rate and/or expiration timestamp
|
|
1085
|
-
*
|
|
1086
|
-
* If the new parameters require more tokens than previously undistributed,
|
|
1087
|
-
* additional tokens will be transferred from the signer's token account.
|
|
1088
|
-
* If fewer tokens are needed, the surplus will be returned to the signer.
|
|
1089
|
-
*
|
|
1090
|
-
* @param signer - The admin address that signs the transaction
|
|
1091
|
-
* @param farmMint - The mint address of the farm reward token
|
|
1092
|
-
* @param farmTokenProgram - The token program for the farm reward token
|
|
1093
|
-
* @param newRate - The new rate of emissions per second (in token smallest units)
|
|
1094
|
-
* @param untilTimestamp - New unix timestamp when the farm emissions should end
|
|
1095
|
-
* @param farmTokenSrc - Optional source/destination token account (derived from signer if not provided)
|
|
1096
|
-
*/
|
|
1097
|
-
ixModifyFarm({
|
|
1098
|
-
signer,
|
|
1099
|
-
farmMint,
|
|
1100
|
-
farmTokenProgram,
|
|
1101
|
-
newRate,
|
|
1102
|
-
untilTimestamp,
|
|
1103
|
-
farmTokenSrc: farmTokenSrcParam,
|
|
1104
|
-
}: {
|
|
1105
|
-
signer: PublicKey
|
|
1106
|
-
farmMint: PublicKey
|
|
1107
|
-
farmTokenProgram: PublicKey
|
|
1108
|
-
newRate: bigint
|
|
1109
|
-
untilTimestamp: number
|
|
1110
|
-
farmTokenSrc?: PublicKey
|
|
1111
|
-
}) {
|
|
1112
|
-
const farmTokenEscrow = getAssociatedTokenAddressSync(farmMint, this.selfAddress, true, farmTokenProgram)
|
|
1113
|
-
const farmTokenSrc = farmTokenSrcParam || getAssociatedTokenAddressSync(farmMint, signer, true, farmTokenProgram)
|
|
1114
|
-
|
|
1115
|
-
const ix = exponentClmm.createModifyFarmInstruction(
|
|
1116
|
-
{
|
|
1117
|
-
market: this.selfAddress,
|
|
1118
|
-
ticks: this.ticksKey,
|
|
1119
|
-
signer,
|
|
1120
|
-
mint: farmMint,
|
|
1121
|
-
tokenSource: farmTokenSrc,
|
|
1122
|
-
tokenFarm: farmTokenEscrow,
|
|
1123
|
-
tokenProgram: farmTokenProgram,
|
|
1124
|
-
eventAuthority: this.eventAuthority,
|
|
1125
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1126
|
-
},
|
|
1127
|
-
{
|
|
1128
|
-
newExpirationTimestamp: untilTimestamp,
|
|
1129
|
-
newRate,
|
|
1130
|
-
},
|
|
1131
|
-
)
|
|
1132
|
-
|
|
1133
|
-
return {
|
|
1134
|
-
ixs: [ix],
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
/**
|
|
1139
|
-
* Buy PT directly from the base asset (e.g. SOL, USDC).
|
|
1140
|
-
*
|
|
1141
|
-
* Wraps a mint-SY step (via the flavor) with a buy-PT swap in a single instruction.
|
|
1142
|
-
* The program mints SY from the base asset, then swaps SY -> PT on the CLMM.
|
|
1143
|
-
*
|
|
1144
|
-
* @param owner - Wallet signing the transaction
|
|
1145
|
-
* @param baseIn - Amount of base asset to spend
|
|
1146
|
-
* @param minPtOut - Minimum PT to receive (slippage protection)
|
|
1147
|
-
* @param lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
1148
|
-
*/
|
|
1149
|
-
async ixWrapperBuyPt({
|
|
1150
|
-
owner,
|
|
1151
|
-
minPtOut,
|
|
1152
|
-
baseIn,
|
|
1153
|
-
tokenSyTrader: tokenSyTraderParam,
|
|
1154
|
-
tokenPtTrader: tokenPtTraderParam,
|
|
1155
|
-
tokenBaseTrader: tokenBaseTraderParam,
|
|
1156
|
-
lnImpliedApyLimit,
|
|
1157
|
-
}: {
|
|
1158
|
-
owner: PublicKey
|
|
1159
|
-
minPtOut: bigint
|
|
1160
|
-
baseIn: bigint
|
|
1161
|
-
tokenSyTrader?: PublicKey
|
|
1162
|
-
tokenPtTrader?: PublicKey
|
|
1163
|
-
tokenBaseTrader?: PublicKey
|
|
1164
|
-
lnImpliedApyLimit?: number
|
|
1165
|
-
}) {
|
|
1166
|
-
const tokenSyTrader =
|
|
1167
|
-
tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
1168
|
-
const tokenPtTrader =
|
|
1169
|
-
tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
1170
|
-
const tokenBaseTrader =
|
|
1171
|
-
tokenBaseTraderParam ||
|
|
1172
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
1173
|
-
|
|
1174
|
-
const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1175
|
-
owner,
|
|
1176
|
-
tokenSyTrader,
|
|
1177
|
-
owner,
|
|
1178
|
-
this.mintSy,
|
|
1179
|
-
)
|
|
1180
|
-
const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1181
|
-
owner,
|
|
1182
|
-
tokenPtTrader,
|
|
1183
|
-
owner,
|
|
1184
|
-
this.mintPt,
|
|
1185
|
-
)
|
|
1186
|
-
const tokenBaseTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1187
|
-
owner,
|
|
1188
|
-
tokenBaseTrader,
|
|
1189
|
-
owner,
|
|
1190
|
-
this.flavor.mintBase,
|
|
1191
|
-
)
|
|
1192
|
-
|
|
1193
|
-
const mintSyIx = await this.flavor.ixMintSy({
|
|
1194
|
-
amountBase: "0",
|
|
1195
|
-
depositor: owner,
|
|
1196
|
-
depositorBaseTokenAccount: tokenBaseTrader,
|
|
1197
|
-
depositorSyTokenAccount: tokenSyTrader,
|
|
1198
|
-
})
|
|
1199
|
-
|
|
1200
|
-
const mintSyRemAccounts = mintSyIx.keys
|
|
1201
|
-
|
|
1202
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
1203
|
-
...this.cpiSyAccounts.getSyState,
|
|
1204
|
-
...this.cpiSyAccounts.depositSy,
|
|
1205
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1206
|
-
])
|
|
1207
|
-
|
|
1208
|
-
const ix = exponentClmm.createBuyPtInstruction(
|
|
1209
|
-
{
|
|
1210
|
-
buyer: owner,
|
|
1211
|
-
market: this.selfAddress,
|
|
1212
|
-
tokenSyTrader,
|
|
1213
|
-
tokenPtTrader,
|
|
1214
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1215
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1216
|
-
addressLookupTable: this.addressLookupTable,
|
|
1217
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1218
|
-
syProgram: this.syProgram,
|
|
1219
|
-
ticks: this.ticksKey,
|
|
1220
|
-
tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
|
|
1221
|
-
tokenFeeTreasuryPt: this.state.tokenFeeTreasuryPt,
|
|
1222
|
-
eventAuthority: this.eventAuthority,
|
|
1223
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1224
|
-
},
|
|
1225
|
-
{
|
|
1226
|
-
minPtAmount: minPtOut,
|
|
1227
|
-
baseAmount: baseIn,
|
|
1228
|
-
priceSpotLimit: lnImpliedApyLimit ?? null,
|
|
1229
|
-
mintSyRemAccountsUntil: mintSyRemAccounts.length,
|
|
1230
|
-
},
|
|
1231
|
-
)
|
|
1232
|
-
ix.keys.push(...mintSyRemAccounts, ...remainingAccounts)
|
|
1233
|
-
|
|
1234
|
-
return {
|
|
1235
|
-
ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
|
|
1236
|
-
setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenBaseTraderAtaIx],
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* Sell PT and receive the base asset (e.g. SOL, USDC).
|
|
1242
|
-
*
|
|
1243
|
-
* Wraps a PT -> SY swap with a redeem-SY step (via the flavor) in a single instruction.
|
|
1244
|
-
* The program swaps PT -> SY on the CLMM, then redeems SY for the base asset.
|
|
1245
|
-
*
|
|
1246
|
-
* @param owner - Wallet signing the transaction
|
|
1247
|
-
* @param amount - Amount of PT to sell
|
|
1248
|
-
* @param minBaseOut - Minimum base asset to receive (slippage protection)
|
|
1249
|
-
* @param lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
1250
|
-
*/
|
|
1251
|
-
async ixWrapperSellPt({
|
|
1252
|
-
owner,
|
|
1253
|
-
amount,
|
|
1254
|
-
minBaseOut,
|
|
1255
|
-
tokenSyTrader: tokenSyTraderParam,
|
|
1256
|
-
tokenPtTrader: tokenPtTraderParam,
|
|
1257
|
-
tokenBaseTrader: tokenBaseTraderParam,
|
|
1258
|
-
lnImpliedApyLimit,
|
|
1259
|
-
}: {
|
|
1260
|
-
owner: PublicKey
|
|
1261
|
-
amount: bigint
|
|
1262
|
-
minBaseOut: bigint
|
|
1263
|
-
tokenSyTrader?: PublicKey
|
|
1264
|
-
tokenPtTrader?: PublicKey
|
|
1265
|
-
tokenBaseTrader?: PublicKey
|
|
1266
|
-
lnImpliedApyLimit?: number
|
|
1267
|
-
}) {
|
|
1268
|
-
const tokenSyTrader =
|
|
1269
|
-
tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
1270
|
-
const tokenPtTrader =
|
|
1271
|
-
tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
1272
|
-
const tokenBaseTrader =
|
|
1273
|
-
tokenBaseTraderParam ||
|
|
1274
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
1275
|
-
|
|
1276
|
-
const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1277
|
-
owner,
|
|
1278
|
-
tokenSyTrader,
|
|
1279
|
-
owner,
|
|
1280
|
-
this.mintSy,
|
|
1281
|
-
)
|
|
1282
|
-
const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1283
|
-
owner,
|
|
1284
|
-
tokenPtTrader,
|
|
1285
|
-
owner,
|
|
1286
|
-
this.mintPt,
|
|
1287
|
-
)
|
|
1288
|
-
const tokenBaseTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1289
|
-
owner,
|
|
1290
|
-
tokenBaseTrader,
|
|
1291
|
-
owner,
|
|
1292
|
-
this.flavor.mintBase,
|
|
1293
|
-
)
|
|
1294
|
-
|
|
1295
|
-
const redeemSyIx = await this.flavor.ixRedeemSy({
|
|
1296
|
-
amountSy: "0",
|
|
1297
|
-
redeemer: owner,
|
|
1298
|
-
redeemerBaseTokenAccount: tokenBaseTrader,
|
|
1299
|
-
redeemerSyTokenAccount: tokenSyTrader,
|
|
1300
|
-
})
|
|
1301
|
-
|
|
1302
|
-
const redeemSyRemAccounts = redeemSyIx.keys
|
|
1303
|
-
|
|
1304
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
1305
|
-
...this.cpiSyAccounts.getSyState,
|
|
1306
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1307
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
1308
|
-
])
|
|
1309
|
-
|
|
1310
|
-
const ix = exponentClmm.createSellPtInstruction(
|
|
1311
|
-
{
|
|
1312
|
-
seller: owner,
|
|
1313
|
-
market: this.selfAddress,
|
|
1314
|
-
tokenSyTrader,
|
|
1315
|
-
tokenPtTrader,
|
|
1316
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1317
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1318
|
-
addressLookupTable: this.addressLookupTable,
|
|
1319
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1320
|
-
syProgram: this.syProgram,
|
|
1321
|
-
tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
|
|
1322
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
1323
|
-
ticks: this.ticksKey,
|
|
1324
|
-
eventAuthority: this.eventAuthority,
|
|
1325
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1326
|
-
},
|
|
1327
|
-
{
|
|
1328
|
-
amountPt: amount,
|
|
1329
|
-
minBaseAmount: minBaseOut,
|
|
1330
|
-
priceSpotLimit: lnImpliedApyLimit ?? null,
|
|
1331
|
-
redeemSyRemAccountsUntil: redeemSyRemAccounts.length,
|
|
1332
|
-
},
|
|
1333
|
-
)
|
|
1334
|
-
ix.keys.push(...redeemSyRemAccounts, ...remainingAccounts)
|
|
1335
|
-
|
|
1336
|
-
return {
|
|
1337
|
-
ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
|
|
1338
|
-
setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenBaseTraderAtaIx],
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
/**
|
|
1343
|
-
* Buy YT directly from the base asset.
|
|
1344
|
-
*
|
|
1345
|
-
* Wraps a mint-SY step with a buy-YT swap. The program mints SY from the base asset,
|
|
1346
|
-
* then strips SY into PT+YT and executes the trade.
|
|
1347
|
-
*
|
|
1348
|
-
* @param owner - Wallet signing the transaction
|
|
1349
|
-
* @param ytOut - Amount of YT to buy
|
|
1350
|
-
* @param maxBaseIn - Maximum base asset to spend (slippage protection)
|
|
1351
|
-
*/
|
|
1352
|
-
async ixWrapperBuyYt({
|
|
1353
|
-
owner,
|
|
1354
|
-
ytOut,
|
|
1355
|
-
maxBaseIn,
|
|
1356
|
-
tokenSyTrader: tokenSyTraderParam,
|
|
1357
|
-
tokenPtTrader: tokenPtTraderParam,
|
|
1358
|
-
tokenYtTrader: tokenYtTraderParam,
|
|
1359
|
-
tokenBaseTrader: tokenBaseTraderParam,
|
|
1360
|
-
}: {
|
|
1361
|
-
owner: PublicKey
|
|
1362
|
-
ytOut: bigint
|
|
1363
|
-
maxBaseIn: bigint
|
|
1364
|
-
tokenSyTrader?: PublicKey
|
|
1365
|
-
tokenPtTrader?: PublicKey
|
|
1366
|
-
tokenYtTrader?: PublicKey
|
|
1367
|
-
tokenBaseTrader?: PublicKey
|
|
1368
|
-
}) {
|
|
1369
|
-
const tokenSyTrader =
|
|
1370
|
-
tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
1371
|
-
const tokenPtTrader =
|
|
1372
|
-
tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
1373
|
-
const tokenYtTrader =
|
|
1374
|
-
tokenYtTraderParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
1375
|
-
const tokenBaseTrader =
|
|
1376
|
-
tokenBaseTraderParam ||
|
|
1377
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
1378
|
-
|
|
1379
|
-
const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1380
|
-
owner,
|
|
1381
|
-
tokenSyTrader,
|
|
1382
|
-
owner,
|
|
1383
|
-
this.mintSy,
|
|
1384
|
-
)
|
|
1385
|
-
const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1386
|
-
owner,
|
|
1387
|
-
tokenPtTrader,
|
|
1388
|
-
owner,
|
|
1389
|
-
this.mintPt,
|
|
1390
|
-
)
|
|
1391
|
-
const tokenYtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1392
|
-
owner,
|
|
1393
|
-
tokenYtTrader,
|
|
1394
|
-
owner,
|
|
1395
|
-
this.mintYt,
|
|
1396
|
-
)
|
|
1397
|
-
|
|
1398
|
-
const mintSyIx = await this.flavor.ixMintSy({
|
|
1399
|
-
amountBase: "0",
|
|
1400
|
-
depositor: owner,
|
|
1401
|
-
depositorBaseTokenAccount: tokenBaseTrader,
|
|
1402
|
-
depositorSyTokenAccount: tokenSyTrader,
|
|
1403
|
-
})
|
|
1404
|
-
|
|
1405
|
-
const depositYtAccounts = this.depositYtAccounts({
|
|
1406
|
-
owner,
|
|
1407
|
-
ytSrc: tokenYtTrader,
|
|
1408
|
-
})
|
|
1409
|
-
|
|
1410
|
-
const mintSyRemAccounts = mintSyIx.keys
|
|
1411
|
-
|
|
1412
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
1413
|
-
...this.cpiSyAccounts.getSyState,
|
|
1414
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1415
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
1416
|
-
...this.cpiCoreAccounts.stripSy,
|
|
1417
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1418
|
-
])
|
|
1419
|
-
|
|
1420
|
-
const depositYtAccounts_until = mintSyRemAccounts.length + depositYtAccounts.keys.length
|
|
1421
|
-
const allRemainingAccounts = mintSyRemAccounts.concat(depositYtAccounts.keys).concat(remainingAccounts)
|
|
1422
|
-
|
|
1423
|
-
const ix1 = exponentClmm.createWrapperBuyYtInstruction(
|
|
1424
|
-
{
|
|
1425
|
-
buyer: owner,
|
|
1426
|
-
market: this.selfAddress,
|
|
1427
|
-
tokenSyTrader,
|
|
1428
|
-
tokenYtTrader,
|
|
1429
|
-
tokenPtTrader,
|
|
1430
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1431
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1432
|
-
tokenYtEscrow: this.tokenYtEscrow,
|
|
1433
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
1434
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1435
|
-
syProgram: this.syProgram,
|
|
1436
|
-
systemProgram: SystemProgram.programId,
|
|
1437
|
-
tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
|
|
1438
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
1439
|
-
ticks: this.ticksKey,
|
|
1440
|
-
exponentCoreProgram: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
1441
|
-
eventAuthority: this.eventAuthority,
|
|
1442
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1443
|
-
},
|
|
1444
|
-
{
|
|
1445
|
-
ytOut,
|
|
1446
|
-
maxBaseAmount: maxBaseIn,
|
|
1447
|
-
mintSyAccountsLength: mintSyRemAccounts.length,
|
|
1448
|
-
depositYtAccountsUntil: depositYtAccounts_until,
|
|
1449
|
-
},
|
|
1450
|
-
)
|
|
1451
|
-
ix1.keys.push(...allRemainingAccounts)
|
|
1452
|
-
|
|
1453
|
-
return {
|
|
1454
|
-
ixs: [...(await this.flavor.preIxs({ signer: owner })), ix1],
|
|
1455
|
-
setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenYtTraderAtaIx],
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
/**
|
|
1460
|
-
* Sell YT and receive the base asset.
|
|
1461
|
-
*
|
|
1462
|
-
* Wraps a YT -> SY swap with a redeem-SY step. The program merges YT+PT back into SY,
|
|
1463
|
-
* executes the trade, then redeems SY for the base asset.
|
|
1464
|
-
*
|
|
1465
|
-
* @param owner - Wallet signing the transaction
|
|
1466
|
-
* @param amount - Amount of YT to sell
|
|
1467
|
-
* @param minBaseOut - Minimum base asset to receive (slippage protection)
|
|
1468
|
-
*/
|
|
1469
|
-
async ixWrapperSellYt({
|
|
1470
|
-
owner,
|
|
1471
|
-
amount,
|
|
1472
|
-
minBaseOut,
|
|
1473
|
-
tokenBaseTrader: tokenBaseTraderParam,
|
|
1474
|
-
tokenSyTrader: tokenSyTraderParam,
|
|
1475
|
-
tokenYtTrader: tokenYtTraderParam,
|
|
1476
|
-
tokenPtTrader: tokenPtTraderParam,
|
|
1477
|
-
}: {
|
|
1478
|
-
owner: PublicKey
|
|
1479
|
-
amount: bigint
|
|
1480
|
-
minBaseOut: bigint
|
|
1481
|
-
tokenBaseTrader?: PublicKey
|
|
1482
|
-
tokenSyTrader?: PublicKey
|
|
1483
|
-
tokenYtTrader?: PublicKey
|
|
1484
|
-
tokenPtTrader?: PublicKey
|
|
1485
|
-
}) {
|
|
1486
|
-
const tokenBaseTrader =
|
|
1487
|
-
tokenBaseTraderParam ||
|
|
1488
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
1489
|
-
const tokenSyTrader =
|
|
1490
|
-
tokenSyTraderParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
1491
|
-
const tokenYtTrader =
|
|
1492
|
-
tokenYtTraderParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
1493
|
-
const tokenPtTrader =
|
|
1494
|
-
tokenPtTraderParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
1495
|
-
|
|
1496
|
-
const tokenSyTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1497
|
-
owner,
|
|
1498
|
-
tokenSyTrader,
|
|
1499
|
-
owner,
|
|
1500
|
-
this.mintSy,
|
|
1501
|
-
)
|
|
1502
|
-
const tokenPtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1503
|
-
owner,
|
|
1504
|
-
tokenPtTrader,
|
|
1505
|
-
owner,
|
|
1506
|
-
this.mintPt,
|
|
1507
|
-
)
|
|
1508
|
-
const tokenYtTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1509
|
-
owner,
|
|
1510
|
-
tokenYtTrader,
|
|
1511
|
-
owner,
|
|
1512
|
-
this.mintYt,
|
|
1513
|
-
)
|
|
1514
|
-
const tokenBaseTraderAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1515
|
-
owner,
|
|
1516
|
-
tokenBaseTrader,
|
|
1517
|
-
owner,
|
|
1518
|
-
this.flavor.mintBase,
|
|
1519
|
-
)
|
|
1520
|
-
|
|
1521
|
-
const redeemSyIx = await this.flavor.ixRedeemSy({
|
|
1522
|
-
amountSy: "0",
|
|
1523
|
-
redeemer: owner,
|
|
1524
|
-
redeemerBaseTokenAccount: tokenBaseTrader,
|
|
1525
|
-
redeemerSyTokenAccount: tokenSyTrader,
|
|
1526
|
-
})
|
|
1527
|
-
|
|
1528
|
-
const redeemSyRemAccounts = redeemSyIx.keys
|
|
1529
|
-
|
|
1530
|
-
const withdrawYtAccounts = this.withdrawYtAccounts({
|
|
1531
|
-
owner,
|
|
1532
|
-
ytDst: tokenYtTrader,
|
|
1533
|
-
})
|
|
1534
|
-
|
|
1535
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
1536
|
-
...this.cpiSyAccounts.getSyState,
|
|
1537
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1538
|
-
...this.cpiCoreAccounts.mergeSy,
|
|
1539
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
1540
|
-
...this.cpiSyAccounts.depositSy,
|
|
1541
|
-
])
|
|
1542
|
-
|
|
1543
|
-
const withdrawYtAccountsUntil = redeemSyRemAccounts.length + withdrawYtAccounts.keys.length
|
|
1544
|
-
|
|
1545
|
-
const ix1 = exponentClmm.createWrapperSellYtInstruction(
|
|
1546
|
-
{
|
|
1547
|
-
seller: owner,
|
|
1548
|
-
market: this.selfAddress,
|
|
1549
|
-
tokenSyTrader,
|
|
1550
|
-
tokenYtTrader,
|
|
1551
|
-
tokenPtTrader,
|
|
1552
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1553
|
-
tokenYtEscrow: this.tokenYtEscrow,
|
|
1554
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1555
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
1556
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1557
|
-
syProgram: this.syProgram,
|
|
1558
|
-
tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
|
|
1559
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
1560
|
-
ticks: this.ticksKey,
|
|
1561
|
-
exponentCoreProgram: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
1562
|
-
eventAuthority: this.eventAuthority,
|
|
1563
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1564
|
-
},
|
|
1565
|
-
{
|
|
1566
|
-
ytAmount: amount,
|
|
1567
|
-
minBaseAmount: minBaseOut,
|
|
1568
|
-
redeemSyAccountsUntil: redeemSyRemAccounts.length,
|
|
1569
|
-
withdrawYtAccountsUntil,
|
|
1570
|
-
},
|
|
1571
|
-
)
|
|
1572
|
-
ix1.keys.push(...redeemSyRemAccounts, ...withdrawYtAccounts.keys, ...remainingAccounts)
|
|
1573
|
-
|
|
1574
|
-
return {
|
|
1575
|
-
ixs: [ix1, ...(await this.flavor.preIxs({ signer: owner }))],
|
|
1576
|
-
setupIxs: [tokenSyTraderAtaIx, tokenPtTraderAtaIx, tokenYtTraderAtaIx, tokenBaseTraderAtaIx],
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
/**
|
|
1581
|
-
* Provide concentrated liquidity from the base asset, receiving LP and YT tokens.
|
|
1582
|
-
*
|
|
1583
|
-
* Wraps a mint-SY step with a deposit-liquidity operation. The program mints SY from the
|
|
1584
|
-
* base asset, strips some into PT, deposits PT+SY as liquidity in the specified tick range,
|
|
1585
|
-
* and returns the leftover YT to the depositor.
|
|
1586
|
-
*
|
|
1587
|
-
* @param depositor - Wallet signing the transaction
|
|
1588
|
-
* @param amountBase - Amount of base asset to deposit
|
|
1589
|
-
* @param minLpOut - Minimum LP tokens to receive (slippage protection)
|
|
1590
|
-
* @param lowerTickApy - Lower APY bound for the liquidity range
|
|
1591
|
-
* @param upperTickApy - Upper APY bound for the liquidity range
|
|
1592
|
-
* @param lpPosition - Optional existing LP position keypair/address (new one generated if omitted)
|
|
1593
|
-
*/
|
|
1594
|
-
async ixWrapperProvideLiquidity({
|
|
1595
|
-
depositor,
|
|
1596
|
-
amountBase,
|
|
1597
|
-
minLpOut,
|
|
1598
|
-
lowerTickApy,
|
|
1599
|
-
upperTickApy,
|
|
1600
|
-
tokenSyDepositor: tokenSyDepositorParam,
|
|
1601
|
-
tokenYtDepositor: tokenYtDepositorParam,
|
|
1602
|
-
tokenPtDepositor: tokenPtDepositorParam,
|
|
1603
|
-
tokenBaseDepositor: tokenBaseDepositorParam,
|
|
1604
|
-
lpPosition: lpPositionParam,
|
|
1605
|
-
}: {
|
|
1606
|
-
depositor: PublicKey
|
|
1607
|
-
amountBase: bigint
|
|
1608
|
-
minLpOut: bigint
|
|
1609
|
-
lowerTickApy: number
|
|
1610
|
-
upperTickApy: number
|
|
1611
|
-
tokenSyDepositor?: PublicKey
|
|
1612
|
-
tokenYtDepositor?: PublicKey
|
|
1613
|
-
tokenPtDepositor?: PublicKey
|
|
1614
|
-
tokenBaseDepositor?: PublicKey
|
|
1615
|
-
lpPosition?: Keypair | PublicKey
|
|
1616
|
-
}) {
|
|
1617
|
-
const tokenSyDepositor =
|
|
1618
|
-
tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
|
|
1619
|
-
const tokenYtDepositor =
|
|
1620
|
-
tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, depositor, true, TOKEN_PROGRAM_ID)
|
|
1621
|
-
const tokenPtDepositor =
|
|
1622
|
-
tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
|
|
1623
|
-
const tokenBaseDepositor =
|
|
1624
|
-
tokenBaseDepositorParam ||
|
|
1625
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, depositor, true, this.flavor.baseTokenProgram)
|
|
1626
|
-
|
|
1627
|
-
const lpPosition = lpPositionParam || Keypair.generate()
|
|
1628
|
-
|
|
1629
|
-
const tokenSyDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1630
|
-
depositor,
|
|
1631
|
-
tokenSyDepositor,
|
|
1632
|
-
depositor,
|
|
1633
|
-
this.mintSy,
|
|
1634
|
-
)
|
|
1635
|
-
const tokenYtDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1636
|
-
depositor,
|
|
1637
|
-
tokenYtDepositor,
|
|
1638
|
-
depositor,
|
|
1639
|
-
this.mintYt,
|
|
1640
|
-
)
|
|
1641
|
-
const tokenPtDepositorAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1642
|
-
depositor,
|
|
1643
|
-
tokenPtDepositor,
|
|
1644
|
-
depositor,
|
|
1645
|
-
this.mintPt,
|
|
1646
|
-
)
|
|
1647
|
-
|
|
1648
|
-
const mintSyIx = await this.flavor.ixMintSy({
|
|
1649
|
-
// argument does not matter - since we are just getting the keys
|
|
1650
|
-
amountBase: "0",
|
|
1651
|
-
depositor,
|
|
1652
|
-
depositorBaseTokenAccount: tokenBaseDepositor,
|
|
1653
|
-
depositorSyTokenAccount: tokenSyDepositor,
|
|
1654
|
-
})
|
|
1655
|
-
|
|
1656
|
-
const mintSyRemAccounts = mintSyIx.keys
|
|
1657
|
-
|
|
1658
|
-
const unorderedRemainingAccounts = uniqueRemainingAccounts([
|
|
1659
|
-
...this.cpiSyAccounts.getSyState,
|
|
1660
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1661
|
-
...this.cpiCoreAccounts.stripSy,
|
|
1662
|
-
...this.cpiSyAccounts.depositSy,
|
|
1663
|
-
])
|
|
1664
|
-
|
|
1665
|
-
const depositYtAccounts = this.depositYtAccounts({
|
|
1666
|
-
owner: depositor,
|
|
1667
|
-
ytSrc: tokenYtDepositor,
|
|
1668
|
-
})
|
|
1669
|
-
const depositAccountsUntil = mintSyRemAccounts.length + depositYtAccounts.keys.length
|
|
1670
|
-
const allRemainingAccounts = [...mintSyRemAccounts, ...depositYtAccounts.keys, ...unorderedRemainingAccounts]
|
|
1671
|
-
|
|
1672
|
-
const ix = exponentClmm.createWrapperProvideLiquidityInstruction(
|
|
1673
|
-
{
|
|
1674
|
-
depositor,
|
|
1675
|
-
market: this.selfAddress,
|
|
1676
|
-
ticks: this.ticksKey,
|
|
1677
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1678
|
-
tokenYtEscrow: this.tokenYtEscrow,
|
|
1679
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1680
|
-
tokenSyDepositor,
|
|
1681
|
-
tokenYtDepositor,
|
|
1682
|
-
tokenPtDepositor,
|
|
1683
|
-
mintYt: this.vault.mintYt,
|
|
1684
|
-
mintPt: this.vault.mintPt,
|
|
1685
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1686
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
1687
|
-
syProgram: this.syProgram,
|
|
1688
|
-
exponentCoreProgram: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
1689
|
-
lpPosition: lpPosition instanceof Keypair ? lpPosition.publicKey : lpPosition,
|
|
1690
|
-
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1691
|
-
systemProgram: SystemProgram.programId,
|
|
1692
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
1693
|
-
eventAuthority: this.eventAuthority,
|
|
1694
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1695
|
-
},
|
|
1696
|
-
{
|
|
1697
|
-
lowerTick: convertApyToApyBp(lowerTickApy),
|
|
1698
|
-
upperTick: convertApyToApyBp(upperTickApy),
|
|
1699
|
-
amountBase,
|
|
1700
|
-
minLpOut,
|
|
1701
|
-
mintSyRemAccountsUntil: mintSyRemAccounts.length,
|
|
1702
|
-
depositYtAccountsUntil: depositAccountsUntil,
|
|
1703
|
-
},
|
|
1704
|
-
)
|
|
1705
|
-
ix.keys.push(...allRemainingAccounts)
|
|
1706
|
-
|
|
1707
|
-
if (lpPosition instanceof Keypair) {
|
|
1708
|
-
ix.keys.find((k) => k.pubkey.equals(lpPosition.publicKey))!.isSigner = true
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
return {
|
|
1712
|
-
ixs: [
|
|
1713
|
-
...(await this.flavor.preIxs({ signer: depositor })),
|
|
1714
|
-
ix,
|
|
1715
|
-
...(await this.flavor.postIxs({ signer: depositor })),
|
|
1716
|
-
],
|
|
1717
|
-
signers: lpPosition instanceof Keypair ? [lpPosition] : [],
|
|
1718
|
-
setupIxs: [tokenSyDepositorAtaIx, tokenYtDepositorAtaIx, tokenPtDepositorAtaIx],
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1722
|
-
/**
|
|
1723
|
-
* Provide concentrated liquidity from a base asset plus existing PT tokens ("classic" mode).
|
|
1724
|
-
*
|
|
1725
|
-
* Unlike {@link ixWrapperProvideLiquidity}, this allows the depositor to supply PT they already
|
|
1726
|
-
* hold instead of having the program strip SY into PT+YT. Useful when the depositor has leftover
|
|
1727
|
-
* PT from a previous trade or wants finer control over token composition.
|
|
1728
|
-
*
|
|
1729
|
-
* @param depositor - Wallet signing the transaction
|
|
1730
|
-
* @param amountBase - Amount of base asset to deposit (converted to SY internally)
|
|
1731
|
-
* @param amountPt - Amount of PT to deposit alongside the base asset
|
|
1732
|
-
* @param minLpOut - Minimum LP tokens to receive (slippage protection)
|
|
1733
|
-
* @param lowerTickApy - Lower APY bound for the liquidity range
|
|
1734
|
-
* @param upperTickApy - Upper APY bound for the liquidity range
|
|
1735
|
-
*/
|
|
1736
|
-
async ixProvideLiquidityClassic({
|
|
1737
|
-
depositor,
|
|
1738
|
-
amountBase,
|
|
1739
|
-
amountPt,
|
|
1740
|
-
minLpOut,
|
|
1741
|
-
lowerTickApy,
|
|
1742
|
-
upperTickApy,
|
|
1743
|
-
tokenSyDepositor: tokenSyDepositorParam,
|
|
1744
|
-
tokenYtDepositor: tokenYtDepositorParam,
|
|
1745
|
-
tokenPtDepositor: tokenPtDepositorParam,
|
|
1746
|
-
tokenBaseDepositor: tokenBaseDepositorParam,
|
|
1747
|
-
lpPositionParam,
|
|
1748
|
-
}: {
|
|
1749
|
-
depositor: PublicKey
|
|
1750
|
-
amountBase: bigint
|
|
1751
|
-
amountPt: bigint
|
|
1752
|
-
minLpOut: bigint
|
|
1753
|
-
lowerTickApy: number
|
|
1754
|
-
upperTickApy: number
|
|
1755
|
-
tokenSyDepositor?: PublicKey
|
|
1756
|
-
tokenYtDepositor?: PublicKey
|
|
1757
|
-
tokenPtDepositor?: PublicKey
|
|
1758
|
-
tokenBaseDepositor?: PublicKey
|
|
1759
|
-
lpPositionParam?: Keypair | PublicKey
|
|
1760
|
-
}) {
|
|
1761
|
-
const tokenSyDepositor =
|
|
1762
|
-
tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
|
|
1763
|
-
const tokenYtDepositor =
|
|
1764
|
-
tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, depositor, true, TOKEN_PROGRAM_ID)
|
|
1765
|
-
const tokenPtDepositor =
|
|
1766
|
-
tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
|
|
1767
|
-
const tokenBaseDepositor =
|
|
1768
|
-
tokenBaseDepositorParam ||
|
|
1769
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, depositor, true, this.flavor.baseTokenProgram)
|
|
1770
|
-
|
|
1771
|
-
const lpPosition = lpPositionParam || Keypair.generate()
|
|
1772
|
-
|
|
1773
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1774
|
-
depositor,
|
|
1775
|
-
tokenSyDepositor,
|
|
1776
|
-
depositor,
|
|
1777
|
-
this.mintSy,
|
|
1778
|
-
)
|
|
1779
|
-
const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1780
|
-
depositor,
|
|
1781
|
-
tokenYtDepositor,
|
|
1782
|
-
depositor,
|
|
1783
|
-
this.mintYt,
|
|
1784
|
-
)
|
|
1785
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1786
|
-
depositor,
|
|
1787
|
-
tokenPtDepositor,
|
|
1788
|
-
depositor,
|
|
1789
|
-
this.mintPt,
|
|
1790
|
-
)
|
|
1791
|
-
const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1792
|
-
depositor,
|
|
1793
|
-
tokenBaseDepositor,
|
|
1794
|
-
depositor,
|
|
1795
|
-
this.flavor.mintBase,
|
|
1796
|
-
this.flavor.baseTokenProgram,
|
|
1797
|
-
)
|
|
1798
|
-
|
|
1799
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
1800
|
-
...this.cpiSyAccounts.depositSy,
|
|
1801
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
1802
|
-
...this.cpiCoreAccounts.stripSy,
|
|
1803
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1804
|
-
])
|
|
1805
|
-
|
|
1806
|
-
const mintSyIx = await this.flavor.ixMintSy({
|
|
1807
|
-
amountBase: "0",
|
|
1808
|
-
depositor,
|
|
1809
|
-
depositorBaseTokenAccount: tokenBaseDepositor,
|
|
1810
|
-
depositorSyTokenAccount: tokenSyDepositor,
|
|
1811
|
-
})
|
|
1812
|
-
|
|
1813
|
-
const mintSyRemAccounts = mintSyIx.keys
|
|
1814
|
-
|
|
1815
|
-
const ix = exponentClmm.createWrapperProvideLiquidityClassicInstruction(
|
|
1816
|
-
{
|
|
1817
|
-
depositor,
|
|
1818
|
-
market: this.selfAddress,
|
|
1819
|
-
ticks: this.ticksKey,
|
|
1820
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1821
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1822
|
-
tokenSyDepositor,
|
|
1823
|
-
tokenPtDepositor,
|
|
1824
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1825
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
1826
|
-
syProgram: this.syProgram,
|
|
1827
|
-
lpPosition: lpPosition instanceof Keypair ? lpPosition.publicKey : lpPosition,
|
|
1828
|
-
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1829
|
-
systemProgram: SystemProgram.programId,
|
|
1830
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
1831
|
-
eventAuthority: this.eventAuthority,
|
|
1832
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1833
|
-
},
|
|
1834
|
-
{
|
|
1835
|
-
lowerTick: convertApyToApyBp(lowerTickApy),
|
|
1836
|
-
upperTick: convertApyToApyBp(upperTickApy),
|
|
1837
|
-
amountBase,
|
|
1838
|
-
amountPt,
|
|
1839
|
-
minLpOut,
|
|
1840
|
-
mintSyAccountsUntil: mintSyRemAccounts.length,
|
|
1841
|
-
},
|
|
1842
|
-
)
|
|
1843
|
-
ix.keys.push(...mintSyRemAccounts, ...remainingAccounts)
|
|
1844
|
-
|
|
1845
|
-
if (lpPosition instanceof Keypair) {
|
|
1846
|
-
ix.keys.find((k) => k.pubkey.equals(lpPosition.publicKey))!.isSigner = true
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
return {
|
|
1850
|
-
ixs: [
|
|
1851
|
-
...(await this.flavor.preIxs({ signer: depositor })),
|
|
1852
|
-
ix,
|
|
1853
|
-
...(await this.flavor.postIxs({ signer: depositor })),
|
|
1854
|
-
],
|
|
1855
|
-
signers: lpPosition instanceof Keypair ? [lpPosition] : [],
|
|
1856
|
-
setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx],
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
async ixProvideLiquidityBase({
|
|
1861
|
-
depositor,
|
|
1862
|
-
externalPtToBuy,
|
|
1863
|
-
externalSyConstraint,
|
|
1864
|
-
minLpOut,
|
|
1865
|
-
lowerTickApy,
|
|
1866
|
-
upperTickApy,
|
|
1867
|
-
tokenSyDepositor: tokenSyDepositorParam,
|
|
1868
|
-
tokenYtDepositor: tokenYtDepositorParam,
|
|
1869
|
-
tokenPtDepositor: tokenPtDepositorParam,
|
|
1870
|
-
tokenBaseDepositor: tokenBaseDepositorParam,
|
|
1871
|
-
lpPositionParam,
|
|
1872
|
-
}: {
|
|
1873
|
-
depositor: PublicKey
|
|
1874
|
-
externalPtToBuy: bigint
|
|
1875
|
-
externalSyConstraint: bigint
|
|
1876
|
-
minLpOut: bigint
|
|
1877
|
-
lowerTickApy: number
|
|
1878
|
-
upperTickApy: number
|
|
1879
|
-
tokenSyDepositor?: PublicKey
|
|
1880
|
-
tokenYtDepositor?: PublicKey
|
|
1881
|
-
tokenPtDepositor?: PublicKey
|
|
1882
|
-
tokenBaseDepositor?: PublicKey
|
|
1883
|
-
lpPositionParam?: Keypair | PublicKey
|
|
1884
|
-
}) {
|
|
1885
|
-
const tokenSyDepositor =
|
|
1886
|
-
tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, depositor, true, TOKEN_PROGRAM_ID)
|
|
1887
|
-
const tokenYtDepositor =
|
|
1888
|
-
tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, depositor, true, TOKEN_PROGRAM_ID)
|
|
1889
|
-
const tokenPtDepositor =
|
|
1890
|
-
tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, depositor, true, TOKEN_PROGRAM_ID)
|
|
1891
|
-
const tokenBaseDepositor =
|
|
1892
|
-
tokenBaseDepositorParam ||
|
|
1893
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, depositor, true, this.flavor.baseTokenProgram)
|
|
1894
|
-
|
|
1895
|
-
const lpPosition = lpPositionParam || Keypair.generate()
|
|
1896
|
-
|
|
1897
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1898
|
-
depositor,
|
|
1899
|
-
tokenSyDepositor,
|
|
1900
|
-
depositor,
|
|
1901
|
-
this.mintSy,
|
|
1902
|
-
)
|
|
1903
|
-
const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1904
|
-
depositor,
|
|
1905
|
-
tokenYtDepositor,
|
|
1906
|
-
depositor,
|
|
1907
|
-
this.mintYt,
|
|
1908
|
-
)
|
|
1909
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1910
|
-
depositor,
|
|
1911
|
-
tokenPtDepositor,
|
|
1912
|
-
depositor,
|
|
1913
|
-
this.mintPt,
|
|
1914
|
-
)
|
|
1915
|
-
const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
1916
|
-
depositor,
|
|
1917
|
-
tokenBaseDepositor,
|
|
1918
|
-
depositor,
|
|
1919
|
-
this.flavor.mintBase,
|
|
1920
|
-
this.flavor.baseTokenProgram,
|
|
1921
|
-
)
|
|
1922
|
-
|
|
1923
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
1924
|
-
...this.cpiSyAccounts.depositSy,
|
|
1925
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
1926
|
-
...this.cpiCoreAccounts.stripSy,
|
|
1927
|
-
...this.cpiSyAccounts.getPositionState,
|
|
1928
|
-
])
|
|
1929
|
-
|
|
1930
|
-
const mintSyIx = await this.flavor.ixMintSy({
|
|
1931
|
-
amountBase: "0",
|
|
1932
|
-
depositor,
|
|
1933
|
-
depositorBaseTokenAccount: tokenBaseDepositor,
|
|
1934
|
-
depositorSyTokenAccount: tokenSyDepositor,
|
|
1935
|
-
})
|
|
1936
|
-
|
|
1937
|
-
const mintSyRemAccounts = mintSyIx.keys
|
|
1938
|
-
|
|
1939
|
-
const ix = exponentClmm.createWrapperProvideLiquidityBaseInstruction(
|
|
1940
|
-
{
|
|
1941
|
-
depositor,
|
|
1942
|
-
market: this.selfAddress,
|
|
1943
|
-
ticks: this.ticksKey,
|
|
1944
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
1945
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
1946
|
-
tokenSyDepositor,
|
|
1947
|
-
tokenPtDepositor,
|
|
1948
|
-
tokenFeeTreasurySy: this.tokenFeeTreasurySy,
|
|
1949
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
1950
|
-
mintPt: this.mintPt,
|
|
1951
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1952
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
1953
|
-
syProgram: this.syProgram,
|
|
1954
|
-
exponentCoreProgram: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
1955
|
-
lpPosition: lpPosition instanceof Keypair ? lpPosition.publicKey : lpPosition,
|
|
1956
|
-
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1957
|
-
systemProgram: SystemProgram.programId,
|
|
1958
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
1959
|
-
eventAuthority: this.eventAuthority,
|
|
1960
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
1961
|
-
},
|
|
1962
|
-
{
|
|
1963
|
-
lowerTickKey: convertApyToApyBp(lowerTickApy),
|
|
1964
|
-
upperTickKey: convertApyToApyBp(upperTickApy),
|
|
1965
|
-
minLpOut,
|
|
1966
|
-
mintSyAccountsUntil: mintSyRemAccounts.length,
|
|
1967
|
-
externalPtToBuy,
|
|
1968
|
-
externalSyConstraint,
|
|
1969
|
-
},
|
|
1970
|
-
)
|
|
1971
|
-
ix.keys.push(...mintSyRemAccounts, ...remainingAccounts)
|
|
1972
|
-
|
|
1973
|
-
if (lpPosition instanceof Keypair) {
|
|
1974
|
-
ix.keys.find((k) => k.pubkey.equals(lpPosition.publicKey))!.isSigner = true
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
return {
|
|
1978
|
-
ixs: [
|
|
1979
|
-
...(await this.flavor.preIxs({ signer: depositor })),
|
|
1980
|
-
ix,
|
|
1981
|
-
...(await this.flavor.postIxs({ signer: depositor })),
|
|
1982
|
-
],
|
|
1983
|
-
signers: lpPosition instanceof Keypair ? [lpPosition] : [],
|
|
1984
|
-
setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx],
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
async ixWithdrawLiquidityToBase({
|
|
1989
|
-
owner,
|
|
1990
|
-
amountLp,
|
|
1991
|
-
minBaseOut,
|
|
1992
|
-
lpPosition,
|
|
1993
|
-
tokenSyWithdrawer: tokenSyWithdrawerParam,
|
|
1994
|
-
tokenYtWithdrawer: tokenYtWithdrawerParam,
|
|
1995
|
-
tokenPtWithdrawer: tokenPtWithdrawerParam,
|
|
1996
|
-
tokenBaseWithdrawer: tokenBaseWithdrawerParam,
|
|
1997
|
-
}: {
|
|
1998
|
-
owner: PublicKey
|
|
1999
|
-
amountLp: bigint
|
|
2000
|
-
minBaseOut: bigint
|
|
2001
|
-
lpPosition: PublicKey
|
|
2002
|
-
tokenSyWithdrawer?: PublicKey
|
|
2003
|
-
tokenYtWithdrawer?: PublicKey
|
|
2004
|
-
tokenPtWithdrawer?: PublicKey
|
|
2005
|
-
tokenBaseWithdrawer?: PublicKey
|
|
2006
|
-
}) {
|
|
2007
|
-
const tokenSyWithdrawer =
|
|
2008
|
-
tokenSyWithdrawerParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
2009
|
-
const tokenYtWithdrawer =
|
|
2010
|
-
tokenYtWithdrawerParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
2011
|
-
const tokenPtWithdrawer =
|
|
2012
|
-
tokenPtWithdrawerParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
2013
|
-
const tokenBaseWithdrawer =
|
|
2014
|
-
tokenBaseWithdrawerParam ||
|
|
2015
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
2016
|
-
|
|
2017
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenSyWithdrawer, owner, this.mintSy)
|
|
2018
|
-
const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenYtWithdrawer, owner, this.mintYt)
|
|
2019
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenPtWithdrawer, owner, this.mintPt)
|
|
2020
|
-
const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
2021
|
-
owner,
|
|
2022
|
-
tokenBaseWithdrawer,
|
|
2023
|
-
owner,
|
|
2024
|
-
this.flavor.mintBase,
|
|
2025
|
-
this.flavor.baseTokenProgram,
|
|
2026
|
-
)
|
|
2027
|
-
|
|
2028
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
2029
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
2030
|
-
...this.cpiSyAccounts.getPositionState,
|
|
2031
|
-
])
|
|
2032
|
-
|
|
2033
|
-
const redeemSyIx = await this.flavor.ixRedeemSy({
|
|
2034
|
-
amountSy: "0",
|
|
2035
|
-
redeemer: owner,
|
|
2036
|
-
redeemerBaseTokenAccount: tokenBaseWithdrawer,
|
|
2037
|
-
redeemerSyTokenAccount: tokenSyWithdrawer,
|
|
2038
|
-
})
|
|
2039
|
-
|
|
2040
|
-
const redeemSyRemAccounts = redeemSyIx.keys
|
|
2041
|
-
|
|
2042
|
-
const minSyOut = Number(minBaseOut) / this.currentSyExchangeRate
|
|
2043
|
-
|
|
2044
|
-
const ix = exponentClmm.createWrapperWithdrawLiquidityInstruction(
|
|
2045
|
-
{
|
|
2046
|
-
withdrawer: owner,
|
|
2047
|
-
market: this.selfAddress,
|
|
2048
|
-
ticks: this.ticksKey,
|
|
2049
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
2050
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
2051
|
-
tokenSyWithdrawer,
|
|
2052
|
-
tokenPtWithdrawer,
|
|
2053
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2054
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
2055
|
-
syProgram: this.syProgram,
|
|
2056
|
-
tokenFeeTreasurySy: this.state.tokenFeeTreasurySy,
|
|
2057
|
-
tokenFeeTreasuryPt: this.tokenFeeTreasuryPt,
|
|
2058
|
-
lpPosition,
|
|
2059
|
-
systemProgram: SystemProgram.programId,
|
|
2060
|
-
eventAuthority: this.eventAuthority,
|
|
2061
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2062
|
-
},
|
|
2063
|
-
{
|
|
2064
|
-
amountLp,
|
|
2065
|
-
syConstraint: BigInt(minSyOut.toFixed(0)),
|
|
2066
|
-
redeemSyAccountsLength: redeemSyRemAccounts.length,
|
|
2067
|
-
},
|
|
2068
|
-
)
|
|
2069
|
-
ix.keys.push(...redeemSyRemAccounts, ...remainingAccounts)
|
|
2070
|
-
|
|
2071
|
-
return {
|
|
2072
|
-
ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
|
|
2073
|
-
setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx],
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
|
|
2077
|
-
async ixWithdrawLiquidityClassic({
|
|
2078
|
-
owner,
|
|
2079
|
-
amountLp,
|
|
2080
|
-
lpPosition,
|
|
2081
|
-
tokenSyWithdrawer: tokenSyWithdrawerParam,
|
|
2082
|
-
tokenYtWithdrawer: tokenYtWithdrawerParam,
|
|
2083
|
-
tokenPtWithdrawer: tokenPtWithdrawerParam,
|
|
2084
|
-
tokenBaseWithdrawer: tokenBaseWithdrawerParam,
|
|
2085
|
-
}: {
|
|
2086
|
-
owner: PublicKey
|
|
2087
|
-
amountLp: bigint
|
|
2088
|
-
lpPosition: PublicKey
|
|
2089
|
-
tokenSyWithdrawer?: PublicKey
|
|
2090
|
-
tokenYtWithdrawer?: PublicKey
|
|
2091
|
-
tokenPtWithdrawer?: PublicKey
|
|
2092
|
-
tokenBaseWithdrawer?: PublicKey
|
|
2093
|
-
}) {
|
|
2094
|
-
const tokenSyWithdrawer =
|
|
2095
|
-
tokenSyWithdrawerParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
2096
|
-
const tokenYtWithdrawer =
|
|
2097
|
-
tokenYtWithdrawerParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
2098
|
-
const tokenPtWithdrawer =
|
|
2099
|
-
tokenPtWithdrawerParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
2100
|
-
const tokenBaseWithdrawer =
|
|
2101
|
-
tokenBaseWithdrawerParam ||
|
|
2102
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
2103
|
-
|
|
2104
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenSyWithdrawer, owner, this.mintSy)
|
|
2105
|
-
const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenYtWithdrawer, owner, this.mintYt)
|
|
2106
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenPtWithdrawer, owner, this.mintPt)
|
|
2107
|
-
const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
2108
|
-
owner,
|
|
2109
|
-
tokenBaseWithdrawer,
|
|
2110
|
-
owner,
|
|
2111
|
-
this.flavor.mintBase,
|
|
2112
|
-
this.flavor.baseTokenProgram,
|
|
2113
|
-
)
|
|
2114
|
-
|
|
2115
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
2116
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
2117
|
-
...this.cpiSyAccounts.getPositionState,
|
|
2118
|
-
])
|
|
2119
|
-
|
|
2120
|
-
const redeemSyIx = await this.flavor.ixRedeemSy({
|
|
2121
|
-
amountSy: "0",
|
|
2122
|
-
redeemer: owner,
|
|
2123
|
-
redeemerBaseTokenAccount: tokenBaseWithdrawer,
|
|
2124
|
-
redeemerSyTokenAccount: tokenSyWithdrawer,
|
|
2125
|
-
})
|
|
2126
|
-
|
|
2127
|
-
const redeemSyRemAccounts = redeemSyIx.keys
|
|
2128
|
-
|
|
2129
|
-
const ixn = exponentClmm.createWrapperWithdrawLiquidityClassicInstruction(
|
|
2130
|
-
{
|
|
2131
|
-
withdrawer: owner,
|
|
2132
|
-
market: this.selfAddress,
|
|
2133
|
-
ticks: this.ticksKey,
|
|
2134
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
2135
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
2136
|
-
tokenSyWithdrawer,
|
|
2137
|
-
tokenPtWithdrawer,
|
|
2138
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2139
|
-
marketAddressLookupTable: this.addressLookupTable,
|
|
2140
|
-
syProgram: this.syProgram,
|
|
2141
|
-
lpPosition,
|
|
2142
|
-
systemProgram: SystemProgram.programId,
|
|
2143
|
-
eventAuthority: this.eventAuthority,
|
|
2144
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2145
|
-
},
|
|
2146
|
-
{
|
|
2147
|
-
amountLp,
|
|
2148
|
-
redeemSyAccountsLength: redeemSyRemAccounts.length,
|
|
2149
|
-
},
|
|
2150
|
-
)
|
|
2151
|
-
ixn.keys.push(...redeemSyRemAccounts, ...remainingAccounts)
|
|
2152
|
-
|
|
2153
|
-
return {
|
|
2154
|
-
ixs: [...(await this.flavor.preIxs({ signer: owner })), ixn, ...(await this.flavor.postIxs({ signer: owner }))],
|
|
2155
|
-
setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx],
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
async ixAddLiquidity({
|
|
2160
|
-
owner,
|
|
2161
|
-
ptInIntent,
|
|
2162
|
-
syInIntent,
|
|
2163
|
-
tokenSyDepositor: tokenSyDepositorParam,
|
|
2164
|
-
tokenYtDepositor: tokenYtDepositorParam,
|
|
2165
|
-
tokenPtDepositor: tokenPtDepositorParam,
|
|
2166
|
-
tokenBaseDepositor: tokenBaseDepositorParam,
|
|
2167
|
-
lpPosition,
|
|
2168
|
-
}: {
|
|
2169
|
-
owner: PublicKey
|
|
2170
|
-
/** Intended (maximum) amount of PT in */
|
|
2171
|
-
ptInIntent: bigint
|
|
2172
|
-
/** Intended (maximum) amount of SY in */
|
|
2173
|
-
syInIntent: bigint
|
|
2174
|
-
tokenSyDepositor?: PublicKey
|
|
2175
|
-
tokenYtDepositor?: PublicKey
|
|
2176
|
-
tokenPtDepositor?: PublicKey
|
|
2177
|
-
tokenBaseDepositor?: PublicKey
|
|
2178
|
-
lpPosition: PublicKey
|
|
2179
|
-
}) {
|
|
2180
|
-
const tokenSyDepositor =
|
|
2181
|
-
tokenSyDepositorParam || getAssociatedTokenAddressSync(this.mintSy, owner, true, TOKEN_PROGRAM_ID)
|
|
2182
|
-
const tokenYtDepositor =
|
|
2183
|
-
tokenYtDepositorParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
2184
|
-
const tokenPtDepositor =
|
|
2185
|
-
tokenPtDepositorParam || getAssociatedTokenAddressSync(this.mintPt, owner, true, TOKEN_PROGRAM_ID)
|
|
2186
|
-
const tokenBaseDepositor =
|
|
2187
|
-
tokenBaseDepositorParam ||
|
|
2188
|
-
getAssociatedTokenAddressSync(this.flavor.mintBase, owner, true, this.flavor.baseTokenProgram)
|
|
2189
|
-
|
|
2190
|
-
const tokenSyAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenSyDepositor, owner, this.mintSy)
|
|
2191
|
-
const tokenYtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenYtDepositor, owner, this.mintYt)
|
|
2192
|
-
const tokenPtAtaIx = createAssociatedTokenAccountIdempotentInstruction(owner, tokenPtDepositor, owner, this.mintPt)
|
|
2193
|
-
const tokenBaseAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
2194
|
-
owner,
|
|
2195
|
-
tokenBaseDepositor,
|
|
2196
|
-
owner,
|
|
2197
|
-
this.flavor.mintBase,
|
|
2198
|
-
this.flavor.baseTokenProgram,
|
|
2199
|
-
)
|
|
2200
|
-
|
|
2201
|
-
const remainingAccounts = uniqueRemainingAccounts([
|
|
2202
|
-
...this.cpiSyAccounts.depositSy,
|
|
2203
|
-
...this.cpiSyAccounts.withdrawSy,
|
|
2204
|
-
...this.cpiCoreAccounts.stripSy,
|
|
2205
|
-
...this.cpiSyAccounts.getPositionState,
|
|
2206
|
-
])
|
|
2207
|
-
|
|
2208
|
-
const ix = exponentClmm.createAddLiquidityInstruction(
|
|
2209
|
-
{
|
|
2210
|
-
owner,
|
|
2211
|
-
market: this.selfAddress,
|
|
2212
|
-
ticks: this.ticksKey,
|
|
2213
|
-
lpPosition: lpPosition instanceof Keypair ? lpPosition.publicKey : lpPosition,
|
|
2214
|
-
tokenPtSrc: tokenPtDepositor,
|
|
2215
|
-
tokenSySrc: tokenSyDepositor,
|
|
2216
|
-
tokenPtEscrow: this.tokenPtEscrow,
|
|
2217
|
-
tokenSyEscrow: this.tokenSyEscrow,
|
|
2218
|
-
addressLookupTable: this.addressLookupTable,
|
|
2219
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2220
|
-
syProgram: this.syProgram,
|
|
2221
|
-
instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2222
|
-
systemProgram: SystemProgram.programId,
|
|
2223
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
2224
|
-
eventAuthority: this.eventAuthority,
|
|
2225
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2226
|
-
},
|
|
2227
|
-
{
|
|
2228
|
-
maxSyInToAdd: syInIntent,
|
|
2229
|
-
maxPtInToAdd: ptInIntent,
|
|
2230
|
-
lowerTickKeyOptional: null,
|
|
2231
|
-
upperTickKeyOptional: null,
|
|
2232
|
-
},
|
|
2233
|
-
)
|
|
2234
|
-
ix.keys.push(...remainingAccounts)
|
|
2235
|
-
|
|
2236
|
-
return {
|
|
2237
|
-
ixs: [...(await this.flavor.preIxs({ signer: owner })), ix, ...(await this.flavor.postIxs({ signer: owner }))],
|
|
2238
|
-
signers: lpPosition instanceof Keypair ? [lpPosition] : [],
|
|
2239
|
-
setupIxs: [tokenSyAtaIx, tokenYtAtaIx, tokenPtAtaIx, tokenBaseAtaIx],
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
async getUserLpPositions(owner: PublicKey, market: PublicKey) {
|
|
2244
|
-
const LP_POSITION_DISCRIMINATOR = Buffer.from([105, 241, 37, 200, 224, 2, 252, 90])
|
|
2245
|
-
|
|
2246
|
-
const accounts = await this.connection.getProgramAccounts(
|
|
2247
|
-
exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2248
|
-
{
|
|
2249
|
-
filters: [
|
|
2250
|
-
{ memcmp: { offset: 0, bytes: bs58.encode(LP_POSITION_DISCRIMINATOR) } },
|
|
2251
|
-
{ memcmp: { offset: 8, bytes: owner.toBase58() } },
|
|
2252
|
-
{ memcmp: { offset: 40, bytes: market.toBase58() } },
|
|
2253
|
-
],
|
|
2254
|
-
},
|
|
2255
|
-
)
|
|
2256
|
-
|
|
2257
|
-
const lpPositions = accounts.map(({ pubkey, account }) => ({
|
|
2258
|
-
publicKey: pubkey,
|
|
2259
|
-
account: exponentClmm.deserializeLpPositionAccount(account.data),
|
|
2260
|
-
}))
|
|
2261
|
-
|
|
2262
|
-
return {
|
|
2263
|
-
lpPositions: [lpPositions],
|
|
2264
|
-
}
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
|
-
ixMarketAccureEmissions({ owner, lpPosition }: { owner: PublicKey; lpPosition: PublicKey }) {
|
|
2268
|
-
const remainingAccounts = uniqueRemainingAccounts([...this.cpiSyAccounts.getPositionState])
|
|
2269
|
-
const ixn = exponentClmm.createMarketAccrueEmissionInstruction({
|
|
2270
|
-
owner,
|
|
2271
|
-
market: this.selfAddress,
|
|
2272
|
-
ticks: this.ticksKey,
|
|
2273
|
-
lpPosition,
|
|
2274
|
-
addressLookupTable: this.addressLookupTable,
|
|
2275
|
-
syProgram: this.syProgram,
|
|
2276
|
-
systemProgram: SystemProgram.programId,
|
|
2277
|
-
eventAuthority: this.eventAuthority,
|
|
2278
|
-
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2279
|
-
})
|
|
2280
|
-
ixn.keys.push(...remainingAccounts)
|
|
2281
|
-
|
|
2282
|
-
return {
|
|
2283
|
-
ixs: [ixn],
|
|
2284
|
-
}
|
|
2285
|
-
}
|
|
2286
|
-
|
|
2287
|
-
/**
|
|
2288
|
-
* Calculate the current price per unit of liquidity (principal only) for a tick range.
|
|
2289
|
-
* Mirrors the on-chain `liquidity_unit_price_in_asset` helper but performs the
|
|
2290
|
-
* principal aggregation client-side using the fetched ticks account.
|
|
2291
|
-
*
|
|
2292
|
-
* @param lowerTickKey - Inclusive tick key (APY in parts-per-million) for the left boundary
|
|
2293
|
-
* @param upperTickKey - Exclusive tick key for the right boundary
|
|
2294
|
-
* @param ticksOverride - Optional ticks account (defaults to the instance state)
|
|
2295
|
-
* @param syExchangeRateOverride - Optional SY exchange rate (defaults to current flavor rate)
|
|
2296
|
-
* @returns Price per unit of liquidity in underlying asset terms (principal only)
|
|
2297
|
-
*/
|
|
2298
|
-
liquidityUnitPriceInAsset({
|
|
2299
|
-
lowerTickKey,
|
|
2300
|
-
upperTickKey,
|
|
2301
|
-
ticksOverride,
|
|
2302
|
-
syExchangeRateOverride,
|
|
2303
|
-
}: {
|
|
2304
|
-
lowerTickKey: number
|
|
2305
|
-
upperTickKey: number
|
|
2306
|
-
ticksOverride?: Ticks
|
|
2307
|
-
syExchangeRateOverride?: number
|
|
2308
|
-
}): number {
|
|
2309
|
-
if (lowerTickKey >= upperTickKey) {
|
|
2310
|
-
throw new Error("lowerTickKey must be less than upperTickKey")
|
|
2311
|
-
}
|
|
2312
|
-
|
|
2313
|
-
const ticksAccount = ticksOverride ?? this.state.ticks
|
|
2314
|
-
if (!ticksAccount) {
|
|
2315
|
-
throw new Error("Ticks account data is unavailable")
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
const relevantIntervals = ticksAccount.ticksTree.filter(
|
|
2319
|
-
(tick) => tick.apyBasePoints >= lowerTickKey && tick.apyBasePoints < upperTickKey,
|
|
2320
|
-
)
|
|
2321
|
-
|
|
2322
|
-
if (relevantIntervals.length === 0) {
|
|
2323
|
-
return 0
|
|
2324
|
-
}
|
|
2325
|
-
|
|
2326
|
-
let totalPrincipalPt = 0n
|
|
2327
|
-
let totalPrincipalSy = 0n
|
|
2328
|
-
let totalShareSupply = 0n
|
|
2329
|
-
|
|
2330
|
-
for (const interval of relevantIntervals) {
|
|
2331
|
-
totalPrincipalPt += interval.principalPt
|
|
2332
|
-
totalPrincipalSy += interval.principalSy
|
|
2333
|
-
totalShareSupply += interval.principalShareSupply
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
|
-
if (totalShareSupply === 0n) {
|
|
2337
|
-
return 0
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
const timeFactor = this.secondsRemaining / SECONDS_PER_YEAR
|
|
2341
|
-
const ptAssetValuePerToken = Math.exp(-timeFactor * ticksAccount.currentSpotPrice)
|
|
2342
|
-
const syExchangeRate = syExchangeRateOverride ?? this.currentSyExchangeRate
|
|
2343
|
-
|
|
2344
|
-
const principalPtValue = new Decimal(totalPrincipalPt.toString()).mul(ptAssetValuePerToken)
|
|
2345
|
-
const principalSyValue = new Decimal(totalPrincipalSy.toString()).mul(syExchangeRate)
|
|
2346
|
-
const principalValue = principalPtValue.plus(principalSyValue)
|
|
2347
|
-
|
|
2348
|
-
return principalValue.div(new Decimal(totalShareSupply.toString())).toNumber()
|
|
2349
|
-
}
|
|
2350
|
-
|
|
2351
|
-
/**
|
|
2352
|
-
* Compute fee growth inside a tick range using Uniswap V3 formula
|
|
2353
|
-
*
|
|
2354
|
-
* @param lowerTick - Lower tick boundary
|
|
2355
|
-
* @param upperTick - Upper tick boundary
|
|
2356
|
-
* @param feeGlobalPt - Optional: Override global PT fees (for historical calculations)
|
|
2357
|
-
* @param feeGlobalSy - Optional: Override global SY fees (for historical calculations)
|
|
2358
|
-
* @returns Object with inside_sy and inside_pt fee growth values
|
|
2359
|
-
*/
|
|
2360
|
-
static computeFeeInsideForRange({
|
|
2361
|
-
currentTickPrice,
|
|
2362
|
-
lowerTickPrice,
|
|
2363
|
-
upperTickPrice,
|
|
2364
|
-
feeGrowthIndexGlobalPt,
|
|
2365
|
-
feeGrowthIndexGlobalSy,
|
|
2366
|
-
lowerTickOutsidePt,
|
|
2367
|
-
lowerTickOutsideSy,
|
|
2368
|
-
upperTickOutsidePt,
|
|
2369
|
-
upperTickOutsideSy,
|
|
2370
|
-
}: {
|
|
2371
|
-
currentTickPrice: number
|
|
2372
|
-
lowerTickPrice: number
|
|
2373
|
-
upperTickPrice: number
|
|
2374
|
-
feeGrowthIndexGlobalPt: bigint
|
|
2375
|
-
feeGrowthIndexGlobalSy: bigint
|
|
2376
|
-
lowerTickOutsidePt: bigint
|
|
2377
|
-
lowerTickOutsideSy: bigint
|
|
2378
|
-
upperTickOutsidePt: bigint
|
|
2379
|
-
upperTickOutsideSy: bigint
|
|
2380
|
-
}): { insideSy: bigint; insidePt: bigint } {
|
|
2381
|
-
// Uniswap V3 formula for computing fee inside a range
|
|
2382
|
-
let insideSy: bigint
|
|
2383
|
-
let insidePt: bigint
|
|
2384
|
-
|
|
2385
|
-
if (currentTickPrice < lowerTickPrice) {
|
|
2386
|
-
// Price below range: inside = outside(lower) - outside(upper)
|
|
2387
|
-
insideSy = lowerTickOutsideSy - upperTickOutsideSy
|
|
2388
|
-
insidePt = lowerTickOutsidePt - upperTickOutsidePt
|
|
2389
|
-
} else if (currentTickPrice >= upperTickPrice) {
|
|
2390
|
-
// Price above range: inside = outside(upper) - outside(lower)
|
|
2391
|
-
insideSy = upperTickOutsideSy - lowerTickOutsideSy
|
|
2392
|
-
insidePt = upperTickOutsidePt - lowerTickOutsidePt
|
|
2393
|
-
} else {
|
|
2394
|
-
// Price in range: inside = global - outside(lower) - outside(upper)
|
|
2395
|
-
insideSy = feeGrowthIndexGlobalSy - lowerTickOutsideSy - upperTickOutsideSy
|
|
2396
|
-
insidePt = feeGrowthIndexGlobalPt - lowerTickOutsidePt - upperTickOutsidePt
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
return { insideSy, insidePt }
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2402
|
-
/**
|
|
2403
|
-
* Calculate claimable fees for a position
|
|
2404
|
-
* Uses Q64.64 fixed-point math: tokens = floor((L * Δindex) >> 64)
|
|
2405
|
-
*
|
|
2406
|
-
* @param lpBalance - Position's liquidity balance
|
|
2407
|
-
* @param feeInsideLastSy - Last snapshot of inside SY fee growth
|
|
2408
|
-
* @param feeInsideLastPt - Last snapshot of inside PT fee growth
|
|
2409
|
-
* @param currentInsideSy - Current inside SY fee growth
|
|
2410
|
-
* @param currentInsidePt - Current inside PT fee growth
|
|
2411
|
-
* @param tokensOwedSy - Previously owed SY fees
|
|
2412
|
-
* @param tokensOwedPt - Previously owed PT fees
|
|
2413
|
-
* @returns Object with claimable and total fees
|
|
2414
|
-
*/
|
|
2415
|
-
static calculateClaimableFees({
|
|
2416
|
-
lpBalance,
|
|
2417
|
-
feeInsideLastSy,
|
|
2418
|
-
feeInsideLastPt,
|
|
2419
|
-
currentInsideSy,
|
|
2420
|
-
currentInsidePt,
|
|
2421
|
-
tokensOwedSy,
|
|
2422
|
-
tokensOwedPt,
|
|
2423
|
-
}: {
|
|
2424
|
-
lpBalance: bigint
|
|
2425
|
-
feeInsideLastSy: bigint
|
|
2426
|
-
feeInsideLastPt: bigint
|
|
2427
|
-
currentInsideSy: bigint
|
|
2428
|
-
currentInsidePt: bigint
|
|
2429
|
-
tokensOwedSy: bigint
|
|
2430
|
-
tokensOwedPt: bigint
|
|
2431
|
-
}): {
|
|
2432
|
-
claimableSy: bigint
|
|
2433
|
-
claimablePt: bigint
|
|
2434
|
-
tokensOwedSy: bigint
|
|
2435
|
-
tokensOwedPt: bigint
|
|
2436
|
-
totalSy: bigint
|
|
2437
|
-
totalPt: bigint
|
|
2438
|
-
} {
|
|
2439
|
-
// Calculate delta (growth since last snapshot)
|
|
2440
|
-
const deltaSy = currentInsideSy > feeInsideLastSy ? currentInsideSy - feeInsideLastSy : 0n
|
|
2441
|
-
const deltaPt = currentInsidePt > feeInsideLastPt ? currentInsidePt - feeInsideLastPt : 0n
|
|
2442
|
-
|
|
2443
|
-
// Calculate claimable fees using Q64.64 math: tokens = floor((L * Δindex) >> 64)
|
|
2444
|
-
const claimableSy = (lpBalance * deltaSy) >> 64n
|
|
2445
|
-
const claimablePt = (lpBalance * deltaPt) >> 64n
|
|
2446
|
-
|
|
2447
|
-
//? TotalPt and TotalSy don't make sense here because tokensOwedSy and tokensOwedPt are always 0
|
|
2448
|
-
// Calculate totals
|
|
2449
|
-
const totalSy = claimableSy + tokensOwedSy
|
|
2450
|
-
const totalPt = claimablePt + tokensOwedPt
|
|
2451
|
-
|
|
2452
|
-
return {
|
|
2453
|
-
claimableSy,
|
|
2454
|
-
claimablePt,
|
|
2455
|
-
tokensOwedSy,
|
|
2456
|
-
tokensOwedPt,
|
|
2457
|
-
totalSy,
|
|
2458
|
-
totalPt,
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
/**
|
|
2463
|
-
* Calculate historical fee APY for a tick range
|
|
2464
|
-
*
|
|
2465
|
-
* @param feeGrowthDeltaSy - Change in global SY fee growth over period
|
|
2466
|
-
* @param feeGrowthDeltaPt - Change in global PT fee growth over period
|
|
2467
|
-
* @param avgLiquidity - Average liquidity in the range during period
|
|
2468
|
-
* @param hoursElapsed - Number of hours in the period
|
|
2469
|
-
* @returns Object with fee APY metrics
|
|
2470
|
-
*/
|
|
2471
|
-
static calculateHistoricalFeeApy({
|
|
2472
|
-
feeGrowthDeltaSy,
|
|
2473
|
-
feeGrowthDeltaPt,
|
|
2474
|
-
avgLiquidity,
|
|
2475
|
-
hoursElapsed,
|
|
2476
|
-
}: {
|
|
2477
|
-
feeGrowthDeltaSy: bigint
|
|
2478
|
-
feeGrowthDeltaPt: bigint
|
|
2479
|
-
avgLiquidity: bigint
|
|
2480
|
-
hoursElapsed: number
|
|
2481
|
-
}): {
|
|
2482
|
-
feeApySy: number
|
|
2483
|
-
feeApyPt: number
|
|
2484
|
-
feeApyTotal: number
|
|
2485
|
-
totalFeesSy: bigint
|
|
2486
|
-
totalFeesPt: bigint
|
|
2487
|
-
} {
|
|
2488
|
-
if (avgLiquidity === 0n || hoursElapsed === 0) {
|
|
2489
|
-
return {
|
|
2490
|
-
feeApySy: 0,
|
|
2491
|
-
feeApyPt: 0,
|
|
2492
|
-
feeApyTotal: 0,
|
|
2493
|
-
totalFeesSy: 0n,
|
|
2494
|
-
totalFeesPt: 0n,
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
|
|
2498
|
-
// Calculate total fees earned in the period using Q64.64 math
|
|
2499
|
-
const totalFeesSy = (feeGrowthDeltaSy * avgLiquidity) >> 64n
|
|
2500
|
-
const totalFeesPt = (feeGrowthDeltaPt * avgLiquidity) >> 64n
|
|
2501
|
-
|
|
2502
|
-
// Annualization factor (hours in a year / hours elapsed)
|
|
2503
|
-
const hoursPerYear = 8760
|
|
2504
|
-
const annualizationFactor = hoursPerYear / hoursElapsed
|
|
2505
|
-
|
|
2506
|
-
// Calculate APY as: (fees / avg_liquidity) * annualization_factor * 100
|
|
2507
|
-
const feeApySy = (Number((totalFeesSy * 10000n) / avgLiquidity) / 100) * annualizationFactor
|
|
2508
|
-
const feeApyPt = (Number((totalFeesPt * 10000n) / avgLiquidity) / 100) * annualizationFactor
|
|
2509
|
-
const feeApyTotal = feeApySy + feeApyPt
|
|
2510
|
-
|
|
2511
|
-
return {
|
|
2512
|
-
feeApySy,
|
|
2513
|
-
feeApyPt,
|
|
2514
|
-
feeApyTotal,
|
|
2515
|
-
totalFeesSy,
|
|
2516
|
-
totalFeesPt,
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
depositYtAccounts({
|
|
2521
|
-
owner,
|
|
2522
|
-
ytSrc: ytSrcParam,
|
|
2523
|
-
}: {
|
|
2524
|
-
owner: PublicKey
|
|
2525
|
-
ytSrc?: PublicKey
|
|
2526
|
-
}): TransactionInstruction {
|
|
2527
|
-
const ytSrc = ytSrcParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
2528
|
-
const userYieldPosition = this.corePda.yieldPosition({ vault: this.state.vault.selfAddress, owner })
|
|
2529
|
-
const yieldPosition = this.corePda.vaultYieldPosition({ vault: this.state.vault.selfAddress })
|
|
2530
|
-
const escrowYt = this.corePda.escrowYt({ vault: this.state.vault.selfAddress })
|
|
2531
|
-
const mainAccounts = {
|
|
2532
|
-
depositor: owner,
|
|
2533
|
-
ytSrc,
|
|
2534
|
-
vault: this.state.vault.selfAddress,
|
|
2535
|
-
userYieldPosition,
|
|
2536
|
-
escrowYt,
|
|
2537
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2538
|
-
syProgram: this.state.syProgram,
|
|
2539
|
-
addressLookupTable: this.vault.addressLookupTable,
|
|
2540
|
-
yieldPosition,
|
|
2541
|
-
systemProgram: SystemProgram.programId,
|
|
2542
|
-
eventAuthority: this.coreEventAuthority,
|
|
2543
|
-
program: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
2544
|
-
}
|
|
2545
|
-
const remainingAccounts = this.cpiSyAccounts.getSyState
|
|
2546
|
-
|
|
2547
|
-
const depositIx = exponentCore.createDepositYtInstruction(mainAccounts, { amount: 0n })
|
|
2548
|
-
depositIx.keys.push(...remainingAccounts)
|
|
2549
|
-
|
|
2550
|
-
return depositIx
|
|
2551
|
-
}
|
|
2552
|
-
|
|
2553
|
-
withdrawYtAccounts({
|
|
2554
|
-
owner,
|
|
2555
|
-
ytDst: ytDstParam,
|
|
2556
|
-
}: {
|
|
2557
|
-
owner: PublicKey
|
|
2558
|
-
ytDst?: PublicKey
|
|
2559
|
-
}): TransactionInstruction {
|
|
2560
|
-
const ytDst = ytDstParam || getAssociatedTokenAddressSync(this.mintYt, owner, true, TOKEN_PROGRAM_ID)
|
|
2561
|
-
const userYieldPosition = this.corePda.yieldPosition({ vault: this.state.vault.selfAddress, owner })
|
|
2562
|
-
const yieldPosition = this.corePda.vaultYieldPosition({ vault: this.state.vault.selfAddress })
|
|
2563
|
-
const escrowYt = this.corePda.escrowYt({ vault: this.state.vault.selfAddress })
|
|
2564
|
-
const mainAccounts = {
|
|
2565
|
-
owner,
|
|
2566
|
-
vault: this.state.vault.selfAddress,
|
|
2567
|
-
userYieldPosition,
|
|
2568
|
-
ytDst,
|
|
2569
|
-
escrowYt,
|
|
2570
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
2571
|
-
authority: this.vault.authority,
|
|
2572
|
-
syProgram: this.state.syProgram,
|
|
2573
|
-
addressLookupTable: this.vault.addressLookupTable,
|
|
2574
|
-
yieldPosition,
|
|
2575
|
-
systemProgram: SystemProgram.programId,
|
|
2576
|
-
eventAuthority: this.coreEventAuthority,
|
|
2577
|
-
program: exponentCore.EXPONENTCORE_PROGRAM_ID,
|
|
2578
|
-
}
|
|
2579
|
-
const remainingAccounts = this.cpiSyAccounts.getSyState
|
|
2580
|
-
|
|
2581
|
-
const withdrawIx = exponentCore.createWithdrawYtInstruction(mainAccounts, { amount: 0n })
|
|
2582
|
-
withdrawIx.keys.push(...remainingAccounts)
|
|
2583
|
-
|
|
2584
|
-
return withdrawIx
|
|
2585
|
-
}
|
|
2586
|
-
|
|
2587
|
-
/**
|
|
2588
|
-
* Estimate the yield (fees + emissions) a hypothetical LP position would have earned
|
|
2589
|
-
* between two market snapshots.
|
|
2590
|
-
*
|
|
2591
|
-
* @param marketSnapshotDataCurrent - The more recent market snapshot
|
|
2592
|
-
* @param marketSnapshotDataHistory - The older market snapshot (defines the look-back window)
|
|
2593
|
-
* @param lowerPricePercentage - Lower price bound as a percentage (e.g. 5 for 5%)
|
|
2594
|
-
* @param upperPricePercentage - Upper price bound as a percentage
|
|
2595
|
-
* @param baseTokenAmount - Amount of base tokens in the hypothetical position
|
|
2596
|
-
*/
|
|
2597
|
-
static calcEstimatedYieldForPosition(
|
|
2598
|
-
marketSnapshotDataCurrent: MarketSnapshotData,
|
|
2599
|
-
marketSnapshotDataHistory: MarketSnapshotData,
|
|
2600
|
-
lowerPricePercentage: number,
|
|
2601
|
-
upperPricePercentage: number,
|
|
2602
|
-
baseTokenAmount: number,
|
|
2603
|
-
) {
|
|
2604
|
-
//? Prices in format of 1 + percentage / 100
|
|
2605
|
-
const lowerPrice = 1 + lowerPricePercentage / 100
|
|
2606
|
-
//? Prices in format of 1 + percentage / 100
|
|
2607
|
-
const upperPrice = 1 + upperPricePercentage / 100
|
|
2608
|
-
|
|
2609
|
-
const { syNeeded: userSyProvided, ptNeeded: userPtProvided } = calcDepositSyAndPtFromBaseAmount({
|
|
2610
|
-
expirationTs:
|
|
2611
|
-
Number(marketSnapshotDataCurrent.financials.expirationTs) - marketSnapshotDataCurrent.snapshotTimeUnix,
|
|
2612
|
-
currentSpotPrice: marketSnapshotDataCurrent.currentSpotPrice,
|
|
2613
|
-
syExchangeRate: marketSnapshotDataCurrent.syExchangeRate,
|
|
2614
|
-
lowerPrice,
|
|
2615
|
-
upperPrice,
|
|
2616
|
-
baseTokenAmount: baseTokenAmount,
|
|
2617
|
-
})
|
|
2618
|
-
|
|
2619
|
-
const [lowerFeeGrowthOutsidePtHistory, lowerFeeGrowthOutsideSyHistory] =
|
|
2620
|
-
lowerPrice <= marketSnapshotDataHistory.currentSpotPrice
|
|
2621
|
-
? [marketSnapshotDataHistory.feeGrowthIndexGlobalPt, marketSnapshotDataHistory.feeGrowthIndexGlobalSy]
|
|
2622
|
-
: [0n, 0n]
|
|
2623
|
-
|
|
2624
|
-
const [upperFeeGrowthOutsidePtHistory, upperFeeGrowthOutsideSyHistory] =
|
|
2625
|
-
upperPrice <= marketSnapshotDataHistory.currentSpotPrice
|
|
2626
|
-
? [marketSnapshotDataHistory.feeGrowthIndexGlobalPt, marketSnapshotDataHistory.feeGrowthIndexGlobalSy]
|
|
2627
|
-
: [0n, 0n]
|
|
2628
|
-
|
|
2629
|
-
const { insideSy: insideSyHistory, insidePt: insidePtHistory } = MarketThree.computeFeeInsideForRange({
|
|
2630
|
-
currentTickPrice: marketSnapshotDataHistory.currentSpotPrice,
|
|
2631
|
-
lowerTickPrice: lowerPrice,
|
|
2632
|
-
upperTickPrice: upperPrice,
|
|
2633
|
-
feeGrowthIndexGlobalPt: marketSnapshotDataHistory.feeGrowthIndexGlobalPt,
|
|
2634
|
-
feeGrowthIndexGlobalSy: marketSnapshotDataHistory.feeGrowthIndexGlobalSy,
|
|
2635
|
-
lowerTickOutsidePt: lowerFeeGrowthOutsidePtHistory,
|
|
2636
|
-
lowerTickOutsideSy: lowerFeeGrowthOutsideSyHistory,
|
|
2637
|
-
upperTickOutsidePt: upperFeeGrowthOutsidePtHistory,
|
|
2638
|
-
upperTickOutsideSy: upperFeeGrowthOutsideSyHistory,
|
|
2639
|
-
})
|
|
2640
|
-
|
|
2641
|
-
const {
|
|
2642
|
-
liquidityTarget: liquidityTargetCurrent,
|
|
2643
|
-
syNeeded,
|
|
2644
|
-
ptNeeded,
|
|
2645
|
-
} = computeLiquidityTargetAndTokenNeedsForSnapshot(marketSnapshotDataCurrent, {
|
|
2646
|
-
lowerPrice,
|
|
2647
|
-
upperPrice,
|
|
2648
|
-
maxSy: userSyProvided,
|
|
2649
|
-
maxPt: userPtProvided,
|
|
2650
|
-
})
|
|
2651
|
-
|
|
2652
|
-
const { insideSy: insideSyCurrent, insidePt: insidePtCurrent } = MarketThree.computeFeeInsideForRange({
|
|
2653
|
-
currentTickPrice: marketSnapshotDataCurrent.currentSpotPrice,
|
|
2654
|
-
lowerTickPrice: lowerPrice,
|
|
2655
|
-
upperTickPrice: upperPrice,
|
|
2656
|
-
feeGrowthIndexGlobalPt: BigInt(marketSnapshotDataCurrent.feeGrowthIndexGlobalPt),
|
|
2657
|
-
feeGrowthIndexGlobalSy: BigInt(marketSnapshotDataCurrent.feeGrowthIndexGlobalSy),
|
|
2658
|
-
lowerTickOutsidePt: BigInt(lowerFeeGrowthOutsidePtHistory),
|
|
2659
|
-
lowerTickOutsideSy: BigInt(lowerFeeGrowthOutsideSyHistory),
|
|
2660
|
-
upperTickOutsidePt: BigInt(upperFeeGrowthOutsidePtHistory),
|
|
2661
|
-
upperTickOutsideSy: BigInt(upperFeeGrowthOutsideSyHistory),
|
|
2662
|
-
})
|
|
2663
|
-
|
|
2664
|
-
//? Single invocation
|
|
2665
|
-
const { claimablePt: ptExpectedFees, claimableSy: syExpectedFees } = MarketThree.calculateClaimableFees({
|
|
2666
|
-
lpBalance: BigInt(liquidityTargetCurrent),
|
|
2667
|
-
feeInsideLastSy: insideSyHistory,
|
|
2668
|
-
feeInsideLastPt: insidePtHistory,
|
|
2669
|
-
currentInsideSy: insideSyCurrent,
|
|
2670
|
-
currentInsidePt: insidePtCurrent,
|
|
2671
|
-
tokensOwedSy: 0n,
|
|
2672
|
-
tokensOwedPt: 0n,
|
|
2673
|
-
})
|
|
2674
|
-
|
|
2675
|
-
//? As we don't have autocompounding, use 1 as annualization factor
|
|
2676
|
-
const ANNUALIZATION_FACTOR = 1
|
|
2677
|
-
|
|
2678
|
-
//? Convert SY amounts to baseToken: baseToken = syAmount / syExchangeRate
|
|
2679
|
-
const syNeededBaseToken = syNeeded > 0 ? syNeeded * marketSnapshotDataCurrent.syExchangeRate : 0
|
|
2680
|
-
const syExpectedFeesBaseToken =
|
|
2681
|
-
syExpectedFees > 0n ? Number(syExpectedFees) * marketSnapshotDataCurrent.syExchangeRate : 0
|
|
2682
|
-
|
|
2683
|
-
const ptPriceInBaseToken = calcPtPriceInAsset(
|
|
2684
|
-
marketSnapshotDataCurrent.currentSpotPrice,
|
|
2685
|
-
Number(marketSnapshotDataCurrent.financials.expirationTs) - marketSnapshotDataCurrent.snapshotTimeUnix,
|
|
2686
|
-
)
|
|
2687
|
-
|
|
2688
|
-
const ptNeededBaseToken = ptNeeded * ptPriceInBaseToken
|
|
2689
|
-
const ptExpectedFeesBaseToken = Number(ptExpectedFees) * ptPriceInBaseToken
|
|
2690
|
-
|
|
2691
|
-
//? Calculate total baseToken value of the position
|
|
2692
|
-
const totalPositionValueBaseToken = syNeededBaseToken + ptNeededBaseToken
|
|
2693
|
-
|
|
2694
|
-
//? Calculate total fees earned in baseToken
|
|
2695
|
-
const totalFeesBaseToken = syExpectedFeesBaseToken + ptExpectedFeesBaseToken
|
|
2696
|
-
|
|
2697
|
-
//? Calculate unified fee rate: total fees / total position value
|
|
2698
|
-
const totalFeeRate = totalPositionValueBaseToken > 0 ? totalFeesBaseToken / totalPositionValueBaseToken : 0
|
|
2699
|
-
|
|
2700
|
-
//? Annualize the fee rate
|
|
2701
|
-
const totalFeeRateAnnualized = totalFeeRate * ANNUALIZATION_FACTOR
|
|
2702
|
-
|
|
2703
|
-
return {
|
|
2704
|
-
totalFeeRate: totalFeeRateAnnualized,
|
|
2705
|
-
ptExpectedFees,
|
|
2706
|
-
syExpectedFees,
|
|
2707
|
-
expectedFeesBaseToken: totalFeesBaseToken,
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
/**
|
|
2712
|
-
* Calculate TVL (Total Value Locked) in baseToken for a market
|
|
2713
|
-
*
|
|
2714
|
-
* @param currentSpotPrice - Current spot price in format of 1 + percentage / 100
|
|
2715
|
-
* @param financials - Market financials containing balances and expiration timestamp
|
|
2716
|
-
* @param syExchangeRate - SY exchange rate
|
|
2717
|
-
* @param timestampUnix - Timestamp in seconds (defaults to current time)
|
|
2718
|
-
* @returns Object with TVL breakdown: total TVL, PT liquidity, and SY liquidity in baseToken
|
|
2719
|
-
*/
|
|
2720
|
-
static calcTvlInBaseToken(params: {
|
|
2721
|
-
financials: MarketThreeFinancials
|
|
2722
|
-
currentSpotPrice: number
|
|
2723
|
-
syExchangeRate: number
|
|
2724
|
-
timestampUnix?: number
|
|
2725
|
-
}): {
|
|
2726
|
-
tvlInBaseToken: number
|
|
2727
|
-
ptLiquidityInBaseToken: number
|
|
2728
|
-
syLiquidityInBaseToken: number
|
|
2729
|
-
} {
|
|
2730
|
-
const { financials, currentSpotPrice, syExchangeRate, timestampUnix = Date.now() / 1000 } = params
|
|
2731
|
-
|
|
2732
|
-
const secondsRemaining = Math.max(0, Number(financials.expirationTs) - timestampUnix)
|
|
2733
|
-
|
|
2734
|
-
const ptPriceInBaseToken = calcPtPriceInAsset(currentSpotPrice, secondsRemaining)
|
|
2735
|
-
|
|
2736
|
-
const ptLiquidityInBaseToken = Number(financials.ptBalance) * ptPriceInBaseToken
|
|
2737
|
-
const syLiquidityInBaseToken = Number(financials.syBalance) * syExchangeRate
|
|
2738
|
-
const tvlInBaseToken = ptLiquidityInBaseToken + syLiquidityInBaseToken
|
|
2739
|
-
|
|
2740
|
-
return {
|
|
2741
|
-
tvlInBaseToken: Math.round(tvlInBaseToken),
|
|
2742
|
-
ptLiquidityInBaseToken: Math.round(ptLiquidityInBaseToken),
|
|
2743
|
-
syLiquidityInBaseToken: Math.round(syLiquidityInBaseToken),
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
|
|
2747
|
-
static calcGlobalFeeRate(
|
|
2748
|
-
marketSnapshotDataCurrent: MarketSnapshotData,
|
|
2749
|
-
marketSnapshotDataHistory: MarketSnapshotData,
|
|
2750
|
-
) {
|
|
2751
|
-
const {
|
|
2752
|
-
financials: financialsCurrent,
|
|
2753
|
-
feeGrowthIndexGlobalPt: feeGrowthIndexGlobalPtCurrent,
|
|
2754
|
-
feeGrowthIndexGlobalSy: feeGrowthIndexGlobalSyCurrent,
|
|
2755
|
-
currentSpotPrice,
|
|
2756
|
-
currentPrefixSum,
|
|
2757
|
-
syExchangeRate,
|
|
2758
|
-
} = marketSnapshotDataCurrent
|
|
2759
|
-
|
|
2760
|
-
const {
|
|
2761
|
-
feeGrowthIndexGlobalPt: feeGrowthIndexGlobalPtHistory,
|
|
2762
|
-
feeGrowthIndexGlobalSy: feeGrowthIndexGlobalSyHistory,
|
|
2763
|
-
} = marketSnapshotDataHistory
|
|
2764
|
-
|
|
2765
|
-
const ptPriceInBaseToken = calcPtPriceInAsset(
|
|
2766
|
-
currentSpotPrice,
|
|
2767
|
-
Number(financialsCurrent.expirationTs) - marketSnapshotDataCurrent.snapshotTimeUnix,
|
|
2768
|
-
)
|
|
2769
|
-
|
|
2770
|
-
const feePt = Number(feeGrowthIndexGlobalPtCurrent - feeGrowthIndexGlobalPtHistory) / Number(currentPrefixSum)
|
|
2771
|
-
const feePtInBaseToken = feePt * ptPriceInBaseToken
|
|
2772
|
-
|
|
2773
|
-
const feeSy = Number(feeGrowthIndexGlobalSyCurrent - feeGrowthIndexGlobalSyHistory) / Number(currentPrefixSum)
|
|
2774
|
-
const feeSyInBaseToken = feeSy * syExchangeRate
|
|
2775
|
-
|
|
2776
|
-
const totalFeesInBaseToken = feePtInBaseToken + feeSyInBaseToken
|
|
2777
|
-
|
|
2778
|
-
const ptLiquidityInBaseToken = Number(financialsCurrent.ptBalance) * ptPriceInBaseToken
|
|
2779
|
-
const syLiquidityInBaseToken = Number(financialsCurrent.syBalance) * syExchangeRate
|
|
2780
|
-
const tvlInBaseToken = ptLiquidityInBaseToken + syLiquidityInBaseToken
|
|
2781
|
-
|
|
2782
|
-
const totalFeeRate = totalFeesInBaseToken / tvlInBaseToken
|
|
2783
|
-
|
|
2784
|
-
return {
|
|
2785
|
-
totalFeeRate,
|
|
2786
|
-
totalFeesInBaseToken,
|
|
2787
|
-
tvlInBaseToken,
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
|
|
2791
|
-
/**
|
|
2792
|
-
* Returns PT and SY amounts that will be received on liquidity removal from a position
|
|
2793
|
-
* If liquidityToRemove is not provided, assume that the full position balance will be removed
|
|
2794
|
-
*/
|
|
2795
|
-
getPtAndSyOnWithdrawLiquidity(position: LpPositionCLMM, liquidityToRemove?: bigint) {
|
|
2796
|
-
const { ticks, emissions } = this.state
|
|
2797
|
-
|
|
2798
|
-
return getPtAndSyOnWithdrawLiquidity(emissions, ticks, position, liquidityToRemove ?? position.lpBalance)
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
|
|
2802
|
-
/**
|
|
2803
|
-
* Convert apy percents to input format
|
|
2804
|
-
*/
|
|
2805
|
-
function convertApyToApyBp(price: number): number {
|
|
2806
|
-
return price * 1e4
|
|
2807
|
-
}
|
|
2808
|
-
|
|
2809
|
-
/** Market snapshot data for CLMM market */
|
|
2810
|
-
export type MarketSnapshotData = {
|
|
2811
|
-
syExchangeRate: number
|
|
2812
|
-
/** Current spot price in format of 1 + percentage / 100 */
|
|
2813
|
-
currentSpotPrice: number
|
|
2814
|
-
financials: MarketThreeFinancials
|
|
2815
|
-
feeGrowthIndexGlobalPt: bigint
|
|
2816
|
-
feeGrowthIndexGlobalSy: bigint
|
|
2817
|
-
currentPrefixSum: bigint
|
|
2818
|
-
snapshotTimeUnix: number
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
/** Wrapper for computeLiquidityTargetAndTokenNeeds that takes a MarketSnapshotData as input */
|
|
2822
|
-
function computeLiquidityTargetAndTokenNeedsForSnapshot(
|
|
2823
|
-
marketSnapshotData: MarketSnapshotData,
|
|
2824
|
-
params: {
|
|
2825
|
-
/** lowerPrice in format of 1 + percentage / 100 */
|
|
2826
|
-
lowerPrice: number
|
|
2827
|
-
/** lowerPrice in format of 1 + percentage / 100 */
|
|
2828
|
-
upperPrice: number
|
|
2829
|
-
maxSy: number
|
|
2830
|
-
maxPt: number
|
|
2831
|
-
},
|
|
2832
|
-
) {
|
|
2833
|
-
const EPSILON_CLAMP = 1e-18
|
|
2834
|
-
|
|
2835
|
-
const { lowerPrice, upperPrice, maxSy, maxPt } = params
|
|
2836
|
-
const { financials, currentSpotPrice, syExchangeRate, snapshotTimeUnix } = marketSnapshotData
|
|
2837
|
-
|
|
2838
|
-
const expirationTsNumber = Number(financials.expirationTs)
|
|
2839
|
-
|
|
2840
|
-
const secondsRemaining = Math.max(0, expirationTsNumber - snapshotTimeUnix)
|
|
2841
|
-
|
|
2842
|
-
const effSnap = new EffSnap(normalizedTimeRemaining(secondsRemaining), syExchangeRate)
|
|
2843
|
-
|
|
2844
|
-
const priceEffLower = effSnap.getEffectivePrice(lowerPrice)
|
|
2845
|
-
const priceEffUpper = effSnap.getEffectivePrice(upperPrice)
|
|
2846
|
-
|
|
2847
|
-
return computeLiquidityTargetAndTokenNeeds(
|
|
2848
|
-
effSnap,
|
|
2849
|
-
currentSpotPrice,
|
|
2850
|
-
priceEffLower,
|
|
2851
|
-
priceEffUpper,
|
|
2852
|
-
lowerPrice,
|
|
2853
|
-
upperPrice,
|
|
2854
|
-
0,
|
|
2855
|
-
0,
|
|
2856
|
-
0,
|
|
2857
|
-
maxSy,
|
|
2858
|
-
maxPt,
|
|
2859
|
-
EPSILON_CLAMP,
|
|
2860
|
-
)
|
|
2861
|
-
}
|