@magmaprotocol/magma-clmm-sdk 0.5.48 → 0.5.50
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 +13 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1824,6 +1824,17 @@ type BinDisplay = {
|
|
|
1824
1824
|
amountX: BN;
|
|
1825
1825
|
amountY: BN;
|
|
1826
1826
|
};
|
|
1827
|
+
type DlmmCreatePairAddLiquidityParams = {
|
|
1828
|
+
baseFee: number;
|
|
1829
|
+
binStep: number;
|
|
1830
|
+
coinTypeA: string;
|
|
1831
|
+
coinTypeB: string;
|
|
1832
|
+
activeId: number;
|
|
1833
|
+
storageIds: number[];
|
|
1834
|
+
amountsX: number[];
|
|
1835
|
+
amountsY: number[];
|
|
1836
|
+
to: string;
|
|
1837
|
+
};
|
|
1827
1838
|
|
|
1828
1839
|
type BigNumber = Decimal.Value | number | string;
|
|
1829
1840
|
|
|
@@ -3707,6 +3718,7 @@ declare class DlmmModule implements IModule {
|
|
|
3707
3718
|
shrinkPosition(params: DlmmShrinkPosition): Promise<Transaction>;
|
|
3708
3719
|
collectReward(params: DlmmCollectRewardParams): Promise<Transaction>;
|
|
3709
3720
|
collectFees(params: DlmmCollectFeeParams): Promise<Transaction>;
|
|
3721
|
+
createPairAddLiquidity(params: DlmmCreatePairAddLiquidityParams): Promise<Transaction>;
|
|
3710
3722
|
swap(params: DLMMSwapParams): Promise<Transaction>;
|
|
3711
3723
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3712
3724
|
getPositionLiquidity(params: GetPositionLiquidityParams): Promise<EventPositionLiquidity>;
|
|
@@ -4448,4 +4460,4 @@ interface InitMagmaSDKOptions {
|
|
|
4448
4460
|
*/
|
|
4449
4461
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4450
4462
|
|
|
4451
|
-
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, 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, DLMMSwapParams, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmAddLiquidityParams, DlmmBurnPositionParams, DlmmCollectFeeParams, DlmmCollectRewardParams, DlmmConfig, DlmmEventEarnedFees, DlmmEventEarnedRewards, DlmmEventPairRewardTypes, DlmmPoolInfo, DlmmRewardsParams, DlmmScript, DlmmShrinkPosition, 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, 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, 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, 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 };
|
|
4463
|
+
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, 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, DLMMSwapParams, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmAddLiquidityParams, DlmmBurnPositionParams, DlmmCollectFeeParams, DlmmCollectRewardParams, DlmmConfig, DlmmCreatePairAddLiquidityParams, DlmmEventEarnedFees, DlmmEventEarnedRewards, DlmmEventPairRewardTypes, DlmmPoolInfo, DlmmRewardsParams, DlmmScript, DlmmShrinkPosition, 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, 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, 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, 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
|
@@ -2819,7 +2819,7 @@ var BinMath = class {
|
|
|
2819
2819
|
static getBinIdFromPrice(price, binStep, decimalsA, decimalsB) {
|
|
2820
2820
|
const twoDec = new import_decimal9.default(2);
|
|
2821
2821
|
const tenDec = new import_decimal9.default(10);
|
|
2822
|
-
const realid = (0, import_calc_dlmm2.get_real_id_from_price_x128)(new import_decimal9.default(price).mul(tenDec.pow(decimalsB -
|
|
2822
|
+
const realid = (0, import_calc_dlmm2.get_real_id_from_price_x128)(new import_decimal9.default(price).mul(tenDec.pow(decimalsB - decimalsA)).mul(twoDec.pow(128)).toDecimalPlaces(0).toString(), binStep);
|
|
2823
2823
|
return realid;
|
|
2824
2824
|
}
|
|
2825
2825
|
};
|
|
@@ -10724,8 +10724,8 @@ var GaugeModule = class {
|
|
|
10724
10724
|
|
|
10725
10725
|
// src/modules/dlmm.ts
|
|
10726
10726
|
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10727
|
-
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10728
10727
|
var import_calc_dlmm3 = require("@magmaprotocol/calc_dlmm");
|
|
10728
|
+
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10729
10729
|
var DlmmModule = class {
|
|
10730
10730
|
_sdk;
|
|
10731
10731
|
constructor(sdk) {
|
|
@@ -11032,6 +11032,38 @@ var DlmmModule = class {
|
|
|
11032
11032
|
});
|
|
11033
11033
|
return tx;
|
|
11034
11034
|
}
|
|
11035
|
+
async createPairAddLiquidity(params) {
|
|
11036
|
+
const tx = new import_transactions12.Transaction();
|
|
11037
|
+
tx.setSender(this.sdk.senderAddress);
|
|
11038
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
11039
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
11040
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11041
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
11042
|
+
const amountATotal = params.amountsX.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
11043
|
+
const amountBTotal = params.amountsY.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
11044
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coinTypeA, false, true);
|
|
11045
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coinTypeB, false, true);
|
|
11046
|
+
const args = [
|
|
11047
|
+
tx.object(dlmmConfig.factory),
|
|
11048
|
+
tx.pure.u64(params.baseFee),
|
|
11049
|
+
tx.pure.u16(params.binStep),
|
|
11050
|
+
tx.pure.u32(params.activeId),
|
|
11051
|
+
primaryCoinAInputs.targetCoin,
|
|
11052
|
+
primaryCoinBInputs.targetCoin,
|
|
11053
|
+
tx.pure.vector("u32", params.storageIds),
|
|
11054
|
+
tx.pure.vector("u64", params.amountsX),
|
|
11055
|
+
tx.pure.vector("u64", params.amountsY),
|
|
11056
|
+
tx.pure.address(params.to),
|
|
11057
|
+
tx.object(CLOCK_ADDRESS)
|
|
11058
|
+
];
|
|
11059
|
+
const target = `${integrate.published_at}::${DlmmScript}::create_pair_add_liquidity`;
|
|
11060
|
+
tx.moveCall({
|
|
11061
|
+
target,
|
|
11062
|
+
typeArguments,
|
|
11063
|
+
arguments: args
|
|
11064
|
+
});
|
|
11065
|
+
return tx;
|
|
11066
|
+
}
|
|
11035
11067
|
async swap(params) {
|
|
11036
11068
|
const tx = new import_transactions12.Transaction();
|
|
11037
11069
|
tx.setSender(this.sdk.senderAddress);
|