@exponent-labs/exponent-sdk 0.1.8 → 0.9.0
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/CodamaEventDecoder.d.ts +49 -0
- package/build/CodamaEventDecoder.js +113 -0
- package/build/CodamaEventDecoder.js.map +1 -0
- package/build/addressLookupTableUtil.d.ts +23 -18
- package/build/addressLookupTableUtil.js +31 -5
- package/build/addressLookupTableUtil.js.map +1 -1
- package/build/client/clmm/accounts/lpPosition.d.ts +29 -0
- package/build/client/clmm/accounts/lpPosition.js +82 -0
- package/build/client/clmm/accounts/lpPosition.js.map +1 -0
- package/build/client/clmm/accounts/marketThree.d.ts +47 -0
- package/build/client/clmm/accounts/marketThree.js +139 -0
- package/build/client/clmm/accounts/marketThree.js.map +1 -0
- package/build/client/clmm/accounts/vault.d.ts +48 -0
- package/build/client/clmm/accounts/vault.js +128 -0
- package/build/client/clmm/accounts/vault.js.map +1 -0
- package/build/client/clmm/eventRegistry.d.ts +59 -0
- package/build/client/clmm/eventRegistry.js +58 -0
- package/build/client/clmm/eventRegistry.js.map +1 -0
- package/build/client/clmm/index.d.ts +78 -0
- package/build/client/clmm/index.js +96 -0
- package/build/client/clmm/index.js.map +1 -0
- package/build/client/clmm/instructions/addFarm.d.ts +19 -0
- package/build/client/clmm/instructions/addFarm.js +31 -0
- package/build/client/clmm/instructions/addFarm.js.map +1 -0
- package/build/client/clmm/instructions/addLiquidity.d.ts +26 -0
- package/build/client/clmm/instructions/addLiquidity.js +38 -0
- package/build/client/clmm/instructions/addLiquidity.js.map +1 -0
- package/build/client/clmm/instructions/addMarketEmission.d.ts +15 -0
- package/build/client/clmm/instructions/addMarketEmission.js +27 -0
- package/build/client/clmm/instructions/addMarketEmission.js.map +1 -0
- package/build/client/clmm/instructions/buyPt.d.ts +24 -0
- package/build/client/clmm/instructions/buyPt.js +36 -0
- package/build/client/clmm/instructions/buyPt.js.map +1 -0
- package/build/client/clmm/instructions/buyYt.d.ts +26 -0
- package/build/client/clmm/instructions/buyYt.js +42 -0
- package/build/client/clmm/instructions/buyYt.js.map +1 -0
- package/build/client/clmm/instructions/claimFarmEmission.d.ts +18 -0
- package/build/client/clmm/instructions/claimFarmEmission.js +30 -0
- package/build/client/clmm/instructions/claimFarmEmission.js.map +1 -0
- package/build/client/clmm/instructions/closeMarket.d.ts +17 -0
- package/build/client/clmm/instructions/closeMarket.js +26 -0
- package/build/client/clmm/instructions/closeMarket.js.map +1 -0
- package/build/client/clmm/instructions/depositLiquidity.d.ts +25 -0
- package/build/client/clmm/instructions/depositLiquidity.js +37 -0
- package/build/client/clmm/instructions/depositLiquidity.js.map +1 -0
- package/build/client/clmm/instructions/initializeMarket.d.ts +47 -0
- package/build/client/clmm/instructions/initializeMarket.js +63 -0
- package/build/client/clmm/instructions/initializeMarket.js.map +1 -0
- package/build/client/clmm/instructions/marketAccrueEmission.d.ts +13 -0
- package/build/client/clmm/instructions/marketAccrueEmission.js +22 -0
- package/build/client/clmm/instructions/marketAccrueEmission.js.map +1 -0
- package/build/client/clmm/instructions/marketCollectEmission.d.ts +18 -0
- package/build/client/clmm/instructions/marketCollectEmission.js +30 -0
- package/build/client/clmm/instructions/marketCollectEmission.js.map +1 -0
- package/build/client/clmm/instructions/modifyFarm.d.ts +17 -0
- package/build/client/clmm/instructions/modifyFarm.js +29 -0
- package/build/client/clmm/instructions/modifyFarm.js.map +1 -0
- package/build/client/clmm/instructions/modifyMarketSetting.d.ts +11 -0
- package/build/client/clmm/instructions/modifyMarketSetting.js +23 -0
- package/build/client/clmm/instructions/modifyMarketSetting.js.map +1 -0
- package/build/client/clmm/instructions/sellPt.d.ts +24 -0
- package/build/client/clmm/instructions/sellPt.js +36 -0
- package/build/client/clmm/instructions/sellPt.js.map +1 -0
- package/build/client/clmm/instructions/sellYt.d.ts +26 -0
- package/build/client/clmm/instructions/sellYt.js +42 -0
- package/build/client/clmm/instructions/sellYt.js.map +1 -0
- package/build/client/clmm/instructions/tradePt.d.ts +25 -0
- package/build/client/clmm/instructions/tradePt.js +37 -0
- package/build/client/clmm/instructions/tradePt.js.map +1 -0
- package/build/client/clmm/instructions/tradePtExactOut.d.ts +25 -0
- package/build/client/clmm/instructions/tradePtExactOut.js +37 -0
- package/build/client/clmm/instructions/tradePtExactOut.js.map +1 -0
- package/build/client/clmm/instructions/withdrawLiquidity.d.ts +23 -0
- package/build/client/clmm/instructions/withdrawLiquidity.js +35 -0
- package/build/client/clmm/instructions/withdrawLiquidity.js.map +1 -0
- package/build/client/clmm/instructions/wrapperBuyYt.d.ts +28 -0
- package/build/client/clmm/instructions/wrapperBuyYt.js +48 -0
- package/build/client/clmm/instructions/wrapperBuyYt.js.map +1 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidity.d.ts +33 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidity.js +53 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidity.js.map +1 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidityBase.d.ts +32 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidityBase.js +52 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidityBase.js.map +1 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.d.ts +28 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.js +44 -0
- package/build/client/clmm/instructions/wrapperProvideLiquidityClassic.js.map +1 -0
- package/build/client/clmm/instructions/wrapperSellYt.d.ts +27 -0
- package/build/client/clmm/instructions/wrapperSellYt.js +47 -0
- package/build/client/clmm/instructions/wrapperSellYt.js.map +1 -0
- package/build/client/clmm/instructions/wrapperWithdrawLiquidity.d.ts +25 -0
- package/build/client/clmm/instructions/wrapperWithdrawLiquidity.js +41 -0
- package/build/client/clmm/instructions/wrapperWithdrawLiquidity.js.map +1 -0
- package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.d.ts +22 -0
- package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.js +38 -0
- package/build/client/clmm/instructions/wrapperWithdrawLiquidityClassic.js.map +1 -0
- package/build/client/clmm/types/addFarmEvent.d.ts +35 -0
- package/build/client/clmm/types/addFarmEvent.js +24 -0
- package/build/client/clmm/types/addFarmEvent.js.map +1 -0
- package/build/client/clmm/types/amount.d.ts +33 -0
- package/build/client/clmm/types/amount.js +20 -0
- package/build/client/clmm/types/amount.js.map +1 -0
- package/build/client/clmm/types/buyPtEvent.d.ts +23 -0
- package/build/client/clmm/types/buyPtEvent.js +18 -0
- package/build/client/clmm/types/buyPtEvent.js.map +1 -0
- package/build/client/clmm/types/buyYtEvent.d.ts +56 -0
- package/build/client/clmm/types/buyYtEvent.js +36 -0
- package/build/client/clmm/types/buyYtEvent.js.map +1 -0
- package/build/client/clmm/types/claimFarmEmissionsEvent.d.ts +171 -0
- package/build/client/clmm/types/claimFarmEmissionsEvent.js +42 -0
- package/build/client/clmm/types/claimFarmEmissionsEvent.js.map +1 -0
- package/build/client/clmm/types/claimLimits.d.ts +22 -0
- package/build/client/clmm/types/claimLimits.js +11 -0
- package/build/client/clmm/types/claimLimits.js.map +1 -0
- package/build/client/clmm/types/closeMarketEvent.d.ts +23 -0
- package/build/client/clmm/types/closeMarketEvent.js +18 -0
- package/build/client/clmm/types/closeMarketEvent.js.map +1 -0
- package/build/client/clmm/types/configurationOptions.d.ts +34 -0
- package/build/client/clmm/types/configurationOptions.js +14 -0
- package/build/client/clmm/types/configurationOptions.js.map +1 -0
- package/build/client/clmm/types/cpiAccounts.d.ts +107 -0
- package/build/client/clmm/types/cpiAccounts.js +13 -0
- package/build/client/clmm/types/cpiAccounts.js.map +1 -0
- package/build/client/clmm/types/cpiCoreAccounts.d.ts +47 -0
- package/build/client/clmm/types/cpiCoreAccounts.js +10 -0
- package/build/client/clmm/types/cpiCoreAccounts.js.map +1 -0
- package/build/client/clmm/types/cpiInterfaceContext.d.ts +18 -0
- package/build/client/clmm/types/cpiInterfaceContext.js +10 -0
- package/build/client/clmm/types/cpiInterfaceContext.js.map +1 -0
- package/build/client/clmm/types/crossingSplit.d.ts +124 -0
- package/build/client/clmm/types/crossingSplit.js +20 -0
- package/build/client/clmm/types/crossingSplit.js.map +1 -0
- package/build/client/clmm/types/depositLiquidityEvent.d.ts +171 -0
- package/build/client/clmm/types/depositLiquidityEvent.js +42 -0
- package/build/client/clmm/types/depositLiquidityEvent.js.map +1 -0
- package/build/client/clmm/types/depositLiquidityReturnData.d.ts +67 -0
- package/build/client/clmm/types/depositLiquidityReturnData.js +38 -0
- package/build/client/clmm/types/depositLiquidityReturnData.js.map +1 -0
- package/build/client/clmm/types/emissionInfo.d.ts +36 -0
- package/build/client/clmm/types/emissionInfo.js +22 -0
- package/build/client/clmm/types/emissionInfo.js.map +1 -0
- package/build/client/clmm/types/farmEmission.d.ts +24 -0
- package/build/client/clmm/types/farmEmission.js +16 -0
- package/build/client/clmm/types/farmEmission.js.map +1 -0
- package/build/client/clmm/types/index.d.ts +48 -0
- package/build/client/clmm/types/index.js +65 -0
- package/build/client/clmm/types/index.js.map +1 -0
- package/build/client/clmm/types/liquidityNetBalanceLimits.d.ts +26 -0
- package/build/client/clmm/types/liquidityNetBalanceLimits.js +12 -0
- package/build/client/clmm/types/liquidityNetBalanceLimits.js.map +1 -0
- package/build/client/clmm/types/lpFarm.d.ts +35 -0
- package/build/client/clmm/types/lpFarm.js +10 -0
- package/build/client/clmm/types/lpFarm.js.map +1 -0
- package/build/client/clmm/types/marketAccrueEmissionEvent.d.ts +151 -0
- package/build/client/clmm/types/marketAccrueEmissionEvent.js +31 -0
- package/build/client/clmm/types/marketAccrueEmissionEvent.js.map +1 -0
- package/build/client/clmm/types/marketAdminAction.d.ts +359 -0
- package/build/client/clmm/types/marketAdminAction.js +72 -0
- package/build/client/clmm/types/marketAdminAction.js.map +1 -0
- package/build/client/clmm/types/marketCollectEmissionEvent.d.ts +163 -0
- package/build/client/clmm/types/marketCollectEmissionEvent.js +37 -0
- package/build/client/clmm/types/marketCollectEmissionEvent.js.map +1 -0
- package/build/client/clmm/types/marketEmission.d.ts +20 -0
- package/build/client/clmm/types/marketEmission.js +15 -0
- package/build/client/clmm/types/marketEmission.js.map +1 -0
- package/build/client/clmm/types/marketEmissions.d.ts +27 -0
- package/build/client/clmm/types/marketEmissions.js +9 -0
- package/build/client/clmm/types/marketEmissions.js.map +1 -0
- package/build/client/clmm/types/marketFinancials.d.ts +26 -0
- package/build/client/clmm/types/marketFinancials.js +12 -0
- package/build/client/clmm/types/marketFinancials.js.map +1 -0
- package/build/client/clmm/types/marketThreeInitEvent.d.ts +71 -0
- package/build/client/clmm/types/marketThreeInitEvent.js +42 -0
- package/build/client/clmm/types/marketThreeInitEvent.js.map +1 -0
- package/build/client/clmm/types/mergeEvent.d.ts +84 -0
- package/build/client/clmm/types/mergeEvent.js +55 -0
- package/build/client/clmm/types/mergeEvent.js.map +1 -0
- package/build/client/clmm/types/modifiedTick.d.ts +18 -0
- package/build/client/clmm/types/modifiedTick.js +10 -0
- package/build/client/clmm/types/modifiedTick.js.map +1 -0
- package/build/client/clmm/types/modifiedTicks.d.ts +43 -0
- package/build/client/clmm/types/modifiedTicks.js +13 -0
- package/build/client/clmm/types/modifiedTicks.js.map +1 -0
- package/build/client/clmm/types/modifyFarmEvent.d.ts +43 -0
- package/build/client/clmm/types/modifyFarmEvent.js +26 -0
- package/build/client/clmm/types/modifyFarmEvent.js.map +1 -0
- package/build/client/clmm/types/number.d.ts +2 -0
- package/build/client/clmm/types/number.js +8 -0
- package/build/client/clmm/types/number.js.map +1 -0
- package/build/client/clmm/types/personalYieldTracker.d.ts +15 -0
- package/build/client/clmm/types/personalYieldTracker.js +10 -0
- package/build/client/clmm/types/personalYieldTracker.js.map +1 -0
- package/build/client/clmm/types/personalYieldTrackers.d.ts +23 -0
- package/build/client/clmm/types/personalYieldTrackers.js +9 -0
- package/build/client/clmm/types/personalYieldTrackers.js.map +1 -0
- package/build/client/clmm/types/principalShare.d.ts +51 -0
- package/build/client/clmm/types/principalShare.js +14 -0
- package/build/client/clmm/types/principalShare.js.map +1 -0
- package/build/client/clmm/types/principalShareTrackers.d.ts +63 -0
- package/build/client/clmm/types/principalShareTrackers.js +9 -0
- package/build/client/clmm/types/principalShareTrackers.js.map +1 -0
- package/build/client/clmm/types/sellPtEvent.d.ts +23 -0
- package/build/client/clmm/types/sellPtEvent.js +18 -0
- package/build/client/clmm/types/sellPtEvent.js.map +1 -0
- package/build/client/clmm/types/sellYtEvent.d.ts +47 -0
- package/build/client/clmm/types/sellYtEvent.js +33 -0
- package/build/client/clmm/types/sellYtEvent.js.map +1 -0
- package/build/client/clmm/types/stripEvent.d.ts +84 -0
- package/build/client/clmm/types/stripEvent.js +58 -0
- package/build/client/clmm/types/stripEvent.js.map +1 -0
- package/build/client/clmm/types/swapDirection.d.ts +5 -0
- package/build/client/clmm/types/swapDirection.js +11 -0
- package/build/client/clmm/types/swapDirection.js.map +1 -0
- package/build/client/clmm/types/tradePtEvent.d.ts +110 -0
- package/build/client/clmm/types/tradePtEvent.js +37 -0
- package/build/client/clmm/types/tradePtEvent.js.map +1 -0
- package/build/client/clmm/types/withdrawLiquidityEvent.d.ts +183 -0
- package/build/client/clmm/types/withdrawLiquidityEvent.js +45 -0
- package/build/client/clmm/types/withdrawLiquidityEvent.js.map +1 -0
- package/build/client/clmm/types/withdrawLiquidityReturnData.d.ts +46 -0
- package/build/client/clmm/types/withdrawLiquidityReturnData.js +17 -0
- package/build/client/clmm/types/withdrawLiquidityReturnData.js.map +1 -0
- package/build/client/clmm/types/wrapperBuyYtEvent.d.ts +23 -0
- package/build/client/clmm/types/wrapperBuyYtEvent.js +18 -0
- package/build/client/clmm/types/wrapperBuyYtEvent.js.map +1 -0
- package/build/client/clmm/types/wrapperProvideLiquidityBaseEvent.d.ts +56 -0
- package/build/client/clmm/types/wrapperProvideLiquidityBaseEvent.js +30 -0
- package/build/client/clmm/types/wrapperProvideLiquidityBaseEvent.js.map +1 -0
- package/build/client/clmm/types/wrapperProvideLiquidityClassicEvent.d.ts +52 -0
- package/build/client/clmm/types/wrapperProvideLiquidityClassicEvent.js +29 -0
- package/build/client/clmm/types/wrapperProvideLiquidityClassicEvent.js.map +1 -0
- package/build/client/clmm/types/wrapperProvideLiquidityEvent.d.ts +56 -0
- package/build/client/clmm/types/wrapperProvideLiquidityEvent.js +30 -0
- package/build/client/clmm/types/wrapperProvideLiquidityEvent.js.map +1 -0
- package/build/client/clmm/types/wrapperSellYtEvent.d.ts +23 -0
- package/build/client/clmm/types/wrapperSellYtEvent.js +18 -0
- package/build/client/clmm/types/wrapperSellYtEvent.js.map +1 -0
- package/build/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.d.ts +60 -0
- package/build/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.js +31 -0
- package/build/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.js.map +1 -0
- package/build/client/clmm/types/wrapperWithdrawLiquidityEvent.d.ts +60 -0
- package/build/client/clmm/types/wrapperWithdrawLiquidityEvent.js +31 -0
- package/build/client/clmm/types/wrapperWithdrawLiquidityEvent.js.map +1 -0
- package/build/client/core/accounts/admin.d.ts +18 -0
- package/build/client/core/accounts/admin.js +71 -0
- package/build/client/core/accounts/admin.js.map +1 -0
- package/build/client/core/accounts/lpPosition.d.ts +20 -0
- package/build/client/core/accounts/lpPosition.js +73 -0
- package/build/client/core/accounts/lpPosition.js.map +1 -0
- package/build/client/core/accounts/marketTwo.d.ts +42 -0
- package/build/client/core/accounts/marketTwo.js +122 -0
- package/build/client/core/accounts/marketTwo.js.map +1 -0
- package/build/client/core/accounts/vault.d.ts +48 -0
- package/build/client/core/accounts/vault.js +128 -0
- package/build/client/core/accounts/vault.js.map +1 -0
- package/build/client/core/accounts/yieldTokenPosition.d.ts +20 -0
- package/build/client/core/accounts/yieldTokenPosition.js +74 -0
- package/build/client/core/accounts/yieldTokenPosition.js.map +1 -0
- package/build/client/core/eventRegistry.d.ts +87 -0
- package/build/client/core/eventRegistry.js +86 -0
- package/build/client/core/eventRegistry.js.map +1 -0
- package/build/client/core/index.d.ts +109 -0
- package/build/client/core/index.js +127 -0
- package/build/client/core/index.js.map +1 -0
- package/build/client/core/instructions/addEmission.d.ts +19 -0
- package/build/client/core/instructions/addEmission.js +35 -0
- package/build/client/core/instructions/addEmission.js.map +1 -0
- package/build/client/core/instructions/addFarm.d.ts +17 -0
- package/build/client/core/instructions/addFarm.js +29 -0
- package/build/client/core/instructions/addFarm.js.map +1 -0
- package/build/client/core/instructions/addLpTokensMetadata.d.ts +16 -0
- package/build/client/core/instructions/addLpTokensMetadata.js +32 -0
- package/build/client/core/instructions/addLpTokensMetadata.js.map +1 -0
- package/build/client/core/instructions/addMarketEmission.d.ts +16 -0
- package/build/client/core/instructions/addMarketEmission.js +28 -0
- package/build/client/core/instructions/addMarketEmission.js.map +1 -0
- package/build/client/core/instructions/buyYt.d.ts +28 -0
- package/build/client/core/instructions/buyYt.js +44 -0
- package/build/client/core/instructions/buyYt.js.map +1 -0
- package/build/client/core/instructions/claimFarmEmissions.d.ts +17 -0
- package/build/client/core/instructions/claimFarmEmissions.js +29 -0
- package/build/client/core/instructions/claimFarmEmissions.js.map +1 -0
- package/build/client/core/instructions/collectEmission.d.ts +21 -0
- package/build/client/core/instructions/collectEmission.js +37 -0
- package/build/client/core/instructions/collectEmission.js.map +1 -0
- package/build/client/core/instructions/collectInterest.d.ts +20 -0
- package/build/client/core/instructions/collectInterest.js +36 -0
- package/build/client/core/instructions/collectInterest.js.map +1 -0
- package/build/client/core/instructions/collectTreasuryEmission.d.ts +21 -0
- package/build/client/core/instructions/collectTreasuryEmission.js +33 -0
- package/build/client/core/instructions/collectTreasuryEmission.js.map +1 -0
- package/build/client/core/instructions/collectTreasuryInterest.d.ts +20 -0
- package/build/client/core/instructions/collectTreasuryInterest.js +32 -0
- package/build/client/core/instructions/collectTreasuryInterest.js.map +1 -0
- package/build/client/core/instructions/depositYt.d.ts +19 -0
- package/build/client/core/instructions/depositYt.js +31 -0
- package/build/client/core/instructions/depositYt.js.map +1 -0
- package/build/client/core/instructions/initLpPosition.d.ts +11 -0
- package/build/client/core/instructions/initLpPosition.js +20 -0
- package/build/client/core/instructions/initLpPosition.js.map +1 -0
- package/build/client/core/instructions/initMarketTwo.d.ts +37 -0
- package/build/client/core/instructions/initMarketTwo.js +53 -0
- package/build/client/core/instructions/initMarketTwo.js.map +1 -0
- package/build/client/core/instructions/initializeVault.d.ts +34 -0
- package/build/client/core/instructions/initializeVault.js +58 -0
- package/build/client/core/instructions/initializeVault.js.map +1 -0
- package/build/client/core/instructions/initializeYieldPosition.d.ts +10 -0
- package/build/client/core/instructions/initializeYieldPosition.js +19 -0
- package/build/client/core/instructions/initializeYieldPosition.js.map +1 -0
- package/build/client/core/instructions/marketCollectEmission.d.ts +17 -0
- package/build/client/core/instructions/marketCollectEmission.js +29 -0
- package/build/client/core/instructions/marketCollectEmission.js.map +1 -0
- package/build/client/core/instructions/marketDepositLp.d.ts +19 -0
- package/build/client/core/instructions/marketDepositLp.js +31 -0
- package/build/client/core/instructions/marketDepositLp.js.map +1 -0
- package/build/client/core/instructions/marketTwoDepositLiquidity.d.ts +22 -0
- package/build/client/core/instructions/marketTwoDepositLiquidity.js +34 -0
- package/build/client/core/instructions/marketTwoDepositLiquidity.js.map +1 -0
- package/build/client/core/instructions/marketTwoWithdrawLiquidity.d.ts +22 -0
- package/build/client/core/instructions/marketTwoWithdrawLiquidity.js +34 -0
- package/build/client/core/instructions/marketTwoWithdrawLiquidity.js.map +1 -0
- package/build/client/core/instructions/marketWithdrawLp.d.ts +19 -0
- package/build/client/core/instructions/marketWithdrawLp.js +31 -0
- package/build/client/core/instructions/marketWithdrawLp.js.map +1 -0
- package/build/client/core/instructions/merge.d.ts +22 -0
- package/build/client/core/instructions/merge.js +32 -0
- package/build/client/core/instructions/merge.js.map +1 -0
- package/build/client/core/instructions/modifyFarm.d.ts +15 -0
- package/build/client/core/instructions/modifyFarm.js +27 -0
- package/build/client/core/instructions/modifyFarm.js.map +1 -0
- package/build/client/core/instructions/modifyMarketSetting.d.ts +12 -0
- package/build/client/core/instructions/modifyMarketSetting.js +24 -0
- package/build/client/core/instructions/modifyMarketSetting.js.map +1 -0
- package/build/client/core/instructions/modifyVaultSetting.d.ts +12 -0
- package/build/client/core/instructions/modifyVaultSetting.js +24 -0
- package/build/client/core/instructions/modifyVaultSetting.js.map +1 -0
- package/build/client/core/instructions/reallocMarket.d.ts +12 -0
- package/build/client/core/instructions/reallocMarket.js +24 -0
- package/build/client/core/instructions/reallocMarket.js.map +1 -0
- package/build/client/core/instructions/sellYt.d.ts +28 -0
- package/build/client/core/instructions/sellYt.js +44 -0
- package/build/client/core/instructions/sellYt.js.map +1 -0
- package/build/client/core/instructions/stageYtYield.d.ts +13 -0
- package/build/client/core/instructions/stageYtYield.js +22 -0
- package/build/client/core/instructions/stageYtYield.js.map +1 -0
- package/build/client/core/instructions/strip.d.ts +22 -0
- package/build/client/core/instructions/strip.js +32 -0
- package/build/client/core/instructions/strip.js.map +1 -0
- package/build/client/core/instructions/tradePt.d.ts +20 -0
- package/build/client/core/instructions/tradePt.js +32 -0
- package/build/client/core/instructions/tradePt.js.map +1 -0
- package/build/client/core/instructions/withdrawYt.d.ts +20 -0
- package/build/client/core/instructions/withdrawYt.js +32 -0
- package/build/client/core/instructions/withdrawYt.js.map +1 -0
- package/build/client/core/instructions/wrapperBuyPt.d.ts +21 -0
- package/build/client/core/instructions/wrapperBuyPt.js +33 -0
- package/build/client/core/instructions/wrapperBuyPt.js.map +1 -0
- package/build/client/core/instructions/wrapperBuyYt.d.ts +32 -0
- package/build/client/core/instructions/wrapperBuyYt.js +52 -0
- package/build/client/core/instructions/wrapperBuyYt.js.map +1 -0
- package/build/client/core/instructions/wrapperCollectInterest.d.ts +19 -0
- package/build/client/core/instructions/wrapperCollectInterest.js +35 -0
- package/build/client/core/instructions/wrapperCollectInterest.js.map +1 -0
- package/build/client/core/instructions/wrapperMerge.d.ts +24 -0
- package/build/client/core/instructions/wrapperMerge.js +44 -0
- package/build/client/core/instructions/wrapperMerge.js.map +1 -0
- package/build/client/core/instructions/wrapperProvideLiquidity.d.ts +35 -0
- package/build/client/core/instructions/wrapperProvideLiquidity.js +59 -0
- package/build/client/core/instructions/wrapperProvideLiquidity.js.map +1 -0
- package/build/client/core/instructions/wrapperProvideLiquidityBase.d.ts +28 -0
- package/build/client/core/instructions/wrapperProvideLiquidityBase.js +44 -0
- package/build/client/core/instructions/wrapperProvideLiquidityBase.js.map +1 -0
- package/build/client/core/instructions/wrapperProvideLiquidityClassic.d.ts +26 -0
- package/build/client/core/instructions/wrapperProvideLiquidityClassic.js +42 -0
- package/build/client/core/instructions/wrapperProvideLiquidityClassic.js.map +1 -0
- package/build/client/core/instructions/wrapperSellPt.d.ts +21 -0
- package/build/client/core/instructions/wrapperSellPt.js +33 -0
- package/build/client/core/instructions/wrapperSellPt.js.map +1 -0
- package/build/client/core/instructions/wrapperSellYt.d.ts +29 -0
- package/build/client/core/instructions/wrapperSellYt.js +49 -0
- package/build/client/core/instructions/wrapperSellYt.js.map +1 -0
- package/build/client/core/instructions/wrapperStrip.d.ts +26 -0
- package/build/client/core/instructions/wrapperStrip.js +46 -0
- package/build/client/core/instructions/wrapperStrip.js.map +1 -0
- package/build/client/core/instructions/wrapperWithdrawLiquidity.d.ts +26 -0
- package/build/client/core/instructions/wrapperWithdrawLiquidity.js +42 -0
- package/build/client/core/instructions/wrapperWithdrawLiquidity.js.map +1 -0
- package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.d.ts +24 -0
- package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.js +40 -0
- package/build/client/core/instructions/wrapperWithdrawLiquidityClassic.js.map +1 -0
- package/build/client/core/types/adminAction.d.ts +326 -0
- package/build/client/core/types/adminAction.js +87 -0
- package/build/client/core/types/adminAction.js.map +1 -0
- package/build/client/core/types/amount.d.ts +33 -0
- package/build/client/core/types/amount.js +20 -0
- package/build/client/core/types/amount.js.map +1 -0
- package/build/client/core/types/buyPtEvent.d.ts +27 -0
- package/build/client/core/types/buyPtEvent.js +19 -0
- package/build/client/core/types/buyPtEvent.js.map +1 -0
- package/build/client/core/types/buyYtEvent.d.ts +68 -0
- package/build/client/core/types/buyYtEvent.js +45 -0
- package/build/client/core/types/buyYtEvent.js.map +1 -0
- package/build/client/core/types/claimFarmEmissionsEvent.d.ts +43 -0
- package/build/client/core/types/claimFarmEmissionsEvent.js +35 -0
- package/build/client/core/types/claimFarmEmissionsEvent.js.map +1 -0
- package/build/client/core/types/claimFarmEmissionsEventV2.d.ts +98 -0
- package/build/client/core/types/claimFarmEmissionsEventV2.js +38 -0
- package/build/client/core/types/claimFarmEmissionsEventV2.js.map +1 -0
- package/build/client/core/types/claimLimits.d.ts +22 -0
- package/build/client/core/types/claimLimits.js +11 -0
- package/build/client/core/types/claimLimits.js.map +1 -0
- package/build/client/core/types/collectEmissionEvent.d.ts +35 -0
- package/build/client/core/types/collectEmissionEvent.js +24 -0
- package/build/client/core/types/collectEmissionEvent.js.map +1 -0
- package/build/client/core/types/collectEmissionEventV2.d.ts +68 -0
- package/build/client/core/types/collectEmissionEventV2.js +27 -0
- package/build/client/core/types/collectEmissionEventV2.js.map +1 -0
- package/build/client/core/types/collectInterestEvent.d.ts +31 -0
- package/build/client/core/types/collectInterestEvent.js +23 -0
- package/build/client/core/types/collectInterestEvent.js.map +1 -0
- package/build/client/core/types/collectInterestEventV2.d.ts +64 -0
- package/build/client/core/types/collectInterestEventV2.js +26 -0
- package/build/client/core/types/collectInterestEventV2.js.map +1 -0
- package/build/client/core/types/collectTreasuryEmissionKind.d.ts +5 -0
- package/build/client/core/types/collectTreasuryEmissionKind.js +11 -0
- package/build/client/core/types/collectTreasuryEmissionKind.js.map +1 -0
- package/build/client/core/types/collectTreasuryInterestKind.d.ts +5 -0
- package/build/client/core/types/collectTreasuryInterestKind.js +11 -0
- package/build/client/core/types/collectTreasuryInterestKind.js.map +1 -0
- package/build/client/core/types/cpiAccounts.d.ts +107 -0
- package/build/client/core/types/cpiAccounts.js +13 -0
- package/build/client/core/types/cpiAccounts.js.map +1 -0
- package/build/client/core/types/cpiInterfaceContext.d.ts +18 -0
- package/build/client/core/types/cpiInterfaceContext.js +10 -0
- package/build/client/core/types/cpiInterfaceContext.js.map +1 -0
- package/build/client/core/types/depositLiquidityEvent.d.ts +67 -0
- package/build/client/core/types/depositLiquidityEvent.js +47 -0
- package/build/client/core/types/depositLiquidityEvent.js.map +1 -0
- package/build/client/core/types/depositLpEvent.d.ts +43 -0
- package/build/client/core/types/depositLpEvent.js +35 -0
- package/build/client/core/types/depositLpEvent.js.map +1 -0
- package/build/client/core/types/depositLpEventV2.d.ts +98 -0
- package/build/client/core/types/depositLpEventV2.js +38 -0
- package/build/client/core/types/depositLpEventV2.js.map +1 -0
- package/build/client/core/types/depositYtEvent.d.ts +56 -0
- package/build/client/core/types/depositYtEvent.js +39 -0
- package/build/client/core/types/depositYtEvent.js.map +1 -0
- package/build/client/core/types/depositYtEventV2.d.ts +89 -0
- package/build/client/core/types/depositYtEventV2.js +42 -0
- package/build/client/core/types/depositYtEventV2.js.map +1 -0
- package/build/client/core/types/emissionInfo.d.ts +36 -0
- package/build/client/core/types/emissionInfo.js +22 -0
- package/build/client/core/types/emissionInfo.js.map +1 -0
- package/build/client/core/types/farmEmission.d.ts +24 -0
- package/build/client/core/types/farmEmission.js +16 -0
- package/build/client/core/types/farmEmission.js.map +1 -0
- package/build/client/core/types/index.d.ts +60 -0
- package/build/client/core/types/index.js +77 -0
- package/build/client/core/types/index.js.map +1 -0
- package/build/client/core/types/initLpPositionEvent.d.ts +35 -0
- package/build/client/core/types/initLpPositionEvent.js +27 -0
- package/build/client/core/types/initLpPositionEvent.js.map +1 -0
- package/build/client/core/types/initializeYieldPositionEvent.d.ts +23 -0
- package/build/client/core/types/initializeYieldPositionEvent.js +21 -0
- package/build/client/core/types/initializeYieldPositionEvent.js.map +1 -0
- package/build/client/core/types/liquidityNetBalanceLimits.d.ts +26 -0
- package/build/client/core/types/liquidityNetBalanceLimits.js +12 -0
- package/build/client/core/types/liquidityNetBalanceLimits.js.map +1 -0
- package/build/client/core/types/lpFarm.d.ts +35 -0
- package/build/client/core/types/lpFarm.js +10 -0
- package/build/client/core/types/lpFarm.js.map +1 -0
- package/build/client/core/types/marketAdminAction.d.ts +286 -0
- package/build/client/core/types/marketAdminAction.js +61 -0
- package/build/client/core/types/marketAdminAction.js.map +1 -0
- package/build/client/core/types/marketCollectEmissionEvent.d.ts +39 -0
- package/build/client/core/types/marketCollectEmissionEvent.js +31 -0
- package/build/client/core/types/marketCollectEmissionEvent.js.map +1 -0
- package/build/client/core/types/marketCollectEmissionEventV2.d.ts +94 -0
- package/build/client/core/types/marketCollectEmissionEventV2.js +34 -0
- package/build/client/core/types/marketCollectEmissionEventV2.js.map +1 -0
- package/build/client/core/types/marketEmission.d.ts +20 -0
- package/build/client/core/types/marketEmission.js +15 -0
- package/build/client/core/types/marketEmission.js.map +1 -0
- package/build/client/core/types/marketEmissions.d.ts +27 -0
- package/build/client/core/types/marketEmissions.js +9 -0
- package/build/client/core/types/marketEmissions.js.map +1 -0
- package/build/client/core/types/marketFinancials.d.ts +30 -0
- package/build/client/core/types/marketFinancials.js +13 -0
- package/build/client/core/types/marketFinancials.js.map +1 -0
- package/build/client/core/types/mergeEvent.d.ts +84 -0
- package/build/client/core/types/mergeEvent.js +55 -0
- package/build/client/core/types/mergeEvent.js.map +1 -0
- package/build/client/core/types/number.d.ts +2 -0
- package/build/client/core/types/number.js +8 -0
- package/build/client/core/types/number.js.map +1 -0
- package/build/client/core/types/personalYieldTracker.d.ts +15 -0
- package/build/client/core/types/personalYieldTracker.js +10 -0
- package/build/client/core/types/personalYieldTracker.js.map +1 -0
- package/build/client/core/types/personalYieldTrackers.d.ts +23 -0
- package/build/client/core/types/personalYieldTrackers.js +9 -0
- package/build/client/core/types/personalYieldTrackers.js.map +1 -0
- package/build/client/core/types/principleDetails.d.ts +11 -0
- package/build/client/core/types/principleDetails.js +12 -0
- package/build/client/core/types/principleDetails.js.map +1 -0
- package/build/client/core/types/principles.d.ts +79 -0
- package/build/client/core/types/principles.js +14 -0
- package/build/client/core/types/principles.js.map +1 -0
- package/build/client/core/types/sellPtEvent.d.ts +27 -0
- package/build/client/core/types/sellPtEvent.js +19 -0
- package/build/client/core/types/sellPtEvent.js.map +1 -0
- package/build/client/core/types/sellYtEvent.d.ts +59 -0
- package/build/client/core/types/sellYtEvent.js +42 -0
- package/build/client/core/types/sellYtEvent.js.map +1 -0
- package/build/client/core/types/stageYieldEvent.d.ts +44 -0
- package/build/client/core/types/stageYieldEvent.js +30 -0
- package/build/client/core/types/stageYieldEvent.js.map +1 -0
- package/build/client/core/types/stageYieldEventV2.d.ts +73 -0
- package/build/client/core/types/stageYieldEventV2.js +32 -0
- package/build/client/core/types/stageYieldEventV2.js.map +1 -0
- package/build/client/core/types/stripEvent.d.ts +84 -0
- package/build/client/core/types/stripEvent.js +58 -0
- package/build/client/core/types/stripEvent.js.map +1 -0
- package/build/client/core/types/tradePtEvent.d.ts +52 -0
- package/build/client/core/types/tradePtEvent.js +38 -0
- package/build/client/core/types/tradePtEvent.js.map +1 -0
- package/build/client/core/types/withdrawLiquidityEvent.d.ts +59 -0
- package/build/client/core/types/withdrawLiquidityEvent.js +45 -0
- package/build/client/core/types/withdrawLiquidityEvent.js.map +1 -0
- package/build/client/core/types/withdrawLpEvent.d.ts +43 -0
- package/build/client/core/types/withdrawLpEvent.js +35 -0
- package/build/client/core/types/withdrawLpEvent.js.map +1 -0
- package/build/client/core/types/withdrawLpEventV2.d.ts +98 -0
- package/build/client/core/types/withdrawLpEventV2.js +38 -0
- package/build/client/core/types/withdrawLpEventV2.js.map +1 -0
- package/build/client/core/types/withdrawYtEvent.d.ts +56 -0
- package/build/client/core/types/withdrawYtEvent.js +39 -0
- package/build/client/core/types/withdrawYtEvent.js.map +1 -0
- package/build/client/core/types/withdrawYtEventV2.d.ts +89 -0
- package/build/client/core/types/withdrawYtEventV2.js +42 -0
- package/build/client/core/types/withdrawYtEventV2.js.map +1 -0
- package/build/client/core/types/wrapperBuyYtEvent.d.ts +27 -0
- package/build/client/core/types/wrapperBuyYtEvent.js +19 -0
- package/build/client/core/types/wrapperBuyYtEvent.js.map +1 -0
- package/build/client/core/types/wrapperCollectInterestEvent.d.ts +23 -0
- package/build/client/core/types/wrapperCollectInterestEvent.js +18 -0
- package/build/client/core/types/wrapperCollectInterestEvent.js.map +1 -0
- package/build/client/core/types/wrapperMergeEvent.d.ts +27 -0
- package/build/client/core/types/wrapperMergeEvent.js +19 -0
- package/build/client/core/types/wrapperMergeEvent.js.map +1 -0
- package/build/client/core/types/wrapperProvideLiquidityBaseEvent.d.ts +35 -0
- package/build/client/core/types/wrapperProvideLiquidityBaseEvent.js +21 -0
- package/build/client/core/types/wrapperProvideLiquidityBaseEvent.js.map +1 -0
- package/build/client/core/types/wrapperProvideLiquidityClassicEvent.d.ts +31 -0
- package/build/client/core/types/wrapperProvideLiquidityClassicEvent.js +20 -0
- package/build/client/core/types/wrapperProvideLiquidityClassicEvent.js.map +1 -0
- package/build/client/core/types/wrapperProvideLiquidityEvent.d.ts +31 -0
- package/build/client/core/types/wrapperProvideLiquidityEvent.js +20 -0
- package/build/client/core/types/wrapperProvideLiquidityEvent.js.map +1 -0
- package/build/client/core/types/wrapperSellYtEvent.d.ts +27 -0
- package/build/client/core/types/wrapperSellYtEvent.js +19 -0
- package/build/client/core/types/wrapperSellYtEvent.js.map +1 -0
- package/build/client/core/types/wrapperStripEvent.d.ts +27 -0
- package/build/client/core/types/wrapperStripEvent.js +19 -0
- package/build/client/core/types/wrapperStripEvent.js.map +1 -0
- package/build/client/core/types/wrapperWithdrawLiquidityClassicEvent.d.ts +31 -0
- package/build/client/core/types/wrapperWithdrawLiquidityClassicEvent.js +20 -0
- package/build/client/core/types/wrapperWithdrawLiquidityClassicEvent.js.map +1 -0
- package/build/client/core/types/wrapperWithdrawLiquidityEvent.d.ts +27 -0
- package/build/client/core/types/wrapperWithdrawLiquidityEvent.js +19 -0
- package/build/client/core/types/wrapperWithdrawLiquidityEvent.js.map +1 -0
- package/build/client/core/types/yieldTokenTracker.d.ts +15 -0
- package/build/client/core/types/yieldTokenTracker.js +10 -0
- package/build/client/core/types/yieldTokenTracker.js.map +1 -0
- package/build/client/orderbook/accounts/cpiAccountsOrderbook.d.ts +18 -0
- package/build/client/orderbook/accounts/cpiAccountsOrderbook.js +66 -0
- package/build/client/orderbook/accounts/cpiAccountsOrderbook.js.map +1 -0
- package/build/client/orderbook/accounts/vault.d.ts +48 -0
- package/build/client/orderbook/accounts/vault.js +128 -0
- package/build/client/orderbook/accounts/vault.js.map +1 -0
- package/build/client/orderbook/eventRegistry.d.ts +45 -0
- package/build/client/orderbook/eventRegistry.js +44 -0
- package/build/client/orderbook/eventRegistry.js.map +1 -0
- package/build/client/orderbook/index.d.ts +51 -0
- package/build/client/orderbook/index.js +69 -0
- package/build/client/orderbook/index.js.map +1 -0
- package/build/client/orderbook/instructions/collectAdminEmission.d.ts +14 -0
- package/build/client/orderbook/instructions/collectAdminEmission.js +26 -0
- package/build/client/orderbook/instructions/collectAdminEmission.js.map +1 -0
- package/build/client/orderbook/instructions/collectAdminFee.d.ts +21 -0
- package/build/client/orderbook/instructions/collectAdminFee.js +34 -0
- package/build/client/orderbook/instructions/collectAdminFee.js.map +1 -0
- package/build/client/orderbook/instructions/collectInterest.d.ts +21 -0
- package/build/client/orderbook/instructions/collectInterest.js +37 -0
- package/build/client/orderbook/instructions/collectInterest.js.map +1 -0
- package/build/client/orderbook/instructions/initializeOrderbook.d.ts +36 -0
- package/build/client/orderbook/instructions/initializeOrderbook.js +52 -0
- package/build/client/orderbook/instructions/initializeOrderbook.js.map +1 -0
- package/build/client/orderbook/instructions/marketOffer.d.ts +30 -0
- package/build/client/orderbook/instructions/marketOffer.js +46 -0
- package/build/client/orderbook/instructions/marketOffer.js.map +1 -0
- package/build/client/orderbook/instructions/postOffer.d.ts +33 -0
- package/build/client/orderbook/instructions/postOffer.js +49 -0
- package/build/client/orderbook/instructions/postOffer.js.map +1 -0
- package/build/client/orderbook/instructions/reallocOrderbookAccount.d.ts +12 -0
- package/build/client/orderbook/instructions/reallocOrderbookAccount.js +24 -0
- package/build/client/orderbook/instructions/reallocOrderbookAccount.js.map +1 -0
- package/build/client/orderbook/instructions/removeExpiredOffers.d.ts +12 -0
- package/build/client/orderbook/instructions/removeExpiredOffers.js +21 -0
- package/build/client/orderbook/instructions/removeExpiredOffers.js.map +1 -0
- package/build/client/orderbook/instructions/removeOffer.d.ts +24 -0
- package/build/client/orderbook/instructions/removeOffer.js +40 -0
- package/build/client/orderbook/instructions/removeOffer.js.map +1 -0
- package/build/client/orderbook/instructions/setConfigurationOptions.d.ts +10 -0
- package/build/client/orderbook/instructions/setConfigurationOptions.js +22 -0
- package/build/client/orderbook/instructions/setConfigurationOptions.js.map +1 -0
- package/build/client/orderbook/instructions/withdrawFunds.d.ts +27 -0
- package/build/client/orderbook/instructions/withdrawFunds.js +43 -0
- package/build/client/orderbook/instructions/withdrawFunds.js.map +1 -0
- package/build/client/orderbook/instructions/wrapperCollectAdminFee.d.ts +24 -0
- package/build/client/orderbook/instructions/wrapperCollectAdminFee.js +40 -0
- package/build/client/orderbook/instructions/wrapperCollectAdminFee.js.map +1 -0
- package/build/client/orderbook/instructions/wrapperCollectInterest.d.ts +20 -0
- package/build/client/orderbook/instructions/wrapperCollectInterest.js +36 -0
- package/build/client/orderbook/instructions/wrapperCollectInterest.js.map +1 -0
- package/build/client/orderbook/instructions/wrapperMarketOffer.d.ts +32 -0
- package/build/client/orderbook/instructions/wrapperMarketOffer.js +48 -0
- package/build/client/orderbook/instructions/wrapperMarketOffer.js.map +1 -0
- package/build/client/orderbook/instructions/wrapperPostOffer.d.ts +34 -0
- package/build/client/orderbook/instructions/wrapperPostOffer.js +50 -0
- package/build/client/orderbook/instructions/wrapperPostOffer.js.map +1 -0
- package/build/client/orderbook/instructions/wrapperRemoveOffer.d.ts +25 -0
- package/build/client/orderbook/instructions/wrapperRemoveOffer.js +41 -0
- package/build/client/orderbook/instructions/wrapperRemoveOffer.js.map +1 -0
- package/build/client/orderbook/instructions/wrapperWithdrawFunds.d.ts +28 -0
- package/build/client/orderbook/instructions/wrapperWithdrawFunds.js +44 -0
- package/build/client/orderbook/instructions/wrapperWithdrawFunds.js.map +1 -0
- package/build/client/orderbook/types/amount.d.ts +33 -0
- package/build/client/orderbook/types/amount.js +20 -0
- package/build/client/orderbook/types/amount.js.map +1 -0
- package/build/client/orderbook/types/claimLimits.d.ts +22 -0
- package/build/client/orderbook/types/claimLimits.js +11 -0
- package/build/client/orderbook/types/claimLimits.js.map +1 -0
- package/build/client/orderbook/types/collectAdminEmissionEvent.d.ts +27 -0
- package/build/client/orderbook/types/collectAdminEmissionEvent.js +19 -0
- package/build/client/orderbook/types/collectAdminEmissionEvent.js.map +1 -0
- package/build/client/orderbook/types/collectAdminFeeEvent.d.ts +26 -0
- package/build/client/orderbook/types/collectAdminFeeEvent.js +12 -0
- package/build/client/orderbook/types/collectAdminFeeEvent.js.map +1 -0
- package/build/client/orderbook/types/collectEmissionEventV2.d.ts +68 -0
- package/build/client/orderbook/types/collectEmissionEventV2.js +27 -0
- package/build/client/orderbook/types/collectEmissionEventV2.js.map +1 -0
- package/build/client/orderbook/types/collectInterestEventV2.d.ts +64 -0
- package/build/client/orderbook/types/collectInterestEventV2.js +26 -0
- package/build/client/orderbook/types/collectInterestEventV2.js.map +1 -0
- package/build/client/orderbook/types/collectUserInterestEvent.d.ts +23 -0
- package/build/client/orderbook/types/collectUserInterestEvent.js +18 -0
- package/build/client/orderbook/types/collectUserInterestEvent.js.map +1 -0
- package/build/client/orderbook/types/cpiAccounts.d.ts +107 -0
- package/build/client/orderbook/types/cpiAccounts.js +13 -0
- package/build/client/orderbook/types/cpiAccounts.js.map +1 -0
- package/build/client/orderbook/types/cpiInterfaceContext.d.ts +18 -0
- package/build/client/orderbook/types/cpiInterfaceContext.js +10 -0
- package/build/client/orderbook/types/cpiInterfaceContext.js.map +1 -0
- package/build/client/orderbook/types/emissionInfo.d.ts +36 -0
- package/build/client/orderbook/types/emissionInfo.js +22 -0
- package/build/client/orderbook/types/emissionInfo.js.map +1 -0
- package/build/client/orderbook/types/exponentCoreCpiAccounts.d.ts +107 -0
- package/build/client/orderbook/types/exponentCoreCpiAccounts.js +13 -0
- package/build/client/orderbook/types/exponentCoreCpiAccounts.js.map +1 -0
- package/build/client/orderbook/types/filledOffersEvent.d.ts +30 -0
- package/build/client/orderbook/types/filledOffersEvent.js +13 -0
- package/build/client/orderbook/types/filledOffersEvent.js.map +1 -0
- package/build/client/orderbook/types/index.d.ts +30 -0
- package/build/client/orderbook/types/index.js +47 -0
- package/build/client/orderbook/types/index.js.map +1 -0
- package/build/client/orderbook/types/marketOfferEvent.d.ts +93 -0
- package/build/client/orderbook/types/marketOfferEvent.js +33 -0
- package/build/client/orderbook/types/marketOfferEvent.js.map +1 -0
- package/build/client/orderbook/types/mergeEvent.d.ts +84 -0
- package/build/client/orderbook/types/mergeEvent.js +55 -0
- package/build/client/orderbook/types/mergeEvent.js.map +1 -0
- package/build/client/orderbook/types/number.d.ts +2 -0
- package/build/client/orderbook/types/number.js +8 -0
- package/build/client/orderbook/types/number.js.map +1 -0
- package/build/client/orderbook/types/offerOptions.d.ts +24 -0
- package/build/client/orderbook/types/offerOptions.js +22 -0
- package/build/client/orderbook/types/offerOptions.js.map +1 -0
- package/build/client/orderbook/types/offerType.d.ts +5 -0
- package/build/client/orderbook/types/offerType.js +11 -0
- package/build/client/orderbook/types/offerType.js.map +1 -0
- package/build/client/orderbook/types/orderbookInitEvent.d.ts +39 -0
- package/build/client/orderbook/types/orderbookInitEvent.js +25 -0
- package/build/client/orderbook/types/orderbookInitEvent.js.map +1 -0
- package/build/client/orderbook/types/postOfferEvent.d.ts +118 -0
- package/build/client/orderbook/types/postOfferEvent.js +36 -0
- package/build/client/orderbook/types/postOfferEvent.js.map +1 -0
- package/build/client/orderbook/types/removeOfferEvent.d.ts +39 -0
- package/build/client/orderbook/types/removeOfferEvent.js +31 -0
- package/build/client/orderbook/types/removeOfferEvent.js.map +1 -0
- package/build/client/orderbook/types/setConfigurationOptionsEnum.d.ts +72 -0
- package/build/client/orderbook/types/setConfigurationOptionsEnum.js +34 -0
- package/build/client/orderbook/types/setConfigurationOptionsEnum.js.map +1 -0
- package/build/client/orderbook/types/stripEvent.d.ts +84 -0
- package/build/client/orderbook/types/stripEvent.js +58 -0
- package/build/client/orderbook/types/stripEvent.js.map +1 -0
- package/build/client/orderbook/types/withdrawFundsEvent.d.ts +39 -0
- package/build/client/orderbook/types/withdrawFundsEvent.js +31 -0
- package/build/client/orderbook/types/withdrawFundsEvent.js.map +1 -0
- package/build/client/orderbook/types/wrapperCollectAdminFeeEvent.d.ts +18 -0
- package/build/client/orderbook/types/wrapperCollectAdminFeeEvent.js +10 -0
- package/build/client/orderbook/types/wrapperCollectAdminFeeEvent.js.map +1 -0
- package/build/client/orderbook/types/wrapperCollectInterestEvent.d.ts +15 -0
- package/build/client/orderbook/types/wrapperCollectInterestEvent.js +13 -0
- package/build/client/orderbook/types/wrapperCollectInterestEvent.js.map +1 -0
- package/build/client/orderbook/types/wrapperMarketOfferEvent.d.ts +19 -0
- package/build/client/orderbook/types/wrapperMarketOfferEvent.js +14 -0
- package/build/client/orderbook/types/wrapperMarketOfferEvent.js.map +1 -0
- package/build/client/orderbook/types/wrapperPostOfferEvent.d.ts +39 -0
- package/build/client/orderbook/types/wrapperPostOfferEvent.js +34 -0
- package/build/client/orderbook/types/wrapperPostOfferEvent.js.map +1 -0
- package/build/client/orderbook/types/wrapperRemoveOfferEvent.d.ts +15 -0
- package/build/client/orderbook/types/wrapperRemoveOfferEvent.js +13 -0
- package/build/client/orderbook/types/wrapperRemoveOfferEvent.js.map +1 -0
- package/build/client/orderbook/types/wrapperWithdrawFundsEvent.d.ts +27 -0
- package/build/client/orderbook/types/wrapperWithdrawFundsEvent.js +19 -0
- package/build/client/orderbook/types/wrapperWithdrawFundsEvent.js.map +1 -0
- package/build/client/orderbook/types/yieldTokenTracker.d.ts +15 -0
- package/build/client/orderbook/types/yieldTokenTracker.js +10 -0
- package/build/client/orderbook/types/yieldTokenTracker.js.map +1 -0
- package/build/client/vaults/accounts/actionProposal.d.ts +30 -0
- package/build/client/vaults/accounts/actionProposal.js +84 -0
- package/build/client/vaults/accounts/actionProposal.js.map +1 -0
- package/build/client/vaults/accounts/exponentStrategyVault.d.ts +39 -0
- package/build/client/vaults/accounts/exponentStrategyVault.js +113 -0
- package/build/client/vaults/accounts/exponentStrategyVault.js.map +1 -0
- package/build/client/vaults/accounts/programConfig.d.ts +19 -0
- package/build/client/vaults/accounts/programConfig.js +76 -0
- package/build/client/vaults/accounts/programConfig.js.map +1 -0
- package/build/client/vaults/accounts/voteAccount.d.ts +23 -0
- package/build/client/vaults/accounts/voteAccount.js +80 -0
- package/build/client/vaults/accounts/voteAccount.js.map +1 -0
- package/build/client/vaults/accounts/withdrawalAccount.d.ts +23 -0
- package/build/client/vaults/accounts/withdrawalAccount.js +78 -0
- package/build/client/vaults/accounts/withdrawalAccount.js.map +1 -0
- package/build/client/vaults/eventRegistry.d.ts +27 -0
- package/build/client/vaults/eventRegistry.js +27 -0
- package/build/client/vaults/eventRegistry.js.map +1 -0
- package/build/client/vaults/index.d.ts +106 -0
- package/build/client/vaults/index.js +125 -0
- package/build/client/vaults/index.js.map +1 -0
- package/build/client/vaults/instructions/activateProposal.d.ts +12 -0
- package/build/client/vaults/instructions/activateProposal.js +25 -0
- package/build/client/vaults/instructions/activateProposal.js.map +1 -0
- package/build/client/vaults/instructions/addPolicy.d.ts +16 -0
- package/build/client/vaults/instructions/addPolicy.js +33 -0
- package/build/client/vaults/instructions/addPolicy.js.map +1 -0
- package/build/client/vaults/instructions/appendProposalActions.d.ts +13 -0
- package/build/client/vaults/instructions/appendProposalActions.js +26 -0
- package/build/client/vaults/instructions/appendProposalActions.js.map +1 -0
- package/build/client/vaults/instructions/cancelProposal.d.ts +7 -0
- package/build/client/vaults/instructions/cancelProposal.js +17 -0
- package/build/client/vaults/instructions/cancelProposal.js.map +1 -0
- package/build/client/vaults/instructions/cancelWithdrawal.d.ts +10 -0
- package/build/client/vaults/instructions/cancelWithdrawal.js +20 -0
- package/build/client/vaults/instructions/cancelWithdrawal.js.map +1 -0
- package/build/client/vaults/instructions/collectManagementFee.d.ts +9 -0
- package/build/client/vaults/instructions/collectManagementFee.js +19 -0
- package/build/client/vaults/instructions/collectManagementFee.js.map +1 -0
- package/build/client/vaults/instructions/depositLiquidity.d.ts +20 -0
- package/build/client/vaults/instructions/depositLiquidity.js +33 -0
- package/build/client/vaults/instructions/depositLiquidity.js.map +1 -0
- package/build/client/vaults/instructions/executeProposal.d.ts +11 -0
- package/build/client/vaults/instructions/executeProposal.js +21 -0
- package/build/client/vaults/instructions/executeProposal.js.map +1 -0
- package/build/client/vaults/instructions/executeWithdrawal.d.ts +18 -0
- package/build/client/vaults/instructions/executeWithdrawal.js +31 -0
- package/build/client/vaults/instructions/executeWithdrawal.js.map +1 -0
- package/build/client/vaults/instructions/executeWithdrawalFromReserves.d.ts +22 -0
- package/build/client/vaults/instructions/executeWithdrawalFromReserves.js +35 -0
- package/build/client/vaults/instructions/executeWithdrawalFromReserves.js.map +1 -0
- package/build/client/vaults/instructions/fillWithdrawal.d.ts +17 -0
- package/build/client/vaults/instructions/fillWithdrawal.js +34 -0
- package/build/client/vaults/instructions/fillWithdrawal.js.map +1 -0
- package/build/client/vaults/instructions/finalizeProposal.d.ts +7 -0
- package/build/client/vaults/instructions/finalizeProposal.js +17 -0
- package/build/client/vaults/instructions/finalizeProposal.js.map +1 -0
- package/build/client/vaults/instructions/initProposal.d.ts +12 -0
- package/build/client/vaults/instructions/initProposal.js +25 -0
- package/build/client/vaults/instructions/initProposal.js.map +1 -0
- package/build/client/vaults/instructions/initializePrices.d.ts +7 -0
- package/build/client/vaults/instructions/initializePrices.js +17 -0
- package/build/client/vaults/instructions/initializePrices.js.map +1 -0
- package/build/client/vaults/instructions/initializeVault.d.ts +44 -0
- package/build/client/vaults/instructions/initializeVault.js +80 -0
- package/build/client/vaults/instructions/initializeVault.js.map +1 -0
- package/build/client/vaults/instructions/makeSentienelManager.d.ts +7 -0
- package/build/client/vaults/instructions/makeSentienelManager.js +17 -0
- package/build/client/vaults/instructions/makeSentienelManager.js.map +1 -0
- package/build/client/vaults/instructions/managePrices.d.ts +11 -0
- package/build/client/vaults/instructions/managePrices.js +24 -0
- package/build/client/vaults/instructions/managePrices.js.map +1 -0
- package/build/client/vaults/instructions/manageVaultSettings.d.ts +12 -0
- package/build/client/vaults/instructions/manageVaultSettings.js +25 -0
- package/build/client/vaults/instructions/manageVaultSettings.js.map +1 -0
- package/build/client/vaults/instructions/managerUpdatePosition.d.ts +12 -0
- package/build/client/vaults/instructions/managerUpdatePosition.js +25 -0
- package/build/client/vaults/instructions/managerUpdatePosition.js.map +1 -0
- package/build/client/vaults/instructions/proposeAction.d.ts +16 -0
- package/build/client/vaults/instructions/proposeAction.js +29 -0
- package/build/client/vaults/instructions/proposeAction.js.map +1 -0
- package/build/client/vaults/instructions/queueWithdrawal.d.ts +14 -0
- package/build/client/vaults/instructions/queueWithdrawal.js +27 -0
- package/build/client/vaults/instructions/queueWithdrawal.js.map +1 -0
- package/build/client/vaults/instructions/removePolicy.d.ts +13 -0
- package/build/client/vaults/instructions/removePolicy.js +27 -0
- package/build/client/vaults/instructions/removePolicy.js.map +1 -0
- package/build/client/vaults/instructions/sentinelSetVaultFlags.d.ts +10 -0
- package/build/client/vaults/instructions/sentinelSetVaultFlags.js +23 -0
- package/build/client/vaults/instructions/sentinelSetVaultFlags.js.map +1 -0
- package/build/client/vaults/instructions/stakeVote.d.ts +18 -0
- package/build/client/vaults/instructions/stakeVote.js +31 -0
- package/build/client/vaults/instructions/stakeVote.js.map +1 -0
- package/build/client/vaults/instructions/unstakeVote.d.ts +14 -0
- package/build/client/vaults/instructions/unstakeVote.js +24 -0
- package/build/client/vaults/instructions/unstakeVote.js.map +1 -0
- package/build/client/vaults/instructions/updatePolicy.d.ts +17 -0
- package/build/client/vaults/instructions/updatePolicy.js +34 -0
- package/build/client/vaults/instructions/updatePolicy.js.map +1 -0
- package/build/client/vaults/instructions/updatePolicyManager.d.ts +13 -0
- package/build/client/vaults/instructions/updatePolicyManager.js +27 -0
- package/build/client/vaults/instructions/updatePolicyManager.js.map +1 -0
- package/build/client/vaults/instructions/updatePrice.d.ts +9 -0
- package/build/client/vaults/instructions/updatePrice.js +22 -0
- package/build/client/vaults/instructions/updatePrice.js.map +1 -0
- package/build/client/vaults/instructions/validateInteractionHook.d.ts +16 -0
- package/build/client/vaults/instructions/validateInteractionHook.js +33 -0
- package/build/client/vaults/instructions/validateInteractionHook.js.map +1 -0
- package/build/client/vaults/instructions/wrapperAddPolicy.d.ts +16 -0
- package/build/client/vaults/instructions/wrapperAddPolicy.js +33 -0
- package/build/client/vaults/instructions/wrapperAddPolicy.js.map +1 -0
- package/build/client/vaults/instructions/wrapperExecuteWithdrawal.d.ts +27 -0
- package/build/client/vaults/instructions/wrapperExecuteWithdrawal.js +40 -0
- package/build/client/vaults/instructions/wrapperExecuteWithdrawal.js.map +1 -0
- package/build/client/vaults/instructions/wrapperManageVaultSettings.d.ts +12 -0
- package/build/client/vaults/instructions/wrapperManageVaultSettings.js +25 -0
- package/build/client/vaults/instructions/wrapperManageVaultSettings.js.map +1 -0
- package/build/client/vaults/instructions/wrapperManagerUpdatePosition.d.ts +12 -0
- package/build/client/vaults/instructions/wrapperManagerUpdatePosition.js +25 -0
- package/build/client/vaults/instructions/wrapperManagerUpdatePosition.js.map +1 -0
- package/build/client/vaults/instructions/wrapperRemovePolicy.d.ts +13 -0
- package/build/client/vaults/instructions/wrapperRemovePolicy.js +27 -0
- package/build/client/vaults/instructions/wrapperRemovePolicy.js.map +1 -0
- package/build/client/vaults/instructions/wrapperUpdatePolicy.d.ts +17 -0
- package/build/client/vaults/instructions/wrapperUpdatePolicy.js +34 -0
- package/build/client/vaults/instructions/wrapperUpdatePolicy.js.map +1 -0
- package/build/client/vaults/types/accountConstraint.d.ts +20 -0
- package/build/client/vaults/types/accountConstraint.js +16 -0
- package/build/client/vaults/types/accountConstraint.js.map +1 -0
- package/build/client/vaults/types/accountConstraintType.d.ts +18 -0
- package/build/client/vaults/types/accountConstraintType.js +38 -0
- package/build/client/vaults/types/accountConstraintType.js.map +1 -0
- package/build/client/vaults/types/allowedSettingsChange.d.ts +79 -0
- package/build/client/vaults/types/allowedSettingsChange.js +45 -0
- package/build/client/vaults/types/allowedSettingsChange.js.map +1 -0
- package/build/client/vaults/types/cancelProposalEvent.d.ts +27 -0
- package/build/client/vaults/types/cancelProposalEvent.js +23 -0
- package/build/client/vaults/types/cancelProposalEvent.js.map +1 -0
- package/build/client/vaults/types/clmmPositionEntry.d.ts +88 -0
- package/build/client/vaults/types/clmmPositionEntry.js +20 -0
- package/build/client/vaults/types/clmmPositionEntry.js.map +1 -0
- package/build/client/vaults/types/dataConstraint.d.ts +116 -0
- package/build/client/vaults/types/dataConstraint.js +13 -0
- package/build/client/vaults/types/dataConstraint.js.map +1 -0
- package/build/client/vaults/types/dataOperator.d.ts +9 -0
- package/build/client/vaults/types/dataOperator.js +16 -0
- package/build/client/vaults/types/dataOperator.js.map +1 -0
- package/build/client/vaults/types/dataValue.d.ts +104 -0
- package/build/client/vaults/types/dataValue.js +33 -0
- package/build/client/vaults/types/dataValue.js.map +1 -0
- package/build/client/vaults/types/depositLiquidityEvent.d.ts +55 -0
- package/build/client/vaults/types/depositLiquidityEvent.js +42 -0
- package/build/client/vaults/types/depositLiquidityEvent.js.map +1 -0
- package/build/client/vaults/types/executeProposalEvent.d.ts +27 -0
- package/build/client/vaults/types/executeProposalEvent.js +23 -0
- package/build/client/vaults/types/executeProposalEvent.js.map +1 -0
- package/build/client/vaults/types/executeWithdrawalEvent.d.ts +14 -0
- package/build/client/vaults/types/executeWithdrawalEvent.js +10 -0
- package/build/client/vaults/types/executeWithdrawalEvent.js.map +1 -0
- package/build/client/vaults/types/fillParam.d.ts +14 -0
- package/build/client/vaults/types/fillParam.js +10 -0
- package/build/client/vaults/types/fillParam.js.map +1 -0
- package/build/client/vaults/types/finalizeProposalEvent.d.ts +48 -0
- package/build/client/vaults/types/finalizeProposalEvent.js +26 -0
- package/build/client/vaults/types/finalizeProposalEvent.js.map +1 -0
- package/build/client/vaults/types/hook.d.ts +44 -0
- package/build/client/vaults/types/hook.js +18 -0
- package/build/client/vaults/types/hook.js.map +1 -0
- package/build/client/vaults/types/hookCompiledInstruction.d.ts +18 -0
- package/build/client/vaults/types/hookCompiledInstruction.js +11 -0
- package/build/client/vaults/types/hookCompiledInstruction.js.map +1 -0
- package/build/client/vaults/types/index.d.ts +65 -0
- package/build/client/vaults/types/index.js +83 -0
- package/build/client/vaults/types/index.js.map +1 -0
- package/build/client/vaults/types/instructionConstraint.d.ts +173 -0
- package/build/client/vaults/types/instructionConstraint.js +17 -0
- package/build/client/vaults/types/instructionConstraint.js.map +1 -0
- package/build/client/vaults/types/internalFundTransferPolicyCreationPayload.d.ts +19 -0
- package/build/client/vaults/types/internalFundTransferPolicyCreationPayload.js +18 -0
- package/build/client/vaults/types/internalFundTransferPolicyCreationPayload.js.map +1 -0
- package/build/client/vaults/types/kaminoObligationEntry.d.ts +117 -0
- package/build/client/vaults/types/kaminoObligationEntry.js +23 -0
- package/build/client/vaults/types/kaminoObligationEntry.js.map +1 -0
- package/build/client/vaults/types/limitedQuantityConstraints.d.ts +10 -0
- package/build/client/vaults/types/limitedQuantityConstraints.js +9 -0
- package/build/client/vaults/types/limitedQuantityConstraints.js.map +1 -0
- package/build/client/vaults/types/limitedSpendingLimit.d.ts +105 -0
- package/build/client/vaults/types/limitedSpendingLimit.js +17 -0
- package/build/client/vaults/types/limitedSpendingLimit.js.map +1 -0
- package/build/client/vaults/types/limitedTimeConstraints.d.ts +67 -0
- package/build/client/vaults/types/limitedTimeConstraints.js +12 -0
- package/build/client/vaults/types/limitedTimeConstraints.js.map +1 -0
- package/build/client/vaults/types/loopscaleLoanEntry.d.ts +11 -0
- package/build/client/vaults/types/loopscaleLoanEntry.js +13 -0
- package/build/client/vaults/types/loopscaleLoanEntry.js.map +1 -0
- package/build/client/vaults/types/loopscaleStrategyEntry.d.ts +11 -0
- package/build/client/vaults/types/loopscaleStrategyEntry.js +13 -0
- package/build/client/vaults/types/loopscaleStrategyEntry.js.map +1 -0
- package/build/client/vaults/types/number.d.ts +2 -0
- package/build/client/vaults/types/number.js +9 -0
- package/build/client/vaults/types/number.js.map +1 -0
- package/build/client/vaults/types/obligationType.d.ts +13 -0
- package/build/client/vaults/types/obligationType.js +24 -0
- package/build/client/vaults/types/obligationType.js.map +1 -0
- package/build/client/vaults/types/orderbookEntry.d.ts +64 -0
- package/build/client/vaults/types/orderbookEntry.js +25 -0
- package/build/client/vaults/types/orderbookEntry.js.map +1 -0
- package/build/client/vaults/types/periodV2.d.ts +60 -0
- package/build/client/vaults/types/periodV2.js +24 -0
- package/build/client/vaults/types/periodV2.js.map +1 -0
- package/build/client/vaults/types/permissions.d.ts +10 -0
- package/build/client/vaults/types/permissions.js +7 -0
- package/build/client/vaults/types/permissions.js.map +1 -0
- package/build/client/vaults/types/policyAction.d.ts +61 -0
- package/build/client/vaults/types/policyAction.js +29 -0
- package/build/client/vaults/types/policyAction.js.map +1 -0
- package/build/client/vaults/types/policyConfig.d.ts +10 -0
- package/build/client/vaults/types/policyConfig.js +15 -0
- package/build/client/vaults/types/policyConfig.js.map +1 -0
- package/build/client/vaults/types/policyCreationPayload.d.ts +287 -0
- package/build/client/vaults/types/policyCreationPayload.js +50 -0
- package/build/client/vaults/types/policyCreationPayload.js.map +1 -0
- package/build/client/vaults/types/policyExpirationArgs.d.ts +33 -0
- package/build/client/vaults/types/policyExpirationArgs.js +21 -0
- package/build/client/vaults/types/policyExpirationArgs.js.map +1 -0
- package/build/client/vaults/types/positionUpdate.d.ts +45 -0
- package/build/client/vaults/types/positionUpdate.js +89 -0
- package/build/client/vaults/types/positionUpdate.js.map +1 -0
- package/build/client/vaults/types/priceId.d.ts +40 -0
- package/build/client/vaults/types/priceId.js +21 -0
- package/build/client/vaults/types/priceId.js.map +1 -0
- package/build/client/vaults/types/priceType.d.ts +19 -0
- package/build/client/vaults/types/priceType.js +26 -0
- package/build/client/vaults/types/priceType.js.map +1 -0
- package/build/client/vaults/types/programInteractionPolicyCreationPayload.d.ts +11 -0
- package/build/client/vaults/types/programInteractionPolicyCreationPayload.js +16 -0
- package/build/client/vaults/types/programInteractionPolicyCreationPayload.js.map +1 -0
- package/build/client/vaults/types/proposalAction.d.ts +226 -0
- package/build/client/vaults/types/proposalAction.js +40 -0
- package/build/client/vaults/types/proposalAction.js.map +1 -0
- package/build/client/vaults/types/proposalActionKind.d.ts +7 -0
- package/build/client/vaults/types/proposalActionKind.js +14 -0
- package/build/client/vaults/types/proposalActionKind.js.map +1 -0
- package/build/client/vaults/types/proposalStatus.d.ts +9 -0
- package/build/client/vaults/types/proposalStatus.js +16 -0
- package/build/client/vaults/types/proposalStatus.js.map +1 -0
- package/build/client/vaults/types/proposalVoteConfig.d.ts +46 -0
- package/build/client/vaults/types/proposalVoteConfig.js +18 -0
- package/build/client/vaults/types/proposalVoteConfig.js.map +1 -0
- package/build/client/vaults/types/proposeActionEvent.d.ts +48 -0
- package/build/client/vaults/types/proposeActionEvent.js +29 -0
- package/build/client/vaults/types/proposeActionEvent.js.map +1 -0
- package/build/client/vaults/types/quantityConstraints.d.ts +18 -0
- package/build/client/vaults/types/quantityConstraints.js +11 -0
- package/build/client/vaults/types/quantityConstraints.js.map +1 -0
- package/build/client/vaults/types/reservePriceMapping.d.ts +48 -0
- package/build/client/vaults/types/reservePriceMapping.js +15 -0
- package/build/client/vaults/types/reservePriceMapping.js.map +1 -0
- package/build/client/vaults/types/settingsChangePolicyCreationPayload.d.ts +81 -0
- package/build/client/vaults/types/settingsChangePolicyCreationPayload.js +10 -0
- package/build/client/vaults/types/settingsChangePolicyCreationPayload.js.map +1 -0
- package/build/client/vaults/types/spendingLimitPolicyCreationPayload.d.ts +142 -0
- package/build/client/vaults/types/spendingLimitPolicyCreationPayload.js +24 -0
- package/build/client/vaults/types/spendingLimitPolicyCreationPayload.js.map +1 -0
- package/build/client/vaults/types/stakeVoteEvent.d.ts +40 -0
- package/build/client/vaults/types/stakeVoteEvent.js +27 -0
- package/build/client/vaults/types/stakeVoteEvent.js.map +1 -0
- package/build/client/vaults/types/strategyPosition.d.ts +43 -0
- package/build/client/vaults/types/strategyPosition.js +54 -0
- package/build/client/vaults/types/strategyPosition.js.map +1 -0
- package/build/client/vaults/types/timeConstraints.d.ts +71 -0
- package/build/client/vaults/types/timeConstraints.js +13 -0
- package/build/client/vaults/types/timeConstraints.js.map +1 -0
- package/build/client/vaults/types/tokenAccountBalance.d.ts +52 -0
- package/build/client/vaults/types/tokenAccountBalance.js +19 -0
- package/build/client/vaults/types/tokenAccountBalance.js.map +1 -0
- package/build/client/vaults/types/tokenAccountEntry.d.ts +72 -0
- package/build/client/vaults/types/tokenAccountEntry.js +15 -0
- package/build/client/vaults/types/tokenAccountEntry.js.map +1 -0
- package/build/client/vaults/types/tokenEntry.d.ts +60 -0
- package/build/client/vaults/types/tokenEntry.js +24 -0
- package/build/client/vaults/types/tokenEntry.js.map +1 -0
- package/build/client/vaults/types/unstakeVoteEvent.d.ts +36 -0
- package/build/client/vaults/types/unstakeVoteEvent.js +26 -0
- package/build/client/vaults/types/unstakeVoteEvent.js.map +1 -0
- package/build/client/vaults/types/updatePriceAction.d.ts +174 -0
- package/build/client/vaults/types/updatePriceAction.js +104 -0
- package/build/client/vaults/types/updatePriceAction.js.map +1 -0
- package/build/client/vaults/types/updatePriceInput.d.ts +14 -0
- package/build/client/vaults/types/updatePriceInput.js +10 -0
- package/build/client/vaults/types/updatePriceInput.js.map +1 -0
- package/build/client/vaults/types/usageState.d.ts +14 -0
- package/build/client/vaults/types/usageState.js +10 -0
- package/build/client/vaults/types/usageState.js.map +1 -0
- package/build/client/vaults/types/vaultConfig.d.ts +87 -0
- package/build/client/vaults/types/vaultConfig.js +19 -0
- package/build/client/vaults/types/vaultConfig.js.map +1 -0
- package/build/client/vaults/types/vaultFinancials.d.ts +58 -0
- package/build/client/vaults/types/vaultFinancials.js +21 -0
- package/build/client/vaults/types/vaultFinancials.js.map +1 -0
- package/build/client/vaults/types/vaultFlagAction.d.ts +56 -0
- package/build/client/vaults/types/vaultFlagAction.js +22 -0
- package/build/client/vaults/types/vaultFlagAction.js.map +1 -0
- package/build/client/vaults/types/vaultFlagsUpdatedEvent.d.ts +23 -0
- package/build/client/vaults/types/vaultFlagsUpdatedEvent.js +19 -0
- package/build/client/vaults/types/vaultFlagsUpdatedEvent.js.map +1 -0
- package/build/client/vaults/types/vaultRoleKind.d.ts +7 -0
- package/build/client/vaults/types/vaultRoleKind.js +14 -0
- package/build/client/vaults/types/vaultRoleKind.js.map +1 -0
- package/build/client/vaults/types/vaultRoles.d.ts +23 -0
- package/build/client/vaults/types/vaultRoles.js +25 -0
- package/build/client/vaults/types/vaultRoles.js.map +1 -0
- package/build/client/vaults/types/vaultSettingsAction.d.ts +109 -0
- package/build/client/vaults/types/vaultSettingsAction.js +161 -0
- package/build/client/vaults/types/vaultSettingsAction.js.map +1 -0
- package/build/client/vaults/types/voteChoice.d.ts +5 -0
- package/build/client/vaults/types/voteChoice.js +12 -0
- package/build/client/vaults/types/voteChoice.js.map +1 -0
- package/build/client/vaults/types/withdrawalPeriodSettings.d.ts +48 -0
- package/build/client/vaults/types/withdrawalPeriodSettings.js +28 -0
- package/build/client/vaults/types/withdrawalPeriodSettings.js.map +1 -0
- package/build/client/vaults/types/withdrawalTokenFill.d.ts +19 -0
- package/build/client/vaults/types/withdrawalTokenFill.js +18 -0
- package/build/client/vaults/types/withdrawalTokenFill.js.map +1 -0
- package/build/client/vaults/types/yieldPositionEntry.d.ts +52 -0
- package/build/client/vaults/types/yieldPositionEntry.js +19 -0
- package/build/client/vaults/types/yieldPositionEntry.js.map +1 -0
- package/build/clmm/codamaEvents.d.ts +23 -0
- package/build/clmm/codamaEvents.js +24 -0
- package/build/clmm/codamaEvents.js.map +1 -0
- package/build/clmm/index.d.ts +1 -1
- package/build/clmm/index.js +1 -1
- package/build/clmm/index.js.map +1 -1
- package/build/codamaEvents.d.ts +18 -0
- package/build/codamaEvents.js +21 -0
- package/build/codamaEvents.js.map +1 -0
- package/build/environment.d.ts +8 -7
- package/build/environment.js +8 -7
- package/build/environment.js.map +1 -1
- package/build/exponentVaults/aumCalculator.d.ts +182 -0
- package/build/exponentVaults/aumCalculator.js +778 -0
- package/build/exponentVaults/aumCalculator.js.map +1 -0
- package/build/exponentVaults/events.d.ts +8 -0
- package/build/exponentVaults/events.js +12 -0
- package/build/exponentVaults/events.js.map +1 -0
- package/build/exponentVaults/index.d.ts +30 -0
- package/build/exponentVaults/index.js +176 -0
- package/build/exponentVaults/index.js.map +1 -0
- package/build/exponentVaults/kamino-markets.d.ts +887 -0
- package/build/exponentVaults/kamino-markets.js +345 -0
- package/build/exponentVaults/kamino-markets.js.map +1 -0
- package/build/exponentVaults/loopscale-client.d.ts +541 -0
- package/build/exponentVaults/loopscale-client.js +732 -0
- package/build/exponentVaults/loopscale-client.js.map +1 -0
- package/build/exponentVaults/policyBuilders.d.ts +694 -0
- package/build/exponentVaults/policyBuilders.js +1131 -0
- package/build/exponentVaults/policyBuilders.js.map +1 -0
- package/build/exponentVaults/policyMatcher.d.ts +82 -0
- package/build/exponentVaults/policyMatcher.js +730 -0
- package/build/exponentVaults/policyMatcher.js.map +1 -0
- package/build/exponentVaults/scope-refresh.d.ts +10 -0
- package/build/exponentVaults/scope-refresh.js +140 -0
- package/build/exponentVaults/scope-refresh.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/constants.d.ts +2 -0
- package/build/exponentVaults/squadsVaultTxnResolver/constants.js +61 -0
- package/build/exponentVaults/squadsVaultTxnResolver/constants.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/helpers.d.ts +26 -0
- package/build/exponentVaults/squadsVaultTxnResolver/helpers.js +268 -0
- package/build/exponentVaults/squadsVaultTxnResolver/helpers.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/index.d.ts +5 -0
- package/build/exponentVaults/squadsVaultTxnResolver/index.js +15 -0
- package/build/exponentVaults/squadsVaultTxnResolver/index.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.d.ts +6 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.js +361 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.d.ts +2 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.js +28 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/index.d.ts +2 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/index.js +25 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/index.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.d.ts +2 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.js +67 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.d.ts +2 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.js +73 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.d.ts +2 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.js +35 -0
- package/build/exponentVaults/squadsVaultTxnResolver/resolvers/titan.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/squadsVaultTxnResolver.d.ts +21 -0
- package/build/exponentVaults/squadsVaultTxnResolver/squadsVaultTxnResolver.js +64 -0
- package/build/exponentVaults/squadsVaultTxnResolver/squadsVaultTxnResolver.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/types.d.ts +111 -0
- package/build/exponentVaults/squadsVaultTxnResolver/types.js +92 -0
- package/build/exponentVaults/squadsVaultTxnResolver/types.js.map +1 -0
- package/build/exponentVaults/squadsVaultTxnResolver/utils.d.ts +3 -0
- package/build/exponentVaults/squadsVaultTxnResolver/utils.js +8 -0
- package/build/exponentVaults/squadsVaultTxnResolver/utils.js.map +1 -0
- package/build/exponentVaults/syncTransaction.d.ts +84 -0
- package/build/exponentVaults/syncTransaction.js +341 -0
- package/build/exponentVaults/syncTransaction.js.map +1 -0
- package/build/exponentVaults/titan-quote.d.ts +22 -0
- package/build/exponentVaults/titan-quote.js +167 -0
- package/build/exponentVaults/titan-quote.js.map +1 -0
- package/build/exponentVaults/vault-interaction.d.ts +3475 -0
- package/build/exponentVaults/vault-interaction.js +2251 -0
- package/build/exponentVaults/vault-interaction.js.map +1 -0
- package/build/exponentVaults/vault.d.ts +613 -0
- package/build/exponentVaults/vault.js +1437 -0
- package/build/exponentVaults/vault.js.map +1 -0
- package/build/exponentVaults/vaultTransactionBuilder.d.ts +319 -0
- package/build/exponentVaults/vaultTransactionBuilder.js +470 -0
- package/build/exponentVaults/vaultTransactionBuilder.js.map +1 -0
- package/build/flavors.d.ts +3 -3
- package/build/flavors.js +115 -111
- package/build/flavors.js.map +1 -1
- package/build/index.d.ts +15 -8
- package/build/index.js +23 -7
- package/build/index.js.map +1 -1
- package/build/lpPosition.d.ts +13 -15
- package/build/lpPosition.js +2 -6
- package/build/lpPosition.js.map +1 -1
- package/build/market.d.ts +203 -230
- package/build/market.js +277 -371
- package/build/market.js.map +1 -1
- package/build/marketThree.d.ts +401 -267
- package/build/marketThree.js +613 -279
- package/build/marketThree.js.map +1 -1
- package/build/marketThree.test.js +12 -12
- package/build/marketThree.test.js.map +1 -1
- package/build/orderbook/codamaEvents.d.ts +19 -0
- package/build/orderbook/codamaEvents.js +22 -0
- package/build/orderbook/codamaEvents.js.map +1 -0
- package/build/orderbook/index.d.ts +6 -3
- package/build/orderbook/index.js +8 -4
- package/build/orderbook/index.js.map +1 -1
- package/build/orderbook/math.d.ts +4 -2
- package/build/orderbook/math.js +23 -11
- package/build/orderbook/math.js.map +1 -1
- package/build/orderbook/orderbook.d.ts +182 -104
- package/build/orderbook/orderbook.js +375 -208
- package/build/orderbook/orderbook.js.map +1 -1
- package/build/orderbook/types.d.ts +6 -20
- package/build/orderbook/types.js +25 -5
- package/build/orderbook/types.js.map +1 -1
- package/build/orderbook/utils.d.ts +1 -3
- package/build/orderbook/utils.js +4 -12
- package/build/orderbook/utils.js.map +1 -1
- package/build/router.d.ts +72 -12
- package/build/router.js +333 -3
- package/build/router.js.map +1 -1
- package/build/syPosition.d.ts +2 -2
- package/build/syPosition.js +7 -7
- package/build/syPosition.js.map +1 -1
- package/build/tokenUtil.d.ts +3 -3
- package/build/tokenUtil.js.map +1 -1
- package/build/utils/index.d.ts +4 -5
- package/build/utils/index.js +3 -24
- package/build/utils/index.js.map +1 -1
- package/build/utils/ix.d.ts +2 -2
- package/build/vault.d.ts +108 -221
- package/build/vault.js +141 -98
- package/build/vault.js.map +1 -1
- package/build/ytPosition.d.ts +28 -36
- package/build/ytPosition.js +71 -62
- package/build/ytPosition.js.map +1 -1
- package/package.json +58 -28
- package/src/CodamaEventDecoder.ts +151 -0
- package/src/addressLookupTableUtil.ts +48 -14
- package/src/client/clmm/accounts/lpPosition.ts +143 -0
- package/src/client/clmm/accounts/marketThree.ts +274 -0
- package/src/client/clmm/accounts/vault.ts +234 -0
- package/src/client/clmm/eventRegistry.ts +92 -0
- package/src/client/clmm/index.ts +82 -0
- package/src/client/clmm/instructions/addFarm.ts +57 -0
- package/src/client/clmm/instructions/addLiquidity.ts +78 -0
- package/src/client/clmm/instructions/addMarketEmission.ts +50 -0
- package/src/client/clmm/instructions/buyPt.ts +73 -0
- package/src/client/clmm/instructions/buyYt.ts +80 -0
- package/src/client/clmm/instructions/claimFarmEmission.ts +56 -0
- package/src/client/clmm/instructions/closeMarket.ts +47 -0
- package/src/client/clmm/instructions/depositLiquidity.ts +71 -0
- package/src/client/clmm/instructions/initializeMarket.ts +127 -0
- package/src/client/clmm/instructions/marketAccrueEmission.ts +39 -0
- package/src/client/clmm/instructions/marketCollectEmission.ts +57 -0
- package/src/client/clmm/instructions/modifyFarm.ts +55 -0
- package/src/client/clmm/instructions/modifyMarketSetting.ts +45 -0
- package/src/client/clmm/instructions/sellPt.ts +73 -0
- package/src/client/clmm/instructions/sellYt.ts +80 -0
- package/src/client/clmm/instructions/tradePt.ts +73 -0
- package/src/client/clmm/instructions/tradePtExactOut.ts +75 -0
- package/src/client/clmm/instructions/withdrawLiquidity.ts +67 -0
- package/src/client/clmm/instructions/wrapperBuyYt.ts +85 -0
- package/src/client/clmm/instructions/wrapperProvideLiquidity.ts +100 -0
- package/src/client/clmm/instructions/wrapperProvideLiquidityBase.ts +98 -0
- package/src/client/clmm/instructions/wrapperProvideLiquidityClassic.ts +86 -0
- package/src/client/clmm/instructions/wrapperSellYt.ts +83 -0
- package/src/client/clmm/instructions/wrapperWithdrawLiquidity.ts +75 -0
- package/src/client/clmm/instructions/wrapperWithdrawLiquidityClassic.ts +69 -0
- package/src/client/clmm/types/addFarmEvent.ts +51 -0
- package/src/client/clmm/types/amount.ts +51 -0
- package/src/client/clmm/types/buyPtEvent.ts +36 -0
- package/src/client/clmm/types/buyYtEvent.ts +74 -0
- package/src/client/clmm/types/claimFarmEmissionsEvent.ts +94 -0
- package/src/client/clmm/types/claimLimits.ts +15 -0
- package/src/client/clmm/types/closeMarketEvent.ts +36 -0
- package/src/client/clmm/types/configurationOptions.ts +29 -0
- package/src/client/clmm/types/cpiAccounts.ts +21 -0
- package/src/client/clmm/types/cpiCoreAccounts.ts +15 -0
- package/src/client/clmm/types/cpiInterfaceContext.ts +13 -0
- package/src/client/clmm/types/crossingSplit.ts +40 -0
- package/src/client/clmm/types/depositLiquidityEvent.ts +93 -0
- package/src/client/clmm/types/depositLiquidityReturnData.ts +81 -0
- package/src/client/clmm/types/emissionInfo.ts +44 -0
- package/src/client/clmm/types/farmEmission.ts +31 -0
- package/src/client/clmm/types/index.ts +48 -0
- package/src/client/clmm/types/liquidityNetBalanceLimits.ts +22 -0
- package/src/client/clmm/types/lpFarm.ts +12 -0
- package/src/client/clmm/types/marketAccrueEmissionEvent.ts +69 -0
- package/src/client/clmm/types/marketAdminAction.ts +239 -0
- package/src/client/clmm/types/marketCollectEmissionEvent.ts +83 -0
- package/src/client/clmm/types/marketEmission.ts +28 -0
- package/src/client/clmm/types/marketEmissions.ts +10 -0
- package/src/client/clmm/types/marketFinancials.ts +17 -0
- package/src/client/clmm/types/marketThreeInitEvent.ts +92 -0
- package/src/client/clmm/types/mergeEvent.ts +118 -0
- package/src/client/clmm/types/modifiedTick.ts +13 -0
- package/src/client/clmm/types/modifiedTicks.ts +18 -0
- package/src/client/clmm/types/modifyFarmEvent.ts +56 -0
- package/src/client/clmm/types/number.ts +7 -0
- package/src/client/clmm/types/personalYieldTracker.ts +12 -0
- package/src/client/clmm/types/personalYieldTrackers.ts +13 -0
- package/src/client/clmm/types/principalShare.ts +22 -0
- package/src/client/clmm/types/principalShareTrackers.ts +10 -0
- package/src/client/clmm/types/sellPtEvent.ts +36 -0
- package/src/client/clmm/types/sellYtEvent.ts +69 -0
- package/src/client/clmm/types/stripEvent.ts +124 -0
- package/src/client/clmm/types/swapDirection.ts +8 -0
- package/src/client/clmm/types/tradePtEvent.ts +76 -0
- package/src/client/clmm/types/withdrawLiquidityEvent.ts +99 -0
- package/src/client/clmm/types/withdrawLiquidityReturnData.ts +27 -0
- package/src/client/clmm/types/wrapperBuyYtEvent.ts +36 -0
- package/src/client/clmm/types/wrapperProvideLiquidityBaseEvent.ts +60 -0
- package/src/client/clmm/types/wrapperProvideLiquidityClassicEvent.ts +58 -0
- package/src/client/clmm/types/wrapperProvideLiquidityEvent.ts +60 -0
- package/src/client/clmm/types/wrapperSellYtEvent.ts +36 -0
- package/src/client/clmm/types/wrapperWithdrawLiquidityClassicEvent.ts +62 -0
- package/src/client/clmm/types/wrapperWithdrawLiquidityEvent.ts +62 -0
- package/src/client/core/accounts/admin.ts +112 -0
- package/src/client/core/accounts/lpPosition.ts +122 -0
- package/src/client/core/accounts/marketTwo.ts +234 -0
- package/src/client/core/accounts/vault.ts +234 -0
- package/src/client/core/accounts/yieldTokenPosition.ts +126 -0
- package/src/client/core/eventRegistry.ts +134 -0
- package/src/client/core/index.ts +113 -0
- package/src/client/core/instructions/addEmission.ts +62 -0
- package/src/client/core/instructions/addFarm.ts +53 -0
- package/src/client/core/instructions/addLpTokensMetadata.ts +62 -0
- package/src/client/core/instructions/addMarketEmission.ts +52 -0
- package/src/client/core/instructions/buyYt.ts +79 -0
- package/src/client/core/instructions/claimFarmEmissions.ts +54 -0
- package/src/client/core/instructions/collectEmission.ts +66 -0
- package/src/client/core/instructions/collectInterest.ts +64 -0
- package/src/client/core/instructions/collectTreasuryEmission.ts +64 -0
- package/src/client/core/instructions/collectTreasuryInterest.ts +62 -0
- package/src/client/core/instructions/depositYt.ts +59 -0
- package/src/client/core/instructions/initLpPosition.ts +35 -0
- package/src/client/core/instructions/initMarketTwo.ts +103 -0
- package/src/client/core/instructions/initializeVault.ts +107 -0
- package/src/client/core/instructions/initializeYieldPosition.ts +33 -0
- package/src/client/core/instructions/marketCollectEmission.ts +55 -0
- package/src/client/core/instructions/marketDepositLp.ts +59 -0
- package/src/client/core/instructions/marketTwoDepositLiquidity.ts +65 -0
- package/src/client/core/instructions/marketTwoWithdrawLiquidity.ts +65 -0
- package/src/client/core/instructions/marketWithdrawLp.ts +59 -0
- package/src/client/core/instructions/merge.ts +61 -0
- package/src/client/core/instructions/modifyFarm.ts +51 -0
- package/src/client/core/instructions/modifyMarketSetting.ts +47 -0
- package/src/client/core/instructions/modifyVaultSetting.ts +44 -0
- package/src/client/core/instructions/reallocMarket.ts +45 -0
- package/src/client/core/instructions/sellYt.ts +79 -0
- package/src/client/core/instructions/stageYtYield.ts +39 -0
- package/src/client/core/instructions/strip.ts +61 -0
- package/src/client/core/instructions/tradePt.ts +59 -0
- package/src/client/core/instructions/withdrawYt.ts +61 -0
- package/src/client/core/instructions/wrapperBuyPt.ts +63 -0
- package/src/client/core/instructions/wrapperBuyYt.ts +93 -0
- package/src/client/core/instructions/wrapperCollectInterest.ts +63 -0
- package/src/client/core/instructions/wrapperMerge.ts +77 -0
- package/src/client/core/instructions/wrapperProvideLiquidity.ts +103 -0
- package/src/client/core/instructions/wrapperProvideLiquidityBase.ts +81 -0
- package/src/client/core/instructions/wrapperProvideLiquidityClassic.ts +77 -0
- package/src/client/core/instructions/wrapperSellPt.ts +63 -0
- package/src/client/core/instructions/wrapperSellYt.ts +87 -0
- package/src/client/core/instructions/wrapperStrip.ts +81 -0
- package/src/client/core/instructions/wrapperWithdrawLiquidity.ts +77 -0
- package/src/client/core/instructions/wrapperWithdrawLiquidityClassic.ts +73 -0
- package/src/client/core/types/adminAction.ts +255 -0
- package/src/client/core/types/amount.ts +51 -0
- package/src/client/core/types/buyPtEvent.ts +39 -0
- package/src/client/core/types/buyYtEvent.ts +95 -0
- package/src/client/core/types/claimFarmEmissionsEvent.ts +75 -0
- package/src/client/core/types/claimFarmEmissionsEventV2.ts +83 -0
- package/src/client/core/types/claimLimits.ts +15 -0
- package/src/client/core/types/collectEmissionEvent.ts +51 -0
- package/src/client/core/types/collectEmissionEventV2.ts +60 -0
- package/src/client/core/types/collectInterestEvent.ts +48 -0
- package/src/client/core/types/collectInterestEventV2.ts +57 -0
- package/src/client/core/types/collectTreasuryEmissionKind.ts +8 -0
- package/src/client/core/types/collectTreasuryInterestKind.ts +8 -0
- package/src/client/core/types/cpiAccounts.ts +21 -0
- package/src/client/core/types/cpiInterfaceContext.ts +13 -0
- package/src/client/core/types/depositLiquidityEvent.ts +101 -0
- package/src/client/core/types/depositLpEvent.ts +75 -0
- package/src/client/core/types/depositLpEventV2.ts +83 -0
- package/src/client/core/types/depositYtEvent.ts +82 -0
- package/src/client/core/types/depositYtEventV2.ts +91 -0
- package/src/client/core/types/emissionInfo.ts +44 -0
- package/src/client/core/types/farmEmission.ts +31 -0
- package/src/client/core/types/index.ts +60 -0
- package/src/client/core/types/initLpPositionEvent.ts +57 -0
- package/src/client/core/types/initializeYieldPositionEvent.ts +43 -0
- package/src/client/core/types/liquidityNetBalanceLimits.ts +22 -0
- package/src/client/core/types/lpFarm.ts +12 -0
- package/src/client/core/types/marketAdminAction.ts +212 -0
- package/src/client/core/types/marketCollectEmissionEvent.ts +67 -0
- package/src/client/core/types/marketCollectEmissionEventV2.ts +75 -0
- package/src/client/core/types/marketEmission.ts +28 -0
- package/src/client/core/types/marketEmissions.ts +10 -0
- package/src/client/core/types/marketFinancials.ts +19 -0
- package/src/client/core/types/mergeEvent.ts +118 -0
- package/src/client/core/types/number.ts +7 -0
- package/src/client/core/types/personalYieldTracker.ts +12 -0
- package/src/client/core/types/personalYieldTrackers.ts +13 -0
- package/src/client/core/types/principleDetails.ts +25 -0
- package/src/client/core/types/principles.ts +23 -0
- package/src/client/core/types/sellPtEvent.ts +39 -0
- package/src/client/core/types/sellYtEvent.ts +90 -0
- package/src/client/core/types/stageYieldEvent.ts +63 -0
- package/src/client/core/types/stageYieldEventV2.ts +69 -0
- package/src/client/core/types/stripEvent.ts +124 -0
- package/src/client/core/types/tradePtEvent.ts +80 -0
- package/src/client/core/types/withdrawLiquidityEvent.ts +97 -0
- package/src/client/core/types/withdrawLpEvent.ts +75 -0
- package/src/client/core/types/withdrawLpEventV2.ts +83 -0
- package/src/client/core/types/withdrawYtEvent.ts +82 -0
- package/src/client/core/types/withdrawYtEventV2.ts +91 -0
- package/src/client/core/types/wrapperBuyYtEvent.ts +39 -0
- package/src/client/core/types/wrapperCollectInterestEvent.ts +37 -0
- package/src/client/core/types/wrapperMergeEvent.ts +38 -0
- package/src/client/core/types/wrapperProvideLiquidityBaseEvent.ts +43 -0
- package/src/client/core/types/wrapperProvideLiquidityClassicEvent.ts +41 -0
- package/src/client/core/types/wrapperProvideLiquidityEvent.ts +41 -0
- package/src/client/core/types/wrapperSellYtEvent.ts +39 -0
- package/src/client/core/types/wrapperStripEvent.ts +38 -0
- package/src/client/core/types/wrapperWithdrawLiquidityClassicEvent.ts +41 -0
- package/src/client/core/types/wrapperWithdrawLiquidityEvent.ts +39 -0
- package/src/client/core/types/yieldTokenTracker.ts +12 -0
- package/src/client/orderbook/accounts/cpiAccountsOrderbook.ts +101 -0
- package/src/client/orderbook/accounts/vault.ts +234 -0
- package/src/client/orderbook/eventRegistry.ts +71 -0
- package/src/client/orderbook/index.ts +55 -0
- package/src/client/orderbook/instructions/collectAdminEmission.ts +48 -0
- package/src/client/orderbook/instructions/collectAdminFee.ts +59 -0
- package/src/client/orderbook/instructions/collectInterest.ts +66 -0
- package/src/client/orderbook/instructions/initializeOrderbook.ts +104 -0
- package/src/client/orderbook/instructions/marketOffer.ts +89 -0
- package/src/client/orderbook/instructions/postOffer.ts +96 -0
- package/src/client/orderbook/instructions/reallocOrderbookAccount.ts +45 -0
- package/src/client/orderbook/instructions/removeExpiredOffers.ts +37 -0
- package/src/client/orderbook/instructions/removeOffer.ts +73 -0
- package/src/client/orderbook/instructions/setConfigurationOptions.ts +43 -0
- package/src/client/orderbook/instructions/withdrawFunds.ts +78 -0
- package/src/client/orderbook/instructions/wrapperCollectAdminFee.ts +73 -0
- package/src/client/orderbook/instructions/wrapperCollectInterest.ts +65 -0
- package/src/client/orderbook/instructions/wrapperMarketOffer.ts +94 -0
- package/src/client/orderbook/instructions/wrapperPostOffer.ts +99 -0
- package/src/client/orderbook/instructions/wrapperRemoveOffer.ts +75 -0
- package/src/client/orderbook/instructions/wrapperWithdrawFunds.ts +80 -0
- package/src/client/orderbook/types/amount.ts +51 -0
- package/src/client/orderbook/types/claimLimits.ts +15 -0
- package/src/client/orderbook/types/collectAdminEmissionEvent.ts +39 -0
- package/src/client/orderbook/types/collectAdminFeeEvent.ts +17 -0
- package/src/client/orderbook/types/collectEmissionEventV2.ts +60 -0
- package/src/client/orderbook/types/collectInterestEventV2.ts +57 -0
- package/src/client/orderbook/types/collectUserInterestEvent.ts +36 -0
- package/src/client/orderbook/types/cpiAccounts.ts +21 -0
- package/src/client/orderbook/types/cpiInterfaceContext.ts +13 -0
- package/src/client/orderbook/types/emissionInfo.ts +44 -0
- package/src/client/orderbook/types/exponentCoreCpiAccounts.ts +21 -0
- package/src/client/orderbook/types/filledOffersEvent.ts +19 -0
- package/src/client/orderbook/types/index.ts +30 -0
- package/src/client/orderbook/types/marketOfferEvent.ts +72 -0
- package/src/client/orderbook/types/mergeEvent.ts +118 -0
- package/src/client/orderbook/types/number.ts +7 -0
- package/src/client/orderbook/types/offerOptions.ts +56 -0
- package/src/client/orderbook/types/offerType.ts +8 -0
- package/src/client/orderbook/types/orderbookInitEvent.ts +54 -0
- package/src/client/orderbook/types/postOfferEvent.ts +78 -0
- package/src/client/orderbook/types/removeOfferEvent.ts +67 -0
- package/src/client/orderbook/types/setConfigurationOptionsEnum.ts +116 -0
- package/src/client/orderbook/types/stripEvent.ts +124 -0
- package/src/client/orderbook/types/withdrawFundsEvent.ts +65 -0
- package/src/client/orderbook/types/wrapperCollectAdminFeeEvent.ts +13 -0
- package/src/client/orderbook/types/wrapperCollectInterestEvent.ts +25 -0
- package/src/client/orderbook/types/wrapperMarketOfferEvent.ts +27 -0
- package/src/client/orderbook/types/wrapperPostOfferEvent.ts +72 -0
- package/src/client/orderbook/types/wrapperRemoveOfferEvent.ts +25 -0
- package/src/client/orderbook/types/wrapperWithdrawFundsEvent.ts +38 -0
- package/src/client/orderbook/types/yieldTokenTracker.ts +12 -0
- package/src/client/vaults/accounts/actionProposal.ts +144 -0
- package/src/client/vaults/accounts/exponentStrategyVault.ts +211 -0
- package/src/client/vaults/accounts/programConfig.ts +123 -0
- package/src/client/vaults/accounts/voteAccount.ts +132 -0
- package/src/client/vaults/accounts/withdrawalAccount.ts +132 -0
- package/src/client/vaults/eventRegistry.ts +45 -0
- package/src/client/vaults/index.ts +111 -0
- package/src/client/vaults/instructions/activateProposal.ts +46 -0
- package/src/client/vaults/instructions/addPolicy.ts +57 -0
- package/src/client/vaults/instructions/appendProposalActions.ts +47 -0
- package/src/client/vaults/instructions/cancelProposal.ts +28 -0
- package/src/client/vaults/instructions/cancelWithdrawal.ts +34 -0
- package/src/client/vaults/instructions/collectManagementFee.ts +32 -0
- package/src/client/vaults/instructions/depositLiquidity.ts +62 -0
- package/src/client/vaults/instructions/executeProposal.ts +36 -0
- package/src/client/vaults/instructions/executeWithdrawal.ts +58 -0
- package/src/client/vaults/instructions/executeWithdrawalFromReserves.ts +66 -0
- package/src/client/vaults/instructions/fillWithdrawal.ts +59 -0
- package/src/client/vaults/instructions/finalizeProposal.ts +28 -0
- package/src/client/vaults/instructions/initProposal.ts +46 -0
- package/src/client/vaults/instructions/initializePrices.ts +28 -0
- package/src/client/vaults/instructions/initializeVault.ts +148 -0
- package/src/client/vaults/instructions/makeSentienelManager.ts +28 -0
- package/src/client/vaults/instructions/managePrices.ts +46 -0
- package/src/client/vaults/instructions/manageVaultSettings.ts +48 -0
- package/src/client/vaults/instructions/managerUpdatePosition.ts +45 -0
- package/src/client/vaults/instructions/queueWithdrawal.ts +50 -0
- package/src/client/vaults/instructions/removePolicy.ts +44 -0
- package/src/client/vaults/instructions/sentinelSetVaultFlags.ts +44 -0
- package/src/client/vaults/instructions/stakeVote.ts +57 -0
- package/src/client/vaults/instructions/unstakeVote.ts +42 -0
- package/src/client/vaults/instructions/updatePolicy.ts +59 -0
- package/src/client/vaults/instructions/updatePolicyManager.ts +44 -0
- package/src/client/vaults/instructions/updatePrice.ts +42 -0
- package/src/client/vaults/instructions/validateInteractionHook.ts +60 -0
- package/src/client/vaults/instructions/wrapperAddPolicy.ts +57 -0
- package/src/client/vaults/instructions/wrapperExecuteWithdrawal.ts +76 -0
- package/src/client/vaults/instructions/wrapperManageVaultSettings.ts +48 -0
- package/src/client/vaults/instructions/wrapperManagerUpdatePosition.ts +45 -0
- package/src/client/vaults/instructions/wrapperRemovePolicy.ts +44 -0
- package/src/client/vaults/instructions/wrapperUpdatePolicy.ts +59 -0
- package/src/client/vaults/types/accountConstraint.ts +35 -0
- package/src/client/vaults/types/accountConstraintType.ts +93 -0
- package/src/client/vaults/types/allowedSettingsChange.ts +136 -0
- package/src/client/vaults/types/cancelProposalEvent.ts +47 -0
- package/src/client/vaults/types/clmmPositionEntry.ts +37 -0
- package/src/client/vaults/types/dataConstraint.ts +16 -0
- package/src/client/vaults/types/dataOperator.ts +13 -0
- package/src/client/vaults/types/dataValue.ts +119 -0
- package/src/client/vaults/types/depositLiquidityEvent.ts +89 -0
- package/src/client/vaults/types/executeProposalEvent.ts +47 -0
- package/src/client/vaults/types/executeWithdrawalEvent.ts +12 -0
- package/src/client/vaults/types/fillParam.ts +12 -0
- package/src/client/vaults/types/finalizeProposalEvent.ts +51 -0
- package/src/client/vaults/types/hook.ts +40 -0
- package/src/client/vaults/types/hookCompiledInstruction.ts +20 -0
- package/src/client/vaults/types/index.ts +66 -0
- package/src/client/vaults/types/instructionConstraint.ts +33 -0
- package/src/client/vaults/types/internalFundTransferPolicyCreationPayload.ts +35 -0
- package/src/client/vaults/types/kaminoObligationEntry.ts +48 -0
- package/src/client/vaults/types/limitedQuantityConstraints.ts +10 -0
- package/src/client/vaults/types/limitedSpendingLimit.ts +35 -0
- package/src/client/vaults/types/limitedTimeConstraints.ts +15 -0
- package/src/client/vaults/types/loopscaleLoanEntry.ts +23 -0
- package/src/client/vaults/types/loopscaleStrategyEntry.ts +23 -0
- package/src/client/vaults/types/number.ts +8 -0
- package/src/client/vaults/types/obligationType.ts +63 -0
- package/src/client/vaults/types/orderbookEntry.ts +50 -0
- package/src/client/vaults/types/periodV2.ts +76 -0
- package/src/client/vaults/types/permissions.ts +8 -0
- package/src/client/vaults/types/policyAction.ts +74 -0
- package/src/client/vaults/types/policyConfig.ts +32 -0
- package/src/client/vaults/types/policyCreationPayload.ts +147 -0
- package/src/client/vaults/types/policyExpirationArgs.ts +67 -0
- package/src/client/vaults/types/positionUpdate.ts +251 -0
- package/src/client/vaults/types/priceId.ts +57 -0
- package/src/client/vaults/types/priceType.ts +23 -0
- package/src/client/vaults/types/programInteractionPolicyCreationPayload.ts +32 -0
- package/src/client/vaults/types/proposalAction.ts +100 -0
- package/src/client/vaults/types/proposalActionKind.ts +11 -0
- package/src/client/vaults/types/proposalStatus.ts +13 -0
- package/src/client/vaults/types/proposalVoteConfig.ts +36 -0
- package/src/client/vaults/types/proposeActionEvent.ts +62 -0
- package/src/client/vaults/types/quantityConstraints.ts +14 -0
- package/src/client/vaults/types/reservePriceMapping.ts +26 -0
- package/src/client/vaults/types/settingsChangePolicyCreationPayload.ts +14 -0
- package/src/client/vaults/types/spendingLimitPolicyCreationPayload.ts +54 -0
- package/src/client/vaults/types/stakeVoteEvent.ts +54 -0
- package/src/client/vaults/types/strategyPosition.ts +161 -0
- package/src/client/vaults/types/timeConstraints.ts +22 -0
- package/src/client/vaults/types/tokenAccountBalance.ts +35 -0
- package/src/client/vaults/types/tokenAccountEntry.ts +30 -0
- package/src/client/vaults/types/tokenEntry.ts +48 -0
- package/src/client/vaults/types/unstakeVoteEvent.ts +53 -0
- package/src/client/vaults/types/updatePriceAction.ts +268 -0
- package/src/client/vaults/types/updatePriceInput.ts +12 -0
- package/src/client/vaults/types/usageState.ts +12 -0
- package/src/client/vaults/types/vaultConfig.ts +38 -0
- package/src/client/vaults/types/vaultFinancials.ts +40 -0
- package/src/client/vaults/types/vaultFlagAction.ts +75 -0
- package/src/client/vaults/types/vaultFlagsUpdatedEvent.ts +37 -0
- package/src/client/vaults/types/vaultRoleKind.ts +11 -0
- package/src/client/vaults/types/vaultRoles.ts +59 -0
- package/src/client/vaults/types/vaultSettingsAction.ts +533 -0
- package/src/client/vaults/types/voteChoice.ts +9 -0
- package/src/client/vaults/types/withdrawalPeriodSettings.ts +83 -0
- package/src/client/vaults/types/withdrawalTokenFill.ts +35 -0
- package/src/client/vaults/types/yieldPositionEntry.ts +35 -0
- package/src/clmm/codamaEvents.ts +34 -0
- package/src/clmm/index.ts +1 -1
- package/src/codamaEvents.ts +27 -0
- package/src/environment.ts +15 -13
- package/src/exponentVaults/aumCalculator.ts +1013 -0
- package/src/exponentVaults/events.ts +15 -0
- package/src/exponentVaults/index.ts +298 -0
- package/src/exponentVaults/kamino-markets.ts +363 -0
- package/src/exponentVaults/loopscale-client.ts +1373 -0
- package/src/exponentVaults/policyBuilders.ts +1559 -0
- package/src/exponentVaults/policyMatcher.ts +895 -0
- package/src/exponentVaults/scope-refresh.ts +169 -0
- package/src/exponentVaults/squadsVaultTxnResolver/constants.ts +59 -0
- package/src/exponentVaults/squadsVaultTxnResolver/helpers.ts +355 -0
- package/src/exponentVaults/squadsVaultTxnResolver/index.ts +16 -0
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/exponent.ts +472 -0
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/helpers.ts +33 -0
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/index.ts +38 -0
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/kamino.ts +83 -0
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/loopscale.ts +94 -0
- package/src/exponentVaults/squadsVaultTxnResolver/resolvers/titan.ts +41 -0
- package/src/exponentVaults/squadsVaultTxnResolver/squadsVaultTxnResolver.ts +91 -0
- package/src/exponentVaults/squadsVaultTxnResolver/types.ts +171 -0
- package/src/exponentVaults/squadsVaultTxnResolver/utils.ts +3 -0
- package/src/exponentVaults/syncTransaction.ts +495 -0
- package/src/exponentVaults/titan-quote.ts +260 -0
- package/src/exponentVaults/vault-interaction.ts +3479 -0
- package/src/exponentVaults/vault.ts +2256 -0
- package/src/exponentVaults/vaultTransactionBuilder.ts +785 -0
- package/src/flavors.ts +100 -99
- package/src/index.ts +17 -8
- package/src/lpPosition.ts +13 -18
- package/src/market.ts +461 -544
- package/src/marketThree.test.ts +16 -14
- package/src/marketThree.ts +906 -483
- package/src/orderbook/codamaEvents.ts +28 -0
- package/src/orderbook/index.ts +5 -4
- package/src/orderbook/math.ts +25 -9
- package/src/orderbook/orderbook.ts +531 -330
- package/src/orderbook/types.ts +6 -11
- package/src/orderbook/utils.ts +4 -12
- package/src/router.ts +469 -19
- package/src/syPosition.ts +15 -16
- package/src/tokenUtil.ts +4 -4
- package/src/utils/index.ts +5 -31
- package/src/utils/ix.ts +2 -2
- package/src/vault.ts +282 -327
- package/src/ytPosition.ts +75 -118
- package/tsconfig.json +6 -1
- package/build/EventDecoderV2.d.ts +0 -31
- package/build/EventDecoderV2.js +0 -76
- package/build/EventDecoderV2.js.map +0 -1
- package/build/clmm/events.d.ts +0 -10
- package/build/clmm/events.js +0 -10
- package/build/clmm/events.js.map +0 -1
- package/build/events.d.ts +0 -563
- package/build/events.js +0 -301
- package/build/events.js.map +0 -1
- package/build/eventsV2.d.ts +0 -7
- package/build/eventsV2.js +0 -10
- package/build/eventsV2.js.map +0 -1
- package/build/orderbook/events.d.ts +0 -7
- package/build/orderbook/events.js +0 -10
- package/build/orderbook/events.js.map +0 -1
- package/src/EventDecoderV2.ts +0 -96
- package/src/clmm/events.ts +0 -17
- package/src/events.ts +0 -921
- package/src/eventsV2.ts +0 -13
- package/src/orderbook/events.ts +0 -13
|
@@ -0,0 +1,2251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SwapDirection = exports.clmmAction = exports.loopscaleAction = exports.titanAction = exports.createOrderbookSyncTransaction = exports.coreAction = exports.syAction = exports.orderbookAction = exports.createVaultSyncTransaction = exports.kaminoAction = exports.ClmmAction = exports.LoopscaleAction = exports.TitanAction = exports.SyAction = exports.CoreAction = exports.OrderbookAction = exports.OrderbookTradeDirection = exports.VaultAction = void 0;
|
|
30
|
+
const kamino_reserve_deserializer_1 = require("@exponent-labs/kamino-reserve-deserializer");
|
|
31
|
+
const kamino_markets_1 = require("./kamino-markets");
|
|
32
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
33
|
+
const constants_1 = require("./../../../kamino-lend-standard/src/constants");
|
|
34
|
+
const policyBuilders_1 = require("./policyBuilders");
|
|
35
|
+
const accounts_1 = require("@exponent-labs/klend-idl/accounts");
|
|
36
|
+
const precise_number_1 = require("@exponent-labs/precise-number");
|
|
37
|
+
const orderbook_1 = require("../orderbook/orderbook");
|
|
38
|
+
const marketThree_1 = require("../marketThree");
|
|
39
|
+
const utils_1 = require("../utils");
|
|
40
|
+
const clmm_1 = require("../client/clmm");
|
|
41
|
+
Object.defineProperty(exports, "SwapDirection", { enumerable: true, get: function () { return clmm_1.SwapDirection; } });
|
|
42
|
+
const exponentClmm = __importStar(require("../client/clmm"));
|
|
43
|
+
const exponentVaults = __importStar(require("../client/vaults"));
|
|
44
|
+
const orderbook_2 = require("../client/orderbook");
|
|
45
|
+
const environment_1 = require("../environment");
|
|
46
|
+
const vault_1 = require("../vault");
|
|
47
|
+
const ytPosition_1 = require("../ytPosition");
|
|
48
|
+
const vault_2 = require("./vault");
|
|
49
|
+
const instructions_1 = require("@exponent-labs/klend-idl/instructions");
|
|
50
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
51
|
+
const syncTransaction_1 = require("./syncTransaction");
|
|
52
|
+
const policyMatcher_1 = require("./policyMatcher");
|
|
53
|
+
const scope_refresh_1 = require("./scope-refresh");
|
|
54
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
55
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
56
|
+
const KAMINO_FARMS_PROGRAM_ID = new web3_js_1.PublicKey("FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr");
|
|
57
|
+
/** Actions that can be performed through the vault instruction builder. */
|
|
58
|
+
var VaultAction;
|
|
59
|
+
(function (VaultAction) {
|
|
60
|
+
VaultAction["INIT_USER_METADATA"] = "INIT_USER_METADATA";
|
|
61
|
+
VaultAction["INIT_OBLIGATION"] = "INIT_OBLIGATION";
|
|
62
|
+
VaultAction["DEPOSIT"] = "DEPOSIT";
|
|
63
|
+
VaultAction["WITHDRAW"] = "WITHDRAW";
|
|
64
|
+
VaultAction["BORROW"] = "BORROW";
|
|
65
|
+
VaultAction["REPAY"] = "REPAY";
|
|
66
|
+
})(VaultAction || (exports.VaultAction = VaultAction = {}));
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Orderbook Instruction Types
|
|
69
|
+
// ============================================================================
|
|
70
|
+
/** Orderbook trade direction */
|
|
71
|
+
var OrderbookTradeDirection;
|
|
72
|
+
(function (OrderbookTradeDirection) {
|
|
73
|
+
OrderbookTradeDirection["BUY_PT"] = "BUY_PT";
|
|
74
|
+
OrderbookTradeDirection["SELL_PT"] = "SELL_PT";
|
|
75
|
+
OrderbookTradeDirection["BUY_YT"] = "BUY_YT";
|
|
76
|
+
OrderbookTradeDirection["SELL_YT"] = "SELL_YT";
|
|
77
|
+
})(OrderbookTradeDirection || (exports.OrderbookTradeDirection = OrderbookTradeDirection = {}));
|
|
78
|
+
/** Actions that can be performed on the Exponent Orderbook */
|
|
79
|
+
var OrderbookAction;
|
|
80
|
+
(function (OrderbookAction) {
|
|
81
|
+
OrderbookAction["POST_OFFER"] = "POST_OFFER";
|
|
82
|
+
OrderbookAction["MARKET_OFFER"] = "MARKET_OFFER";
|
|
83
|
+
OrderbookAction["REMOVE_OFFER"] = "REMOVE_OFFER";
|
|
84
|
+
OrderbookAction["WITHDRAW_FUNDS"] = "WITHDRAW_FUNDS";
|
|
85
|
+
})(OrderbookAction || (exports.OrderbookAction = OrderbookAction = {}));
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Core Instruction Types (Strip/Merge)
|
|
88
|
+
// ============================================================================
|
|
89
|
+
/** Actions that can be performed on Exponent Core */
|
|
90
|
+
var CoreAction;
|
|
91
|
+
(function (CoreAction) {
|
|
92
|
+
CoreAction["STRIP"] = "STRIP";
|
|
93
|
+
CoreAction["MERGE"] = "MERGE";
|
|
94
|
+
CoreAction["WITHDRAW_YT"] = "WITHDRAW_YT";
|
|
95
|
+
CoreAction["DEPOSIT_YT"] = "DEPOSIT_YT";
|
|
96
|
+
CoreAction["INITIALIZE_YIELD_POSITION"] = "INITIALIZE_YIELD_POSITION";
|
|
97
|
+
})(CoreAction || (exports.CoreAction = CoreAction = {}));
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// Standard Program Instruction Types (mint_sy / redeem_sy)
|
|
100
|
+
// ============================================================================
|
|
101
|
+
var SyAction;
|
|
102
|
+
(function (SyAction) {
|
|
103
|
+
SyAction["MINT"] = "MINT_SY";
|
|
104
|
+
SyAction["REDEEM"] = "REDEEM_SY";
|
|
105
|
+
})(SyAction || (exports.SyAction = SyAction = {}));
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Titan Instruction Types
|
|
108
|
+
// ============================================================================
|
|
109
|
+
var TitanAction;
|
|
110
|
+
(function (TitanAction) {
|
|
111
|
+
TitanAction["SWAP"] = "SWAP";
|
|
112
|
+
})(TitanAction || (exports.TitanAction = TitanAction = {}));
|
|
113
|
+
// ============================================================================
|
|
114
|
+
// Loopscale Instruction Types
|
|
115
|
+
// ============================================================================
|
|
116
|
+
/** Actions for Loopscale interactions (loans = borrower side, strategies = lender side). */
|
|
117
|
+
var LoopscaleAction;
|
|
118
|
+
(function (LoopscaleAction) {
|
|
119
|
+
LoopscaleAction["CREATE_LOAN"] = "LOOPSCALE_CREATE_LOAN";
|
|
120
|
+
LoopscaleAction["DEPOSIT_COLLATERAL"] = "LOOPSCALE_DEPOSIT_COLLATERAL";
|
|
121
|
+
LoopscaleAction["BORROW_PRINCIPAL"] = "LOOPSCALE_BORROW_PRINCIPAL";
|
|
122
|
+
LoopscaleAction["REPAY_PRINCIPAL"] = "LOOPSCALE_REPAY_PRINCIPAL";
|
|
123
|
+
LoopscaleAction["WITHDRAW_COLLATERAL"] = "LOOPSCALE_WITHDRAW_COLLATERAL";
|
|
124
|
+
LoopscaleAction["CLOSE_LOAN"] = "LOOPSCALE_CLOSE_LOAN";
|
|
125
|
+
LoopscaleAction["UPDATE_WEIGHT_MATRIX"] = "LOOPSCALE_UPDATE_WEIGHT_MATRIX";
|
|
126
|
+
LoopscaleAction["CREATE_STRATEGY"] = "LOOPSCALE_CREATE_STRATEGY";
|
|
127
|
+
LoopscaleAction["DEPOSIT_STRATEGY"] = "LOOPSCALE_DEPOSIT_STRATEGY";
|
|
128
|
+
LoopscaleAction["WITHDRAW_STRATEGY"] = "LOOPSCALE_WITHDRAW_STRATEGY";
|
|
129
|
+
LoopscaleAction["CLOSE_STRATEGY"] = "LOOPSCALE_CLOSE_STRATEGY";
|
|
130
|
+
LoopscaleAction["UPDATE_STRATEGY"] = "LOOPSCALE_UPDATE_STRATEGY";
|
|
131
|
+
LoopscaleAction["LOCK_LOAN"] = "LOOPSCALE_LOCK_LOAN";
|
|
132
|
+
LoopscaleAction["UNLOCK_LOAN"] = "LOOPSCALE_UNLOCK_LOAN";
|
|
133
|
+
LoopscaleAction["REFINANCE_LEDGER"] = "LOOPSCALE_REFINANCE_LEDGER";
|
|
134
|
+
})(LoopscaleAction || (exports.LoopscaleAction = LoopscaleAction = {}));
|
|
135
|
+
// ============================================================================
|
|
136
|
+
// CLMM Instruction Types
|
|
137
|
+
// ============================================================================
|
|
138
|
+
/** Actions that can be performed on the Exponent CLMM (Concentrated Liquidity Market Maker). */
|
|
139
|
+
var ClmmAction;
|
|
140
|
+
(function (ClmmAction) {
|
|
141
|
+
/** Create a new LP position with a specified tick range. Generates keypair internally. */
|
|
142
|
+
ClmmAction["DEPOSIT_LIQUIDITY"] = "CLMM_DEPOSIT_LIQUIDITY";
|
|
143
|
+
/** Add more liquidity to an existing LP position. */
|
|
144
|
+
ClmmAction["ADD_LIQUIDITY"] = "CLMM_ADD_LIQUIDITY";
|
|
145
|
+
/** Remove liquidity from an LP position and receive PT + SY. */
|
|
146
|
+
ClmmAction["WITHDRAW_LIQUIDITY"] = "CLMM_WITHDRAW_LIQUIDITY";
|
|
147
|
+
/** Low-level PT/SY swap. Prefer buyPt/sellPt for directional trades. */
|
|
148
|
+
ClmmAction["TRADE_PT"] = "CLMM_TRADE_PT";
|
|
149
|
+
/** Buy PT with SY on the CLMM. */
|
|
150
|
+
ClmmAction["BUY_PT"] = "CLMM_BUY_PT";
|
|
151
|
+
/** Sell PT for SY on the CLMM. */
|
|
152
|
+
ClmmAction["SELL_PT"] = "CLMM_SELL_PT";
|
|
153
|
+
/** Buy YT with SY on the CLMM. */
|
|
154
|
+
ClmmAction["BUY_YT"] = "CLMM_BUY_YT";
|
|
155
|
+
/** Sell YT for SY on the CLMM. */
|
|
156
|
+
ClmmAction["SELL_YT"] = "CLMM_SELL_YT";
|
|
157
|
+
/** Claim farm emissions from an LP position. */
|
|
158
|
+
ClmmAction["CLAIM_FARM_EMISSION"] = "CLMM_CLAIM_FARM_EMISSION";
|
|
159
|
+
})(ClmmAction || (exports.ClmmAction = ClmmAction = {}));
|
|
160
|
+
// ============================================================================
|
|
161
|
+
// Kamino Action Builders
|
|
162
|
+
// ============================================================================
|
|
163
|
+
/**
|
|
164
|
+
* Builder for Kamino Lending (KLend) vault action descriptors.
|
|
165
|
+
*
|
|
166
|
+
* Each method returns a `VaultInstruction` that describes what to do.
|
|
167
|
+
* Pass these to `createVaultSyncTransaction` which resolves them into
|
|
168
|
+
* raw Solana instructions, handles refresh ordering, and wraps them
|
|
169
|
+
* in a Squads sync transaction.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* import { kaminoAction, KaminoMarket, createVaultSyncTransaction } from "@exponent-labs/exponent-sdk"
|
|
174
|
+
*
|
|
175
|
+
* const syncTx = await createVaultSyncTransaction({
|
|
176
|
+
* instructions: [
|
|
177
|
+
* kaminoAction.initUserMetadata(KaminoMarket.MAIN),
|
|
178
|
+
* kaminoAction.initObligation(KaminoMarket.MAIN),
|
|
179
|
+
* kaminoAction.deposit(KaminoMarket.MAIN, "USDC", new BN(1_000_000)),
|
|
180
|
+
* ],
|
|
181
|
+
* owner: vaultPda,
|
|
182
|
+
* connection,
|
|
183
|
+
* policyPda,
|
|
184
|
+
* vaultPda,
|
|
185
|
+
* signer: walletPublicKey,
|
|
186
|
+
* })
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
exports.kaminoAction = {
|
|
190
|
+
/**
|
|
191
|
+
* Initialize Kamino user metadata for a market.
|
|
192
|
+
* No-ops if the account already exists on-chain.
|
|
193
|
+
* @param market - The Kamino lending market
|
|
194
|
+
*/
|
|
195
|
+
initUserMetadata(market) {
|
|
196
|
+
return { action: VaultAction.INIT_USER_METADATA, market };
|
|
197
|
+
},
|
|
198
|
+
/**
|
|
199
|
+
* Initialize a Kamino obligation for a market.
|
|
200
|
+
* No-ops if the account already exists on-chain.
|
|
201
|
+
* @param market - The Kamino lending market
|
|
202
|
+
*/
|
|
203
|
+
initObligation(market) {
|
|
204
|
+
return { action: VaultAction.INIT_OBLIGATION, market };
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Deposit collateral into a Kamino reserve.
|
|
208
|
+
* Automatically prepends refreshReserve + refreshObligation instructions.
|
|
209
|
+
* @param market - The Kamino lending market
|
|
210
|
+
* @param asset - The reserve asset (e.g. "USDC", "SOL")
|
|
211
|
+
* @param amount - Amount in the asset's native units
|
|
212
|
+
*/
|
|
213
|
+
deposit(market, asset, amount) {
|
|
214
|
+
return { action: VaultAction.DEPOSIT, market, asset: asset, amount };
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* Withdraw collateral from a Kamino reserve.
|
|
218
|
+
* @param market - The Kamino lending market
|
|
219
|
+
* @param asset - The reserve asset (e.g. "USDC", "SOL")
|
|
220
|
+
* @param amount - Amount in the asset's native units
|
|
221
|
+
*/
|
|
222
|
+
withdraw(market, asset, amount) {
|
|
223
|
+
return { action: VaultAction.WITHDRAW, market, asset: asset, amount };
|
|
224
|
+
},
|
|
225
|
+
/**
|
|
226
|
+
* Borrow from a Kamino reserve.
|
|
227
|
+
* @param market - The Kamino lending market
|
|
228
|
+
* @param asset - The reserve asset (e.g. "USDC", "SOL")
|
|
229
|
+
* @param amount - Amount in the asset's native units
|
|
230
|
+
*/
|
|
231
|
+
borrow(market, asset, amount) {
|
|
232
|
+
return { action: VaultAction.BORROW, market, asset: asset, amount };
|
|
233
|
+
},
|
|
234
|
+
/**
|
|
235
|
+
* Repay a borrow on a Kamino reserve.
|
|
236
|
+
* @param market - The Kamino lending market
|
|
237
|
+
* @param asset - The reserve asset (e.g. "USDC", "SOL")
|
|
238
|
+
* @param amount - Amount in the asset's native units
|
|
239
|
+
*/
|
|
240
|
+
repay(market, asset, amount) {
|
|
241
|
+
return { action: VaultAction.REPAY, market, asset: asset, amount };
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Build vault instructions and wrap them in a Squads sync transaction.
|
|
246
|
+
*
|
|
247
|
+
* Takes high-level `VaultInstruction` descriptors (built with `kamino.*`),
|
|
248
|
+
* resolves them to raw Solana instructions, then separates them:
|
|
249
|
+
* - Permissionless refresh instructions → `preInstructions` (top-level)
|
|
250
|
+
* - Vault-signed instructions → `instruction` (Squads sync transaction)
|
|
251
|
+
*
|
|
252
|
+
* KLend's `check_refresh` requires refreshReserve to be a top-level instruction
|
|
253
|
+
* so it can be found via the instruction sysvar.
|
|
254
|
+
*
|
|
255
|
+
* @returns `{ setupInstructions, preInstructions, instruction, postInstructions, signers, addressLookupTableAddresses }`
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* const { setupInstructions, preInstructions, instruction, postInstructions, signers, addressLookupTableAddresses } = await createVaultSyncTransaction({
|
|
260
|
+
* instructions: [
|
|
261
|
+
* kamino.initUserMetadata(KaminoMarket.MAIN),
|
|
262
|
+
* kamino.initObligation(KaminoMarket.MAIN),
|
|
263
|
+
* kamino.deposit(KaminoMarket.MAIN, "USDC", new BN(1_000_000)),
|
|
264
|
+
* ],
|
|
265
|
+
* owner: vaultPda,
|
|
266
|
+
* connection,
|
|
267
|
+
* policyPda,
|
|
268
|
+
* vaultPda,
|
|
269
|
+
* signer: wallet.publicKey,
|
|
270
|
+
* vaultAddress: VAULT_ADDRESS,
|
|
271
|
+
* })
|
|
272
|
+
* // Send: [...setupInstructions, ...preInstructions, instruction, ...postInstructions]
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
async function createVaultSyncTransaction({ instructions, owner, connection, policyPda, vaultPda, signer, accountIndex = 0, constraintIndices, vaultAddress, leadingAccounts, preHookAccounts, postHookAccounts, squadsProgram = syncTransaction_1.SQUADS_PROGRAM_ID, }) {
|
|
276
|
+
const { setupInstructions, syncInstructions, preInstructions, postInstructions, signers, addressLookupTableAddresses } = await buildVaultInstructions(instructions, owner, connection, signer, policyPda, vaultPda, accountIndex, vaultAddress, leadingAccounts, preHookAccounts, postHookAccounts, squadsProgram);
|
|
277
|
+
let resolvedPolicyPda = policyPda;
|
|
278
|
+
let resolvedConstraintIndices = constraintIndices;
|
|
279
|
+
if (!resolvedPolicyPda) {
|
|
280
|
+
if (!vaultAddress) {
|
|
281
|
+
throw new Error("vaultAddress is required when policyPda is not provided");
|
|
282
|
+
}
|
|
283
|
+
const match = await (0, policyMatcher_1.resolvePolicyMatchForVault)(connection, vaultAddress, signer, syncInstructions);
|
|
284
|
+
resolvedPolicyPda = match.policyPda;
|
|
285
|
+
resolvedConstraintIndices ??= match.constraintIndices;
|
|
286
|
+
}
|
|
287
|
+
// Auto-resolve constraint indices when not explicitly provided
|
|
288
|
+
resolvedConstraintIndices ??= await (0, policyMatcher_1.resolveConstraintIndices)(connection, resolvedPolicyPda, syncInstructions);
|
|
289
|
+
// Auto-resolve policy prefix and hook accounts when not explicitly provided
|
|
290
|
+
let resolvedLeadingAccounts = leadingAccounts;
|
|
291
|
+
let resolvedPreHookAccounts = preHookAccounts;
|
|
292
|
+
let resolvedPostHookAccounts = postHookAccounts;
|
|
293
|
+
if (vaultAddress && (!leadingAccounts || !preHookAccounts || !postHookAccounts)) {
|
|
294
|
+
const hooks = await (0, policyMatcher_1.resolveHookAccounts)(connection, resolvedPolicyPda, vaultAddress, signer);
|
|
295
|
+
resolvedLeadingAccounts ??= hooks.leadingAccounts;
|
|
296
|
+
resolvedPreHookAccounts ??= hooks.preHookAccounts;
|
|
297
|
+
resolvedPostHookAccounts ??= hooks.postHookAccounts;
|
|
298
|
+
}
|
|
299
|
+
const instruction = (0, syncTransaction_1.wrapInstructionsInSyncTransaction)({
|
|
300
|
+
policyPda: resolvedPolicyPda,
|
|
301
|
+
vaultPda,
|
|
302
|
+
signer,
|
|
303
|
+
instructions: syncInstructions,
|
|
304
|
+
squadsProgram,
|
|
305
|
+
accountIndex,
|
|
306
|
+
constraintIndices: resolvedConstraintIndices,
|
|
307
|
+
leadingAccounts: resolvedLeadingAccounts,
|
|
308
|
+
preHookAccounts: resolvedPreHookAccounts,
|
|
309
|
+
postHookAccounts: resolvedPostHookAccounts,
|
|
310
|
+
});
|
|
311
|
+
return { setupInstructions, preInstructions, instruction, postInstructions, signers, addressLookupTableAddresses };
|
|
312
|
+
}
|
|
313
|
+
exports.createVaultSyncTransaction = createVaultSyncTransaction;
|
|
314
|
+
// ============================================================================
|
|
315
|
+
// Internal: Instruction Assembly
|
|
316
|
+
// ============================================================================
|
|
317
|
+
/** KLend farm modes — collateral for deposit/withdraw, debt for borrow/repay. */
|
|
318
|
+
const FARM_COLLATERAL = 0;
|
|
319
|
+
const FARM_DEBT = 1;
|
|
320
|
+
function isOrderbookInstruction(ix) {
|
|
321
|
+
return Object.values(OrderbookAction).includes(ix.action);
|
|
322
|
+
}
|
|
323
|
+
function isCoreInstruction(ix) {
|
|
324
|
+
return Object.values(CoreAction).includes(ix.action);
|
|
325
|
+
}
|
|
326
|
+
function isSyInstruction(ix) {
|
|
327
|
+
return Object.values(SyAction).includes(ix.action);
|
|
328
|
+
}
|
|
329
|
+
function isTitanInstruction(ix) {
|
|
330
|
+
return Object.values(TitanAction).includes(ix.action);
|
|
331
|
+
}
|
|
332
|
+
function isClmmInstruction(ix) {
|
|
333
|
+
return Object.values(ClmmAction).includes(ix.action);
|
|
334
|
+
}
|
|
335
|
+
function isLoopscaleInstruction(ix) {
|
|
336
|
+
return Object.values(LoopscaleAction).includes(ix.action);
|
|
337
|
+
}
|
|
338
|
+
/** Cache for loaded vaults to avoid redundant fetches */
|
|
339
|
+
const vaultCache = new Map();
|
|
340
|
+
const TITAN_INPUT_MINT_ACCOUNT_INDEX = 2;
|
|
341
|
+
const TITAN_INPUT_TOKEN_ACCOUNT_INDEX = 3;
|
|
342
|
+
const TITAN_OUTPUT_MINT_ACCOUNT_INDEX = 4;
|
|
343
|
+
const TITAN_OUTPUT_TOKEN_ACCOUNT_INDEX = 5;
|
|
344
|
+
const TITAN_INPUT_TOKEN_PROGRAM_ACCOUNT_INDEX = 6;
|
|
345
|
+
const TITAN_OUTPUT_TOKEN_PROGRAM_ACCOUNT_INDEX = 7;
|
|
346
|
+
const YIELD_POSITION_BASE_SIZE = 124;
|
|
347
|
+
const YIELD_POSITION_TRACKER_SIZE = 40;
|
|
348
|
+
function createStrategySetupContext({ connection, env, owner, signer, vaultAddress, policyPda, vaultPda, accountIndex = 0, squadsProgram = syncTransaction_1.SQUADS_PROGRAM_ID, leadingAccounts, preHookAccounts, postHookAccounts, }) {
|
|
349
|
+
return {
|
|
350
|
+
connection,
|
|
351
|
+
env,
|
|
352
|
+
owner,
|
|
353
|
+
signer,
|
|
354
|
+
vaultAddress,
|
|
355
|
+
policyPda,
|
|
356
|
+
vaultPda,
|
|
357
|
+
accountIndex,
|
|
358
|
+
squadsProgram,
|
|
359
|
+
leadingAccounts,
|
|
360
|
+
preHookAccounts,
|
|
361
|
+
postHookAccounts,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
async function loadStrategySetupState(context) {
|
|
365
|
+
if (!context.vaultAddress) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
if (!context.statePromise) {
|
|
369
|
+
context.statePromise = (async () => {
|
|
370
|
+
const strategyVault = await vault_2.ExponentVault.load({
|
|
371
|
+
env: context.env,
|
|
372
|
+
connection: context.connection,
|
|
373
|
+
address: context.vaultAddress,
|
|
374
|
+
});
|
|
375
|
+
const prices = await strategyVault.fetcher.fetchExponentPrices();
|
|
376
|
+
const trackedOrderbooks = new Set();
|
|
377
|
+
const trackedYieldVaults = new Set();
|
|
378
|
+
const tokenEntryAccountByMint = new Map();
|
|
379
|
+
const tokenPositionIndexByMint = new Map();
|
|
380
|
+
const trackedTokenAccounts = new Set();
|
|
381
|
+
for (const entry of strategyVault.state.tokenEntries) {
|
|
382
|
+
tokenEntryAccountByMint.set(entry.mint.toBase58(), entry.tokenSquadsAccount.toBase58());
|
|
383
|
+
trackedTokenAccounts.add(entry.tokenSquadsAccount.toBase58());
|
|
384
|
+
}
|
|
385
|
+
for (const [index, position] of strategyVault.state.strategyPositions.entries()) {
|
|
386
|
+
if ("orderbook" in position && position.orderbook?.[0]) {
|
|
387
|
+
trackedOrderbooks.add(position.orderbook[0].orderbook.toBase58());
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if ("yieldPosition" in position && position.yieldPosition?.[0]) {
|
|
391
|
+
trackedYieldVaults.add(position.yieldPosition[0].vault.toBase58());
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if ("tokenAccount" in position && position.tokenAccount?.[0]) {
|
|
395
|
+
const entry = position.tokenAccount[0];
|
|
396
|
+
tokenPositionIndexByMint.set(entry.tokenMint.toBase58(), index);
|
|
397
|
+
for (const balance of entry.balances) {
|
|
398
|
+
trackedTokenAccounts.add(balance.tokenAccount.toBase58());
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
strategyVault,
|
|
404
|
+
prices,
|
|
405
|
+
nextStrategyPositionIndex: strategyVault.state.strategyPositions.length,
|
|
406
|
+
trackedOrderbooks,
|
|
407
|
+
trackedYieldVaults,
|
|
408
|
+
tokenEntryAccountByMint,
|
|
409
|
+
tokenPositionIndexByMint,
|
|
410
|
+
trackedTokenAccounts,
|
|
411
|
+
existingAccounts: new Map(),
|
|
412
|
+
};
|
|
413
|
+
})();
|
|
414
|
+
}
|
|
415
|
+
return context.statePromise;
|
|
416
|
+
}
|
|
417
|
+
function findSimplePrice(prices, priceMint, underlyingMint) {
|
|
418
|
+
for (const entry of prices.prices) {
|
|
419
|
+
if (!entry)
|
|
420
|
+
continue;
|
|
421
|
+
if (!entry.priceMint.equals(priceMint) || !entry.underlyingMint.equals(underlyingMint)) {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
priceId: entry.priceId,
|
|
426
|
+
price: exponentPriceToDecimal(entry),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
function exponentPriceToDecimal(entry) {
|
|
432
|
+
const raw = entry.price[0];
|
|
433
|
+
if (!Array.isArray(raw)) {
|
|
434
|
+
throw new Error(`Invalid Exponent price format for ${entry.priceId.toString()}`);
|
|
435
|
+
}
|
|
436
|
+
return new decimal_js_1.default((0, precise_number_1.bigintU256ToString)(raw.map((value) => BigInt(value.toString()))));
|
|
437
|
+
}
|
|
438
|
+
async function accountExists(state, connection, address) {
|
|
439
|
+
const cacheKey = address.toBase58();
|
|
440
|
+
const cached = state.existingAccounts.get(cacheKey);
|
|
441
|
+
if (cached !== undefined) {
|
|
442
|
+
return cached;
|
|
443
|
+
}
|
|
444
|
+
const exists = (await connection.getAccountInfo(address)) !== null;
|
|
445
|
+
state.existingAccounts.set(cacheKey, exists);
|
|
446
|
+
return exists;
|
|
447
|
+
}
|
|
448
|
+
async function maybeCreateOwnedAtaSetupInstruction({ state, connection, payer, owner, mint, tokenProgram, tokenAccount, }) {
|
|
449
|
+
if (await accountExists(state, connection, tokenAccount)) {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
const expectedAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, owner, true, tokenProgram);
|
|
453
|
+
if (!expectedAta.equals(tokenAccount)) {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
state.existingAccounts.set(tokenAccount.toBase58(), true);
|
|
457
|
+
return (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payer, tokenAccount, owner, mint, tokenProgram);
|
|
458
|
+
}
|
|
459
|
+
async function ensureOrderbookPositionSetup(orderbook, buckets, setupContext) {
|
|
460
|
+
const state = await loadStrategySetupState(setupContext);
|
|
461
|
+
if (!state) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const orderbookKey = orderbook.selfAddress.toBase58();
|
|
465
|
+
if (state.trackedOrderbooks.has(orderbookKey)) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const ptPrice = findSimplePrice(state.prices, orderbook.mintPt, state.strategyVault.state.underlyingMint);
|
|
469
|
+
if (!ptPrice) {
|
|
470
|
+
throw new Error(`Missing Exponent price for orderbook setup (${orderbook.selfAddress.toBase58()})`);
|
|
471
|
+
}
|
|
472
|
+
buckets.setupInstructions.push(state.strategyVault.ixWrapperManageVaultSettings({
|
|
473
|
+
manager: setupContext.signer,
|
|
474
|
+
actions: [
|
|
475
|
+
exponentVaults.vaultSettingsAction("AddOrderbookEntry", [{
|
|
476
|
+
orderbook: orderbook.selfAddress,
|
|
477
|
+
// Legacy field retained for layout compatibility. Order ownership is
|
|
478
|
+
// derived from live orderbook state during AUM calculation.
|
|
479
|
+
userEscrowIdx: 0,
|
|
480
|
+
mint: orderbook.vault.mintSy,
|
|
481
|
+
offerIdxVec: [],
|
|
482
|
+
priceIdPt: exponentVaults.priceId("Simple", { priceId: ptPrice.priceId }),
|
|
483
|
+
baseMint: state.strategyVault.state.underlyingMint,
|
|
484
|
+
}]),
|
|
485
|
+
],
|
|
486
|
+
remainingAccounts: [
|
|
487
|
+
{ pubkey: orderbook.selfAddress, isSigner: false, isWritable: false },
|
|
488
|
+
{ pubkey: orderbook.state.vault, isSigner: false, isWritable: false },
|
|
489
|
+
],
|
|
490
|
+
}));
|
|
491
|
+
state.trackedOrderbooks.add(orderbookKey);
|
|
492
|
+
state.nextStrategyPositionIndex += 1;
|
|
493
|
+
}
|
|
494
|
+
async function ensureYieldPositionSetup(coreVault, buckets, setupContext) {
|
|
495
|
+
const state = await loadStrategySetupState(setupContext);
|
|
496
|
+
if (!state) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const coreVaultKey = coreVault.selfAddress.toBase58();
|
|
500
|
+
if (state.trackedYieldVaults.has(coreVaultKey)) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const ptPrice = findSimplePrice(state.prices, coreVault.mintPt, state.strategyVault.state.underlyingMint);
|
|
504
|
+
if (!ptPrice) {
|
|
505
|
+
throw new Error(`Missing Exponent price for core vault setup (${coreVault.selfAddress.toBase58()})`);
|
|
506
|
+
}
|
|
507
|
+
const yieldPosition = coreVault.pda.yieldPosition({ owner: setupContext.owner, vault: coreVault.selfAddress });
|
|
508
|
+
if (!(await accountExists(state, setupContext.connection, yieldPosition))) {
|
|
509
|
+
const requiredLamports = await setupContext.connection.getMinimumBalanceForRentExemption(YIELD_POSITION_BASE_SIZE + (coreVault.state.emissions.length * YIELD_POSITION_TRACKER_SIZE));
|
|
510
|
+
const ownerLamports = await setupContext.connection.getBalance(setupContext.owner);
|
|
511
|
+
if (ownerLamports < requiredLamports) {
|
|
512
|
+
buckets.setupInstructions.push(web3_js_1.SystemProgram.transfer({
|
|
513
|
+
fromPubkey: setupContext.signer,
|
|
514
|
+
toPubkey: setupContext.owner,
|
|
515
|
+
lamports: requiredLamports - ownerLamports,
|
|
516
|
+
}));
|
|
517
|
+
}
|
|
518
|
+
const initializeYieldPositionIx = coreVault.ixInitializeYieldPosition({ owner: setupContext.owner });
|
|
519
|
+
try {
|
|
520
|
+
buckets.setupInstructions.push(await wrapVaultSignedSetupInstruction({
|
|
521
|
+
instruction: initializeYieldPositionIx,
|
|
522
|
+
setupContext,
|
|
523
|
+
}));
|
|
524
|
+
}
|
|
525
|
+
catch (error) {
|
|
526
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
527
|
+
throw new Error(`Failed to auto-initialize yield position ${yieldPosition.toBase58()} for ${coreVault.selfAddress.toBase58()}: ${reason}`);
|
|
528
|
+
}
|
|
529
|
+
state.existingAccounts.set(yieldPosition.toBase58(), true);
|
|
530
|
+
}
|
|
531
|
+
buckets.setupInstructions.push(state.strategyVault.ixWrapperManageVaultSettings({
|
|
532
|
+
manager: setupContext.signer,
|
|
533
|
+
actions: [
|
|
534
|
+
exponentVaults.vaultSettingsAction("AddYieldPositionEntry", {
|
|
535
|
+
yieldPosition,
|
|
536
|
+
vault: coreVault.selfAddress,
|
|
537
|
+
priceIdPt: exponentVaults.priceId("Simple", { priceId: ptPrice.priceId }),
|
|
538
|
+
}),
|
|
539
|
+
],
|
|
540
|
+
remainingAccounts: [
|
|
541
|
+
{ pubkey: coreVault.selfAddress, isSigner: false, isWritable: false },
|
|
542
|
+
{ pubkey: yieldPosition, isSigner: false, isWritable: false },
|
|
543
|
+
],
|
|
544
|
+
}));
|
|
545
|
+
state.trackedYieldVaults.add(coreVaultKey);
|
|
546
|
+
state.nextStrategyPositionIndex += 1;
|
|
547
|
+
}
|
|
548
|
+
async function wrapVaultSignedSetupInstruction({ instruction, setupContext, }) {
|
|
549
|
+
if (!setupContext.vaultPda) {
|
|
550
|
+
throw new Error("vaultPda is required to auto-wrap setup instructions");
|
|
551
|
+
}
|
|
552
|
+
let resolvedPolicyPda = setupContext.policyPda;
|
|
553
|
+
let constraintIndices;
|
|
554
|
+
if (!resolvedPolicyPda) {
|
|
555
|
+
if (!setupContext.vaultAddress) {
|
|
556
|
+
throw new Error("vaultAddress is required when policyPda is not provided");
|
|
557
|
+
}
|
|
558
|
+
const match = await (0, policyMatcher_1.resolvePolicyMatchForVault)(setupContext.connection, setupContext.vaultAddress, setupContext.signer, [instruction]);
|
|
559
|
+
resolvedPolicyPda = match.policyPda;
|
|
560
|
+
constraintIndices = match.constraintIndices;
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
constraintIndices = await (0, policyMatcher_1.resolveConstraintIndices)(setupContext.connection, resolvedPolicyPda, [instruction]);
|
|
564
|
+
}
|
|
565
|
+
let resolvedLeadingAccounts = setupContext.leadingAccounts;
|
|
566
|
+
let resolvedPreHookAccounts = setupContext.preHookAccounts;
|
|
567
|
+
let resolvedPostHookAccounts = setupContext.postHookAccounts;
|
|
568
|
+
if (setupContext.vaultAddress
|
|
569
|
+
&& (!resolvedLeadingAccounts || !resolvedPreHookAccounts || !resolvedPostHookAccounts)) {
|
|
570
|
+
const hooks = await (0, policyMatcher_1.resolveHookAccounts)(setupContext.connection, resolvedPolicyPda, setupContext.vaultAddress, setupContext.signer);
|
|
571
|
+
resolvedLeadingAccounts ??= hooks.leadingAccounts;
|
|
572
|
+
resolvedPreHookAccounts ??= hooks.preHookAccounts;
|
|
573
|
+
resolvedPostHookAccounts ??= hooks.postHookAccounts;
|
|
574
|
+
}
|
|
575
|
+
return (0, syncTransaction_1.wrapInstructionsInSyncTransaction)({
|
|
576
|
+
policyPda: resolvedPolicyPda,
|
|
577
|
+
vaultPda: setupContext.vaultPda,
|
|
578
|
+
signer: setupContext.signer,
|
|
579
|
+
instructions: [instruction],
|
|
580
|
+
squadsProgram: setupContext.squadsProgram,
|
|
581
|
+
accountIndex: setupContext.accountIndex,
|
|
582
|
+
constraintIndices,
|
|
583
|
+
leadingAccounts: resolvedLeadingAccounts,
|
|
584
|
+
preHookAccounts: resolvedPreHookAccounts,
|
|
585
|
+
postHookAccounts: resolvedPostHookAccounts,
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
async function ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext, }) {
|
|
589
|
+
const state = await loadStrategySetupState(setupContext);
|
|
590
|
+
if (!state) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const tokenMintKey = tokenMint.toBase58();
|
|
594
|
+
const tokenAccountKey = tokenAccount.toBase58();
|
|
595
|
+
const tokenEntryAccount = state.tokenEntryAccountByMint.get(tokenMintKey);
|
|
596
|
+
if (tokenEntryAccount) {
|
|
597
|
+
if (tokenEntryAccount !== tokenAccountKey) {
|
|
598
|
+
throw new Error(`Mint ${tokenMintKey} is tracked as a token entry on ${tokenEntryAccount}; use that account instead of ${tokenAccountKey}`);
|
|
599
|
+
}
|
|
600
|
+
state.trackedTokenAccounts.add(tokenAccountKey);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (state.trackedTokenAccounts.has(tokenAccountKey)) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const price = findSimplePrice(state.prices, tokenMint, state.strategyVault.state.underlyingMint);
|
|
607
|
+
if (!price) {
|
|
608
|
+
throw new Error(`Missing Exponent price for token position setup (${tokenMint.toBase58()})`);
|
|
609
|
+
}
|
|
610
|
+
const maybeAtaIx = await maybeCreateOwnedAtaSetupInstruction({
|
|
611
|
+
state,
|
|
612
|
+
connection: setupContext.connection,
|
|
613
|
+
payer: setupContext.signer,
|
|
614
|
+
owner: setupContext.owner,
|
|
615
|
+
mint: tokenMint,
|
|
616
|
+
tokenProgram,
|
|
617
|
+
tokenAccount,
|
|
618
|
+
});
|
|
619
|
+
if (maybeAtaIx) {
|
|
620
|
+
buckets.setupInstructions.push(maybeAtaIx);
|
|
621
|
+
}
|
|
622
|
+
const positionIndex = state.tokenPositionIndexByMint.get(tokenMintKey);
|
|
623
|
+
if (positionIndex === undefined) {
|
|
624
|
+
buckets.setupInstructions.push(state.strategyVault.ixWrapperManageVaultSettings({
|
|
625
|
+
manager: setupContext.signer,
|
|
626
|
+
actions: [
|
|
627
|
+
exponentVaults.vaultSettingsAction("AddTokenAccountEntry", [{
|
|
628
|
+
tokenMint,
|
|
629
|
+
balances: [{
|
|
630
|
+
tokenAccount,
|
|
631
|
+
mint: tokenMint,
|
|
632
|
+
priceId: exponentVaults.priceId("Simple", { priceId: price.priceId }),
|
|
633
|
+
}],
|
|
634
|
+
}]),
|
|
635
|
+
],
|
|
636
|
+
remainingAccounts: [
|
|
637
|
+
{ pubkey: tokenAccount, isSigner: false, isWritable: false },
|
|
638
|
+
],
|
|
639
|
+
}));
|
|
640
|
+
state.tokenPositionIndexByMint.set(tokenMintKey, state.nextStrategyPositionIndex);
|
|
641
|
+
state.nextStrategyPositionIndex += 1;
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
buckets.setupInstructions.push(state.strategyVault.ixWrapperManagerUpdatePosition({
|
|
645
|
+
manager: setupContext.signer,
|
|
646
|
+
update: {
|
|
647
|
+
__kind: "AddTokenAccountBalance",
|
|
648
|
+
tokenMint,
|
|
649
|
+
balance: {
|
|
650
|
+
tokenAccount,
|
|
651
|
+
mint: tokenMint,
|
|
652
|
+
priceId: exponentVaults.priceId("Simple", { priceId: price.priceId }),
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
remainingAccounts: [
|
|
656
|
+
{ pubkey: tokenAccount, isSigner: false, isWritable: false },
|
|
657
|
+
],
|
|
658
|
+
}));
|
|
659
|
+
}
|
|
660
|
+
state.trackedTokenAccounts.add(tokenAccountKey);
|
|
661
|
+
}
|
|
662
|
+
async function buildVaultInstructions(instructions, owner, connection, signer, policyPda, vaultPda, accountIndex, vaultAddress, leadingAccounts, preHookAccounts, postHookAccounts, squadsProgram = syncTransaction_1.SQUADS_PROGRAM_ID) {
|
|
663
|
+
const buckets = {
|
|
664
|
+
setupInstructions: [],
|
|
665
|
+
syncInstructions: [],
|
|
666
|
+
preInstructions: [],
|
|
667
|
+
postInstructions: [],
|
|
668
|
+
signers: [],
|
|
669
|
+
addressLookupTableAddresses: [],
|
|
670
|
+
};
|
|
671
|
+
const setupContext = createStrategySetupContext({
|
|
672
|
+
connection,
|
|
673
|
+
env: environment_1.LOCAL_ENV,
|
|
674
|
+
owner,
|
|
675
|
+
signer,
|
|
676
|
+
vaultAddress,
|
|
677
|
+
policyPda,
|
|
678
|
+
vaultPda,
|
|
679
|
+
accountIndex,
|
|
680
|
+
squadsProgram,
|
|
681
|
+
leadingAccounts,
|
|
682
|
+
preHookAccounts,
|
|
683
|
+
postHookAccounts,
|
|
684
|
+
});
|
|
685
|
+
for (const ix of instructions) {
|
|
686
|
+
if (isOrderbookInstruction(ix)) {
|
|
687
|
+
await buildOrderbookInstruction(ix, owner, connection, buckets, setupContext);
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
if (isCoreInstruction(ix)) {
|
|
691
|
+
await buildCoreInstruction(ix, owner, connection, buckets, setupContext);
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (isSyInstruction(ix)) {
|
|
695
|
+
await buildSyInstruction(ix, owner, connection, buckets, setupContext);
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (isTitanInstruction(ix)) {
|
|
699
|
+
await buildTitanInstruction(ix, buckets, setupContext);
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
if (isLoopscaleInstruction(ix)) {
|
|
703
|
+
await buildLoopscaleInstruction(ix, buckets, setupContext);
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (isClmmInstruction(ix)) {
|
|
707
|
+
await buildClmmInstruction(ix, owner, connection, buckets, setupContext);
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
switch (ix.action) {
|
|
711
|
+
case VaultAction.INIT_USER_METADATA:
|
|
712
|
+
await buildInitUserMetadata(owner, connection, buckets);
|
|
713
|
+
break;
|
|
714
|
+
case VaultAction.INIT_OBLIGATION:
|
|
715
|
+
await buildInitObligation(ix, owner, connection, buckets);
|
|
716
|
+
break;
|
|
717
|
+
case VaultAction.DEPOSIT:
|
|
718
|
+
await buildDeposit(ix, owner, connection, signer, buckets);
|
|
719
|
+
break;
|
|
720
|
+
case VaultAction.WITHDRAW:
|
|
721
|
+
await buildWithdraw(ix, owner, connection, signer, buckets);
|
|
722
|
+
break;
|
|
723
|
+
case VaultAction.BORROW:
|
|
724
|
+
await buildBorrow(ix, owner, connection, signer, buckets);
|
|
725
|
+
break;
|
|
726
|
+
case VaultAction.REPAY:
|
|
727
|
+
await buildRepay(ix, owner, connection, signer, buckets);
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return buckets;
|
|
732
|
+
}
|
|
733
|
+
async function buildTitanInstruction(ix, buckets, setupContext) {
|
|
734
|
+
const inputMint = ix.instruction.keys[TITAN_INPUT_MINT_ACCOUNT_INDEX]?.pubkey;
|
|
735
|
+
const inputTokenAccount = ix.instruction.keys[TITAN_INPUT_TOKEN_ACCOUNT_INDEX]?.pubkey;
|
|
736
|
+
const outputMint = ix.instruction.keys[TITAN_OUTPUT_MINT_ACCOUNT_INDEX]?.pubkey;
|
|
737
|
+
const outputTokenAccount = ix.instruction.keys[TITAN_OUTPUT_TOKEN_ACCOUNT_INDEX]?.pubkey;
|
|
738
|
+
const inputTokenProgram = ix.instruction.keys[TITAN_INPUT_TOKEN_PROGRAM_ACCOUNT_INDEX]?.pubkey;
|
|
739
|
+
const outputTokenProgram = ix.instruction.keys[TITAN_OUTPUT_TOKEN_PROGRAM_ACCOUNT_INDEX]?.pubkey;
|
|
740
|
+
if (!inputMint
|
|
741
|
+
|| !inputTokenAccount
|
|
742
|
+
|| !outputMint
|
|
743
|
+
|| !outputTokenAccount
|
|
744
|
+
|| !inputTokenProgram
|
|
745
|
+
|| !outputTokenProgram) {
|
|
746
|
+
throw new Error("Titan SwapRouteV2 instruction is missing expected token accounts");
|
|
747
|
+
}
|
|
748
|
+
await ensureTrackedTokenAccountSetup({
|
|
749
|
+
tokenMint: inputMint,
|
|
750
|
+
tokenAccount: inputTokenAccount,
|
|
751
|
+
tokenProgram: inputTokenProgram,
|
|
752
|
+
buckets,
|
|
753
|
+
setupContext,
|
|
754
|
+
});
|
|
755
|
+
await ensureTrackedTokenAccountSetup({
|
|
756
|
+
tokenMint: outputMint,
|
|
757
|
+
tokenAccount: outputTokenAccount,
|
|
758
|
+
tokenProgram: outputTokenProgram,
|
|
759
|
+
buckets,
|
|
760
|
+
setupContext,
|
|
761
|
+
});
|
|
762
|
+
buckets.syncInstructions.push(ix.instruction);
|
|
763
|
+
}
|
|
764
|
+
// Loopscale account indices per instruction (from the Loopscale IDL)
|
|
765
|
+
const LOOPSCALE_DEPOSIT_COLLATERAL_MINT_INDEX = 6;
|
|
766
|
+
const LOOPSCALE_DEPOSIT_COLLATERAL_BORROWER_TA_INDEX = 4;
|
|
767
|
+
const LOOPSCALE_DEPOSIT_COLLATERAL_TOKEN_PROGRAM_INDEX = 9;
|
|
768
|
+
const LOOPSCALE_BORROW_PRINCIPAL_MINT_INDEX = 6;
|
|
769
|
+
const LOOPSCALE_BORROW_PRINCIPAL_BORROWER_TA_INDEX = 7;
|
|
770
|
+
const LOOPSCALE_BORROW_PRINCIPAL_TOKEN_PROGRAM_INDEX = 10;
|
|
771
|
+
const LOOPSCALE_REPAY_PRINCIPAL_MINT_INDEX = 6;
|
|
772
|
+
const LOOPSCALE_REPAY_PRINCIPAL_BORROWER_TA_INDEX = 7;
|
|
773
|
+
const LOOPSCALE_REPAY_PRINCIPAL_TOKEN_PROGRAM_INDEX = 10;
|
|
774
|
+
const LOOPSCALE_WITHDRAW_COLLATERAL_MINT_INDEX = 7;
|
|
775
|
+
const LOOPSCALE_WITHDRAW_COLLATERAL_BORROWER_TA_INDEX = 4;
|
|
776
|
+
const LOOPSCALE_WITHDRAW_COLLATERAL_TOKEN_PROGRAM_INDEX = 8;
|
|
777
|
+
const LOOPSCALE_DEPOSIT_STRATEGY_MINT_INDEX = 4;
|
|
778
|
+
const LOOPSCALE_DEPOSIT_STRATEGY_LENDER_TA_INDEX = 6;
|
|
779
|
+
const LOOPSCALE_DEPOSIT_STRATEGY_TOKEN_PROGRAM_INDEX = 8;
|
|
780
|
+
const LOOPSCALE_WITHDRAW_STRATEGY_MINT_INDEX = 4;
|
|
781
|
+
const LOOPSCALE_WITHDRAW_STRATEGY_LENDER_TA_INDEX = 6;
|
|
782
|
+
const LOOPSCALE_WITHDRAW_STRATEGY_TOKEN_PROGRAM_INDEX = 9;
|
|
783
|
+
/** Build a single Loopscale instruction (loan or strategy). Extracts token accounts for tracking. */
|
|
784
|
+
async function buildLoopscaleInstruction(ix, buckets, setupContext) {
|
|
785
|
+
switch (ix.action) {
|
|
786
|
+
case LoopscaleAction.DEPOSIT_COLLATERAL: {
|
|
787
|
+
const tokenMint = ix.instruction.keys[LOOPSCALE_DEPOSIT_COLLATERAL_MINT_INDEX]?.pubkey;
|
|
788
|
+
const tokenAccount = ix.instruction.keys[LOOPSCALE_DEPOSIT_COLLATERAL_BORROWER_TA_INDEX]?.pubkey;
|
|
789
|
+
const tokenProgram = ix.instruction.keys[LOOPSCALE_DEPOSIT_COLLATERAL_TOKEN_PROGRAM_INDEX]?.pubkey;
|
|
790
|
+
if (!tokenMint || !tokenAccount || !tokenProgram) {
|
|
791
|
+
throw new Error("Loopscale deposit_collateral instruction is missing expected token accounts");
|
|
792
|
+
}
|
|
793
|
+
await ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext });
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
case LoopscaleAction.BORROW_PRINCIPAL: {
|
|
797
|
+
const tokenMint = ix.instruction.keys[LOOPSCALE_BORROW_PRINCIPAL_MINT_INDEX]?.pubkey;
|
|
798
|
+
const tokenAccount = ix.instruction.keys[LOOPSCALE_BORROW_PRINCIPAL_BORROWER_TA_INDEX]?.pubkey;
|
|
799
|
+
const tokenProgram = ix.instruction.keys[LOOPSCALE_BORROW_PRINCIPAL_TOKEN_PROGRAM_INDEX]?.pubkey;
|
|
800
|
+
if (!tokenMint || !tokenAccount || !tokenProgram) {
|
|
801
|
+
throw new Error("Loopscale borrow_principal instruction is missing expected token accounts");
|
|
802
|
+
}
|
|
803
|
+
await ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext });
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
case LoopscaleAction.REPAY_PRINCIPAL: {
|
|
807
|
+
const tokenMint = ix.instruction.keys[LOOPSCALE_REPAY_PRINCIPAL_MINT_INDEX]?.pubkey;
|
|
808
|
+
const tokenAccount = ix.instruction.keys[LOOPSCALE_REPAY_PRINCIPAL_BORROWER_TA_INDEX]?.pubkey;
|
|
809
|
+
const tokenProgram = ix.instruction.keys[LOOPSCALE_REPAY_PRINCIPAL_TOKEN_PROGRAM_INDEX]?.pubkey;
|
|
810
|
+
if (!tokenMint || !tokenAccount || !tokenProgram) {
|
|
811
|
+
throw new Error("Loopscale repay_principal instruction is missing expected token accounts");
|
|
812
|
+
}
|
|
813
|
+
await ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext });
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
case LoopscaleAction.WITHDRAW_COLLATERAL: {
|
|
817
|
+
const tokenMint = ix.instruction.keys[LOOPSCALE_WITHDRAW_COLLATERAL_MINT_INDEX]?.pubkey;
|
|
818
|
+
const tokenAccount = ix.instruction.keys[LOOPSCALE_WITHDRAW_COLLATERAL_BORROWER_TA_INDEX]?.pubkey;
|
|
819
|
+
const tokenProgram = ix.instruction.keys[LOOPSCALE_WITHDRAW_COLLATERAL_TOKEN_PROGRAM_INDEX]?.pubkey;
|
|
820
|
+
if (!tokenMint || !tokenAccount || !tokenProgram) {
|
|
821
|
+
throw new Error("Loopscale withdraw_collateral instruction is missing expected token accounts");
|
|
822
|
+
}
|
|
823
|
+
await ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext });
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
// create_loan, close_loan, and update_weight_matrix have no token accounts to track —
|
|
827
|
+
// the on-chain hook handles TrackLoopscaleLoan/UntrackLoopscaleLoan mutations.
|
|
828
|
+
// update_weight_matrix only has 3 accounts (bs_auth, borrower, loan).
|
|
829
|
+
case LoopscaleAction.DEPOSIT_STRATEGY: {
|
|
830
|
+
const tokenMint = ix.instruction.keys[LOOPSCALE_DEPOSIT_STRATEGY_MINT_INDEX]?.pubkey;
|
|
831
|
+
const tokenAccount = ix.instruction.keys[LOOPSCALE_DEPOSIT_STRATEGY_LENDER_TA_INDEX]?.pubkey;
|
|
832
|
+
const tokenProgram = ix.instruction.keys[LOOPSCALE_DEPOSIT_STRATEGY_TOKEN_PROGRAM_INDEX]?.pubkey;
|
|
833
|
+
if (!tokenMint || !tokenAccount || !tokenProgram) {
|
|
834
|
+
throw new Error("Loopscale deposit_strategy instruction is missing expected token accounts");
|
|
835
|
+
}
|
|
836
|
+
await ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext });
|
|
837
|
+
break;
|
|
838
|
+
}
|
|
839
|
+
case LoopscaleAction.WITHDRAW_STRATEGY: {
|
|
840
|
+
const tokenMint = ix.instruction.keys[LOOPSCALE_WITHDRAW_STRATEGY_MINT_INDEX]?.pubkey;
|
|
841
|
+
const tokenAccount = ix.instruction.keys[LOOPSCALE_WITHDRAW_STRATEGY_LENDER_TA_INDEX]?.pubkey;
|
|
842
|
+
const tokenProgram = ix.instruction.keys[LOOPSCALE_WITHDRAW_STRATEGY_TOKEN_PROGRAM_INDEX]?.pubkey;
|
|
843
|
+
if (!tokenMint || !tokenAccount || !tokenProgram) {
|
|
844
|
+
throw new Error("Loopscale withdraw_strategy instruction is missing expected token accounts");
|
|
845
|
+
}
|
|
846
|
+
await ensureTrackedTokenAccountSetup({ tokenMint, tokenAccount, tokenProgram, buckets, setupContext });
|
|
847
|
+
break;
|
|
848
|
+
}
|
|
849
|
+
// create_strategy and close_strategy have no token accounts to track
|
|
850
|
+
}
|
|
851
|
+
buckets.syncInstructions.push(ix.instruction);
|
|
852
|
+
}
|
|
853
|
+
/** Build a single orderbook instruction (uses LOCAL_ENV for Orderbook.load) */
|
|
854
|
+
async function buildOrderbookInstruction(ix, owner, connection, buckets, setupContext, env = environment_1.LOCAL_ENV) {
|
|
855
|
+
const cacheKey = ix.orderbook.toBase58();
|
|
856
|
+
let orderbook = orderbookCache.get(cacheKey);
|
|
857
|
+
if (!orderbook) {
|
|
858
|
+
orderbook = await orderbook_1.Orderbook.load(env, connection, ix.orderbook);
|
|
859
|
+
orderbookCache.set(cacheKey, orderbook);
|
|
860
|
+
}
|
|
861
|
+
switch (ix.action) {
|
|
862
|
+
case OrderbookAction.POST_OFFER:
|
|
863
|
+
await buildPostOffer(ix, orderbook, owner, setupContext?.signer ?? owner, buckets, setupContext);
|
|
864
|
+
break;
|
|
865
|
+
case OrderbookAction.MARKET_OFFER:
|
|
866
|
+
await buildMarketOffer(ix, orderbook, owner, setupContext?.signer ?? owner, buckets, setupContext);
|
|
867
|
+
break;
|
|
868
|
+
case OrderbookAction.REMOVE_OFFER:
|
|
869
|
+
await buildRemoveOffer(ix, orderbook, owner, buckets);
|
|
870
|
+
break;
|
|
871
|
+
case OrderbookAction.WITHDRAW_FUNDS:
|
|
872
|
+
await buildWithdrawFunds(ix, orderbook, owner, buckets);
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
// ============================================================================
|
|
877
|
+
// Action Builders (one per VaultAction)
|
|
878
|
+
// ============================================================================
|
|
879
|
+
async function buildInitUserMetadata(owner, connection, { syncInstructions }) {
|
|
880
|
+
const userMetadata = (0, constants_1.getKaminoUserMetadata)(owner, policyBuilders_1.KAMINO_LENDING_PROGRAM_ID);
|
|
881
|
+
const userMetadataAccount = await connection.getAccountInfo(userMetadata);
|
|
882
|
+
if (userMetadataAccount)
|
|
883
|
+
return;
|
|
884
|
+
syncInstructions.push((0, instructions_1.initUserMetadata)({ userLookupTable: web3_js_1.PublicKey.default }, {
|
|
885
|
+
owner,
|
|
886
|
+
feePayer: owner,
|
|
887
|
+
userMetadata,
|
|
888
|
+
referrerUserMetadata: policyBuilders_1.KAMINO_LENDING_PROGRAM_ID,
|
|
889
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
890
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
891
|
+
}));
|
|
892
|
+
}
|
|
893
|
+
async function buildInitObligation(ix, owner, connection, { syncInstructions }) {
|
|
894
|
+
const lendingMarket = kamino_markets_1.KAMINO_MARKETS[ix.market];
|
|
895
|
+
const obligation = (0, constants_1.getKaminoLendObligation)(owner, lendingMarket, policyBuilders_1.KAMINO_LENDING_PROGRAM_ID);
|
|
896
|
+
const userMetadata = (0, constants_1.getKaminoUserMetadata)(owner, policyBuilders_1.KAMINO_LENDING_PROGRAM_ID);
|
|
897
|
+
const obligationAccount = await connection.getAccountInfo(obligation);
|
|
898
|
+
if (obligationAccount)
|
|
899
|
+
return;
|
|
900
|
+
syncInstructions.push((0, instructions_1.initObligation)({ args: { tag: 0, id: 0 } }, {
|
|
901
|
+
obligationOwner: owner,
|
|
902
|
+
feePayer: owner,
|
|
903
|
+
obligation,
|
|
904
|
+
lendingMarket,
|
|
905
|
+
seed1Account: web3_js_1.SystemProgram.programId,
|
|
906
|
+
seed2Account: web3_js_1.SystemProgram.programId,
|
|
907
|
+
ownerUserMetadata: userMetadata,
|
|
908
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
909
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
910
|
+
}));
|
|
911
|
+
}
|
|
912
|
+
async function buildDeposit(ix, owner, connection, signer, { setupInstructions, syncInstructions, preInstructions, postInstructions }) {
|
|
913
|
+
const ctx = await resolveReserveContext(ix, owner, connection);
|
|
914
|
+
const refreshes = await buildRefreshInstructions({
|
|
915
|
+
...ctx, owner, farmMode: FARM_COLLATERAL, signer, connection, needsScopeRefresh: false,
|
|
916
|
+
});
|
|
917
|
+
const isSOL = ctx.reserveAccount.liquidity.mintPubkey.equals(spl_token_1.NATIVE_MINT);
|
|
918
|
+
const userSourceLiquidity = (0, spl_token_1.getAssociatedTokenAddressSync)(ctx.reserveAccount.liquidity.mintPubkey, owner, true, ctx.reserveAccount.liquidity.tokenProgram);
|
|
919
|
+
if (isSOL) {
|
|
920
|
+
setupInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(signer, userSourceLiquidity, owner, spl_token_1.NATIVE_MINT, spl_token_1.TOKEN_PROGRAM_ID));
|
|
921
|
+
}
|
|
922
|
+
preInstructions.push(...refreshes.preInstructions);
|
|
923
|
+
postInstructions.push(...refreshes.postInstructions);
|
|
924
|
+
syncInstructions.push((0, instructions_1.depositReserveLiquidityAndObligationCollateralV2)({ liquidityAmount: ix.amount }, {
|
|
925
|
+
depositAccounts: {
|
|
926
|
+
owner,
|
|
927
|
+
obligation: ctx.obligation,
|
|
928
|
+
lendingMarket: ctx.lendingMarket,
|
|
929
|
+
lendingMarketAuthority: ctx.lendingMarketAuthority,
|
|
930
|
+
reserve: ctx.reservePubkey,
|
|
931
|
+
reserveLiquidityMint: ctx.reserveAccount.liquidity.mintPubkey,
|
|
932
|
+
reserveLiquiditySupply: ctx.reserveAccount.liquidity.supplyVault,
|
|
933
|
+
reserveCollateralMint: ctx.reserveAccount.collateral.mintPubkey,
|
|
934
|
+
reserveDestinationDepositCollateral: ctx.reserveAccount.collateral.supplyVault,
|
|
935
|
+
userSourceLiquidity,
|
|
936
|
+
placeholderUserDestinationCollateral: owner,
|
|
937
|
+
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
938
|
+
liquidityTokenProgram: ctx.reserveAccount.liquidity.tokenProgram,
|
|
939
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
940
|
+
},
|
|
941
|
+
farmsAccounts: refreshes.farmsAccounts,
|
|
942
|
+
farmsProgram: KAMINO_FARMS_PROGRAM_ID,
|
|
943
|
+
}));
|
|
944
|
+
}
|
|
945
|
+
async function buildWithdraw(ix, owner, connection, signer, { setupInstructions, syncInstructions, preInstructions, postInstructions }) {
|
|
946
|
+
const ctx = await resolveReserveContext(ix, owner, connection);
|
|
947
|
+
const refreshes = await buildRefreshInstructions({
|
|
948
|
+
...ctx, owner, farmMode: FARM_COLLATERAL, signer, connection, needsScopeRefresh: true,
|
|
949
|
+
});
|
|
950
|
+
const isSOL = ctx.reserveAccount.liquidity.mintPubkey.equals(spl_token_1.NATIVE_MINT);
|
|
951
|
+
const userDestinationLiquidity = (0, spl_token_1.getAssociatedTokenAddressSync)(ctx.reserveAccount.liquidity.mintPubkey, owner, true, ctx.reserveAccount.liquidity.tokenProgram);
|
|
952
|
+
preInstructions.push(...refreshes.scopeRefreshInstructions);
|
|
953
|
+
if (isSOL) {
|
|
954
|
+
setupInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(signer, userDestinationLiquidity, owner, spl_token_1.NATIVE_MINT, spl_token_1.TOKEN_PROGRAM_ID));
|
|
955
|
+
}
|
|
956
|
+
preInstructions.push(...refreshes.preInstructions);
|
|
957
|
+
postInstructions.push(...refreshes.postInstructions);
|
|
958
|
+
// Convert liquidity amount → collateral amount using the reserve's exchange rate
|
|
959
|
+
const exchangeRate = ctx.reserveAccount.getCollateralExchangeRate();
|
|
960
|
+
if (exchangeRate.isZero())
|
|
961
|
+
throw new Error(`Reserve ${ctx.reservePubkey.toBase58()} has zero exchange rate`);
|
|
962
|
+
const collateralAmount = new bn_js_1.default(new decimal_js_1.default(ix.amount.toString()).div(exchangeRate).floor().toString());
|
|
963
|
+
syncInstructions.push((0, instructions_1.withdrawObligationCollateralAndRedeemReserveCollateralV2)({ collateralAmount }, {
|
|
964
|
+
withdrawAccounts: {
|
|
965
|
+
owner,
|
|
966
|
+
obligation: ctx.obligation,
|
|
967
|
+
lendingMarket: ctx.lendingMarket,
|
|
968
|
+
lendingMarketAuthority: ctx.lendingMarketAuthority,
|
|
969
|
+
withdrawReserve: ctx.reservePubkey,
|
|
970
|
+
reserveLiquidityMint: ctx.reserveAccount.liquidity.mintPubkey,
|
|
971
|
+
reserveSourceCollateral: ctx.reserveAccount.collateral.supplyVault,
|
|
972
|
+
reserveCollateralMint: ctx.reserveAccount.collateral.mintPubkey,
|
|
973
|
+
reserveLiquiditySupply: ctx.reserveAccount.liquidity.supplyVault,
|
|
974
|
+
userDestinationLiquidity,
|
|
975
|
+
placeholderUserDestinationCollateral: owner,
|
|
976
|
+
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
977
|
+
liquidityTokenProgram: ctx.reserveAccount.liquidity.tokenProgram,
|
|
978
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
979
|
+
},
|
|
980
|
+
farmsAccounts: refreshes.farmsAccounts,
|
|
981
|
+
farmsProgram: KAMINO_FARMS_PROGRAM_ID,
|
|
982
|
+
}));
|
|
983
|
+
}
|
|
984
|
+
async function buildBorrow(ix, owner, connection, signer, { setupInstructions, syncInstructions, preInstructions, postInstructions }) {
|
|
985
|
+
const ctx = await resolveReserveContext(ix, owner, connection);
|
|
986
|
+
const refreshes = await buildRefreshInstructions({
|
|
987
|
+
...ctx, owner, farmMode: FARM_DEBT, signer, connection, needsScopeRefresh: true,
|
|
988
|
+
});
|
|
989
|
+
const isSOL = ctx.reserveAccount.liquidity.mintPubkey.equals(spl_token_1.NATIVE_MINT);
|
|
990
|
+
const userDestinationLiquidity = (0, spl_token_1.getAssociatedTokenAddressSync)(ctx.reserveAccount.liquidity.mintPubkey, owner, true, ctx.reserveAccount.liquidity.tokenProgram);
|
|
991
|
+
preInstructions.push(...refreshes.scopeRefreshInstructions);
|
|
992
|
+
setupInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(signer, userDestinationLiquidity, owner, ctx.reserveAccount.liquidity.mintPubkey, ctx.reserveAccount.liquidity.tokenProgram));
|
|
993
|
+
preInstructions.push(...refreshes.preInstructions);
|
|
994
|
+
postInstructions.push(...refreshes.postInstructions);
|
|
995
|
+
syncInstructions.push((0, instructions_1.borrowObligationLiquidityV2)({ liquidityAmount: ix.amount }, {
|
|
996
|
+
borrowAccounts: {
|
|
997
|
+
owner,
|
|
998
|
+
obligation: ctx.obligation,
|
|
999
|
+
lendingMarket: ctx.lendingMarket,
|
|
1000
|
+
lendingMarketAuthority: ctx.lendingMarketAuthority,
|
|
1001
|
+
borrowReserve: ctx.reservePubkey,
|
|
1002
|
+
borrowReserveLiquidityMint: ctx.reserveAccount.liquidity.mintPubkey,
|
|
1003
|
+
reserveSourceLiquidity: ctx.reserveAccount.liquidity.supplyVault,
|
|
1004
|
+
borrowReserveLiquidityFeeReceiver: ctx.reserveAccount.liquidity.feeVault,
|
|
1005
|
+
userDestinationLiquidity,
|
|
1006
|
+
referrerTokenState: null,
|
|
1007
|
+
tokenProgram: ctx.reserveAccount.liquidity.tokenProgram,
|
|
1008
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1009
|
+
},
|
|
1010
|
+
farmsAccounts: refreshes.farmsAccounts,
|
|
1011
|
+
farmsProgram: KAMINO_FARMS_PROGRAM_ID,
|
|
1012
|
+
}));
|
|
1013
|
+
}
|
|
1014
|
+
async function buildRepay(ix, owner, connection, signer, { setupInstructions, syncInstructions, preInstructions, postInstructions }) {
|
|
1015
|
+
const ctx = await resolveReserveContext(ix, owner, connection);
|
|
1016
|
+
const refreshes = await buildRefreshInstructions({
|
|
1017
|
+
...ctx, owner, farmMode: FARM_DEBT, signer, connection, needsScopeRefresh: false,
|
|
1018
|
+
});
|
|
1019
|
+
const isSOL = ctx.reserveAccount.liquidity.mintPubkey.equals(spl_token_1.NATIVE_MINT);
|
|
1020
|
+
const userSourceLiquidity = (0, spl_token_1.getAssociatedTokenAddressSync)(ctx.reserveAccount.liquidity.mintPubkey, owner, true, ctx.reserveAccount.liquidity.tokenProgram);
|
|
1021
|
+
if (isSOL) {
|
|
1022
|
+
setupInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(signer, userSourceLiquidity, owner, spl_token_1.NATIVE_MINT, spl_token_1.TOKEN_PROGRAM_ID));
|
|
1023
|
+
}
|
|
1024
|
+
preInstructions.push(...refreshes.preInstructions);
|
|
1025
|
+
postInstructions.push(...refreshes.postInstructions);
|
|
1026
|
+
syncInstructions.push((0, instructions_1.repayObligationLiquidityV2)({ liquidityAmount: ix.amount }, {
|
|
1027
|
+
repayAccounts: {
|
|
1028
|
+
owner,
|
|
1029
|
+
obligation: ctx.obligation,
|
|
1030
|
+
lendingMarket: ctx.lendingMarket,
|
|
1031
|
+
repayReserve: ctx.reservePubkey,
|
|
1032
|
+
reserveLiquidityMint: ctx.reserveAccount.liquidity.mintPubkey,
|
|
1033
|
+
reserveDestinationLiquidity: ctx.reserveAccount.liquidity.supplyVault,
|
|
1034
|
+
userSourceLiquidity,
|
|
1035
|
+
tokenProgram: ctx.reserveAccount.liquidity.tokenProgram,
|
|
1036
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
1037
|
+
},
|
|
1038
|
+
farmsAccounts: refreshes.farmsAccounts,
|
|
1039
|
+
lendingMarketAuthority: ctx.lendingMarketAuthority,
|
|
1040
|
+
farmsProgram: KAMINO_FARMS_PROGRAM_ID,
|
|
1041
|
+
}));
|
|
1042
|
+
}
|
|
1043
|
+
async function resolveReserveContext(ix, owner, connection) {
|
|
1044
|
+
const lendingMarket = kamino_markets_1.KAMINO_MARKETS[ix.market];
|
|
1045
|
+
const reserveEntry = kamino_markets_1.KAMINO_RESERVES[ix.market][ix.asset];
|
|
1046
|
+
const reservePubkey = reserveEntry?.pubkey;
|
|
1047
|
+
if (!reservePubkey)
|
|
1048
|
+
throw new Error(`Unknown reserve: ${ix.market}/${ix.asset}`);
|
|
1049
|
+
const reserveAccount = await kamino_reserve_deserializer_1.Reserve.fetch(connection, reservePubkey);
|
|
1050
|
+
if (!reserveAccount)
|
|
1051
|
+
throw new Error(`Reserve not found: ${reservePubkey.toBase58()}`);
|
|
1052
|
+
const obligation = (0, constants_1.getKaminoLendObligation)(owner, lendingMarket, policyBuilders_1.KAMINO_LENDING_PROGRAM_ID);
|
|
1053
|
+
const [lendingMarketAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("lma"), lendingMarket.toBuffer()], policyBuilders_1.KAMINO_LENDING_PROGRAM_ID);
|
|
1054
|
+
return { reservePubkey, reserveAccount, obligation, lendingMarket, lendingMarketAuthority };
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Build the freshness and farm-setup instructions required before direct KLend operations.
|
|
1058
|
+
*
|
|
1059
|
+
* @param farmMode - FARM_COLLATERAL (deposit/withdraw) or FARM_DEBT (borrow/repay)
|
|
1060
|
+
* @param needsScopeRefresh - true for borrow/withdraw (ALL_CHECKS), false for deposit/repay (NONE)
|
|
1061
|
+
*/
|
|
1062
|
+
async function buildRefreshInstructions({ reservePubkey, reserveAccount, lendingMarket, lendingMarketAuthority, obligation, owner, farmMode, signer, connection, needsScopeRefresh, }) {
|
|
1063
|
+
const pre = [];
|
|
1064
|
+
const post = [];
|
|
1065
|
+
const defaultKey = web3_js_1.PublicKey.default;
|
|
1066
|
+
const oracleOrSentinel = (key) => key.equals(defaultKey) ? policyBuilders_1.KAMINO_LENDING_PROGRAM_ID : key;
|
|
1067
|
+
// Determine farm state based on mode (collateral vs debt)
|
|
1068
|
+
const farmState = farmMode === FARM_COLLATERAL ? reserveAccount.farmCollateral : reserveAccount.farmDebt;
|
|
1069
|
+
const hasFarm = !farmState.equals(defaultKey);
|
|
1070
|
+
let obligationFarmUserState;
|
|
1071
|
+
if (hasFarm) {
|
|
1072
|
+
obligationFarmUserState = (0, constants_1.getKaminoFarmsObligationFarm)(obligation, farmState, KAMINO_FARMS_PROGRAM_ID);
|
|
1073
|
+
}
|
|
1074
|
+
const farmsAccounts = hasFarm
|
|
1075
|
+
? {
|
|
1076
|
+
obligationFarmUserState,
|
|
1077
|
+
reserveFarmState: farmState,
|
|
1078
|
+
}
|
|
1079
|
+
: {};
|
|
1080
|
+
// 1. Init obligation farms (if needed, before all refreshes)
|
|
1081
|
+
if (hasFarm) {
|
|
1082
|
+
const farmUserStateAccount = await connection.getAccountInfo(obligationFarmUserState);
|
|
1083
|
+
if (!farmUserStateAccount) {
|
|
1084
|
+
pre.push((0, instructions_1.initObligationFarmsForReserve)({ mode: farmMode }, {
|
|
1085
|
+
payer: signer,
|
|
1086
|
+
owner,
|
|
1087
|
+
obligation,
|
|
1088
|
+
lendingMarketAuthority,
|
|
1089
|
+
reserve: reservePubkey,
|
|
1090
|
+
reserveFarmState: farmState,
|
|
1091
|
+
obligationFarm: obligationFarmUserState,
|
|
1092
|
+
lendingMarket,
|
|
1093
|
+
farmsProgram: KAMINO_FARMS_PROGRAM_ID,
|
|
1094
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1095
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
1096
|
+
}));
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
// 2. Refresh ALL active reserves in the obligation + the operation reserve.
|
|
1100
|
+
// KLend's refreshObligation requires every reserve passed as a remaining
|
|
1101
|
+
// account to have been refreshed in the same transaction.
|
|
1102
|
+
// IMPORTANT: The operation reserve's refreshReserve MUST be the last one
|
|
1103
|
+
// pushed (position -3 from the sync tx) because check_refresh looks for it there.
|
|
1104
|
+
const obligationState = await accounts_1.Obligation.fetch(connection, obligation);
|
|
1105
|
+
const otherReservePubkeys = [];
|
|
1106
|
+
if (obligationState) {
|
|
1107
|
+
for (const d of obligationState.deposits) {
|
|
1108
|
+
if (!d.depositReserve.equals(defaultKey) && !d.depositReserve.equals(reservePubkey)) {
|
|
1109
|
+
otherReservePubkeys.push(d.depositReserve);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
for (const b of obligationState.borrows) {
|
|
1113
|
+
if (!b.borrowReserve.equals(defaultKey) && !b.borrowReserve.equals(reservePubkey)) {
|
|
1114
|
+
otherReservePubkeys.push(b.borrowReserve);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
// Fetch all other reserve accounts (needed for refreshReserve and optionally Scope refresh)
|
|
1119
|
+
const otherReserves = [];
|
|
1120
|
+
for (const rPubkey of otherReservePubkeys) {
|
|
1121
|
+
const rAccount = await kamino_reserve_deserializer_1.Reserve.fetch(connection, rPubkey);
|
|
1122
|
+
if (!rAccount)
|
|
1123
|
+
continue;
|
|
1124
|
+
otherReserves.push({ pubkey: rPubkey, account: rAccount });
|
|
1125
|
+
}
|
|
1126
|
+
// Scope refreshPriceList — only needed for operations that check ALL_CHECKS
|
|
1127
|
+
// (borrow/withdraw). Must be the FIRST instructions in the transaction
|
|
1128
|
+
// (after ComputeBudget) because the Scope program validates ordering.
|
|
1129
|
+
const allReserves = [...otherReserves, { pubkey: reservePubkey, account: reserveAccount }];
|
|
1130
|
+
const scopeRefreshIxs = needsScopeRefresh
|
|
1131
|
+
? await (0, scope_refresh_1.buildScopeRefreshInstructions)(connection, allReserves)
|
|
1132
|
+
: [];
|
|
1133
|
+
// Refresh other reserves first (order doesn't matter for these)
|
|
1134
|
+
for (const { pubkey: rPubkey, account: rAccount } of otherReserves) {
|
|
1135
|
+
const ti = rAccount.config.tokenInfo;
|
|
1136
|
+
pre.push((0, instructions_1.refreshReserve)({
|
|
1137
|
+
reserve: rPubkey,
|
|
1138
|
+
lendingMarket,
|
|
1139
|
+
pythOracle: oracleOrSentinel(ti.pythConfiguration.price),
|
|
1140
|
+
switchboardPriceOracle: oracleOrSentinel(ti.switchboardConfiguration.priceAggregator),
|
|
1141
|
+
switchboardTwapOracle: oracleOrSentinel(ti.switchboardConfiguration.twapAggregator),
|
|
1142
|
+
scopePrices: oracleOrSentinel(ti.scopeConfiguration.priceFeed),
|
|
1143
|
+
}));
|
|
1144
|
+
}
|
|
1145
|
+
// Refresh the operation reserve LAST — must be at position -3 from the sync tx
|
|
1146
|
+
const ti = reserveAccount.config.tokenInfo;
|
|
1147
|
+
pre.push((0, instructions_1.refreshReserve)({
|
|
1148
|
+
reserve: reservePubkey,
|
|
1149
|
+
lendingMarket,
|
|
1150
|
+
pythOracle: oracleOrSentinel(ti.pythConfiguration.price),
|
|
1151
|
+
switchboardPriceOracle: oracleOrSentinel(ti.switchboardConfiguration.priceAggregator),
|
|
1152
|
+
switchboardTwapOracle: oracleOrSentinel(ti.switchboardConfiguration.twapAggregator),
|
|
1153
|
+
scopePrices: oracleOrSentinel(ti.scopeConfiguration.priceFeed),
|
|
1154
|
+
}));
|
|
1155
|
+
// 3. RefreshObligation — pass all active reserves as remaining accounts.
|
|
1156
|
+
const refreshObligationIx = (0, instructions_1.refreshObligation)({ lendingMarket, obligation });
|
|
1157
|
+
if (obligationState) {
|
|
1158
|
+
const depositReserves = obligationState.deposits
|
|
1159
|
+
.map(d => d.depositReserve)
|
|
1160
|
+
.filter(r => !r.equals(defaultKey));
|
|
1161
|
+
const borrowReserves = obligationState.borrows
|
|
1162
|
+
.map(b => b.borrowReserve)
|
|
1163
|
+
.filter(r => !r.equals(defaultKey));
|
|
1164
|
+
for (const reserve of [...depositReserves, ...borrowReserves]) {
|
|
1165
|
+
refreshObligationIx.keys.push({ pubkey: reserve, isSigner: false, isWritable: false });
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
pre.push(refreshObligationIx);
|
|
1169
|
+
return {
|
|
1170
|
+
scopeRefreshInstructions: scopeRefreshIxs,
|
|
1171
|
+
preInstructions: pre,
|
|
1172
|
+
postInstructions: post,
|
|
1173
|
+
farmsAccounts,
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
// ============================================================================
|
|
1177
|
+
// Orderbook Action Builders
|
|
1178
|
+
// ============================================================================
|
|
1179
|
+
/**
|
|
1180
|
+
* Builder for Exponent Orderbook vault action descriptors.
|
|
1181
|
+
*
|
|
1182
|
+
* Each method returns an `OrderbookInstruction` that describes what to do.
|
|
1183
|
+
* Pass these to `createVaultSyncTransaction` which resolves them into
|
|
1184
|
+
* raw Solana instructions and wraps them in a Squads sync transaction.
|
|
1185
|
+
*
|
|
1186
|
+
* @example
|
|
1187
|
+
* ```ts
|
|
1188
|
+
* import { orderbookAction, createVaultSyncTransaction, OrderbookTradeDirection } from "@exponent-labs/exponent-sdk"
|
|
1189
|
+
*
|
|
1190
|
+
* const { instruction, preInstructions } = await createVaultSyncTransaction({
|
|
1191
|
+
* instructions: [
|
|
1192
|
+
* orderbookAction.postOffer({
|
|
1193
|
+
* orderbook: ORDERBOOK_ADDRESS,
|
|
1194
|
+
* direction: OrderbookTradeDirection.BUY_PT,
|
|
1195
|
+
* priceApy: 0.10,
|
|
1196
|
+
* amount: 1_000_000n,
|
|
1197
|
+
* }),
|
|
1198
|
+
* ],
|
|
1199
|
+
* owner: squadsVault,
|
|
1200
|
+
* connection,
|
|
1201
|
+
* policyPda,
|
|
1202
|
+
* vaultPda: squadsVault,
|
|
1203
|
+
* signer: walletPublicKey,
|
|
1204
|
+
* })
|
|
1205
|
+
* ```
|
|
1206
|
+
*/
|
|
1207
|
+
exports.orderbookAction = {
|
|
1208
|
+
/**
|
|
1209
|
+
* Post a limit order on the orderbook.
|
|
1210
|
+
* @param params - Order parameters
|
|
1211
|
+
* @param params.offerIdx - Required offer index for position tracking. Must be unique per trader.
|
|
1212
|
+
*/
|
|
1213
|
+
postOffer(params) {
|
|
1214
|
+
return {
|
|
1215
|
+
action: OrderbookAction.POST_OFFER,
|
|
1216
|
+
orderbook: params.orderbook,
|
|
1217
|
+
mode: params.mode,
|
|
1218
|
+
direction: params.direction,
|
|
1219
|
+
priceApy: params.priceApy,
|
|
1220
|
+
amount: params.amount,
|
|
1221
|
+
offerIdx: params.offerIdx,
|
|
1222
|
+
offerOption: params.offerOption,
|
|
1223
|
+
virtualOffer: params.virtualOffer,
|
|
1224
|
+
expirySeconds: params.expirySeconds,
|
|
1225
|
+
};
|
|
1226
|
+
},
|
|
1227
|
+
/**
|
|
1228
|
+
* Execute a market order on the orderbook.
|
|
1229
|
+
* @param params - Order parameters
|
|
1230
|
+
*/
|
|
1231
|
+
marketOffer(params) {
|
|
1232
|
+
return {
|
|
1233
|
+
action: OrderbookAction.MARKET_OFFER,
|
|
1234
|
+
orderbook: params.orderbook,
|
|
1235
|
+
mode: params.mode,
|
|
1236
|
+
direction: params.direction,
|
|
1237
|
+
maxPriceApy: params.maxPriceApy,
|
|
1238
|
+
amount: params.amount,
|
|
1239
|
+
minAmountOut: params.minAmountOut,
|
|
1240
|
+
virtualOffer: params.virtualOffer,
|
|
1241
|
+
};
|
|
1242
|
+
},
|
|
1243
|
+
/**
|
|
1244
|
+
* Cancel an existing limit order.
|
|
1245
|
+
* @param params - Cancel parameters
|
|
1246
|
+
*/
|
|
1247
|
+
removeOffer(params) {
|
|
1248
|
+
return {
|
|
1249
|
+
action: OrderbookAction.REMOVE_OFFER,
|
|
1250
|
+
orderbook: params.orderbook,
|
|
1251
|
+
offerIdx: params.offerIdx,
|
|
1252
|
+
};
|
|
1253
|
+
},
|
|
1254
|
+
/**
|
|
1255
|
+
* Withdraw funds from user escrow to token accounts.
|
|
1256
|
+
* @param params - Withdraw parameters (null amounts = withdraw max)
|
|
1257
|
+
*/
|
|
1258
|
+
withdrawFunds(params) {
|
|
1259
|
+
return {
|
|
1260
|
+
action: OrderbookAction.WITHDRAW_FUNDS,
|
|
1261
|
+
orderbook: params.orderbook,
|
|
1262
|
+
ptAmount: params.ptAmount,
|
|
1263
|
+
ytAmount: params.ytAmount,
|
|
1264
|
+
syAmount: params.syAmount,
|
|
1265
|
+
};
|
|
1266
|
+
},
|
|
1267
|
+
};
|
|
1268
|
+
exports.syAction = {
|
|
1269
|
+
mint(params) {
|
|
1270
|
+
return {
|
|
1271
|
+
action: SyAction.MINT,
|
|
1272
|
+
vault: params.vault,
|
|
1273
|
+
amountBase: params.amountBase,
|
|
1274
|
+
};
|
|
1275
|
+
},
|
|
1276
|
+
redeem(params) {
|
|
1277
|
+
return {
|
|
1278
|
+
action: SyAction.REDEEM,
|
|
1279
|
+
vault: params.vault,
|
|
1280
|
+
amountSy: params.amountSy,
|
|
1281
|
+
};
|
|
1282
|
+
},
|
|
1283
|
+
};
|
|
1284
|
+
// ============================================================================
|
|
1285
|
+
// Core Action Builders (Strip/Merge)
|
|
1286
|
+
// ============================================================================
|
|
1287
|
+
/**
|
|
1288
|
+
* Builder for Exponent Core strip/merge action descriptors.
|
|
1289
|
+
*
|
|
1290
|
+
* Each method returns a `CoreInstruction` that describes what to do.
|
|
1291
|
+
* Pass these to `createVaultSyncTransaction` which resolves them into
|
|
1292
|
+
* raw Solana instructions and wraps them in a Squads sync transaction.
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* ```ts
|
|
1296
|
+
* import { coreAction, createVaultSyncTransaction } from "@exponent-labs/exponent-sdk"
|
|
1297
|
+
*
|
|
1298
|
+
* const { instruction, preInstructions } = await createVaultSyncTransaction({
|
|
1299
|
+
* instructions: [
|
|
1300
|
+
* coreAction.strip({
|
|
1301
|
+
* vault: VAULT_ADDRESS,
|
|
1302
|
+
* amountBase: 1_000_000_000n, // 1 SOL worth
|
|
1303
|
+
* }),
|
|
1304
|
+
* ],
|
|
1305
|
+
* owner: squadsVault,
|
|
1306
|
+
* connection,
|
|
1307
|
+
* policyPda,
|
|
1308
|
+
* vaultPda: squadsVault,
|
|
1309
|
+
* signer: walletPublicKey,
|
|
1310
|
+
* })
|
|
1311
|
+
* ```
|
|
1312
|
+
*/
|
|
1313
|
+
exports.coreAction = {
|
|
1314
|
+
/**
|
|
1315
|
+
* Strip LST (base token) into PT + YT.
|
|
1316
|
+
* @param params - Strip parameters
|
|
1317
|
+
*/
|
|
1318
|
+
strip(params) {
|
|
1319
|
+
return {
|
|
1320
|
+
action: CoreAction.STRIP,
|
|
1321
|
+
vault: params.vault,
|
|
1322
|
+
amountBase: params.amountBase,
|
|
1323
|
+
};
|
|
1324
|
+
},
|
|
1325
|
+
/**
|
|
1326
|
+
* Merge PT + YT into LST (base token).
|
|
1327
|
+
* Requires equal amounts of PT and YT.
|
|
1328
|
+
* @param params - Merge parameters
|
|
1329
|
+
*/
|
|
1330
|
+
merge(params) {
|
|
1331
|
+
return {
|
|
1332
|
+
action: CoreAction.MERGE,
|
|
1333
|
+
vault: params.vault,
|
|
1334
|
+
amountPy: params.amountPy,
|
|
1335
|
+
};
|
|
1336
|
+
},
|
|
1337
|
+
/**
|
|
1338
|
+
* Withdraw YT from the tracked yield position into the owner's YT token account.
|
|
1339
|
+
* Useful before wrapper_merge, which consumes YT from the token account.
|
|
1340
|
+
*/
|
|
1341
|
+
withdrawYt(params) {
|
|
1342
|
+
return {
|
|
1343
|
+
action: CoreAction.WITHDRAW_YT,
|
|
1344
|
+
vault: params.vault,
|
|
1345
|
+
amountYt: params.amountYt,
|
|
1346
|
+
};
|
|
1347
|
+
},
|
|
1348
|
+
/**
|
|
1349
|
+
* Deposit YT from the owner's YT token account back into the tracked yield position.
|
|
1350
|
+
* Use this to ensure idle YT continues earning yield.
|
|
1351
|
+
*/
|
|
1352
|
+
depositYt(params) {
|
|
1353
|
+
return {
|
|
1354
|
+
action: CoreAction.DEPOSIT_YT,
|
|
1355
|
+
vault: params.vault,
|
|
1356
|
+
amountYt: params.amountYt,
|
|
1357
|
+
};
|
|
1358
|
+
},
|
|
1359
|
+
/**
|
|
1360
|
+
* Initialize yield position for the Squads vault (owner).
|
|
1361
|
+
* Required before buying YT or depositing YT.
|
|
1362
|
+
*/
|
|
1363
|
+
initializeYieldPosition(params) {
|
|
1364
|
+
return {
|
|
1365
|
+
action: CoreAction.INITIALIZE_YIELD_POSITION,
|
|
1366
|
+
vault: params.vault,
|
|
1367
|
+
};
|
|
1368
|
+
},
|
|
1369
|
+
};
|
|
1370
|
+
/**
|
|
1371
|
+
* Convert trade direction to OfferType used by the orderbook program.
|
|
1372
|
+
*/
|
|
1373
|
+
function directionToOfferType(direction) {
|
|
1374
|
+
switch (direction) {
|
|
1375
|
+
case OrderbookTradeDirection.BUY_PT:
|
|
1376
|
+
case OrderbookTradeDirection.SELL_YT:
|
|
1377
|
+
return orderbook_2.OfferType.SellYt;
|
|
1378
|
+
case OrderbookTradeDirection.SELL_PT:
|
|
1379
|
+
case OrderbookTradeDirection.BUY_YT:
|
|
1380
|
+
return orderbook_2.OfferType.BuyYt;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Build orderbook instructions and wrap them in a Squads sync transaction.
|
|
1385
|
+
*
|
|
1386
|
+
* Takes high-level `OrderbookInstruction` descriptors (built with `orderbookAction.*`),
|
|
1387
|
+
* loads the orderbook SDK, resolves them to raw Solana instructions, and wraps them
|
|
1388
|
+
* in a Squads sync transaction.
|
|
1389
|
+
*
|
|
1390
|
+
* @returns `{ setupInstructions, preInstructions, instruction, postInstructions }` — include all in your transaction
|
|
1391
|
+
*
|
|
1392
|
+
* @example
|
|
1393
|
+
* ```ts
|
|
1394
|
+
* const { setupInstructions, preInstructions, instruction, postInstructions } = await createOrderbookSyncTransaction({
|
|
1395
|
+
* instructions: [
|
|
1396
|
+
* orderbookAction.postOffer({
|
|
1397
|
+
* orderbook: ORDERBOOK_ADDRESS,
|
|
1398
|
+
* direction: OrderbookTradeDirection.BUY_PT,
|
|
1399
|
+
* priceApy: 0.10,
|
|
1400
|
+
* amount: 1_000_000n,
|
|
1401
|
+
* }),
|
|
1402
|
+
* ],
|
|
1403
|
+
* owner: squadsVault,
|
|
1404
|
+
* connection,
|
|
1405
|
+
* policyPda,
|
|
1406
|
+
* vaultPda: squadsVault,
|
|
1407
|
+
* signer: wallet.publicKey,
|
|
1408
|
+
* vaultAddress: VAULT_ADDRESS,
|
|
1409
|
+
* })
|
|
1410
|
+
* // Send: [...setupInstructions, ...preInstructions, instruction, ...postInstructions]
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
async function createOrderbookSyncTransaction({ instructions, owner, connection, policyPda, vaultPda, signer, accountIndex = 0, constraintIndices, vaultAddress, leadingAccounts, preHookAccounts, postHookAccounts, squadsProgram = syncTransaction_1.SQUADS_PROGRAM_ID, env = environment_1.LOCAL_ENV, }) {
|
|
1414
|
+
const { setupInstructions, syncInstructions, preInstructions, postInstructions, signers, addressLookupTableAddresses } = await buildOrderbookInstructions(instructions, owner, connection, signer, policyPda, vaultPda, accountIndex, vaultAddress, leadingAccounts, preHookAccounts, postHookAccounts, squadsProgram, env);
|
|
1415
|
+
let resolvedPolicyPda = policyPda;
|
|
1416
|
+
let resolvedConstraintIndices = constraintIndices;
|
|
1417
|
+
if (!resolvedPolicyPda) {
|
|
1418
|
+
if (!vaultAddress) {
|
|
1419
|
+
throw new Error("vaultAddress is required when policyPda is not provided");
|
|
1420
|
+
}
|
|
1421
|
+
const match = await (0, policyMatcher_1.resolvePolicyMatchForVault)(connection, vaultAddress, signer, syncInstructions);
|
|
1422
|
+
resolvedPolicyPda = match.policyPda;
|
|
1423
|
+
resolvedConstraintIndices ??= match.constraintIndices;
|
|
1424
|
+
}
|
|
1425
|
+
// Auto-resolve constraint indices when not explicitly provided
|
|
1426
|
+
resolvedConstraintIndices ??= await (0, policyMatcher_1.resolveConstraintIndices)(connection, resolvedPolicyPda, syncInstructions);
|
|
1427
|
+
// Auto-resolve policy prefix and hook accounts when not explicitly provided
|
|
1428
|
+
let resolvedLeadingAccounts = leadingAccounts;
|
|
1429
|
+
let resolvedPreHookAccounts = preHookAccounts;
|
|
1430
|
+
let resolvedPostHookAccounts = postHookAccounts;
|
|
1431
|
+
if (vaultAddress && (!leadingAccounts || !preHookAccounts || !postHookAccounts)) {
|
|
1432
|
+
const hooks = await (0, policyMatcher_1.resolveHookAccounts)(connection, resolvedPolicyPda, vaultAddress, signer);
|
|
1433
|
+
resolvedLeadingAccounts ??= hooks.leadingAccounts;
|
|
1434
|
+
resolvedPreHookAccounts ??= hooks.preHookAccounts;
|
|
1435
|
+
resolvedPostHookAccounts ??= hooks.postHookAccounts;
|
|
1436
|
+
}
|
|
1437
|
+
const instruction = (0, syncTransaction_1.wrapInstructionsInSyncTransaction)({
|
|
1438
|
+
policyPda: resolvedPolicyPda,
|
|
1439
|
+
vaultPda,
|
|
1440
|
+
signer,
|
|
1441
|
+
instructions: syncInstructions,
|
|
1442
|
+
squadsProgram,
|
|
1443
|
+
accountIndex,
|
|
1444
|
+
constraintIndices: resolvedConstraintIndices,
|
|
1445
|
+
leadingAccounts: resolvedLeadingAccounts,
|
|
1446
|
+
preHookAccounts: resolvedPreHookAccounts,
|
|
1447
|
+
postHookAccounts: resolvedPostHookAccounts,
|
|
1448
|
+
});
|
|
1449
|
+
return { setupInstructions, preInstructions, instruction, postInstructions, signers, addressLookupTableAddresses };
|
|
1450
|
+
}
|
|
1451
|
+
exports.createOrderbookSyncTransaction = createOrderbookSyncTransaction;
|
|
1452
|
+
/** Cache for loaded orderbooks to avoid redundant fetches */
|
|
1453
|
+
const orderbookCache = new Map();
|
|
1454
|
+
/**
|
|
1455
|
+
* Build raw Solana instructions from orderbook action descriptors.
|
|
1456
|
+
*/
|
|
1457
|
+
async function buildOrderbookInstructions(instructions, owner, connection, signer, policyPda, vaultPda, accountIndex, vaultAddress, leadingAccounts, preHookAccounts, postHookAccounts, squadsProgram, env) {
|
|
1458
|
+
const buckets = {
|
|
1459
|
+
setupInstructions: [],
|
|
1460
|
+
syncInstructions: [],
|
|
1461
|
+
preInstructions: [],
|
|
1462
|
+
postInstructions: [],
|
|
1463
|
+
signers: [],
|
|
1464
|
+
addressLookupTableAddresses: [],
|
|
1465
|
+
};
|
|
1466
|
+
const setupContext = createStrategySetupContext({
|
|
1467
|
+
connection,
|
|
1468
|
+
env,
|
|
1469
|
+
owner,
|
|
1470
|
+
signer,
|
|
1471
|
+
vaultAddress,
|
|
1472
|
+
policyPda,
|
|
1473
|
+
vaultPda,
|
|
1474
|
+
accountIndex,
|
|
1475
|
+
squadsProgram,
|
|
1476
|
+
leadingAccounts,
|
|
1477
|
+
preHookAccounts,
|
|
1478
|
+
postHookAccounts,
|
|
1479
|
+
});
|
|
1480
|
+
for (const ix of instructions) {
|
|
1481
|
+
await buildOrderbookInstruction(ix, owner, connection, buckets, setupContext, env);
|
|
1482
|
+
}
|
|
1483
|
+
return buckets;
|
|
1484
|
+
}
|
|
1485
|
+
async function buildPostOffer(ix, orderbook, owner, setupPayer, buckets, setupContext) {
|
|
1486
|
+
const offerType = directionToOfferType(ix.direction);
|
|
1487
|
+
const option = ix.offerOption ?? "FillOrKill";
|
|
1488
|
+
if (setupContext) {
|
|
1489
|
+
await ensureOrderbookPositionSetup(orderbook, buckets, setupContext);
|
|
1490
|
+
await ensureTrackedTokenAccountSetup({
|
|
1491
|
+
tokenMint: orderbook.vault.mintSy,
|
|
1492
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(orderbook.vault.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1493
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1494
|
+
buckets,
|
|
1495
|
+
setupContext,
|
|
1496
|
+
});
|
|
1497
|
+
await ensureTrackedTokenAccountSetup({
|
|
1498
|
+
tokenMint: orderbook.mintPt,
|
|
1499
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(orderbook.mintPt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1500
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1501
|
+
buckets,
|
|
1502
|
+
setupContext,
|
|
1503
|
+
});
|
|
1504
|
+
await ensureTrackedTokenAccountSetup({
|
|
1505
|
+
tokenMint: orderbook.mintYt,
|
|
1506
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(orderbook.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1507
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1508
|
+
buckets,
|
|
1509
|
+
setupContext,
|
|
1510
|
+
});
|
|
1511
|
+
await ensureYieldPositionSetup(orderbook.vault, buckets, setupContext);
|
|
1512
|
+
}
|
|
1513
|
+
if (ix.mode === "raw") {
|
|
1514
|
+
buckets.syncInstructions.push(orderbook.ixPostOffer({
|
|
1515
|
+
trader: owner,
|
|
1516
|
+
price: ix.priceApy,
|
|
1517
|
+
amount: ix.amount,
|
|
1518
|
+
offerType,
|
|
1519
|
+
offerOption: (0, orderbook_2.offerOptions)(option, [false]),
|
|
1520
|
+
virtualOffer: ix.virtualOffer ?? false,
|
|
1521
|
+
expirySeconds: ix.expirySeconds ?? 3600,
|
|
1522
|
+
mintSy: orderbook.vault.mintSy,
|
|
1523
|
+
offerIdx: ix.offerIdx,
|
|
1524
|
+
}));
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
const { ix: postOfferIx, setupIxs } = await orderbook.ixWrapperPostOffer({
|
|
1528
|
+
trader: owner,
|
|
1529
|
+
setupPayer,
|
|
1530
|
+
price: ix.priceApy,
|
|
1531
|
+
amount: ix.amount,
|
|
1532
|
+
offerType,
|
|
1533
|
+
offerOption: (0, orderbook_2.offerOptions)(option, [false]),
|
|
1534
|
+
virtualOffer: ix.virtualOffer ?? false,
|
|
1535
|
+
expirySeconds: ix.expirySeconds ?? 3600,
|
|
1536
|
+
mintSy: orderbook.vault.mintSy,
|
|
1537
|
+
offerIdx: ix.offerIdx,
|
|
1538
|
+
});
|
|
1539
|
+
buckets.preInstructions.push(...setupIxs);
|
|
1540
|
+
buckets.syncInstructions.push(postOfferIx);
|
|
1541
|
+
}
|
|
1542
|
+
async function buildMarketOffer(ix, orderbook, owner, setupPayer, buckets, setupContext) {
|
|
1543
|
+
const offerType = directionToOfferType(ix.direction);
|
|
1544
|
+
if (setupContext) {
|
|
1545
|
+
await ensureOrderbookPositionSetup(orderbook, buckets, setupContext);
|
|
1546
|
+
await ensureTrackedTokenAccountSetup({
|
|
1547
|
+
tokenMint: orderbook.vault.mintSy,
|
|
1548
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(orderbook.vault.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1549
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1550
|
+
buckets,
|
|
1551
|
+
setupContext,
|
|
1552
|
+
});
|
|
1553
|
+
await ensureTrackedTokenAccountSetup({
|
|
1554
|
+
tokenMint: orderbook.mintPt,
|
|
1555
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(orderbook.mintPt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1556
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1557
|
+
buckets,
|
|
1558
|
+
setupContext,
|
|
1559
|
+
});
|
|
1560
|
+
await ensureTrackedTokenAccountSetup({
|
|
1561
|
+
tokenMint: orderbook.mintYt,
|
|
1562
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(orderbook.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1563
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1564
|
+
buckets,
|
|
1565
|
+
setupContext,
|
|
1566
|
+
});
|
|
1567
|
+
await ensureYieldPositionSetup(orderbook.vault, buckets, setupContext);
|
|
1568
|
+
}
|
|
1569
|
+
if (ix.mode === "raw") {
|
|
1570
|
+
buckets.syncInstructions.push(orderbook.ixMarketOffer({
|
|
1571
|
+
trader: owner,
|
|
1572
|
+
maxPriceApy: ix.maxPriceApy,
|
|
1573
|
+
amount: ix.amount,
|
|
1574
|
+
minAmountOut: ix.minAmountOut,
|
|
1575
|
+
offerType,
|
|
1576
|
+
virtualOffer: ix.virtualOffer ?? false,
|
|
1577
|
+
mintSy: orderbook.vault.mintSy,
|
|
1578
|
+
}));
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
const { ix: marketOfferIx, setupIxs } = await orderbook.ixWrapperMarketOffer({
|
|
1582
|
+
trader: owner,
|
|
1583
|
+
setupPayer,
|
|
1584
|
+
maxPriceApy: ix.maxPriceApy,
|
|
1585
|
+
amount: ix.amount,
|
|
1586
|
+
offerType,
|
|
1587
|
+
minAmountOut: ix.minAmountOut,
|
|
1588
|
+
virtualOffer: ix.virtualOffer ?? false,
|
|
1589
|
+
mintSy: orderbook.vault.mintSy,
|
|
1590
|
+
});
|
|
1591
|
+
buckets.preInstructions.push(...setupIxs);
|
|
1592
|
+
buckets.syncInstructions.push(marketOfferIx);
|
|
1593
|
+
}
|
|
1594
|
+
async function buildRemoveOffer(ix, orderbook, owner, { syncInstructions }) {
|
|
1595
|
+
const removeOfferIx = await orderbook.ixWrapperRemoveOffer({
|
|
1596
|
+
trader: owner,
|
|
1597
|
+
offerIdx: ix.offerIdx,
|
|
1598
|
+
mintSy: orderbook.vault.mintSy,
|
|
1599
|
+
});
|
|
1600
|
+
syncInstructions.push(removeOfferIx);
|
|
1601
|
+
}
|
|
1602
|
+
async function buildWithdrawFunds(ix, orderbook, owner, { syncInstructions }) {
|
|
1603
|
+
// Convert bigint | null | undefined to Amount type
|
|
1604
|
+
const toAmount = (value) => {
|
|
1605
|
+
if (value === null || value === undefined) {
|
|
1606
|
+
return (0, orderbook_2.amount)("All");
|
|
1607
|
+
}
|
|
1608
|
+
return (0, orderbook_2.amount)("Some", [value]);
|
|
1609
|
+
};
|
|
1610
|
+
const withdrawFundsIx = await orderbook.ixWrapperWithdrawFunds({
|
|
1611
|
+
trader: owner,
|
|
1612
|
+
mintSy: orderbook.vault.mintSy,
|
|
1613
|
+
ptAmount: toAmount(ix.ptAmount),
|
|
1614
|
+
ytAmount: toAmount(ix.ytAmount),
|
|
1615
|
+
syAmount: toAmount(ix.syAmount),
|
|
1616
|
+
});
|
|
1617
|
+
syncInstructions.push(withdrawFundsIx);
|
|
1618
|
+
}
|
|
1619
|
+
// ============================================================================
|
|
1620
|
+
// Core Instruction Builders (Strip/Merge)
|
|
1621
|
+
// ============================================================================
|
|
1622
|
+
/** Build a single core instruction (strip/merge) */
|
|
1623
|
+
async function buildCoreInstruction(ix, owner, connection, buckets, setupContext) {
|
|
1624
|
+
const cacheKey = ix.vault.toBase58();
|
|
1625
|
+
let vault = vaultCache.get(cacheKey);
|
|
1626
|
+
if (!vault) {
|
|
1627
|
+
vault = await vault_1.Vault.load(environment_1.LOCAL_ENV, connection, ix.vault);
|
|
1628
|
+
vaultCache.set(cacheKey, vault);
|
|
1629
|
+
}
|
|
1630
|
+
const isInitializeYieldPosition = ix.action === CoreAction.INITIALIZE_YIELD_POSITION;
|
|
1631
|
+
if (setupContext && !isInitializeYieldPosition) {
|
|
1632
|
+
await ensureTrackedTokenAccountSetup({
|
|
1633
|
+
tokenMint: vault.mintPt,
|
|
1634
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintPt, setupContext.owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1635
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1636
|
+
buckets,
|
|
1637
|
+
setupContext,
|
|
1638
|
+
});
|
|
1639
|
+
await ensureYieldPositionSetup(vault, buckets, setupContext);
|
|
1640
|
+
if (ix.action === CoreAction.WITHDRAW_YT) {
|
|
1641
|
+
await ensureTrackedTokenAccountSetup({
|
|
1642
|
+
tokenMint: vault.mintYt,
|
|
1643
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintYt, setupContext.owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
1644
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1645
|
+
buckets,
|
|
1646
|
+
setupContext,
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
switch (ix.action) {
|
|
1651
|
+
case CoreAction.STRIP:
|
|
1652
|
+
await buildStrip(ix, vault, owner, setupContext?.signer ?? owner, buckets);
|
|
1653
|
+
break;
|
|
1654
|
+
case CoreAction.MERGE:
|
|
1655
|
+
await buildMerge(ix, vault, owner, setupContext?.signer ?? owner, buckets);
|
|
1656
|
+
break;
|
|
1657
|
+
case CoreAction.WITHDRAW_YT:
|
|
1658
|
+
await buildWithdrawYt(ix, vault, owner, setupContext?.signer ?? owner, buckets);
|
|
1659
|
+
break;
|
|
1660
|
+
case CoreAction.DEPOSIT_YT:
|
|
1661
|
+
await buildDepositYt(ix, vault, owner, buckets);
|
|
1662
|
+
break;
|
|
1663
|
+
case CoreAction.INITIALIZE_YIELD_POSITION:
|
|
1664
|
+
await buildInitializeYieldPosition(ix, vault, owner, buckets);
|
|
1665
|
+
break;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
async function buildInitializeYieldPosition(ix, vault, owner, { syncInstructions }) {
|
|
1669
|
+
const initIx = vault.ixInitializeYieldPosition({ owner });
|
|
1670
|
+
syncInstructions.push(initIx);
|
|
1671
|
+
}
|
|
1672
|
+
async function buildStrip(ix, vault, owner, payer, { syncInstructions, preInstructions }) {
|
|
1673
|
+
const sySrc = (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1674
|
+
const ptDst = (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintPt, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1675
|
+
const ytDst = (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1676
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payer, sySrc, owner, vault.mintSy), (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payer, ptDst, owner, vault.mintPt), (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payer, ytDst, owner, vault.mintYt));
|
|
1677
|
+
const stripIx = await vault.ixStripFromBase({
|
|
1678
|
+
owner,
|
|
1679
|
+
amountBase: ix.amountBase,
|
|
1680
|
+
sySrc,
|
|
1681
|
+
ptDst,
|
|
1682
|
+
ytDst,
|
|
1683
|
+
});
|
|
1684
|
+
// Strip instruction needs vault signature
|
|
1685
|
+
syncInstructions.push(stripIx);
|
|
1686
|
+
}
|
|
1687
|
+
async function buildMerge(ix, vault, owner, payer, { syncInstructions, preInstructions }) {
|
|
1688
|
+
const { ixs, setupIxs } = await vault.ixMergeToBase({
|
|
1689
|
+
owner,
|
|
1690
|
+
payer,
|
|
1691
|
+
amountPy: ix.amountPy,
|
|
1692
|
+
});
|
|
1693
|
+
// Setup instructions (ATA creation) go in preInstructions
|
|
1694
|
+
preInstructions.push(...setupIxs);
|
|
1695
|
+
// Merge instructions need vault signature
|
|
1696
|
+
syncInstructions.push(...ixs);
|
|
1697
|
+
}
|
|
1698
|
+
async function buildWithdrawYt(ix, vault, owner, payer, { syncInstructions, preInstructions }) {
|
|
1699
|
+
const ytDst = (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1700
|
+
preInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payer, ytDst, owner, vault.mintYt));
|
|
1701
|
+
const ytPosition = await ytPosition_1.YtPosition.loadByOwner(environment_1.LOCAL_ENV, vault.connection, owner, vault);
|
|
1702
|
+
syncInstructions.push(ytPosition.ixWithdrawYt({
|
|
1703
|
+
amount: ix.amountYt,
|
|
1704
|
+
ytDst,
|
|
1705
|
+
}));
|
|
1706
|
+
}
|
|
1707
|
+
async function buildDepositYt(ix, vault, owner, { syncInstructions }) {
|
|
1708
|
+
const ytSrc = (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1709
|
+
const ytPosition = await ytPosition_1.YtPosition.loadByOwner(environment_1.LOCAL_ENV, vault.connection, owner, vault);
|
|
1710
|
+
syncInstructions.push(ytPosition.ixDepositYt({
|
|
1711
|
+
amount: ix.amountYt,
|
|
1712
|
+
ytSrc,
|
|
1713
|
+
}));
|
|
1714
|
+
}
|
|
1715
|
+
async function buildSyInstruction(ix, owner, connection, buckets, setupContext) {
|
|
1716
|
+
const cacheKey = ix.vault.toBase58();
|
|
1717
|
+
let vault = vaultCache.get(cacheKey);
|
|
1718
|
+
if (!vault) {
|
|
1719
|
+
vault = await vault_1.Vault.load(environment_1.LOCAL_ENV, connection, ix.vault);
|
|
1720
|
+
vaultCache.set(cacheKey, vault);
|
|
1721
|
+
}
|
|
1722
|
+
if (!setupContext) {
|
|
1723
|
+
throw new Error("SY actions require a strategy setup context");
|
|
1724
|
+
}
|
|
1725
|
+
const setupState = await loadStrategySetupState(setupContext);
|
|
1726
|
+
if (!setupState) {
|
|
1727
|
+
throw new Error("SY actions require a strategy vault context");
|
|
1728
|
+
}
|
|
1729
|
+
const trackedBaseTokenAccount = setupState.tokenEntryAccountByMint.get(vault.flavor.mintBase.toBase58());
|
|
1730
|
+
const baseTokenAccount = trackedBaseTokenAccount
|
|
1731
|
+
? new web3_js_1.PublicKey(trackedBaseTokenAccount)
|
|
1732
|
+
: (0, spl_token_1.getAssociatedTokenAddressSync)(vault.flavor.mintBase, owner, true, vault.flavor.baseTokenProgram);
|
|
1733
|
+
const syTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(vault.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1734
|
+
await ensureTrackedTokenAccountSetup({
|
|
1735
|
+
tokenMint: vault.mintSy,
|
|
1736
|
+
tokenAccount: syTokenAccount,
|
|
1737
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1738
|
+
buckets,
|
|
1739
|
+
setupContext,
|
|
1740
|
+
});
|
|
1741
|
+
if (!setupState.trackedTokenAccounts.has(baseTokenAccount.toBase58())) {
|
|
1742
|
+
throw new Error(`Base mint ${vault.flavor.mintBase.toBase58()} must be tracked on the strategy vault before using mint_sy/redeem_sy`);
|
|
1743
|
+
}
|
|
1744
|
+
switch (ix.action) {
|
|
1745
|
+
case SyAction.MINT:
|
|
1746
|
+
buckets.syncInstructions.push(await vault.flavor.ixMintSy({
|
|
1747
|
+
amountBase: ix.amountBase.toString(),
|
|
1748
|
+
depositor: owner,
|
|
1749
|
+
depositorBaseTokenAccount: baseTokenAccount,
|
|
1750
|
+
depositorSyTokenAccount: syTokenAccount,
|
|
1751
|
+
}));
|
|
1752
|
+
break;
|
|
1753
|
+
case SyAction.REDEEM:
|
|
1754
|
+
buckets.syncInstructions.push(await vault.flavor.ixRedeemSy({
|
|
1755
|
+
amountSy: ix.amountSy.toString(),
|
|
1756
|
+
redeemer: owner,
|
|
1757
|
+
redeemerBaseTokenAccount: baseTokenAccount,
|
|
1758
|
+
redeemerSyTokenAccount: syTokenAccount,
|
|
1759
|
+
}));
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Builder for Titan swap vault action descriptors.
|
|
1765
|
+
*
|
|
1766
|
+
* Since Titan swap instructions contain complex routing data from Titan's API,
|
|
1767
|
+
* you pass a pre-built `TransactionInstruction` and we wrap it in a sync transaction.
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* ```ts
|
|
1771
|
+
* import { titanAction, createVaultSyncTransaction } from "@exponent-labs/exponent-sdk"
|
|
1772
|
+
*
|
|
1773
|
+
* const { setupInstructions, instruction } = await createVaultSyncTransaction({
|
|
1774
|
+
* instructions: [titanAction.swap({ instruction: titanSwapIx })],
|
|
1775
|
+
* owner: squadsVault,
|
|
1776
|
+
* connection,
|
|
1777
|
+
* policyPda,
|
|
1778
|
+
* vaultPda: squadsVault,
|
|
1779
|
+
* signer: wallet.publicKey,
|
|
1780
|
+
* vaultAddress: VAULT_ADDRESS,
|
|
1781
|
+
* })
|
|
1782
|
+
* ```
|
|
1783
|
+
*/
|
|
1784
|
+
exports.titanAction = {
|
|
1785
|
+
/**
|
|
1786
|
+
* Wrap a Titan SwapRouteV2 instruction for vault execution.
|
|
1787
|
+
* @param params.instruction - Pre-built TransactionInstruction from Titan's router API
|
|
1788
|
+
*/
|
|
1789
|
+
swap(params) {
|
|
1790
|
+
return { action: TitanAction.SWAP, instruction: params.instruction };
|
|
1791
|
+
},
|
|
1792
|
+
};
|
|
1793
|
+
// ============================================================================
|
|
1794
|
+
// Loopscale Action Builder
|
|
1795
|
+
// ============================================================================
|
|
1796
|
+
/**
|
|
1797
|
+
* Builder for Loopscale vault action descriptors.
|
|
1798
|
+
*
|
|
1799
|
+
* Loans (BORROWER side): create/close loan, deposit/withdraw collateral, borrow/repay principal.
|
|
1800
|
+
* Strategies (LENDER side): create/close strategy, deposit/withdraw into strategy.
|
|
1801
|
+
*
|
|
1802
|
+
* Since Loopscale instructions come from the Loopscale API (which also
|
|
1803
|
+
* handles `bs_auth` co-signing), you pass pre-built `TransactionInstruction`s
|
|
1804
|
+
* and we wrap them in a sync transaction.
|
|
1805
|
+
*
|
|
1806
|
+
* @example
|
|
1807
|
+
* ```ts
|
|
1808
|
+
* import { loopscaleAction, createVaultSyncTransaction } from "@exponent-labs/exponent-sdk"
|
|
1809
|
+
*
|
|
1810
|
+
* const { instruction } = await createVaultSyncTransaction({
|
|
1811
|
+
* instructions: [
|
|
1812
|
+
* loopscaleAction.createLoan({ instruction: createLoanIx }),
|
|
1813
|
+
* loopscaleAction.depositCollateral({ instruction: depositIx }),
|
|
1814
|
+
* loopscaleAction.borrowPrincipal({ instruction: borrowIx }),
|
|
1815
|
+
* ],
|
|
1816
|
+
* owner: squadsSettings,
|
|
1817
|
+
* connection,
|
|
1818
|
+
* policyPda,
|
|
1819
|
+
* vaultPda: squadsVault,
|
|
1820
|
+
* signer: wallet.publicKey,
|
|
1821
|
+
* vaultAddress,
|
|
1822
|
+
* })
|
|
1823
|
+
* ```
|
|
1824
|
+
*/
|
|
1825
|
+
exports.loopscaleAction = {
|
|
1826
|
+
createLoan(params) {
|
|
1827
|
+
return { action: LoopscaleAction.CREATE_LOAN, instruction: params.instruction };
|
|
1828
|
+
},
|
|
1829
|
+
depositCollateral(params) {
|
|
1830
|
+
return { action: LoopscaleAction.DEPOSIT_COLLATERAL, instruction: params.instruction };
|
|
1831
|
+
},
|
|
1832
|
+
borrowPrincipal(params) {
|
|
1833
|
+
return { action: LoopscaleAction.BORROW_PRINCIPAL, instruction: params.instruction };
|
|
1834
|
+
},
|
|
1835
|
+
repayPrincipal(params) {
|
|
1836
|
+
return { action: LoopscaleAction.REPAY_PRINCIPAL, instruction: params.instruction };
|
|
1837
|
+
},
|
|
1838
|
+
withdrawCollateral(params) {
|
|
1839
|
+
return { action: LoopscaleAction.WITHDRAW_COLLATERAL, instruction: params.instruction };
|
|
1840
|
+
},
|
|
1841
|
+
closeLoan(params) {
|
|
1842
|
+
return { action: LoopscaleAction.CLOSE_LOAN, instruction: params.instruction };
|
|
1843
|
+
},
|
|
1844
|
+
/** Assign collateral fractions to ledgers (BORROWER side). Must call before borrow_principal. */
|
|
1845
|
+
updateWeightMatrix(params) {
|
|
1846
|
+
return { action: LoopscaleAction.UPDATE_WEIGHT_MATRIX, instruction: params.instruction };
|
|
1847
|
+
},
|
|
1848
|
+
createStrategy(params) {
|
|
1849
|
+
return { action: LoopscaleAction.CREATE_STRATEGY, instruction: params.instruction };
|
|
1850
|
+
},
|
|
1851
|
+
depositStrategy(params) {
|
|
1852
|
+
return { action: LoopscaleAction.DEPOSIT_STRATEGY, instruction: params.instruction };
|
|
1853
|
+
},
|
|
1854
|
+
withdrawStrategy(params) {
|
|
1855
|
+
return { action: LoopscaleAction.WITHDRAW_STRATEGY, instruction: params.instruction };
|
|
1856
|
+
},
|
|
1857
|
+
closeStrategy(params) {
|
|
1858
|
+
return { action: LoopscaleAction.CLOSE_STRATEGY, instruction: params.instruction };
|
|
1859
|
+
},
|
|
1860
|
+
/** Configure collateral terms on a strategy (LENDER side). */
|
|
1861
|
+
updateStrategy(params) {
|
|
1862
|
+
return { action: LoopscaleAction.UPDATE_STRATEGY, instruction: params.instruction };
|
|
1863
|
+
},
|
|
1864
|
+
/** Lock loan before borrow_principal (BORROWER side). Must be in same tx as unlock. */
|
|
1865
|
+
lockLoan(params) {
|
|
1866
|
+
return { action: LoopscaleAction.LOCK_LOAN, instruction: params.instruction };
|
|
1867
|
+
},
|
|
1868
|
+
/** Unlock loan after borrow_principal (BORROWER side). Runs health check. */
|
|
1869
|
+
unlockLoan(params) {
|
|
1870
|
+
return { action: LoopscaleAction.UNLOCK_LOAN, instruction: params.instruction };
|
|
1871
|
+
},
|
|
1872
|
+
/** Refinance a loan ledger from one strategy to another (BORROWER side). */
|
|
1873
|
+
refinanceLedger(params) {
|
|
1874
|
+
return { action: LoopscaleAction.REFINANCE_LEDGER, instruction: params.instruction };
|
|
1875
|
+
},
|
|
1876
|
+
};
|
|
1877
|
+
// ============================================================================
|
|
1878
|
+
// CLMM Action Builder
|
|
1879
|
+
// ============================================================================
|
|
1880
|
+
/**
|
|
1881
|
+
* Builder for Exponent CLMM vault action descriptors.
|
|
1882
|
+
*
|
|
1883
|
+
* Each method returns a `VaultInstruction` descriptor. Pass these to
|
|
1884
|
+
* `createVaultSyncTransaction` which resolves them into raw Solana
|
|
1885
|
+
* instructions, wraps them in a Squads sync transaction, and returns
|
|
1886
|
+
* any extra signers (e.g., the new LP position keypair from deposit).
|
|
1887
|
+
*
|
|
1888
|
+
* @example
|
|
1889
|
+
* ```ts
|
|
1890
|
+
* import { clmmAction, createVaultSyncTransaction } from "@exponent-labs/exponent-sdk"
|
|
1891
|
+
*
|
|
1892
|
+
* const result = await createVaultSyncTransaction({
|
|
1893
|
+
* instructions: [
|
|
1894
|
+
* clmmAction.depositLiquidity({
|
|
1895
|
+
* market: CLMM_MARKET,
|
|
1896
|
+
* ptInIntent: 1_000_000n,
|
|
1897
|
+
* syInIntent: 1_000_000n,
|
|
1898
|
+
* lowerTickKey: 500,
|
|
1899
|
+
* upperTickKey: 1500,
|
|
1900
|
+
* }),
|
|
1901
|
+
* ],
|
|
1902
|
+
* owner: squadsVault,
|
|
1903
|
+
* connection,
|
|
1904
|
+
* vaultPda: squadsVault,
|
|
1905
|
+
* signer: wallet.publicKey,
|
|
1906
|
+
* vaultAddress: VAULT_ADDRESS,
|
|
1907
|
+
* })
|
|
1908
|
+
* // result.signers contains the generated LP position keypair
|
|
1909
|
+
* ```
|
|
1910
|
+
*/
|
|
1911
|
+
exports.clmmAction = {
|
|
1912
|
+
/**
|
|
1913
|
+
* Create a new LP position on the CLMM with a specified tick range.
|
|
1914
|
+
* The LP position keypair is generated internally — retrieve it from
|
|
1915
|
+
* `result.signers[0]` after calling `createVaultSyncTransaction`.
|
|
1916
|
+
*
|
|
1917
|
+
* @param params.market - CLMM MarketThree account address
|
|
1918
|
+
* @param params.ptInIntent - Maximum PT to deposit
|
|
1919
|
+
* @param params.syInIntent - Maximum SY to deposit
|
|
1920
|
+
* @param params.lowerTickKey - Lower tick boundary (APY value)
|
|
1921
|
+
* @param params.upperTickKey - Upper tick boundary (APY value)
|
|
1922
|
+
*/
|
|
1923
|
+
depositLiquidity(params) {
|
|
1924
|
+
return { action: ClmmAction.DEPOSIT_LIQUIDITY, ...params };
|
|
1925
|
+
},
|
|
1926
|
+
/**
|
|
1927
|
+
* Add liquidity to an existing LP position.
|
|
1928
|
+
*
|
|
1929
|
+
* @param params.market - CLMM MarketThree account address
|
|
1930
|
+
* @param params.lpPosition - Existing LpPosition account public key
|
|
1931
|
+
* @param params.ptInIntent - Maximum PT to add
|
|
1932
|
+
* @param params.syInIntent - Maximum SY to add
|
|
1933
|
+
*/
|
|
1934
|
+
addLiquidity(params) {
|
|
1935
|
+
return { action: ClmmAction.ADD_LIQUIDITY, ...params };
|
|
1936
|
+
},
|
|
1937
|
+
/**
|
|
1938
|
+
* Withdraw liquidity from an LP position, receiving PT + SY.
|
|
1939
|
+
*
|
|
1940
|
+
* @param params.market - CLMM MarketThree account address
|
|
1941
|
+
* @param params.lpPosition - LpPosition account to withdraw from
|
|
1942
|
+
* @param params.lpIn - Amount of liquidity (LP units) to remove
|
|
1943
|
+
* @param params.minPtOut - Minimum PT to receive (slippage protection)
|
|
1944
|
+
* @param params.minSyOut - Minimum SY to receive (slippage protection)
|
|
1945
|
+
*/
|
|
1946
|
+
withdrawLiquidity(params) {
|
|
1947
|
+
return { action: ClmmAction.WITHDRAW_LIQUIDITY, ...params };
|
|
1948
|
+
},
|
|
1949
|
+
/**
|
|
1950
|
+
* Low-level PT/SY swap on the CLMM. Prefer {@link buyPt} / {@link sellPt}
|
|
1951
|
+
* for directional trades.
|
|
1952
|
+
*
|
|
1953
|
+
* @param params.market - CLMM MarketThree account address
|
|
1954
|
+
* @param params.traderAmount - Amount of the input token
|
|
1955
|
+
* @param params.outConstraint - Minimum output amount (slippage protection)
|
|
1956
|
+
* @param params.swapDirection - `SwapDirection.SyToPt` or `SwapDirection.PtToSy`
|
|
1957
|
+
* @param params.lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
1958
|
+
*/
|
|
1959
|
+
tradePt(params) {
|
|
1960
|
+
return { action: ClmmAction.TRADE_PT, ...params };
|
|
1961
|
+
},
|
|
1962
|
+
/**
|
|
1963
|
+
* Buy PT with SY on the CLMM.
|
|
1964
|
+
*
|
|
1965
|
+
* @param params.market - CLMM MarketThree account address
|
|
1966
|
+
* @param params.amountSy - Amount of SY to spend
|
|
1967
|
+
* @param params.outConstraint - Minimum PT to receive (slippage protection)
|
|
1968
|
+
* @param params.lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
1969
|
+
*/
|
|
1970
|
+
buyPt(params) {
|
|
1971
|
+
return { action: ClmmAction.BUY_PT, ...params };
|
|
1972
|
+
},
|
|
1973
|
+
/**
|
|
1974
|
+
* Sell PT for SY on the CLMM.
|
|
1975
|
+
*
|
|
1976
|
+
* @param params.market - CLMM MarketThree account address
|
|
1977
|
+
* @param params.amountPt - Amount of PT to sell
|
|
1978
|
+
* @param params.outConstraint - Minimum SY to receive (slippage protection)
|
|
1979
|
+
* @param params.lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
1980
|
+
*/
|
|
1981
|
+
sellPt(params) {
|
|
1982
|
+
return { action: ClmmAction.SELL_PT, ...params };
|
|
1983
|
+
},
|
|
1984
|
+
/**
|
|
1985
|
+
* Buy YT with SY on the CLMM.
|
|
1986
|
+
*
|
|
1987
|
+
* @param params.market - CLMM MarketThree account address
|
|
1988
|
+
* @param params.ytOut - Minimum YT to receive
|
|
1989
|
+
* @param params.maxSyIn - Maximum SY to spend
|
|
1990
|
+
* @param params.lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
1991
|
+
*/
|
|
1992
|
+
buyYt(params) {
|
|
1993
|
+
return { action: ClmmAction.BUY_YT, ...params };
|
|
1994
|
+
},
|
|
1995
|
+
/**
|
|
1996
|
+
* Sell YT for SY on the CLMM.
|
|
1997
|
+
*
|
|
1998
|
+
* @param params.market - CLMM MarketThree account address
|
|
1999
|
+
* @param params.ytIn - Amount of YT to sell
|
|
2000
|
+
* @param params.minSyOut - Minimum SY to receive (slippage protection)
|
|
2001
|
+
* @param params.lnImpliedApyLimit - Optional price limit (ln implied APY)
|
|
2002
|
+
*/
|
|
2003
|
+
sellYt(params) {
|
|
2004
|
+
return { action: ClmmAction.SELL_YT, ...params };
|
|
2005
|
+
},
|
|
2006
|
+
/**
|
|
2007
|
+
* Claim farm emissions from an LP position.
|
|
2008
|
+
*
|
|
2009
|
+
* @param params.market - CLMM MarketThree account address
|
|
2010
|
+
* @param params.lpPosition - LpPosition account to claim from
|
|
2011
|
+
* @param params.farmIndex - Index of the farm emission to claim
|
|
2012
|
+
*/
|
|
2013
|
+
claimFarmEmission(params) {
|
|
2014
|
+
return { action: ClmmAction.CLAIM_FARM_EMISSION, ...params };
|
|
2015
|
+
},
|
|
2016
|
+
};
|
|
2017
|
+
// ============================================================================
|
|
2018
|
+
// Internal: CLMM Instruction Resolution
|
|
2019
|
+
// ============================================================================
|
|
2020
|
+
/** Cache for loaded MarketThree instances to avoid redundant fetches. */
|
|
2021
|
+
const marketThreeCache = new Map();
|
|
2022
|
+
/**
|
|
2023
|
+
* Resolve a high-level CLMM action descriptor into raw Solana instructions.
|
|
2024
|
+
* Loads the MarketThree from cache, derives token accounts from the vault
|
|
2025
|
+
* owner, and delegates to the appropriate sub-builder.
|
|
2026
|
+
*/
|
|
2027
|
+
async function buildClmmInstruction(ix, owner, connection, buckets, setupContext, env = environment_1.LOCAL_ENV) {
|
|
2028
|
+
const cacheKey = ix.market.toBase58();
|
|
2029
|
+
let market = marketThreeCache.get(cacheKey);
|
|
2030
|
+
if (!market) {
|
|
2031
|
+
market = await marketThree_1.MarketThree.load(env, connection, ix.market);
|
|
2032
|
+
marketThreeCache.set(cacheKey, market);
|
|
2033
|
+
}
|
|
2034
|
+
// Ensure PT and SY token accounts are tracked (needed by all CLMM actions)
|
|
2035
|
+
if (setupContext) {
|
|
2036
|
+
await ensureTrackedTokenAccountSetup({
|
|
2037
|
+
tokenMint: market.mintPt,
|
|
2038
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintPt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
2039
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2040
|
+
buckets,
|
|
2041
|
+
setupContext,
|
|
2042
|
+
});
|
|
2043
|
+
await ensureTrackedTokenAccountSetup({
|
|
2044
|
+
tokenMint: market.mintSy,
|
|
2045
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
2046
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2047
|
+
buckets,
|
|
2048
|
+
setupContext,
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
// Include the CLMM market's ALT so callers can compress remaining accounts
|
|
2052
|
+
buckets.addressLookupTableAddresses.push(market.addressLookupTable);
|
|
2053
|
+
switch (ix.action) {
|
|
2054
|
+
case ClmmAction.DEPOSIT_LIQUIDITY:
|
|
2055
|
+
buildClmmDepositLiquidity(ix, market, owner, buckets);
|
|
2056
|
+
break;
|
|
2057
|
+
case ClmmAction.ADD_LIQUIDITY:
|
|
2058
|
+
buildClmmAddLiquidity(ix, market, owner, buckets);
|
|
2059
|
+
break;
|
|
2060
|
+
case ClmmAction.WITHDRAW_LIQUIDITY:
|
|
2061
|
+
buildClmmWithdrawLiquidity(ix, market, owner, buckets);
|
|
2062
|
+
break;
|
|
2063
|
+
case ClmmAction.TRADE_PT:
|
|
2064
|
+
buildClmmTradePt(ix, market, owner, buckets);
|
|
2065
|
+
break;
|
|
2066
|
+
case ClmmAction.BUY_PT:
|
|
2067
|
+
buildClmmBuyPt(ix, market, owner, buckets);
|
|
2068
|
+
break;
|
|
2069
|
+
case ClmmAction.SELL_PT:
|
|
2070
|
+
buildClmmSellPt(ix, market, owner, buckets);
|
|
2071
|
+
break;
|
|
2072
|
+
case ClmmAction.BUY_YT:
|
|
2073
|
+
await buildClmmBuyYt(ix, market, owner, buckets, setupContext);
|
|
2074
|
+
break;
|
|
2075
|
+
case ClmmAction.SELL_YT:
|
|
2076
|
+
await buildClmmSellYt(ix, market, owner, buckets, setupContext);
|
|
2077
|
+
break;
|
|
2078
|
+
case ClmmAction.CLAIM_FARM_EMISSION:
|
|
2079
|
+
buildClmmClaimFarmEmission(ix, market, owner, buckets);
|
|
2080
|
+
break;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Create a new LP position. Generates the keypair internally and adds it
|
|
2085
|
+
* to `buckets.signers` so consumers can include it in the transaction.
|
|
2086
|
+
*/
|
|
2087
|
+
function buildClmmDepositLiquidity(ix, market, owner, buckets) {
|
|
2088
|
+
const ptSrc = (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintPt, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2089
|
+
const sySrc = (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2090
|
+
const { ix: depositIx, signers: lpPositionKeypair } = market.ixDepositLiquidity({
|
|
2091
|
+
depositor: owner,
|
|
2092
|
+
ptInIntent: ix.ptInIntent,
|
|
2093
|
+
syInIntent: ix.syInIntent,
|
|
2094
|
+
lowerTickKey: ix.lowerTickKey,
|
|
2095
|
+
upperTickKey: ix.upperTickKey,
|
|
2096
|
+
ptSrc,
|
|
2097
|
+
sySrc,
|
|
2098
|
+
});
|
|
2099
|
+
buckets.syncInstructions.push(depositIx);
|
|
2100
|
+
buckets.signers.push(lpPositionKeypair);
|
|
2101
|
+
}
|
|
2102
|
+
/** Add liquidity to an existing LP position. */
|
|
2103
|
+
function buildClmmAddLiquidity(ix, market, owner, buckets) {
|
|
2104
|
+
const ptSrc = (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintPt, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2105
|
+
const sySrc = (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintSy, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2106
|
+
const remainingAccounts = (0, utils_1.uniqueRemainingAccounts)([
|
|
2107
|
+
...market.cpiSyAccounts.depositSy,
|
|
2108
|
+
...market.cpiSyAccounts.withdrawSy,
|
|
2109
|
+
...market.cpiCoreAccounts.stripSy,
|
|
2110
|
+
...market.cpiSyAccounts.getPositionState,
|
|
2111
|
+
]);
|
|
2112
|
+
const addLiqIx = exponentClmm.createAddLiquidityInstruction({
|
|
2113
|
+
owner,
|
|
2114
|
+
market: market.selfAddress,
|
|
2115
|
+
ticks: market.ticksKey,
|
|
2116
|
+
lpPosition: ix.lpPosition,
|
|
2117
|
+
tokenPtSrc: ptSrc,
|
|
2118
|
+
tokenSySrc: sySrc,
|
|
2119
|
+
tokenPtEscrow: market.tokenPtEscrow,
|
|
2120
|
+
tokenSyEscrow: market.tokenSyEscrow,
|
|
2121
|
+
addressLookupTable: market.addressLookupTable,
|
|
2122
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2123
|
+
syProgram: market.syProgram,
|
|
2124
|
+
instructionsSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2125
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2126
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
2127
|
+
eventAuthority: market.eventAuthority,
|
|
2128
|
+
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2129
|
+
}, {
|
|
2130
|
+
maxSyInToAdd: ix.syInIntent,
|
|
2131
|
+
maxPtInToAdd: ix.ptInIntent,
|
|
2132
|
+
lowerTickKeyOptional: null,
|
|
2133
|
+
upperTickKeyOptional: null,
|
|
2134
|
+
});
|
|
2135
|
+
addLiqIx.keys.push(...remainingAccounts);
|
|
2136
|
+
buckets.syncInstructions.push(addLiqIx);
|
|
2137
|
+
}
|
|
2138
|
+
/** Remove liquidity from an LP position. */
|
|
2139
|
+
function buildClmmWithdrawLiquidity(ix, market, owner, buckets) {
|
|
2140
|
+
const { ixs } = market.ixWithdrawLiquidity({
|
|
2141
|
+
withdrawer: owner,
|
|
2142
|
+
lpPosition: ix.lpPosition,
|
|
2143
|
+
lpIn: ix.lpIn,
|
|
2144
|
+
minPtOut: ix.minPtOut,
|
|
2145
|
+
minSyOut: ix.minSyOut,
|
|
2146
|
+
});
|
|
2147
|
+
buckets.syncInstructions.push(...ixs);
|
|
2148
|
+
}
|
|
2149
|
+
/** Low-level PT/SY swap. */
|
|
2150
|
+
function buildClmmTradePt(ix, market, owner, buckets) {
|
|
2151
|
+
const { ixs } = market.ixTradePt({
|
|
2152
|
+
trader: owner,
|
|
2153
|
+
traderAmount: ix.traderAmount,
|
|
2154
|
+
outConstraint: ix.outConstraint,
|
|
2155
|
+
swapDirection: ix.swapDirection,
|
|
2156
|
+
lnImpliedApyLimit: ix.lnImpliedApyLimit,
|
|
2157
|
+
});
|
|
2158
|
+
buckets.syncInstructions.push(...ixs);
|
|
2159
|
+
}
|
|
2160
|
+
/** Buy PT with SY. */
|
|
2161
|
+
function buildClmmBuyPt(ix, market, owner, buckets) {
|
|
2162
|
+
const { ixs } = market.ixBuyPt({
|
|
2163
|
+
trader: owner,
|
|
2164
|
+
amountSy: ix.amountSy,
|
|
2165
|
+
outConstraint: ix.outConstraint,
|
|
2166
|
+
lnImpliedApyLimit: ix.lnImpliedApyLimit,
|
|
2167
|
+
});
|
|
2168
|
+
buckets.syncInstructions.push(...ixs);
|
|
2169
|
+
}
|
|
2170
|
+
/** Sell PT for SY. */
|
|
2171
|
+
function buildClmmSellPt(ix, market, owner, buckets) {
|
|
2172
|
+
const { ixs } = market.ixSellPt({
|
|
2173
|
+
trader: owner,
|
|
2174
|
+
amountPt: ix.amountPt,
|
|
2175
|
+
outConstraint: ix.outConstraint,
|
|
2176
|
+
lnImpliedApyLimit: ix.lnImpliedApyLimit,
|
|
2177
|
+
});
|
|
2178
|
+
buckets.syncInstructions.push(...ixs);
|
|
2179
|
+
}
|
|
2180
|
+
/** Buy YT with SY. Also ensures YT token account is tracked. */
|
|
2181
|
+
async function buildClmmBuyYt(ix, market, owner, buckets, setupContext) {
|
|
2182
|
+
// YT operations need the YT token account tracked
|
|
2183
|
+
if (setupContext) {
|
|
2184
|
+
await ensureTrackedTokenAccountSetup({
|
|
2185
|
+
tokenMint: market.mintYt,
|
|
2186
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
2187
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2188
|
+
buckets,
|
|
2189
|
+
setupContext,
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
const { ixs, setupIxs } = market.ixBuyYt({
|
|
2193
|
+
trader: owner,
|
|
2194
|
+
ytOut: ix.ytOut,
|
|
2195
|
+
maxSyIn: ix.maxSyIn,
|
|
2196
|
+
lnImpliedApyLimit: ix.lnImpliedApyLimit,
|
|
2197
|
+
});
|
|
2198
|
+
buckets.setupInstructions.push(...setupIxs);
|
|
2199
|
+
buckets.syncInstructions.push(...ixs);
|
|
2200
|
+
}
|
|
2201
|
+
/** Sell YT for SY. Also ensures YT token account is tracked. */
|
|
2202
|
+
async function buildClmmSellYt(ix, market, owner, buckets, setupContext) {
|
|
2203
|
+
// YT operations need the YT token account tracked
|
|
2204
|
+
if (setupContext) {
|
|
2205
|
+
await ensureTrackedTokenAccountSetup({
|
|
2206
|
+
tokenMint: market.mintYt,
|
|
2207
|
+
tokenAccount: (0, spl_token_1.getAssociatedTokenAddressSync)(market.mintYt, owner, true, spl_token_1.TOKEN_PROGRAM_ID),
|
|
2208
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2209
|
+
buckets,
|
|
2210
|
+
setupContext,
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
const { ixs, setupIxs } = market.ixSellYt({
|
|
2214
|
+
trader: owner,
|
|
2215
|
+
ytIn: ix.ytIn,
|
|
2216
|
+
minSyOut: ix.minSyOut,
|
|
2217
|
+
lnImpliedApyLimit: ix.lnImpliedApyLimit,
|
|
2218
|
+
});
|
|
2219
|
+
buckets.setupInstructions.push(...setupIxs);
|
|
2220
|
+
buckets.syncInstructions.push(...ixs);
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* Claim farm emissions from an LP position. Reads the farm info from the
|
|
2224
|
+
* loaded market state and builds the instruction directly.
|
|
2225
|
+
*/
|
|
2226
|
+
function buildClmmClaimFarmEmission(ix, market, owner, buckets) {
|
|
2227
|
+
const farm = market.state.lpFarm.farmEmissions[ix.farmIndex];
|
|
2228
|
+
if (!farm) {
|
|
2229
|
+
throw new Error(`Farm at index ${ix.farmIndex} not found on CLMM market ${ix.market.toBase58()}`);
|
|
2230
|
+
}
|
|
2231
|
+
const tokenDst = (0, spl_token_1.getAssociatedTokenAddressSync)(farm.mint, owner, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2232
|
+
const tokenFarm = (0, spl_token_1.getAssociatedTokenAddressSync)(farm.mint, ix.market, true, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2233
|
+
const claimIx = exponentClmm.createClaimFarmEmissionInstruction({
|
|
2234
|
+
owner,
|
|
2235
|
+
market: ix.market,
|
|
2236
|
+
ticks: market.ticksKey,
|
|
2237
|
+
lpPosition: ix.lpPosition,
|
|
2238
|
+
tokenDst,
|
|
2239
|
+
mint: farm.mint,
|
|
2240
|
+
tokenFarm,
|
|
2241
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2242
|
+
eventAuthority: market.eventAuthority,
|
|
2243
|
+
program: exponentClmm.EXPONENTCLMM_PROGRAM_ID,
|
|
2244
|
+
}, {
|
|
2245
|
+
amount: exponentClmm.amount("All"),
|
|
2246
|
+
});
|
|
2247
|
+
// Setup: ensure destination ATA exists
|
|
2248
|
+
buckets.setupInstructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(owner, tokenDst, owner, farm.mint));
|
|
2249
|
+
buckets.syncInstructions.push(claimIx);
|
|
2250
|
+
}
|
|
2251
|
+
//# sourceMappingURL=vault-interaction.js.map
|