@magmaprotocol/magma-clmm-sdk 0.5.41 → 0.5.43
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 +5 -2
- package/dist/index.js +42 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2553,6 +2553,10 @@ declare class SplitSwap {
|
|
|
2553
2553
|
computeSwap(): SplitSwapResult;
|
|
2554
2554
|
}
|
|
2555
2555
|
|
|
2556
|
+
declare class BinMath {
|
|
2557
|
+
static getPriceOfBinByBinId(binId: number, binStep: number, decimalsA: number, decimalsB: number): Decimal;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2556
2560
|
type FetchPosRewardParams = {
|
|
2557
2561
|
poolAddress: string;
|
|
2558
2562
|
positionId: string;
|
|
@@ -3493,7 +3497,6 @@ declare class GaugeModule implements IModule {
|
|
|
3493
3497
|
getEmissions(): Promise<EpochEmission>;
|
|
3494
3498
|
getRewardByPosition(params: GetRewardByPosition): Promise<Transaction>;
|
|
3495
3499
|
getAllRewardByPositions(paramsList: GetRewardByPosition[]): Promise<Transaction>;
|
|
3496
|
-
testTeacherCap(): Promise<Transaction>;
|
|
3497
3500
|
getEpochRewardByPool(pool: string, incentive_tokens: string[]): Promise<Map<string, string>>;
|
|
3498
3501
|
}
|
|
3499
3502
|
|
|
@@ -4443,4 +4446,4 @@ interface InitMagmaSDKOptions {
|
|
|
4443
4446
|
*/
|
|
4444
4447
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4445
4448
|
|
|
4446
|
-
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, BinLiquidity, Bits, BuildCoinResult, CLOCK_ADDRESS, CachedContent, CalculateRatesParams, CalculateRatesResult, ClaimAndLockParams, ClaimFeesParams, ClaimFeesPoolsParams, ClmmConfig, ClmmExpectSwapModule, ClmmFetcherModule, ClmmIntegratePoolModule, ClmmIntegratePoolV2Module, ClmmIntegratePoolV3Module, ClmmIntegrateRouterModule, ClmmIntegrateRouterWithPartnerModule, ClmmIntegrateUtilsModule, ClmmPartnerModule, ClmmPoolConfig, ClmmPoolUtil, ClmmPositionStatus, ClmmpoolData, ClosePositionParams, CoinAmounts, CoinAsset, CoinAssist, CoinConfig, CoinInfoAddress, CoinNode, CoinPairType, CoinProvider, CoinStoreAddress, CollectFeeParams, CollectFeesQuote, CollectFeesQuoteParam, CollectRewarderParams, ConfigModule, CreateLockParams, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmConfig, DlmmScript, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityAndCoinYResult, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_NO_LIQUIDITY, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, StakedPositionOfPool, StrategyType, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams$1 as SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, WithdrawPosition, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getCoinXYForLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityAndCoinYByCoinX, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getPriceOfBinByBinId, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16, withLiquiditySlippage };
|
|
4449
|
+
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, 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, CreatePartnerEvent, CreatePoolAddLiquidityParams, CreatePoolParams, DEFAULT_GAS_BUDGET_FOR_MERGE, DEFAULT_GAS_BUDGET_FOR_SPLIT, DEFAULT_GAS_BUDGET_FOR_STAKE, DEFAULT_GAS_BUDGET_FOR_TRANSFER, DEFAULT_GAS_BUDGET_FOR_TRANSFER_SUI, DEFAULT_NFT_TRANSFER_GAS_FEE, DataPage, DeepbookClobV2Moudle, DeepbookCustodianV2Moudle, DeepbookEndpointsV2Moudle, DeepbookPool, DeepbookUtils, DepositPosition, DlmmConfig, DlmmScript, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, LiquidityAndCoinYResult, LiquidityInput, LockModule, LockPermanentParams, LockVoteEvent, MAX_SQRT_PRICE, MAX_TICK_INDEX, MIN_SQRT_PRICE, MIN_TICK_INDEX, MagmaClmmSDK, MagmaConfigs, MathUtil, MergeLockParams, Minter, NFT, ONE, OnePath, OpenPositionAddLiquidityWithProtectionParams, OpenPositionParams, Order, POOL_NO_LIQUIDITY, POOL_STRUCT, Package, PageQuery, PaginationArgs, PathLink, PathProvider, Percentage, PokeParams, Pool, PoolImmutables, PoolInfo, PoolModule, Position, PositionModule, PositionReward, PositionStatus, PositionUtil, PreRouterSwapParams, PreSwapLpChangeParams, PreSwapParams, PreSwapResult, PreSwapWithMultiPoolParams, PriceResult, RemoveLiquidityParams, RewardDistributor, Rewarder, RewarderAmountOwed, RouterModule, RouterModuleV2, RpcModule, SUI_SYSTEM_STATE_OBJECT_ID, SdkOptions, SplitPath, SplitSwap, SplitSwapResult, SplitUnit, StakedPositionOfPool, StrategyType, SuiAddressType, SuiBasicTypes, SuiInputTypes, SuiObjectDataWithContent, SuiObjectIdType, SuiResource, SuiStructTag, SuiTxArg, SwapDirection, SwapModule, SwapParams$1 as SwapParams, SwapResult, SwapStepResult, SwapUtils, SwapWithRouterParams, TICK_ARRAY_SIZE, TWO, Tick, TickData, TickMath, TickUtil, TokenConfig, TokenConfigEvent, TokenInfo, TokenModule, TransPreSwapWithMultiPoolParams, TransactionUtil, TransferLockParams, TxBlock, U128, U128_MAX, U64_MAX, VoteParams, Voter, VotingEscrow, WithdrawPosition, ZERO, addHexPrefix, adjustForCoinSlippage, adjustForSlippage, asIntN, asUintN, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, bufferToHex, buildClmmPositionName, buildNFT, buildPool, buildPosition, buildPositionReward, buildTickData, buildTickDataByEvent, cacheTime24h, cacheTime5min, checkAddress, checkInvalidSuiAddress, clmmMainnet, clmmTestnet, collectFeesQuote, composeType, computeSwap, computeSwapStep, createSplitAmountArray, createSplitArray, createTestTransferTxPayloadParams, d, decimalsMultiplier, MagmaClmmSDK as default, estPoolAPR, estPosAPRResult, estPositionAPRWithDeltaMethod, estPositionAPRWithMultiMethod, estimateLiquidityForCoinA, estimateLiquidityForCoinB, extractAddressFromType, extractStructTagFromType, findAdjustCoin, fixCoinType, fixSuiObjectId, fromDecimalsAmount, getAmountFixedDelta, getAmountUnfixedDelta, getCoinAFromLiquidity, getCoinBFromLiquidity, getCoinXYForLiquidity, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityAndCoinYByCoinX, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getPriceOfBinByBinId, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16, withLiquiditySlippage };
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ var src_exports = {};
|
|
|
37
37
|
__export(src_exports, {
|
|
38
38
|
AMM_SWAP_MODULE: () => AMM_SWAP_MODULE,
|
|
39
39
|
AmountSpecified: () => AmountSpecified,
|
|
40
|
+
BinMath: () => BinMath,
|
|
40
41
|
CLOCK_ADDRESS: () => CLOCK_ADDRESS,
|
|
41
42
|
CachedContent: () => CachedContent,
|
|
42
43
|
ClmmExpectSwapModule: () => ClmmExpectSwapModule,
|
|
@@ -2806,6 +2807,17 @@ var SplitSwap = class {
|
|
|
2806
2807
|
}
|
|
2807
2808
|
};
|
|
2808
2809
|
|
|
2810
|
+
// src/math/bin.ts
|
|
2811
|
+
var import_decimal9 = __toESM(require("decimal.js"));
|
|
2812
|
+
var import_calc_dlmm2 = require("@magmaprotocol/calc_dlmm");
|
|
2813
|
+
var BinMath = class {
|
|
2814
|
+
static getPriceOfBinByBinId(binId, binStep, decimalsA, decimalsB) {
|
|
2815
|
+
const twoDec = new import_decimal9.default(2);
|
|
2816
|
+
const price = new import_decimal9.default((0, import_calc_dlmm2.get_price_from_real_id)(binId, binStep));
|
|
2817
|
+
return price.div(twoDec.pow(128)).mul(import_decimal9.default.pow(10, decimalsB - decimalsA));
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
|
|
2809
2821
|
// src/utils/objects.ts
|
|
2810
2822
|
function getSuiObjectData(resp) {
|
|
2811
2823
|
return resp.data;
|
|
@@ -3252,7 +3264,7 @@ function getRewardInTickRange(pool, tickLower, tickUpper, tickLowerIndex, tickUp
|
|
|
3252
3264
|
|
|
3253
3265
|
// src/utils/transaction-util.ts
|
|
3254
3266
|
var import_bn15 = __toESM(require("bn.js"));
|
|
3255
|
-
var
|
|
3267
|
+
var import_decimal10 = __toESM(require("decimal.js"));
|
|
3256
3268
|
var import_transactions = require("@mysten/sui/transactions");
|
|
3257
3269
|
function findAdjustCoin(coinPair) {
|
|
3258
3270
|
const isAdjustCoinA = CoinAssist.isSuiCoin(coinPair.coinTypeA);
|
|
@@ -3260,7 +3272,7 @@ function findAdjustCoin(coinPair) {
|
|
|
3260
3272
|
return { isAdjustCoinA, isAdjustCoinB };
|
|
3261
3273
|
}
|
|
3262
3274
|
function reverSlippageAmount(slippageAmount, slippage) {
|
|
3263
|
-
return
|
|
3275
|
+
return import_decimal10.default.ceil(d(slippageAmount).div(1 + slippage)).toString();
|
|
3264
3276
|
}
|
|
3265
3277
|
async function printTransaction(tx, isPrint = true) {
|
|
3266
3278
|
console.log(`inputs`, tx.blockData.inputs);
|
|
@@ -3634,12 +3646,12 @@ var _TransactionUtil = class {
|
|
|
3634
3646
|
max_amount_a = params.amount_a;
|
|
3635
3647
|
min_amount_a = params.amount_a;
|
|
3636
3648
|
max_amount_b = params.amount_b;
|
|
3637
|
-
min_amount_b = new
|
|
3649
|
+
min_amount_b = new import_decimal10.default(params.amount_b).div(new import_decimal10.default(1).plus(new import_decimal10.default(params.slippage))).mul(new import_decimal10.default(1).minus(new import_decimal10.default(params.slippage))).toDecimalPlaces(0).toNumber();
|
|
3638
3650
|
} else {
|
|
3639
3651
|
max_amount_b = params.amount_b;
|
|
3640
3652
|
min_amount_b = params.amount_b;
|
|
3641
3653
|
max_amount_a = params.amount_a;
|
|
3642
|
-
min_amount_a = new
|
|
3654
|
+
min_amount_a = new import_decimal10.default(params.amount_a).div(new import_decimal10.default(1).plus(new import_decimal10.default(params.slippage))).mul(new import_decimal10.default(1).minus(new import_decimal10.default(params.slippage))).toDecimalPlaces(0).toNumber();
|
|
3643
3655
|
}
|
|
3644
3656
|
const args = params.is_open ? [
|
|
3645
3657
|
tx.object(clmmConfig.global_config_id),
|
|
@@ -7756,7 +7768,7 @@ var RouterModule = class {
|
|
|
7756
7768
|
|
|
7757
7769
|
// src/modules/swapModule.ts
|
|
7758
7770
|
var import_bn20 = __toESM(require("bn.js"));
|
|
7759
|
-
var
|
|
7771
|
+
var import_decimal11 = __toESM(require("decimal.js"));
|
|
7760
7772
|
var import_transactions8 = require("@mysten/sui/transactions");
|
|
7761
7773
|
var AMM_SWAP_MODULE = "amm_swap";
|
|
7762
7774
|
var POOL_STRUCT = "Pool";
|
|
@@ -7774,14 +7786,14 @@ var SwapModule = class {
|
|
|
7774
7786
|
const pathCount = item.basePaths.length;
|
|
7775
7787
|
if (pathCount > 0) {
|
|
7776
7788
|
const path = item.basePaths[0];
|
|
7777
|
-
const feeRate = path.label === "Magma" ? new
|
|
7789
|
+
const feeRate = path.label === "Magma" ? new import_decimal11.default(path.feeRate).div(10 ** 6) : new import_decimal11.default(path.feeRate).div(10 ** 9);
|
|
7778
7790
|
const feeAmount = d(path.inputAmount).div(10 ** path.fromDecimal).mul(feeRate);
|
|
7779
7791
|
fee = fee.add(feeAmount);
|
|
7780
7792
|
if (pathCount > 1) {
|
|
7781
7793
|
const path2 = item.basePaths[1];
|
|
7782
|
-
const price1 = path.direction ? path.currentPrice : new
|
|
7783
|
-
const price2 = path2.direction ? path2.currentPrice : new
|
|
7784
|
-
const feeRate2 = path2.label === "Magma" ? new
|
|
7794
|
+
const price1 = path.direction ? path.currentPrice : new import_decimal11.default(1).div(path.currentPrice);
|
|
7795
|
+
const price2 = path2.direction ? path2.currentPrice : new import_decimal11.default(1).div(path2.currentPrice);
|
|
7796
|
+
const feeRate2 = path2.label === "Magma" ? new import_decimal11.default(path2.feeRate).div(10 ** 6) : new import_decimal11.default(path2.feeRate).div(10 ** 9);
|
|
7785
7797
|
const feeAmount2 = d(path2.outputAmount).div(10 ** path2.toDecimal).mul(feeRate2);
|
|
7786
7798
|
const fee2 = feeAmount2.div(price1.mul(price2));
|
|
7787
7799
|
fee = fee.add(fee2);
|
|
@@ -7799,17 +7811,17 @@ var SwapModule = class {
|
|
|
7799
7811
|
const outputAmount = d(path.outputAmount).div(10 ** path.toDecimal);
|
|
7800
7812
|
const inputAmount = d(path.inputAmount).div(10 ** path.fromDecimal);
|
|
7801
7813
|
const rate = outputAmount.div(inputAmount);
|
|
7802
|
-
const cprice = path.direction ? new
|
|
7814
|
+
const cprice = path.direction ? new import_decimal11.default(path.currentPrice) : new import_decimal11.default(1).div(path.currentPrice);
|
|
7803
7815
|
impactValue = impactValue.add(this.calculateSingleImpact(rate, cprice));
|
|
7804
7816
|
}
|
|
7805
7817
|
if (pathCount === 2) {
|
|
7806
7818
|
const path = item.basePaths[0];
|
|
7807
7819
|
const path2 = item.basePaths[1];
|
|
7808
|
-
const cprice1 = path.direction ? new
|
|
7809
|
-
const cprice2 = path2.direction ? new
|
|
7820
|
+
const cprice1 = path.direction ? new import_decimal11.default(path.currentPrice) : new import_decimal11.default(1).div(path.currentPrice);
|
|
7821
|
+
const cprice2 = path2.direction ? new import_decimal11.default(path2.currentPrice) : new import_decimal11.default(1).div(path2.currentPrice);
|
|
7810
7822
|
const cprice = cprice1.mul(cprice2);
|
|
7811
|
-
const outputAmount = new
|
|
7812
|
-
const inputAmount = new
|
|
7823
|
+
const outputAmount = new import_decimal11.default(path2.outputAmount).div(10 ** path2.toDecimal);
|
|
7824
|
+
const inputAmount = new import_decimal11.default(path.inputAmount).div(10 ** path.fromDecimal);
|
|
7813
7825
|
const rate = outputAmount.div(inputAmount);
|
|
7814
7826
|
impactValue = impactValue.add(this.calculateSingleImpact(rate, cprice));
|
|
7815
7827
|
}
|
|
@@ -9472,7 +9484,7 @@ var TokenModule = class {
|
|
|
9472
9484
|
|
|
9473
9485
|
// src/modules/routerModuleV2.ts
|
|
9474
9486
|
var import_bn21 = __toESM(require("bn.js"));
|
|
9475
|
-
var
|
|
9487
|
+
var import_decimal12 = __toESM(require("decimal.js"));
|
|
9476
9488
|
var import_uuid = require("uuid");
|
|
9477
9489
|
var import_axios = __toESM(require("axios"));
|
|
9478
9490
|
var RouterModuleV2 = class {
|
|
@@ -9489,7 +9501,7 @@ var RouterModuleV2 = class {
|
|
|
9489
9501
|
if (label === "Magma") {
|
|
9490
9502
|
return TickMath.sqrtPriceX64ToPrice(currentSqrtPrice, decimalA, decimalB);
|
|
9491
9503
|
}
|
|
9492
|
-
return new
|
|
9504
|
+
return new import_decimal12.default(currentSqrtPrice.toString()).div(new import_decimal12.default(10).pow(new import_decimal12.default(decimalB + 9 - decimalA)));
|
|
9493
9505
|
}
|
|
9494
9506
|
parseJsonResult(data) {
|
|
9495
9507
|
const result = {
|
|
@@ -10672,20 +10684,6 @@ var GaugeModule = class {
|
|
|
10672
10684
|
});
|
|
10673
10685
|
return tx;
|
|
10674
10686
|
}
|
|
10675
|
-
async testTeacherCap() {
|
|
10676
|
-
const tx = new import_transactions11.Transaction();
|
|
10677
|
-
tx.moveCall({
|
|
10678
|
-
target: `0xd1bf0385f6d298d3b6f140869c28700e85709d570984200cd82c8164401c5e49::hello_world::call_func1`,
|
|
10679
|
-
arguments: [tx.object("0xe1af009a9212aa4bf936ff51794d39e8a75dfbd8e65e3265d3a8e93b4c9256bf")],
|
|
10680
|
-
typeArguments: []
|
|
10681
|
-
});
|
|
10682
|
-
tx.moveCall({
|
|
10683
|
-
target: `0xd1bf0385f6d298d3b6f140869c28700e85709d570984200cd82c8164401c5e49::hello_world::call_func2`,
|
|
10684
|
-
arguments: [tx.object("0xe1af009a9212aa4bf936ff51794d39e8a75dfbd8e65e3265d3a8e93b4c9256bf")],
|
|
10685
|
-
typeArguments: []
|
|
10686
|
-
});
|
|
10687
|
-
return tx;
|
|
10688
|
-
}
|
|
10689
10687
|
async getEpochRewardByPool(pool, incentive_tokens) {
|
|
10690
10688
|
const tx = new import_transactions11.Transaction();
|
|
10691
10689
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -10720,8 +10718,8 @@ var GaugeModule = class {
|
|
|
10720
10718
|
|
|
10721
10719
|
// src/modules/dlmm.ts
|
|
10722
10720
|
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10723
|
-
var
|
|
10724
|
-
var
|
|
10721
|
+
var import_decimal13 = __toESM(require("decimal.js"));
|
|
10722
|
+
var import_calc_dlmm3 = require("@magmaprotocol/calc_dlmm");
|
|
10725
10723
|
var DlmmModule = class {
|
|
10726
10724
|
_sdk;
|
|
10727
10725
|
constructor(sdk) {
|
|
@@ -10793,12 +10791,12 @@ var DlmmModule = class {
|
|
|
10793
10791
|
}
|
|
10794
10792
|
// params price: input (b/(10^b_decimal))/(a/(10^a_decimal))
|
|
10795
10793
|
price_to_storage_id(price, bin_step, tokenADecimal, tokenBDecimal) {
|
|
10796
|
-
const priceDec = new
|
|
10797
|
-
const tenDec = new
|
|
10798
|
-
const twoDec = new
|
|
10794
|
+
const priceDec = new import_decimal13.default(price);
|
|
10795
|
+
const tenDec = new import_decimal13.default(10);
|
|
10796
|
+
const twoDec = new import_decimal13.default(2);
|
|
10799
10797
|
const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
|
|
10800
|
-
const active_id = (0,
|
|
10801
|
-
return (0,
|
|
10798
|
+
const active_id = (0, import_calc_dlmm3.get_real_id_from_price)(price_x128.toFixed(0).toString(), bin_step);
|
|
10799
|
+
return (0, import_calc_dlmm3.get_storage_id_from_real_id)(active_id);
|
|
10802
10800
|
}
|
|
10803
10801
|
// NOTE: x, y should be sorted
|
|
10804
10802
|
async createPairPayload(params) {
|
|
@@ -11556,7 +11554,7 @@ var SDKConfig = {
|
|
|
11556
11554
|
clmmConfig: {
|
|
11557
11555
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
11558
11556
|
// clmm and dlmm both use this global_config
|
|
11559
|
-
global_config_id: "
|
|
11557
|
+
global_config_id: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
11560
11558
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
11561
11559
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
11562
11560
|
},
|
|
@@ -11577,7 +11575,7 @@ var SDKConfig = {
|
|
|
11577
11575
|
minter_id: "0x4fa5766cd83b33b215b139fec27ac344040f3bbd84fcbee7b61fc671aadc51fa"
|
|
11578
11576
|
},
|
|
11579
11577
|
dlmmConfig: {
|
|
11580
|
-
factory: "
|
|
11578
|
+
factory: ""
|
|
11581
11579
|
},
|
|
11582
11580
|
gaugeConfig: {}
|
|
11583
11581
|
};
|
|
@@ -11597,8 +11595,8 @@ var clmmMainnet = {
|
|
|
11597
11595
|
config: SDKConfig.clmmConfig
|
|
11598
11596
|
},
|
|
11599
11597
|
dlmm_pool: {
|
|
11600
|
-
package_id: "
|
|
11601
|
-
published_at: "
|
|
11598
|
+
package_id: "",
|
|
11599
|
+
published_at: "",
|
|
11602
11600
|
config: SDKConfig.dlmmConfig
|
|
11603
11601
|
},
|
|
11604
11602
|
distribution: {
|
|
@@ -11606,8 +11604,8 @@ var clmmMainnet = {
|
|
|
11606
11604
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
11607
11605
|
},
|
|
11608
11606
|
integrate: {
|
|
11609
|
-
package_id: "
|
|
11610
|
-
published_at: "
|
|
11607
|
+
package_id: "0x2e704d8afc1d6d7f154dee337cc14c153f6f9ce1708213e5dc04a32afe0e45f1",
|
|
11608
|
+
published_at: "0x2e704d8afc1d6d7f154dee337cc14c153f6f9ce1708213e5dc04a32afe0e45f1"
|
|
11611
11609
|
},
|
|
11612
11610
|
deepbook: {
|
|
11613
11611
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -11724,6 +11722,7 @@ var src_default = MagmaClmmSDK;
|
|
|
11724
11722
|
0 && (module.exports = {
|
|
11725
11723
|
AMM_SWAP_MODULE,
|
|
11726
11724
|
AmountSpecified,
|
|
11725
|
+
BinMath,
|
|
11727
11726
|
CLOCK_ADDRESS,
|
|
11728
11727
|
CachedContent,
|
|
11729
11728
|
ClmmExpectSwapModule,
|