@magmaprotocol/magma-clmm-sdk 0.5.84 → 0.5.86
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 +20 -4
- package/dist/index.js +156 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1879,6 +1879,24 @@ type MintByStrategyParams = {
|
|
|
1879
1879
|
*/
|
|
1880
1880
|
slippage: number;
|
|
1881
1881
|
};
|
|
1882
|
+
type RaiseByStrategyParams = {
|
|
1883
|
+
pair: string;
|
|
1884
|
+
positionId: string;
|
|
1885
|
+
bin_step: number;
|
|
1886
|
+
coinTypeA: string;
|
|
1887
|
+
coinTypeB: string;
|
|
1888
|
+
amountATotal: number;
|
|
1889
|
+
amountBTotal: number;
|
|
1890
|
+
fixCoinA: boolean;
|
|
1891
|
+
fixCoinB: boolean;
|
|
1892
|
+
strategy: number;
|
|
1893
|
+
min_bin: number;
|
|
1894
|
+
max_bin: number;
|
|
1895
|
+
active_bin: number;
|
|
1896
|
+
slippage: number;
|
|
1897
|
+
receiver: string;
|
|
1898
|
+
rewards_token: string[];
|
|
1899
|
+
};
|
|
1882
1900
|
|
|
1883
1901
|
type BigNumber = Decimal.Value | number | string;
|
|
1884
1902
|
|
|
@@ -3754,9 +3772,7 @@ declare class DlmmModule implements IModule {
|
|
|
3754
3772
|
fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
|
|
3755
3773
|
createPairPayload(params: CreatePairParams): Promise<Transaction>;
|
|
3756
3774
|
mintByStrategy(params: MintByStrategyParams): Promise<Transaction>;
|
|
3757
|
-
|
|
3758
|
-
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
3759
|
-
addLiquidity(params: DlmmAddLiquidityParams): Promise<Transaction>;
|
|
3775
|
+
addLiquidityByStrategy(params: RaiseByStrategyParams): Promise<Transaction>;
|
|
3760
3776
|
private _raisePositionByAmounts;
|
|
3761
3777
|
private _raisePositionByAmountsReward;
|
|
3762
3778
|
burnPosition(params: DlmmBurnPositionParams): Promise<Transaction>;
|
|
@@ -4540,4 +4556,4 @@ interface InitMagmaSDKOptions {
|
|
|
4540
4556
|
*/
|
|
4541
4557
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4542
4558
|
|
|
4543
|
-
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, 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 };
|
|
4559
|
+
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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -2232,6 +2232,9 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
2234
|
function assignLeftAmountX(activeId, binStep, maxBinId, amountX, strategyType) {
|
|
2235
|
+
if (maxBinId < activeId) {
|
|
2236
|
+
return [];
|
|
2237
|
+
}
|
|
2235
2238
|
let weights = [];
|
|
2236
2239
|
switch (strategyType) {
|
|
2237
2240
|
case 1 /* Spot */: {
|
|
@@ -2257,6 +2260,9 @@ function assignLeftAmountX(activeId, binStep, maxBinId, amountX, strategyType) {
|
|
|
2257
2260
|
});
|
|
2258
2261
|
}
|
|
2259
2262
|
function assignLeftAmountY(activeId, minBinId, amountY, strategyType) {
|
|
2263
|
+
if (minBinId > activeId) {
|
|
2264
|
+
return [];
|
|
2265
|
+
}
|
|
2260
2266
|
let weights = [];
|
|
2261
2267
|
switch (strategyType) {
|
|
2262
2268
|
case 1 /* Spot */: {
|
|
@@ -10803,65 +10809,65 @@ var DlmmModule = class {
|
|
|
10803
10809
|
});
|
|
10804
10810
|
return tx;
|
|
10805
10811
|
}
|
|
10806
|
-
// Create a position by percent
|
|
10807
|
-
async mintPercent(params) {
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
}
|
|
10836
|
-
// Create a position by amount
|
|
10837
|
-
async createPositionByAmount(params) {
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
}
|
|
10864
|
-
async
|
|
10812
|
+
// // Create a position by percent
|
|
10813
|
+
// async mintPercent(params: MintPercentParams): Promise<Transaction> {
|
|
10814
|
+
// const tx = new Transaction()
|
|
10815
|
+
// tx.setSender(this.sdk.senderAddress)
|
|
10816
|
+
// const { dlmm_pool, integrate } = this.sdk.sdkOptions
|
|
10817
|
+
// const dlmmConfig = getPackagerConfigs(dlmm_pool)
|
|
10818
|
+
// const typeArguments = [params.coinTypeA, params.coinTypeB]
|
|
10819
|
+
// const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress)
|
|
10820
|
+
// const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true)
|
|
10821
|
+
// const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true)
|
|
10822
|
+
// const args = [
|
|
10823
|
+
// tx.object(params.pair),
|
|
10824
|
+
// tx.object(dlmmConfig.factory),
|
|
10825
|
+
// primaryCoinAInputs.targetCoin,
|
|
10826
|
+
// primaryCoinBInputs.targetCoin,
|
|
10827
|
+
// tx.pure.u64(params.amountATotal),
|
|
10828
|
+
// tx.pure.u64(params.amountBTotal),
|
|
10829
|
+
// tx.pure.vector('u32', params.storageIds),
|
|
10830
|
+
// tx.pure.vector('u64', params.binsAPercent),
|
|
10831
|
+
// tx.pure.vector('u64', params.binsBPercent),
|
|
10832
|
+
// tx.pure.address(params.to),
|
|
10833
|
+
// tx.object(CLOCK_ADDRESS),
|
|
10834
|
+
// ]
|
|
10835
|
+
// tx.moveCall({
|
|
10836
|
+
// target: `${integrate.published_at}::${DlmmScript}::mint_percent`,
|
|
10837
|
+
// typeArguments,
|
|
10838
|
+
// arguments: args,
|
|
10839
|
+
// })
|
|
10840
|
+
// return tx
|
|
10841
|
+
// }
|
|
10842
|
+
// // Create a position by amount
|
|
10843
|
+
// async createPositionByAmount(params: MintAmountParams): Promise<Transaction> {
|
|
10844
|
+
// const tx = new Transaction()
|
|
10845
|
+
// tx.setSender(this.sdk.senderAddress)
|
|
10846
|
+
// const { dlmm_pool, integrate } = this.sdk.sdkOptions
|
|
10847
|
+
// const dlmmConfig = getPackagerConfigs(dlmm_pool)
|
|
10848
|
+
// const typeArguments = [params.coinTypeA, params.coinTypeB]
|
|
10849
|
+
// const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress)
|
|
10850
|
+
// const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true)
|
|
10851
|
+
// const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true)
|
|
10852
|
+
// const args = [
|
|
10853
|
+
// tx.object(params.pair),
|
|
10854
|
+
// tx.object(dlmmConfig.factory),
|
|
10855
|
+
// primaryCoinAInputs.targetCoin,
|
|
10856
|
+
// primaryCoinBInputs.targetCoin,
|
|
10857
|
+
// tx.pure.vector('u32', params.storageIds),
|
|
10858
|
+
// tx.pure.vector('u64', params.amountsA),
|
|
10859
|
+
// tx.pure.vector('u64', params.amountsB),
|
|
10860
|
+
// tx.pure.address(params.to),
|
|
10861
|
+
// tx.object(CLOCK_ADDRESS),
|
|
10862
|
+
// ]
|
|
10863
|
+
// tx.moveCall({
|
|
10864
|
+
// target: `${integrate.published_at}::${DlmmScript}::mint_amounts`,
|
|
10865
|
+
// typeArguments,
|
|
10866
|
+
// arguments: args,
|
|
10867
|
+
// })
|
|
10868
|
+
// return tx
|
|
10869
|
+
// }
|
|
10870
|
+
async addLiquidityByStrategy(params) {
|
|
10865
10871
|
if (params.rewards_token.length === 0) {
|
|
10866
10872
|
return this._raisePositionByAmounts(params);
|
|
10867
10873
|
}
|
|
@@ -10869,28 +10875,62 @@ var DlmmModule = class {
|
|
|
10869
10875
|
}
|
|
10870
10876
|
async _raisePositionByAmounts(params) {
|
|
10871
10877
|
const tx = new import_transactions12.Transaction();
|
|
10878
|
+
const slippage = new import_decimal13.default(params.slippage);
|
|
10879
|
+
const lower_slippage = new import_decimal13.default(1).sub(slippage.div(new import_decimal13.default(1e4)));
|
|
10880
|
+
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
10872
10881
|
tx.setSender(this.sdk.senderAddress);
|
|
10873
10882
|
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10874
10883
|
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10875
|
-
const
|
|
10884
|
+
const price = (0, import_calc_dlmm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10885
|
+
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10886
|
+
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10887
|
+
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));
|
|
10888
|
+
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));
|
|
10889
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10876
10890
|
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10891
|
+
let amount_min = 0;
|
|
10892
|
+
let amount_max = 0;
|
|
10893
|
+
let primaryCoinAInputs;
|
|
10894
|
+
let primaryCoinBInputs;
|
|
10895
|
+
if (params.fixCoinA && params.fixCoinB) {
|
|
10896
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10897
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10898
|
+
} else if (params.fixCoinA) {
|
|
10899
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10900
|
+
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10901
|
+
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10902
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10903
|
+
} else if (params.fixCoinB) {
|
|
10904
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10905
|
+
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10906
|
+
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10907
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true);
|
|
10908
|
+
}
|
|
10909
|
+
if (params.fixCoinA && params.fixCoinB) {
|
|
10910
|
+
} else if (params.fixCoinA) {
|
|
10911
|
+
params.amountBTotal = 0;
|
|
10912
|
+
} else if (params.fixCoinB) {
|
|
10913
|
+
params.amountATotal = 0;
|
|
10914
|
+
}
|
|
10881
10915
|
const args = [
|
|
10882
|
-
tx.object(params.
|
|
10916
|
+
tx.object(params.pair),
|
|
10883
10917
|
tx.object(dlmmConfig.factory),
|
|
10884
|
-
tx.object(params.
|
|
10918
|
+
tx.object(params.positionId),
|
|
10885
10919
|
primaryCoinAInputs.targetCoin,
|
|
10886
10920
|
primaryCoinBInputs.targetCoin,
|
|
10887
|
-
tx.pure.
|
|
10888
|
-
tx.pure.
|
|
10889
|
-
tx.pure.
|
|
10921
|
+
tx.pure.bool(params.fixCoinA),
|
|
10922
|
+
tx.pure.u64(params.amountATotal),
|
|
10923
|
+
tx.pure.bool(params.fixCoinB),
|
|
10924
|
+
tx.pure.u64(params.amountBTotal),
|
|
10925
|
+
tx.pure.u8(params.strategy),
|
|
10926
|
+
tx.pure.u32(active_min),
|
|
10927
|
+
tx.pure.u32(active_max),
|
|
10928
|
+
tx.pure.u64(amount_min),
|
|
10929
|
+
tx.pure.u64(amount_max),
|
|
10890
10930
|
tx.object(CLOCK_ADDRESS)
|
|
10891
10931
|
];
|
|
10892
10932
|
tx.moveCall({
|
|
10893
|
-
target: `${integrate.published_at}::${DlmmScript}::
|
|
10933
|
+
target: `${integrate.published_at}::${DlmmScript}::raise_by_strategy`,
|
|
10894
10934
|
typeArguments,
|
|
10895
10935
|
arguments: args
|
|
10896
10936
|
});
|
|
@@ -10898,30 +10938,62 @@ var DlmmModule = class {
|
|
|
10898
10938
|
}
|
|
10899
10939
|
async _raisePositionByAmountsReward(params) {
|
|
10900
10940
|
const tx = new import_transactions12.Transaction();
|
|
10941
|
+
const slippage = new import_decimal13.default(params.slippage);
|
|
10942
|
+
const lower_slippage = new import_decimal13.default(1).sub(slippage.div(new import_decimal13.default(1e4)));
|
|
10943
|
+
const upper_slippage = new import_decimal13.default(1).plus(slippage.div(new import_decimal13.default(1e4)));
|
|
10901
10944
|
tx.setSender(this.sdk.senderAddress);
|
|
10902
|
-
const { dlmm_pool, integrate
|
|
10945
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10903
10946
|
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10904
|
-
const
|
|
10905
|
-
const
|
|
10947
|
+
const price = (0, import_calc_dlmm3.get_price_x128_from_real_id)(params.active_bin, params.bin_step);
|
|
10948
|
+
const min_price = new import_decimal13.default(price).mul(lower_slippage);
|
|
10949
|
+
const max_price = new import_decimal13.default(price).mul(upper_slippage);
|
|
10950
|
+
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));
|
|
10951
|
+
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));
|
|
10952
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB, ...params.rewards_token];
|
|
10906
10953
|
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10954
|
+
let amount_min = 0;
|
|
10955
|
+
let amount_max = 0;
|
|
10956
|
+
let primaryCoinAInputs;
|
|
10957
|
+
let primaryCoinBInputs;
|
|
10958
|
+
if (params.fixCoinA && params.fixCoinB) {
|
|
10959
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10960
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10961
|
+
} else if (params.fixCoinA) {
|
|
10962
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10963
|
+
amount_min = new import_decimal13.default(params.amountBTotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10964
|
+
amount_max = new import_decimal13.default(params.amountBTotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10965
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeB, false, true);
|
|
10966
|
+
} else if (params.fixCoinB) {
|
|
10967
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10968
|
+
amount_min = new import_decimal13.default(params.amountATotal).mul(lower_slippage).toDecimalPlaces(0).toNumber();
|
|
10969
|
+
amount_max = new import_decimal13.default(params.amountATotal).mul(upper_slippage).toDecimalPlaces(0).toNumber();
|
|
10970
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amount_max), params.coinTypeA, false, true);
|
|
10971
|
+
}
|
|
10972
|
+
if (params.fixCoinA && params.fixCoinB) {
|
|
10973
|
+
} else if (params.fixCoinA) {
|
|
10974
|
+
params.amountBTotal = 0;
|
|
10975
|
+
} else if (params.fixCoinB) {
|
|
10976
|
+
params.amountATotal = 0;
|
|
10977
|
+
}
|
|
10911
10978
|
const args = [
|
|
10912
|
-
tx.object(params.
|
|
10979
|
+
tx.object(params.pair),
|
|
10913
10980
|
tx.object(dlmmConfig.factory),
|
|
10914
|
-
tx.object(
|
|
10915
|
-
tx.object(params.position_id),
|
|
10981
|
+
tx.object(params.positionId),
|
|
10916
10982
|
primaryCoinAInputs.targetCoin,
|
|
10917
10983
|
primaryCoinBInputs.targetCoin,
|
|
10918
|
-
tx.pure.
|
|
10919
|
-
tx.pure.
|
|
10920
|
-
tx.pure.
|
|
10984
|
+
tx.pure.bool(params.fixCoinA),
|
|
10985
|
+
tx.pure.u64(params.amountATotal),
|
|
10986
|
+
tx.pure.bool(params.fixCoinB),
|
|
10987
|
+
tx.pure.u64(params.amountBTotal),
|
|
10988
|
+
tx.pure.u8(params.strategy),
|
|
10989
|
+
tx.pure.u32(active_min),
|
|
10990
|
+
tx.pure.u32(active_max),
|
|
10991
|
+
tx.pure.u64(amount_min),
|
|
10992
|
+
tx.pure.u64(amount_max),
|
|
10921
10993
|
tx.object(CLOCK_ADDRESS)
|
|
10922
10994
|
];
|
|
10923
10995
|
tx.moveCall({
|
|
10924
|
-
target: `${integrate.published_at}::${DlmmScript}::
|
|
10996
|
+
target: `${integrate.published_at}::${DlmmScript}::raise_by_strategy_${params.rewards_token.length}`,
|
|
10925
10997
|
typeArguments,
|
|
10926
10998
|
arguments: args
|
|
10927
10999
|
});
|