@magmaprotocol/magma-clmm-sdk 0.5.36 → 0.5.38

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/dist/index.d.ts CHANGED
@@ -2180,6 +2180,122 @@ type CollectFeesQuote = {
2180
2180
  */
2181
2181
  declare function collectFeesQuote(param: CollectFeesQuoteParam): CollectFeesQuote;
2182
2182
 
2183
+ declare enum StrategyType {
2184
+ Spot = 0,
2185
+ Curve = 1,
2186
+ BidAsk = 2
2187
+ }
2188
+ type BinLiquidity = {
2189
+ ActiveId: number;
2190
+ StorageId: number;
2191
+ Price: number;
2192
+ CoinAType: number;
2193
+ CoinBType: number;
2194
+ CoinAAmount: number;
2195
+ CoinBAmount: number;
2196
+ };
2197
+ declare function autoFillYByStrategy(activeId: number, binStep: number, amountX: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, minBinId: number, maxBinId: number, strategyType: StrategyType): BN;
2198
+ declare function autoFillXByStrategy(activeId: number, binStep: number, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, minBinId: number, maxBinId: number, strategyType: StrategyType): BN;
2199
+ /**
2200
+ * Given a strategy type and amounts of X and Y, returns the distribution of liquidity.
2201
+ * @param activeId The bin id of the active bin.
2202
+ * @param binStep The step size of each bin.
2203
+ * @param minBinId The min bin id.
2204
+ * @param maxBinId The max bin id.
2205
+ * @param amountX The amount of X token to deposit.
2206
+ * @param amountY The amount of Y token to deposit.
2207
+ * @param amountXInActiveBin The amount of X token in the active bin.
2208
+ * @param amountYInActiveBin The amount of Y token in the active bin.
2209
+ * @param strategyType The strategy type.
2210
+ * @param mintX The mint info of X token. Get from DLMM instance.
2211
+ * @param mintY The mint info of Y token. Get from DLMM instance.
2212
+ * @param clock The clock info. Get from DLMM instance.
2213
+ * @returns The distribution of liquidity.
2214
+ */
2215
+ declare function toAmountsBothSideByStrategy(activeId: number, binStep: number, minBinId: number, maxBinId: number, amountX: BN, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, strategyType: StrategyType): {
2216
+ binId: number;
2217
+ amountX: BN;
2218
+ amountY: BN;
2219
+ }[];
2220
+
2221
+ declare function getPriceOfBinByBinId(binId: number, binStep: number): Decimal;
2222
+ declare function autoFillYByWeight(activeId: number, binStep: number, amountX: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, distributions: {
2223
+ binId: number;
2224
+ weight: number;
2225
+ }[]): BN;
2226
+ declare function autoFillXByWeight(activeId: number, binStep: number, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, distributions: {
2227
+ binId: number;
2228
+ weight: number;
2229
+ }[]): BN;
2230
+ /**
2231
+ * Distribute totalAmount to all bid side bins according to given distributions.
2232
+ * @param activeId active bin id
2233
+ * @param totalAmount total amount of token Y to be distributed
2234
+ * @param distributions weight distribution of each bin
2235
+ * @param mintY mint of token Y, get from DLMM instance
2236
+ * @param clock clock of the program, for calculating transfer fee, get from DLMM instance
2237
+ * @returns array of {binId, amount} where amount is the amount of token Y in each bin
2238
+ */
2239
+ declare function toAmountBidSide(activeId: number, totalAmount: BN, distributions: {
2240
+ binId: number;
2241
+ weight: number;
2242
+ }[]): {
2243
+ binId: number;
2244
+ amount: BN;
2245
+ }[];
2246
+ /**
2247
+ * Distribute totalAmount to all ask side bins according to given distributions.
2248
+ * @param activeId active bin id
2249
+ * @param totalAmount total amount of token Y to be distributed
2250
+ * @param distributions weight distribution of each bin
2251
+ * @param mintX mint of token X, get from DLMM instance
2252
+ * @param clock clock of the program, for calculating transfer fee, get from DLMM instance
2253
+ * @returns array of {binId, amount} where amount is the amount of token X in each bin
2254
+ */
2255
+ declare function toAmountAskSide(activeId: number, binStep: number, totalAmount: BN, distributions: {
2256
+ binId: number;
2257
+ weight: number;
2258
+ }[]): {
2259
+ binId: number;
2260
+ amount: BN;
2261
+ }[];
2262
+ /**
2263
+ * Distributes the given amounts of tokens X and Y to both bid and ask side bins
2264
+ * based on the provided weight distributions.
2265
+ *
2266
+ * @param activeId - The id of the active bin.
2267
+ * @param binStep - The step interval between bin ids.
2268
+ * @param amountX - Total amount of token X to distribute.
2269
+ * @param amountY - Total amount of token Y to distribute.
2270
+ * @param amountXInActiveBin - Amount of token X already in the active bin.
2271
+ * @param amountYInActiveBin - Amount of token Y already in the active bin.
2272
+ * @param distributions - Array of bins with their respective weight distributions.
2273
+ * @param mintX - Mint information for token X. Get from DLMM instance.
2274
+ * @param mintY - Mint information for token Y. Get from DLMM instance.
2275
+ * @param clock - Clock instance. Get from DLMM instance.
2276
+ * @returns An array of objects containing binId, amountX, and amountY for each bin.
2277
+ */
2278
+ declare function toAmountBothSide(activeId: number, binStep: number, amountX: BN, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, distributions: {
2279
+ binId: number;
2280
+ weight: number;
2281
+ }[]): {
2282
+ binId: number;
2283
+ amountX: BN;
2284
+ amountY: BN;
2285
+ }[];
2286
+
2287
+ declare function withLiquiditySlippage(value: Decimal.Instance, slippage: Decimal.Instance, mode: 'plus' | 'minus'): Decimal;
2288
+ type POOL_NO_LIQUIDITY = -1;
2289
+ type LiquidityAndCoinYResult = {
2290
+ coinYAmount: Decimal;
2291
+ lpAmount: Decimal;
2292
+ };
2293
+ declare function getLiquidityAndCoinYByCoinX(coinInVal: Decimal.Instance, reserveInSize: Decimal.Instance, reserveOutSize: Decimal.Instance, lpSupply: Decimal.Instance): LiquidityAndCoinYResult | POOL_NO_LIQUIDITY;
2294
+ declare function getCoinXYForLiquidity(liquidity: Decimal.Instance, reserveInSize: Decimal.Instance, reserveOutSize: Decimal.Instance, lpSuply: Decimal.Instance): {
2295
+ coinXAmount: Decimal;
2296
+ coinYAmount: Decimal;
2297
+ };
2298
+
2183
2299
  /**
2184
2300
  * Percentage - the util set for percentage struct.
2185
2301
  */
@@ -3491,11 +3607,21 @@ type EventPairLiquidity = {
3491
3607
  bin_x: number[] | string[];
3492
3608
  bin_y: number[] | string[];
3493
3609
  };
3610
+ type DlmmPoolInfo = {
3611
+ pool_id: string;
3612
+ bin_step: number;
3613
+ coin_a: string;
3614
+ coin_b: string;
3615
+ base_factor: number;
3616
+ base_fee: number;
3617
+ active_index: number;
3618
+ };
3494
3619
 
3495
3620
  declare class DlmmModule implements IModule {
3496
3621
  protected _sdk: MagmaClmmSDK;
3497
3622
  constructor(sdk: MagmaClmmSDK);
3498
3623
  get sdk(): MagmaClmmSDK;
3624
+ getPoolInfo(pools: string[]): Promise<DlmmPoolInfo[]>;
3499
3625
  fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
3500
3626
  price_to_storage_id(price: string, bin_step: number, tokenADecimal: number, tokenBDecimal: number): number;
3501
3627
  createPairPayload(params: CreatePairParams): Promise<Transaction>;
@@ -4238,4 +4364,4 @@ interface InitMagmaSDKOptions {
4238
4364
  */
4239
4365
  declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
4240
4366
 
4241
- export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmConfig, DlmmScript, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, StakedPositionOfPool, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams$1 as SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, WithdrawPosition, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
4367
+ export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, BinLiquidity, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmConfig, DlmmScript, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityAndCoinYResult, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_NO_LIQUIDITY, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, StakedPositionOfPool, StrategyType, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams$1 as SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, WithdrawPosition, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getCoinXYForLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityAndCoinYByCoinX, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getPriceOfBinByBinId, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16, withLiquiditySlippage };