@magmaprotocol/magma-clmm-sdk 0.5.64 → 0.5.66
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 +27 -9
- package/dist/index.js +101 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1752,6 +1752,8 @@ type DlmmPoolInfo = {
|
|
|
1752
1752
|
base_factor: number;
|
|
1753
1753
|
base_fee: number;
|
|
1754
1754
|
active_index: number;
|
|
1755
|
+
coinAmountA: string;
|
|
1756
|
+
coinAmountB: string;
|
|
1755
1757
|
};
|
|
1756
1758
|
type DlmmAddLiquidityParams = {
|
|
1757
1759
|
pool_id: string;
|
|
@@ -1849,6 +1851,21 @@ type DlmmPositionInfo = {
|
|
|
1849
1851
|
fees: DlmmEventEarnedFees;
|
|
1850
1852
|
contractPool: DlmmPoolInfo | undefined;
|
|
1851
1853
|
};
|
|
1854
|
+
type MintByStrategyParams = {
|
|
1855
|
+
pair: string;
|
|
1856
|
+
bin_step: number;
|
|
1857
|
+
coinTypeA: string;
|
|
1858
|
+
coinTypeB: string;
|
|
1859
|
+
amountATotal: number;
|
|
1860
|
+
amountBTotal: number;
|
|
1861
|
+
fixCoinA: boolean;
|
|
1862
|
+
fixCoinB: boolean;
|
|
1863
|
+
strategy: number;
|
|
1864
|
+
min_bin: number;
|
|
1865
|
+
max_bin: number;
|
|
1866
|
+
active_bin: number;
|
|
1867
|
+
slippage: number;
|
|
1868
|
+
};
|
|
1852
1869
|
|
|
1853
1870
|
type BigNumber = Decimal.Value | number | string;
|
|
1854
1871
|
|
|
@@ -3722,8 +3739,8 @@ declare class DlmmModule implements IModule {
|
|
|
3722
3739
|
get sdk(): MagmaClmmSDK;
|
|
3723
3740
|
getPoolInfo(pools: string[]): Promise<DlmmPoolInfo[]>;
|
|
3724
3741
|
fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
|
|
3725
|
-
price_to_storage_id(price: string, bin_step: number, tokenADecimal: number, tokenBDecimal: number): number;
|
|
3726
3742
|
createPairPayload(params: CreatePairParams): Promise<Transaction>;
|
|
3743
|
+
mintByStrategy(params: MintByStrategyParams): Promise<Transaction>;
|
|
3727
3744
|
mintPercent(params: MintPercentParams): Promise<Transaction>;
|
|
3728
3745
|
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
3729
3746
|
addLiquidity(params: DlmmAddLiquidityParams): Promise<Transaction>;
|
|
@@ -3731,17 +3748,18 @@ declare class DlmmModule implements IModule {
|
|
|
3731
3748
|
private _raisePositionByAmountsReward;
|
|
3732
3749
|
burnPosition(params: DlmmBurnPositionParams): Promise<Transaction>;
|
|
3733
3750
|
shrinkPosition(params: DlmmShrinkPosition): Promise<Transaction>;
|
|
3734
|
-
|
|
3735
|
-
|
|
3751
|
+
collectFeeAndReward(params: DlmmCollectRewardParams & DlmmCollectFeeParams): Promise<Transaction>;
|
|
3752
|
+
collectReward(params: DlmmCollectRewardParams, transaction?: Transaction): Promise<Transaction>;
|
|
3753
|
+
collectFees(params: DlmmCollectFeeParams, transaction?: Transaction): Promise<Transaction>;
|
|
3736
3754
|
createPairAddLiquidity(params: DlmmCreatePairAddLiquidityParams): Promise<Transaction>;
|
|
3737
3755
|
swap(params: DLMMSwapParams): Promise<Transaction>;
|
|
3738
3756
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3739
3757
|
/**
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3758
|
+
* Gets a list of positions for the given account address.
|
|
3759
|
+
* @param accountAddress The account address to get positions for.
|
|
3760
|
+
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
3761
|
+
* @returns array of Position objects.
|
|
3762
|
+
*/
|
|
3745
3763
|
getUserPositionById(positionId: string, showDisplay?: boolean): Promise<DlmmPositionInfo>;
|
|
3746
3764
|
/**
|
|
3747
3765
|
* Gets a list of positions for the given account address.
|
|
@@ -4508,4 +4526,4 @@ interface InitMagmaSDKOptions {
|
|
|
4508
4526
|
*/
|
|
4509
4527
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4510
4528
|
|
|
4511
|
-
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, DlmmPosition, DlmmPositionInfo, 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 };
|
|
4529
|
+
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, DlmmPosition, DlmmPositionInfo, 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, 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, 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
|
@@ -10750,7 +10750,9 @@ var DlmmModule = class {
|
|
|
10750
10750
|
coin_b: fields.y.fields.name,
|
|
10751
10751
|
base_factor: fields.params.fields.base_factor,
|
|
10752
10752
|
base_fee: fields.params.fields.base_factor / 1e4 * (fields.bin_step / 1e4),
|
|
10753
|
-
active_index: fields.params.fields.active_index
|
|
10753
|
+
active_index: fields.params.fields.active_index,
|
|
10754
|
+
coinAmountA: fields.reserve_x,
|
|
10755
|
+
coinAmountB: fields.reserve_y
|
|
10754
10756
|
});
|
|
10755
10757
|
});
|
|
10756
10758
|
return poolList;
|
|
@@ -10796,18 +10798,11 @@ var DlmmModule = class {
|
|
|
10796
10798
|
});
|
|
10797
10799
|
return res;
|
|
10798
10800
|
}
|
|
10799
|
-
// params price: input (b/(10^b_decimal))/(a/(10^a_decimal))
|
|
10800
|
-
price_to_storage_id(price, bin_step, tokenADecimal, tokenBDecimal) {
|
|
10801
|
-
const priceDec = new import_decimal13.default(price);
|
|
10802
|
-
const tenDec = new import_decimal13.default(10);
|
|
10803
|
-
const twoDec = new import_decimal13.default(2);
|
|
10804
|
-
const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
|
|
10805
|
-
const active_id = (0, import_calc_dlmm3.get_real_id_from_price_x128)(price_x128.toFixed(0).toString(), bin_step);
|
|
10806
|
-
return (0, import_calc_dlmm3.get_storage_id_from_real_id)(active_id);
|
|
10807
|
-
}
|
|
10808
10801
|
// NOTE: x, y should be sorted
|
|
10809
10802
|
async createPairPayload(params) {
|
|
10810
|
-
const storage_id =
|
|
10803
|
+
const storage_id = (0, import_calc_dlmm3.get_storage_id_from_real_id)(
|
|
10804
|
+
BinMath.getBinIdFromPrice(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal)
|
|
10805
|
+
);
|
|
10811
10806
|
const tx = new import_transactions12.Transaction();
|
|
10812
10807
|
tx.setSender(this.sdk.senderAddress);
|
|
10813
10808
|
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
@@ -10828,6 +10823,64 @@ var DlmmModule = class {
|
|
|
10828
10823
|
});
|
|
10829
10824
|
return tx;
|
|
10830
10825
|
}
|
|
10826
|
+
async mintByStrategy(params) {
|
|
10827
|
+
const tx = new import_transactions12.Transaction();
|
|
10828
|
+
const slippage = new import_decimal13.default(params.slippage);
|
|
10829
|
+
const lower_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
10830
|
+
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
10831
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10832
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10833
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10834
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10835
|
+
const price = (0, import_calc_dlmm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10836
|
+
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10837
|
+
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10838
|
+
const active_min = (0, import_calc_dlmm3.get_storage_id_from_real_id)((0, import_calc_dlmm3.get_real_id_from_price_x128)(min_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10839
|
+
const active_max = (0, import_calc_dlmm3.get_storage_id_from_real_id)((0, import_calc_dlmm3.get_real_id_from_price_x128)(max_price.toDecimalPlaces(0).toString(), params.bin_step));
|
|
10840
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10841
|
+
let primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10842
|
+
let primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10843
|
+
let amount_min = 0;
|
|
10844
|
+
let amount_max = 0;
|
|
10845
|
+
if (params.fixCoinA) {
|
|
10846
|
+
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10847
|
+
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10848
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10849
|
+
}
|
|
10850
|
+
if (params.fixCoinB) {
|
|
10851
|
+
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10852
|
+
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10853
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10854
|
+
}
|
|
10855
|
+
if (params.fixCoinA && params.fixCoinB) {
|
|
10856
|
+
} else if (params.fixCoinA) {
|
|
10857
|
+
params.amountBTotal = 0;
|
|
10858
|
+
} else if (params.fixCoinB) {
|
|
10859
|
+
params.amountATotal = 0;
|
|
10860
|
+
}
|
|
10861
|
+
const args = [
|
|
10862
|
+
tx.object(params.pair),
|
|
10863
|
+
tx.object(dlmmConfig.factory),
|
|
10864
|
+
primaryCoinAInputs.targetCoin,
|
|
10865
|
+
primaryCoinBInputs.targetCoin,
|
|
10866
|
+
tx.pure.u64(params.amountATotal),
|
|
10867
|
+
tx.pure.u64(params.amountBTotal),
|
|
10868
|
+
tx.pure.u8(params.strategy),
|
|
10869
|
+
tx.pure.u32(params.min_bin),
|
|
10870
|
+
tx.pure.u32(params.max_bin),
|
|
10871
|
+
tx.pure.u32(active_min),
|
|
10872
|
+
tx.pure.u32(active_max),
|
|
10873
|
+
tx.pure.u64(amount_min),
|
|
10874
|
+
tx.pure.u64(amount_max),
|
|
10875
|
+
tx.object(CLOCK_ADDRESS)
|
|
10876
|
+
];
|
|
10877
|
+
tx.moveCall({
|
|
10878
|
+
target: `${integrate.published_at}::${DlmmScript}::mint_percent`,
|
|
10879
|
+
typeArguments,
|
|
10880
|
+
arguments: args
|
|
10881
|
+
});
|
|
10882
|
+
return tx;
|
|
10883
|
+
}
|
|
10831
10884
|
// Create a position by percent
|
|
10832
10885
|
async mintPercent(params) {
|
|
10833
10886
|
const tx = new import_transactions12.Transaction();
|
|
@@ -10996,8 +11049,16 @@ var DlmmModule = class {
|
|
|
10996
11049
|
});
|
|
10997
11050
|
return tx;
|
|
10998
11051
|
}
|
|
10999
|
-
async
|
|
11000
|
-
|
|
11052
|
+
async collectFeeAndReward(params) {
|
|
11053
|
+
let tx = new import_transactions12.Transaction();
|
|
11054
|
+
tx = await this.collectFees(params);
|
|
11055
|
+
if (params.rewards_token.length > 0) {
|
|
11056
|
+
tx = await this.collectReward(params);
|
|
11057
|
+
}
|
|
11058
|
+
return tx;
|
|
11059
|
+
}
|
|
11060
|
+
async collectReward(params, transaction) {
|
|
11061
|
+
const tx = transaction || new import_transactions12.Transaction();
|
|
11001
11062
|
tx.setSender(this.sdk.senderAddress);
|
|
11002
11063
|
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
11003
11064
|
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
@@ -11019,8 +11080,8 @@ var DlmmModule = class {
|
|
|
11019
11080
|
});
|
|
11020
11081
|
return tx;
|
|
11021
11082
|
}
|
|
11022
|
-
async collectFees(params) {
|
|
11023
|
-
const tx = new import_transactions12.Transaction();
|
|
11083
|
+
async collectFees(params, transaction) {
|
|
11084
|
+
const tx = transaction || new import_transactions12.Transaction();
|
|
11024
11085
|
tx.setSender(this.sdk.senderAddress);
|
|
11025
11086
|
const { integrate } = this.sdk.sdkOptions;
|
|
11026
11087
|
const typeArguments = [params.coin_a, params.coin_b];
|
|
@@ -11071,11 +11132,28 @@ var DlmmModule = class {
|
|
|
11071
11132
|
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
11072
11133
|
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
11073
11134
|
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
11135
|
+
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
11136
|
+
const primaryCoinInputA = TransactionUtil.buildCoinForAmount(
|
|
11137
|
+
tx,
|
|
11138
|
+
allCoinAsset,
|
|
11139
|
+
params.swapForY ? BigInt(params.amountIn) : BigInt(0),
|
|
11140
|
+
params.coinTypeA,
|
|
11141
|
+
false,
|
|
11142
|
+
true
|
|
11143
|
+
);
|
|
11144
|
+
const primaryCoinInputB = TransactionUtil.buildCoinForAmount(
|
|
11145
|
+
tx,
|
|
11146
|
+
allCoinAsset,
|
|
11147
|
+
params.swapForY ? BigInt(0) : BigInt(params.amountIn),
|
|
11148
|
+
params.coinTypeB,
|
|
11149
|
+
false,
|
|
11150
|
+
true
|
|
11151
|
+
);
|
|
11074
11152
|
const args = [
|
|
11075
11153
|
tx.object(params.pair),
|
|
11076
11154
|
tx.object(global_config_id),
|
|
11077
|
-
|
|
11078
|
-
|
|
11155
|
+
primaryCoinInputA.targetCoin,
|
|
11156
|
+
primaryCoinInputB.targetCoin,
|
|
11079
11157
|
tx.pure.u64(params.amountIn),
|
|
11080
11158
|
tx.pure.u64(params.minAmountOut),
|
|
11081
11159
|
tx.pure.bool(params.swapForY),
|
|
@@ -11116,11 +11194,11 @@ var DlmmModule = class {
|
|
|
11116
11194
|
return res;
|
|
11117
11195
|
}
|
|
11118
11196
|
/**
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11197
|
+
* Gets a list of positions for the given account address.
|
|
11198
|
+
* @param accountAddress The account address to get positions for.
|
|
11199
|
+
* @param assignPoolIds An array of pool IDs to filter the positions by.
|
|
11200
|
+
* @returns array of Position objects.
|
|
11201
|
+
*/
|
|
11124
11202
|
async getUserPositionById(positionId, showDisplay = true) {
|
|
11125
11203
|
let position;
|
|
11126
11204
|
const ownerRes = await this._sdk.fullClient.getObject({
|
|
@@ -11386,7 +11464,7 @@ var DlmmModule = class {
|
|
|
11386
11464
|
fee_y: 0
|
|
11387
11465
|
};
|
|
11388
11466
|
if (simulateRes.error != null) {
|
|
11389
|
-
throw new Error(`
|
|
11467
|
+
throw new Error(`fetchPairRewards error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11390
11468
|
}
|
|
11391
11469
|
simulateRes.events?.forEach((item) => {
|
|
11392
11470
|
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|