@magmaprotocol/magma-clmm-sdk 0.5.114 → 0.5.116
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 +33 -13
- package/dist/index.js +81 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1708,6 +1708,7 @@ type EventPairParams = {
|
|
|
1708
1708
|
time_of_last_update: number | string;
|
|
1709
1709
|
oracle_index: number;
|
|
1710
1710
|
active_index: number;
|
|
1711
|
+
protocol_variable_share: number;
|
|
1711
1712
|
};
|
|
1712
1713
|
type EventBin = {
|
|
1713
1714
|
storage_id: number | string;
|
|
@@ -1720,11 +1721,14 @@ type EventBin = {
|
|
|
1720
1721
|
fee_y: number | string;
|
|
1721
1722
|
fee_growth_x: number | string;
|
|
1722
1723
|
fee_growth_y: number | string;
|
|
1723
|
-
rewarder_growth:
|
|
1724
|
+
rewarder_growth: RewarderGrowth;
|
|
1724
1725
|
distribution_growth: number | string;
|
|
1725
1726
|
distribution_last_updated: number | string;
|
|
1726
1727
|
real_bin_id: number;
|
|
1727
1728
|
};
|
|
1729
|
+
type RewarderGrowth = {
|
|
1730
|
+
contents: string[];
|
|
1731
|
+
};
|
|
1728
1732
|
type EventPositionLiquidity = {
|
|
1729
1733
|
position_id: string;
|
|
1730
1734
|
shares: number | string;
|
|
@@ -1759,6 +1763,7 @@ type AlmmPoolInfo = {
|
|
|
1759
1763
|
index?: number;
|
|
1760
1764
|
liquidity: string;
|
|
1761
1765
|
rewarder_infos: Rewarder[];
|
|
1766
|
+
params: EventPairParams;
|
|
1762
1767
|
};
|
|
1763
1768
|
type AlmmAddLiquidityParams = {
|
|
1764
1769
|
pool_id: string;
|
|
@@ -1881,7 +1886,7 @@ type MintByStrategyParams = {
|
|
|
1881
1886
|
*/
|
|
1882
1887
|
active_bin: number;
|
|
1883
1888
|
/**
|
|
1884
|
-
* base 10000 =100%
|
|
1889
|
+
* base 10000 = 100%
|
|
1885
1890
|
*/
|
|
1886
1891
|
slippage: number;
|
|
1887
1892
|
};
|
|
@@ -1903,6 +1908,19 @@ type RaiseByStrategyParams = {
|
|
|
1903
1908
|
receiver: string;
|
|
1904
1909
|
rewards_token: string[];
|
|
1905
1910
|
};
|
|
1911
|
+
type EventCreatePair = {
|
|
1912
|
+
pair_id: string;
|
|
1913
|
+
factory_id: string;
|
|
1914
|
+
bin_step: number;
|
|
1915
|
+
active_id: number;
|
|
1916
|
+
params: EventPairParams;
|
|
1917
|
+
token_x: Token;
|
|
1918
|
+
token_y: Token;
|
|
1919
|
+
lp_token_id: string;
|
|
1920
|
+
};
|
|
1921
|
+
type Token = {
|
|
1922
|
+
name: string;
|
|
1923
|
+
};
|
|
1906
1924
|
|
|
1907
1925
|
type BigNumber = Decimal.Value | number | string;
|
|
1908
1926
|
|
|
@@ -2479,9 +2497,9 @@ declare function autoFillXByStrategy(activeId: number, binStep: number, amountY:
|
|
|
2479
2497
|
* @param amountXInActiveBin The amount of X token in the active bin.
|
|
2480
2498
|
* @param amountYInActiveBin The amount of Y token in the active bin.
|
|
2481
2499
|
* @param strategyType The strategy type.
|
|
2482
|
-
* @param mintX The mint info of X token. Get from
|
|
2483
|
-
* @param mintY The mint info of Y token. Get from
|
|
2484
|
-
* @param clock The clock info. Get from
|
|
2500
|
+
* @param mintX The mint info of X token. Get from ALMM instance.
|
|
2501
|
+
* @param mintY The mint info of Y token. Get from ALMM instance.
|
|
2502
|
+
* @param clock The clock info. Get from ALMM instance.
|
|
2485
2503
|
* @returns The distribution of liquidity.
|
|
2486
2504
|
*/
|
|
2487
2505
|
declare function toAmountsBothSideByStrategy(activeId: number, binStep: number, minBinId: number, maxBinId: number, amountX: BN, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, strategyType: StrategyType): BinDisplay[];
|
|
@@ -2500,8 +2518,8 @@ declare function autoFillXByWeight(activeId: number, binStep: number, amountY: B
|
|
|
2500
2518
|
* @param activeId active bin id
|
|
2501
2519
|
* @param totalAmount total amount of token Y to be distributed
|
|
2502
2520
|
* @param distributions weight distribution of each bin
|
|
2503
|
-
* @param mintY mint of token Y, get from
|
|
2504
|
-
* @param clock clock of the program, for calculating transfer fee, get from
|
|
2521
|
+
* @param mintY mint of token Y, get from ALMM instance
|
|
2522
|
+
* @param clock clock of the program, for calculating transfer fee, get from ALMM instance
|
|
2505
2523
|
* @returns array of {binId, amount} where amount is the amount of token Y in each bin
|
|
2506
2524
|
*/
|
|
2507
2525
|
declare function toAmountBidSide(activeId: number, totalAmount: BN, distributions: {
|
|
@@ -2516,8 +2534,8 @@ declare function toAmountBidSide(activeId: number, totalAmount: BN, distribution
|
|
|
2516
2534
|
* @param activeId active bin id
|
|
2517
2535
|
* @param totalAmount total amount of token Y to be distributed
|
|
2518
2536
|
* @param distributions weight distribution of each bin
|
|
2519
|
-
* @param mintX mint of token X, get from
|
|
2520
|
-
* @param clock clock of the program, for calculating transfer fee, get from
|
|
2537
|
+
* @param mintX mint of token X, get from ALMM instance
|
|
2538
|
+
* @param clock clock of the program, for calculating transfer fee, get from ALMM instance
|
|
2521
2539
|
* @returns array of {binId, amount} where amount is the amount of token X in each bin
|
|
2522
2540
|
*/
|
|
2523
2541
|
declare function toAmountAskSide(activeId: number, binStep: number, totalAmount: BN, distributions: {
|
|
@@ -2538,9 +2556,9 @@ declare function toAmountAskSide(activeId: number, binStep: number, totalAmount:
|
|
|
2538
2556
|
* @param amountXInActiveBin - Amount of token X already in the active bin.
|
|
2539
2557
|
* @param amountYInActiveBin - Amount of token Y already in the active bin.
|
|
2540
2558
|
* @param distributions - Array of bins with their respective weight distributions.
|
|
2541
|
-
* @param mintX - Mint information for token X. Get from
|
|
2542
|
-
* @param mintY - Mint information for token Y. Get from
|
|
2543
|
-
* @param clock - Clock instance. Get from
|
|
2559
|
+
* @param mintX - Mint information for token X. Get from ALMM instance.
|
|
2560
|
+
* @param mintY - Mint information for token Y. Get from ALMM instance.
|
|
2561
|
+
* @param clock - Clock instance. Get from ALMM instance.
|
|
2544
2562
|
* @returns An array of objects containing binId, amountX, and amountY for each bin.
|
|
2545
2563
|
*/
|
|
2546
2564
|
declare function toAmountBothSide(activeId: number, binStep: number, amountX: BN, amountY: BN, amountXInActiveBin: BN, amountYInActiveBin: BN, distributions: {
|
|
@@ -3774,6 +3792,7 @@ declare class AlmmModule implements IModule {
|
|
|
3774
3792
|
private readonly _cache;
|
|
3775
3793
|
constructor(sdk: MagmaClmmSDK);
|
|
3776
3794
|
get sdk(): MagmaClmmSDK;
|
|
3795
|
+
getPools(paginationArgs?: PaginationArgs, forceRefresh?: boolean): Promise<EventCreatePair[]>;
|
|
3777
3796
|
getPoolInfo(pools: string[]): Promise<AlmmPoolInfo[]>;
|
|
3778
3797
|
fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
|
|
3779
3798
|
createPairPayload(params: CreatePairParams): Promise<Transaction>;
|
|
@@ -3801,6 +3820,7 @@ declare class AlmmModule implements IModule {
|
|
|
3801
3820
|
* Gets a list of positions for the given account address.
|
|
3802
3821
|
* @param accountAddress The account address to get positions for.
|
|
3803
3822
|
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
3823
|
+
* @param showDisplay When some testnet rpc nodes can't return object's display data, you can set this option to false, avoid returning errors. Default set true.
|
|
3804
3824
|
* @returns array of Position objects.
|
|
3805
3825
|
*/
|
|
3806
3826
|
getUserPositions(accountAddress: string, assignPoolIds?: string[], showDisplay?: boolean): Promise<AlmmPositionInfo[]>;
|
|
@@ -4572,4 +4592,4 @@ interface InitMagmaSDKOptions {
|
|
|
4572
4592
|
*/
|
|
4573
4593
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4574
4594
|
|
|
4575
|
-
export { ALMMSwapParams, AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AlmmAddLiquidityParams, AlmmBurnPositionParams, AlmmCollectFeeParams, AlmmCollectRewardParams, AlmmConfig, AlmmCreatePairAddLiquidityParams, AlmmEventEarnedFees, AlmmEventEarnedRewards, AlmmEventPairRewardTypes, AlmmPoolInfo, AlmmPosition, AlmmPositionInfo, AlmmRewardsParams, AlmmScript, AlmmShrinkPosition, AmountSpecified, BasePath, BigNumber, BinDisplay, BinLiquidity, BinMath, 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, CreatePairParams, 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, EpochEmission, EventBin, EventPairLiquidity, EventPairParams, EventPositionLiquidity, FEE_RATE_DENOMINATOR, FaucetCoin, FetchBinsParams, FetchPairParams, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetPairLiquidityParams, GetPairRewarderParams, GetPositionLiquidityParams, 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, MintAmountParams, MintByStrategyParams, MintPercentParams, 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, RaiseByStrategyParams, 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, 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, Ve33Config, 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 };
|
|
4595
|
+
export { ALMMSwapParams, AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AlmmAddLiquidityParams, AlmmBurnPositionParams, AlmmCollectFeeParams, AlmmCollectRewardParams, AlmmConfig, AlmmCreatePairAddLiquidityParams, AlmmEventEarnedFees, AlmmEventEarnedRewards, AlmmEventPairRewardTypes, AlmmPoolInfo, AlmmPosition, AlmmPositionInfo, AlmmRewardsParams, AlmmScript, AlmmShrinkPosition, AmountSpecified, BasePath, BigNumber, BinDisplay, BinLiquidity, BinMath, 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, CreatePairParams, 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, EpochEmission, EventBin, EventCreatePair, EventPairLiquidity, EventPairParams, EventPositionLiquidity, FEE_RATE_DENOMINATOR, FaucetCoin, FetchBinsParams, FetchPairParams, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetPairLiquidityParams, GetPairRewarderParams, GetPositionLiquidityParams, 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, MintAmountParams, MintByStrategyParams, MintPercentParams, 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, RaiseByStrategyParams, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RewarderGrowth, 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, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, Token, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, Ve33Config, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1818,10 +1818,10 @@ var import_bn10 = __toESM(require("bn.js"));
|
|
|
1818
1818
|
// src/math/almmWeightToAmounts.ts
|
|
1819
1819
|
var import_bn9 = __toESM(require("bn.js"));
|
|
1820
1820
|
var import_decimal6 = __toESM(require("decimal.js"));
|
|
1821
|
-
var
|
|
1821
|
+
var import_calc_almm = require("@magmaprotocol/calc_almm");
|
|
1822
1822
|
function getPriceOfBinByBinId(binId, binStep) {
|
|
1823
1823
|
const twoDec = new import_decimal6.default(2);
|
|
1824
|
-
const price = new import_decimal6.default((0,
|
|
1824
|
+
const price = new import_decimal6.default((0, import_calc_almm.get_price_x128_from_real_id)(binId, binStep));
|
|
1825
1825
|
return price.div(twoDec.pow(128));
|
|
1826
1826
|
}
|
|
1827
1827
|
function autoFillYByWeight(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, distributions) {
|
|
@@ -2757,17 +2757,20 @@ var SplitSwap = class {
|
|
|
2757
2757
|
|
|
2758
2758
|
// src/math/bin.ts
|
|
2759
2759
|
var import_decimal9 = __toESM(require("decimal.js"));
|
|
2760
|
-
var
|
|
2760
|
+
var import_calc_almm2 = require("@magmaprotocol/calc_almm");
|
|
2761
2761
|
var BinMath = class {
|
|
2762
2762
|
static getPriceOfBinByBinId(binId, binStep, decimalsA, decimalsB) {
|
|
2763
2763
|
const twoDec = new import_decimal9.default(2);
|
|
2764
|
-
const price = new import_decimal9.default((0,
|
|
2764
|
+
const price = new import_decimal9.default((0, import_calc_almm2.get_price_x128_from_real_id)(binId, binStep));
|
|
2765
2765
|
return price.div(twoDec.pow(128)).mul(import_decimal9.default.pow(10, decimalsA - decimalsB));
|
|
2766
2766
|
}
|
|
2767
2767
|
static getBinIdFromPrice(price, binStep, decimalsA, decimalsB) {
|
|
2768
2768
|
const twoDec = new import_decimal9.default(2);
|
|
2769
2769
|
const tenDec = new import_decimal9.default(10);
|
|
2770
|
-
const realid = (0,
|
|
2770
|
+
const realid = (0, import_calc_almm2.get_real_id_from_price_x128)(
|
|
2771
|
+
new import_decimal9.default(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(),
|
|
2772
|
+
binStep
|
|
2773
|
+
);
|
|
2771
2774
|
return realid;
|
|
2772
2775
|
}
|
|
2773
2776
|
};
|
|
@@ -5398,6 +5401,7 @@ var PoolModule = class {
|
|
|
5398
5401
|
}
|
|
5399
5402
|
return dataPage;
|
|
5400
5403
|
}
|
|
5404
|
+
// TODO: 实现这个方法为almm
|
|
5401
5405
|
/**
|
|
5402
5406
|
* Gets a list of pools.
|
|
5403
5407
|
* @param {string[]} assignPools An array of pool IDs to get.
|
|
@@ -10635,7 +10639,7 @@ var GaugeModule = class {
|
|
|
10635
10639
|
|
|
10636
10640
|
// src/modules/almm.ts
|
|
10637
10641
|
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10638
|
-
var
|
|
10642
|
+
var import_calc_almm3 = require("@magmaprotocol/calc_almm");
|
|
10639
10643
|
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10640
10644
|
var import_bn22 = __toESM(require("bn.js"));
|
|
10641
10645
|
var AlmmModule = class {
|
|
@@ -10647,6 +10651,37 @@ var AlmmModule = class {
|
|
|
10647
10651
|
get sdk() {
|
|
10648
10652
|
return this._sdk;
|
|
10649
10653
|
}
|
|
10654
|
+
async getPools(paginationArgs = "all", forceRefresh = false) {
|
|
10655
|
+
const { package_id } = this._sdk.sdkOptions.almm_pool;
|
|
10656
|
+
const allPools = [];
|
|
10657
|
+
const cacheKey = `${package_id}_getInitCreatePairEvent`;
|
|
10658
|
+
const cacheData = this.getCache(cacheKey, forceRefresh);
|
|
10659
|
+
if (cacheData !== void 0) {
|
|
10660
|
+
allPools.push(...cacheData);
|
|
10661
|
+
}
|
|
10662
|
+
if (allPools.length === 0) {
|
|
10663
|
+
try {
|
|
10664
|
+
const moveEventType = `${package_id}::almm_pair::EventCreatePair`;
|
|
10665
|
+
const objects = await this._sdk.fullClient.queryEventsByPage({ MoveEventType: moveEventType }, paginationArgs);
|
|
10666
|
+
const dataPage = {
|
|
10667
|
+
data: [],
|
|
10668
|
+
hasNextPage: false
|
|
10669
|
+
};
|
|
10670
|
+
dataPage.hasNextPage = objects.hasNextPage;
|
|
10671
|
+
dataPage.nextCursor = objects.nextCursor;
|
|
10672
|
+
objects.data.forEach((object) => {
|
|
10673
|
+
const fields = object.parsedJson;
|
|
10674
|
+
if (fields) {
|
|
10675
|
+
allPools.push(fields);
|
|
10676
|
+
}
|
|
10677
|
+
});
|
|
10678
|
+
this.updateCache(cacheKey, allPools, cacheTime24h);
|
|
10679
|
+
} catch (error) {
|
|
10680
|
+
console.log("getCreatePairEvents", error);
|
|
10681
|
+
}
|
|
10682
|
+
}
|
|
10683
|
+
return allPools;
|
|
10684
|
+
}
|
|
10650
10685
|
async getPoolInfo(pools) {
|
|
10651
10686
|
const cachePoolList = [];
|
|
10652
10687
|
pools = pools.filter((poolID) => {
|
|
@@ -10684,11 +10719,12 @@ var AlmmModule = class {
|
|
|
10684
10719
|
base_factor: fields.params.fields.base_factor,
|
|
10685
10720
|
base_fee: fields.params.fields.base_factor * fields.bin_step / 1e9,
|
|
10686
10721
|
active_index: fields.params.fields.active_index,
|
|
10687
|
-
real_bin_id: (0,
|
|
10722
|
+
real_bin_id: (0, import_calc_almm3.get_real_id)(fields.params.fields.active_index),
|
|
10688
10723
|
coinAmountA: fields.reserve_x,
|
|
10689
10724
|
coinAmountB: fields.reserve_y,
|
|
10690
10725
|
liquidity: fields.liquidity,
|
|
10691
|
-
rewarder_infos: rewarders
|
|
10726
|
+
rewarder_infos: rewarders,
|
|
10727
|
+
params: fields.params.fields
|
|
10692
10728
|
};
|
|
10693
10729
|
poolList.push(poolInfo);
|
|
10694
10730
|
this.updateCache(`${fields.id.id}_getPoolObject`, poolInfo, cacheTime24h);
|
|
@@ -10726,7 +10762,8 @@ var AlmmModule = class {
|
|
|
10726
10762
|
index_reference: 0,
|
|
10727
10763
|
time_of_last_update: 0,
|
|
10728
10764
|
oracle_index: 0,
|
|
10729
|
-
active_index: 0
|
|
10765
|
+
active_index: 0,
|
|
10766
|
+
protocol_variable_share: 0
|
|
10730
10767
|
};
|
|
10731
10768
|
simulateRes.events?.forEach((item) => {
|
|
10732
10769
|
console.log(extractStructTagFromType(item.type).name);
|
|
@@ -10738,7 +10775,7 @@ var AlmmModule = class {
|
|
|
10738
10775
|
}
|
|
10739
10776
|
// NOTE: x, y should be sorted
|
|
10740
10777
|
async createPairPayload(params) {
|
|
10741
|
-
const storage_id = (0,
|
|
10778
|
+
const storage_id = (0, import_calc_almm3.get_storage_id_from_real_id)(
|
|
10742
10779
|
BinMath.getBinIdFromPrice(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal)
|
|
10743
10780
|
);
|
|
10744
10781
|
const tx = new import_transactions12.Transaction();
|
|
@@ -10781,11 +10818,11 @@ var AlmmModule = class {
|
|
|
10781
10818
|
const { almm_pool, integrate } = this.sdk.sdkOptions;
|
|
10782
10819
|
const almmConfig = getPackagerConfigs(almm_pool);
|
|
10783
10820
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10784
|
-
const price = (0,
|
|
10821
|
+
const price = (0, import_calc_almm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10785
10822
|
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10786
10823
|
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10787
|
-
const active_min = (0,
|
|
10788
|
-
const active_max = (0,
|
|
10824
|
+
const active_min = (0, import_calc_almm3.get_storage_id_from_real_id)((0, import_calc_almm3.get_real_id_from_price_x128)(min_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10825
|
+
const active_max = (0, import_calc_almm3.get_storage_id_from_real_id)((0, import_calc_almm3.get_real_id_from_price_x128)(max_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10789
10826
|
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10790
10827
|
let amount_min = 0;
|
|
10791
10828
|
let amount_max = 0;
|
|
@@ -10821,8 +10858,8 @@ var AlmmModule = class {
|
|
|
10821
10858
|
tx.pure.bool(params.fixCoinB),
|
|
10822
10859
|
tx.pure.u64(params.amountBTotal),
|
|
10823
10860
|
tx.pure.u8(params.strategy),
|
|
10824
|
-
tx.pure.u32((0,
|
|
10825
|
-
tx.pure.u32((0,
|
|
10861
|
+
tx.pure.u32((0, import_calc_almm3.get_storage_id_from_real_id)(params.min_bin)),
|
|
10862
|
+
tx.pure.u32((0, import_calc_almm3.get_storage_id_from_real_id)(params.max_bin)),
|
|
10826
10863
|
tx.pure.u32(active_min),
|
|
10827
10864
|
tx.pure.u32(active_max),
|
|
10828
10865
|
tx.pure.u64(amount_min),
|
|
@@ -10908,11 +10945,11 @@ var AlmmModule = class {
|
|
|
10908
10945
|
tx.setSender(this.sdk.senderAddress);
|
|
10909
10946
|
const { almm_pool, integrate } = this.sdk.sdkOptions;
|
|
10910
10947
|
const almmConfig = getPackagerConfigs(almm_pool);
|
|
10911
|
-
const price = (0,
|
|
10948
|
+
const price = (0, import_calc_almm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10912
10949
|
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10913
10950
|
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10914
|
-
const active_min = (0,
|
|
10915
|
-
const active_max = (0,
|
|
10951
|
+
const active_min = (0, import_calc_almm3.get_storage_id_from_real_id)((0, import_calc_almm3.get_real_id_from_price_x128)(min_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10952
|
+
const active_max = (0, import_calc_almm3.get_storage_id_from_real_id)((0, import_calc_almm3.get_real_id_from_price_x128)(max_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10916
10953
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10917
10954
|
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10918
10955
|
let amount_min = 0;
|
|
@@ -10971,11 +11008,11 @@ var AlmmModule = class {
|
|
|
10971
11008
|
tx.setSender(this.sdk.senderAddress);
|
|
10972
11009
|
const { almm_pool, integrate } = this.sdk.sdkOptions;
|
|
10973
11010
|
const almmConfig = getPackagerConfigs(almm_pool);
|
|
10974
|
-
const price = (0,
|
|
11011
|
+
const price = (0, import_calc_almm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10975
11012
|
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10976
11013
|
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10977
|
-
const active_min = (0,
|
|
10978
|
-
const active_max = (0,
|
|
11014
|
+
const active_min = (0, import_calc_almm3.get_storage_id_from_real_id)((0, import_calc_almm3.get_real_id_from_price_x128)(min_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
11015
|
+
const active_max = (0, import_calc_almm3.get_storage_id_from_real_id)((0, import_calc_almm3.get_real_id_from_price_x128)(max_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10979
11016
|
const typeArguments = [params.coinTypeA, params.coinTypeB, ...params.rewards_token];
|
|
10980
11017
|
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10981
11018
|
let amount_min = 0;
|
|
@@ -11140,14 +11177,14 @@ var AlmmModule = class {
|
|
|
11140
11177
|
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coinTypeB, false, true);
|
|
11141
11178
|
const storageIds = [];
|
|
11142
11179
|
params.realIds.forEach((i) => {
|
|
11143
|
-
storageIds.push((0,
|
|
11180
|
+
storageIds.push((0, import_calc_almm3.get_storage_id_from_real_id)(i));
|
|
11144
11181
|
});
|
|
11145
11182
|
const args = [
|
|
11146
11183
|
tx.object(almmConfig.factory),
|
|
11147
11184
|
tx.object(global_config_id),
|
|
11148
11185
|
tx.pure.u64(params.baseFee),
|
|
11149
11186
|
tx.pure.u16(params.binStep),
|
|
11150
|
-
tx.pure.u32((0,
|
|
11187
|
+
tx.pure.u32((0, import_calc_almm3.get_storage_id_from_real_id)(params.activeId)),
|
|
11151
11188
|
primaryCoinAInputs.targetCoin,
|
|
11152
11189
|
primaryCoinBInputs.targetCoin,
|
|
11153
11190
|
tx.pure.vector("u32", storageIds),
|
|
@@ -11230,7 +11267,7 @@ var AlmmModule = class {
|
|
|
11230
11267
|
}
|
|
11231
11268
|
});
|
|
11232
11269
|
res.forEach((bin) => {
|
|
11233
|
-
bin.real_bin_id = (0,
|
|
11270
|
+
bin.real_bin_id = (0, import_calc_almm3.get_real_id)(Number(bin.storage_id));
|
|
11234
11271
|
});
|
|
11235
11272
|
return res.sort((a, b) => a.real_bin_id - b.real_bin_id);
|
|
11236
11273
|
}
|
|
@@ -11303,24 +11340,28 @@ var AlmmModule = class {
|
|
|
11303
11340
|
* @returns array of Position objects.
|
|
11304
11341
|
*/
|
|
11305
11342
|
async getUserPositionById(positionId, showDisplay = true) {
|
|
11306
|
-
|
|
11343
|
+
const allPosition = [];
|
|
11307
11344
|
const ownerRes = await this._sdk.fullClient.getObject({
|
|
11308
11345
|
id: positionId,
|
|
11309
11346
|
options: { showContent: true, showType: true, showDisplay, showOwner: true }
|
|
11310
11347
|
});
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11348
|
+
if (ownerRes.data) {
|
|
11349
|
+
const type = extractStructTagFromType(ownerRes.data.type);
|
|
11350
|
+
if (type.full_address === this.buildPositionType()) {
|
|
11351
|
+
const position = this.buildPosition(ownerRes);
|
|
11352
|
+
const cacheKey = `${position.pos_object_id}_getPositionList`;
|
|
11353
|
+
this.updateCache(cacheKey, position, cacheTime24h);
|
|
11354
|
+
allPosition.push(position);
|
|
11355
|
+
}
|
|
11356
|
+
return await this.getUserPositionInfo(allPosition);
|
|
11317
11357
|
}
|
|
11318
|
-
return
|
|
11358
|
+
return [];
|
|
11319
11359
|
}
|
|
11320
11360
|
/**
|
|
11321
11361
|
* Gets a list of positions for the given account address.
|
|
11322
11362
|
* @param accountAddress The account address to get positions for.
|
|
11323
11363
|
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11364
|
+
* @param showDisplay When some testnet rpc nodes can't return object's display data, you can set this option to false, avoid returning errors. Default set true.
|
|
11324
11365
|
* @returns array of Position objects.
|
|
11325
11366
|
*/
|
|
11326
11367
|
async getUserPositions(accountAddress, assignPoolIds = [], showDisplay = true) {
|
|
@@ -11414,7 +11455,7 @@ var AlmmModule = class {
|
|
|
11414
11455
|
liquidity: item2.parsedJson.liquidity,
|
|
11415
11456
|
x_equivalent: item2.parsedJson.x_equivalent,
|
|
11416
11457
|
y_equivalent: item2.parsedJson.y_equivalent,
|
|
11417
|
-
bin_real_ids: item2.parsedJson.bin_ids.map((id) => (0,
|
|
11458
|
+
bin_real_ids: item2.parsedJson.bin_ids.map((id) => (0, import_calc_almm3.get_real_id)(id)),
|
|
11418
11459
|
bin_x_eq: item2.parsedJson.bin_x_eq,
|
|
11419
11460
|
bin_y_eq: item2.parsedJson.bin_y_eq,
|
|
11420
11461
|
bin_liquidity: item2.parsedJson.bin_liquidity
|
|
@@ -11481,7 +11522,7 @@ var AlmmModule = class {
|
|
|
11481
11522
|
pos_object_id: fields.id.id,
|
|
11482
11523
|
owner: ownerWarp.AddressOwner,
|
|
11483
11524
|
pool: fields.pair_id,
|
|
11484
|
-
bin_real_ids: fields.bin_ids.map((id) => (0,
|
|
11525
|
+
bin_real_ids: fields.bin_ids.map((id) => (0, import_calc_almm3.get_real_id)(id)),
|
|
11485
11526
|
type: ""
|
|
11486
11527
|
};
|
|
11487
11528
|
}
|
|
@@ -11553,7 +11594,7 @@ var AlmmModule = class {
|
|
|
11553
11594
|
liquidity: item.parsedJson.liquidity,
|
|
11554
11595
|
x_equivalent: item.parsedJson.x_equivalent,
|
|
11555
11596
|
y_equivalent: item.parsedJson.y_equivalent,
|
|
11556
|
-
bin_real_ids: item.parsedJson.bin_ids.map((id) => (0,
|
|
11597
|
+
bin_real_ids: item.parsedJson.bin_ids.map((id) => (0, import_calc_almm3.get_real_id)(id)),
|
|
11557
11598
|
bin_x_eq: item.parsedJson.bin_x_eq,
|
|
11558
11599
|
bin_y_eq: item.parsedJson.bin_y_eq,
|
|
11559
11600
|
bin_liquidity: item.parsedJson.bin_liquidity
|
|
@@ -12073,7 +12114,7 @@ var main_default = MagmaClmmSDK;
|
|
|
12073
12114
|
var SDKConfig = {
|
|
12074
12115
|
clmmConfig: {
|
|
12075
12116
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
12076
|
-
// clmm and
|
|
12117
|
+
// clmm and almm both use this global_config
|
|
12077
12118
|
global_config_id: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
12078
12119
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
12079
12120
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
@@ -12122,8 +12163,8 @@ var clmmMainnet = {
|
|
|
12122
12163
|
config: SDKConfig.clmmConfig
|
|
12123
12164
|
},
|
|
12124
12165
|
almm_pool: {
|
|
12125
|
-
package_id: "",
|
|
12126
|
-
published_at: "",
|
|
12166
|
+
package_id: "0x17ec44d20706af7f4ca563be7424bfa07c190f7f47bec157fa1eedaeec0bae3d",
|
|
12167
|
+
published_at: "0x17ec44d20706af7f4ca563be7424bfa07c190f7f47bec157fa1eedaeec0bae3d",
|
|
12127
12168
|
config: SDKConfig.almmConfig
|
|
12128
12169
|
},
|
|
12129
12170
|
distribution: {
|
|
@@ -12131,8 +12172,8 @@ var clmmMainnet = {
|
|
|
12131
12172
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
12132
12173
|
},
|
|
12133
12174
|
integrate: {
|
|
12134
|
-
package_id: "
|
|
12135
|
-
published_at: "
|
|
12175
|
+
package_id: "0x7701ae515703598d6f2451f4bfec857d3cba994fd3e1968b11110d674e3126c4",
|
|
12176
|
+
published_at: "0x7701ae515703598d6f2451f4bfec857d3cba994fd3e1968b11110d674e3126c4"
|
|
12136
12177
|
},
|
|
12137
12178
|
deepbook: {
|
|
12138
12179
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|