@magmaprotocol/magma-clmm-sdk 0.5.34 → 0.5.35
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/README.md +1 -1
- package/dist/index.d.ts +147 -12
- package/dist/index.js +298 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +297 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ declare const Voter = "voter";
|
|
|
37
37
|
declare const RewardDistributor = "reward_distributor";
|
|
38
38
|
declare const Gauge = "gauge";
|
|
39
39
|
declare const Minter = "minter";
|
|
40
|
+
declare const DlmmScript = "dlmm_script";
|
|
40
41
|
/**
|
|
41
42
|
* The address for CoinInfo module.
|
|
42
43
|
*/
|
|
@@ -451,6 +452,9 @@ type ClmmConfig = {
|
|
|
451
452
|
*/
|
|
452
453
|
partners_id?: SuiObjectIdType;
|
|
453
454
|
};
|
|
455
|
+
type DlmmConfig = {
|
|
456
|
+
factory: SuiObjectIdType;
|
|
457
|
+
};
|
|
454
458
|
/**
|
|
455
459
|
* Represents an event to create a liquidity mining partner.
|
|
456
460
|
*/
|
|
@@ -800,7 +804,7 @@ type CalculateRatesResult = {
|
|
|
800
804
|
/**
|
|
801
805
|
* Represents parameters for a swap operation.
|
|
802
806
|
*/
|
|
803
|
-
type SwapParams = {
|
|
807
|
+
type SwapParams$1 = {
|
|
804
808
|
/**
|
|
805
809
|
* The identifier of the pool.
|
|
806
810
|
*/
|
|
@@ -2998,7 +3002,7 @@ declare class SwapModule implements IModule {
|
|
|
2998
3002
|
* If this parameter is not passed, gas estimation is not performed
|
|
2999
3003
|
* @returns
|
|
3000
3004
|
*/
|
|
3001
|
-
createSwapTransactionPayload(params: SwapParams, gasEstimateArg?: {
|
|
3005
|
+
createSwapTransactionPayload(params: SwapParams$1, gasEstimateArg?: {
|
|
3002
3006
|
byAmountIn: boolean;
|
|
3003
3007
|
slippage: Percentage;
|
|
3004
3008
|
decimalsA: number;
|
|
@@ -3013,7 +3017,7 @@ declare class SwapModule implements IModule {
|
|
|
3013
3017
|
* If this parameter is not passed, gas estimation is not performed
|
|
3014
3018
|
* @returns tx and coin ABs
|
|
3015
3019
|
*/
|
|
3016
|
-
createSwapTransactionWithoutTransferCoinsPayload(params: SwapParams, gasEstimateArg?: {
|
|
3020
|
+
createSwapTransactionWithoutTransferCoinsPayload(params: SwapParams$1, gasEstimateArg?: {
|
|
3017
3021
|
byAmountIn: boolean;
|
|
3018
3022
|
slippage: Percentage;
|
|
3019
3023
|
decimalsA: number;
|
|
@@ -3376,6 +3380,134 @@ declare class GaugeModule implements IModule {
|
|
|
3376
3380
|
getEpochRewardByPool(pool: string, incentive_tokens: string[]): Promise<Map<string, string>>;
|
|
3377
3381
|
}
|
|
3378
3382
|
|
|
3383
|
+
type FetchPairParams = {
|
|
3384
|
+
pair: string;
|
|
3385
|
+
coinTypeA: string;
|
|
3386
|
+
coinTypeB: string;
|
|
3387
|
+
};
|
|
3388
|
+
type CreatePairParams = {
|
|
3389
|
+
bin_step: number;
|
|
3390
|
+
coinTypeA: string;
|
|
3391
|
+
coinTypeB: string;
|
|
3392
|
+
coinADecimal: number;
|
|
3393
|
+
coinBDecimal: number;
|
|
3394
|
+
priceTokenBPerTokenA: string;
|
|
3395
|
+
};
|
|
3396
|
+
type MintPercentParams = {
|
|
3397
|
+
pair: string;
|
|
3398
|
+
coinTypeA: string;
|
|
3399
|
+
coinTypeB: string;
|
|
3400
|
+
amountATotal: number;
|
|
3401
|
+
amountBTotal: number;
|
|
3402
|
+
storageIds: number[];
|
|
3403
|
+
binsAPercent: number[];
|
|
3404
|
+
binsBPercent: number[];
|
|
3405
|
+
to: string;
|
|
3406
|
+
};
|
|
3407
|
+
type MintAmountParams = {
|
|
3408
|
+
pair: string;
|
|
3409
|
+
coinTypeA: string;
|
|
3410
|
+
coinTypeB: string;
|
|
3411
|
+
amountATotal: number;
|
|
3412
|
+
amountBTotal: number;
|
|
3413
|
+
storageIds: number[];
|
|
3414
|
+
amountsA: number[];
|
|
3415
|
+
amountsB: number[];
|
|
3416
|
+
to: string;
|
|
3417
|
+
};
|
|
3418
|
+
type SwapParams = {
|
|
3419
|
+
pair: string;
|
|
3420
|
+
coinTypeA: string;
|
|
3421
|
+
coinTypeB: string;
|
|
3422
|
+
amountIn: number;
|
|
3423
|
+
minAmountOut: number;
|
|
3424
|
+
swapForY: boolean;
|
|
3425
|
+
to: string;
|
|
3426
|
+
};
|
|
3427
|
+
type FetchBinsParams = {
|
|
3428
|
+
pair: string;
|
|
3429
|
+
coinTypeA: string;
|
|
3430
|
+
coinTypeB: string;
|
|
3431
|
+
offset: number;
|
|
3432
|
+
limit: number;
|
|
3433
|
+
};
|
|
3434
|
+
type GetPositionLiquidityParams = {
|
|
3435
|
+
pair: string;
|
|
3436
|
+
coinTypeA: string;
|
|
3437
|
+
coinTypeB: string;
|
|
3438
|
+
positionId: string;
|
|
3439
|
+
};
|
|
3440
|
+
type GetPairLiquidityParams = {
|
|
3441
|
+
pair: string;
|
|
3442
|
+
coinTypeA: string;
|
|
3443
|
+
coinTypeB: string;
|
|
3444
|
+
};
|
|
3445
|
+
type EventPairParams = {
|
|
3446
|
+
base_factor: number;
|
|
3447
|
+
filter_period: number;
|
|
3448
|
+
decay_period: number;
|
|
3449
|
+
reduction_factor: number;
|
|
3450
|
+
variable_fee_control: number;
|
|
3451
|
+
protocol_share: number;
|
|
3452
|
+
max_volatility_accumulator: number;
|
|
3453
|
+
volatility_accumulator: number;
|
|
3454
|
+
volatility_reference: number;
|
|
3455
|
+
index_reference: number;
|
|
3456
|
+
time_of_last_update: number | string;
|
|
3457
|
+
oracle_index: number;
|
|
3458
|
+
active_index: number;
|
|
3459
|
+
};
|
|
3460
|
+
type EventBin = {
|
|
3461
|
+
storage_id: number | string;
|
|
3462
|
+
price_q128: number | string;
|
|
3463
|
+
reserve_x: number | string;
|
|
3464
|
+
reserve_y: number | string;
|
|
3465
|
+
staked_liquidity: number | string;
|
|
3466
|
+
staked_lp_amount: number | string;
|
|
3467
|
+
fee_x: number | string;
|
|
3468
|
+
fee_y: number | string;
|
|
3469
|
+
fee_growth_x: number | string;
|
|
3470
|
+
fee_growth_y: number | string;
|
|
3471
|
+
rewarder_growth: number[] | string[];
|
|
3472
|
+
distribution_growth: number | string;
|
|
3473
|
+
distribution_last_updated: number | string;
|
|
3474
|
+
};
|
|
3475
|
+
type EventPositionLiquidity = {
|
|
3476
|
+
shares: number | string;
|
|
3477
|
+
liquidity: number | string;
|
|
3478
|
+
x_equivalent: number | string;
|
|
3479
|
+
y_equivalent: number | string;
|
|
3480
|
+
bin_ids: number[] | string[];
|
|
3481
|
+
bin_x_eq: number[] | string[];
|
|
3482
|
+
bin_y_eq: number[] | string[];
|
|
3483
|
+
bin_liquidity: number[] | string[];
|
|
3484
|
+
};
|
|
3485
|
+
type EventPairLiquidity = {
|
|
3486
|
+
shares: number | string;
|
|
3487
|
+
liquidity: number | string;
|
|
3488
|
+
x: number | string;
|
|
3489
|
+
y: number | string;
|
|
3490
|
+
bin_ids: number[] | string[];
|
|
3491
|
+
bin_x: number[] | string[];
|
|
3492
|
+
bin_y: number[] | string[];
|
|
3493
|
+
};
|
|
3494
|
+
|
|
3495
|
+
declare class DlmmModule implements IModule {
|
|
3496
|
+
protected _sdk: MagmaClmmSDK;
|
|
3497
|
+
constructor(sdk: MagmaClmmSDK);
|
|
3498
|
+
get sdk(): MagmaClmmSDK;
|
|
3499
|
+
fetchPairParams(params: FetchPairParams): Promise<EventPairParams>;
|
|
3500
|
+
price_to_storage_id(price: string, bin_step: number, tokenADecimal: number, tokenBDecimal: number): number;
|
|
3501
|
+
createPairPayload(params: CreatePairParams): Promise<Transaction>;
|
|
3502
|
+
createAddLiquidityPayload(): Promise<Transaction>;
|
|
3503
|
+
mintPercent(params: MintPercentParams): Promise<Transaction>;
|
|
3504
|
+
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
3505
|
+
swap(params: SwapParams): Promise<Transaction>;
|
|
3506
|
+
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3507
|
+
getPositionLiquidity(params: GetPositionLiquidityParams): Promise<EventPositionLiquidity>;
|
|
3508
|
+
getPairLiquidity(params: GetPairLiquidityParams): Promise<EventPairLiquidity>;
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3379
3511
|
/**
|
|
3380
3512
|
* Represents options and configurations for an SDK.
|
|
3381
3513
|
*/
|
|
@@ -3413,6 +3545,7 @@ type SdkOptions = {
|
|
|
3413
3545
|
* Package containing Cryptocurrency Liquidity Mining Module (CLMM) pool configurations.
|
|
3414
3546
|
*/
|
|
3415
3547
|
clmm_pool: Package<ClmmConfig>;
|
|
3548
|
+
dlmm_pool: Package<DlmmConfig>;
|
|
3416
3549
|
distribution: Package;
|
|
3417
3550
|
/**
|
|
3418
3551
|
* Package containing integration-related configurations.
|
|
@@ -3461,6 +3594,7 @@ declare class MagmaClmmSDK {
|
|
|
3461
3594
|
*/
|
|
3462
3595
|
protected _lock: LockModule;
|
|
3463
3596
|
protected _gauge: GaugeModule;
|
|
3597
|
+
protected _dlmm: DlmmModule;
|
|
3464
3598
|
/**
|
|
3465
3599
|
* Provide interact with a position rewarder interface.
|
|
3466
3600
|
*/
|
|
@@ -3508,6 +3642,7 @@ declare class MagmaClmmSDK {
|
|
|
3508
3642
|
get Swap(): SwapModule;
|
|
3509
3643
|
get Lock(): LockModule;
|
|
3510
3644
|
get Gauge(): GaugeModule;
|
|
3645
|
+
get Dlmm(): DlmmModule;
|
|
3511
3646
|
/**
|
|
3512
3647
|
* Getter for the fullClient property.
|
|
3513
3648
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -3839,7 +3974,7 @@ declare class TransactionUtil {
|
|
|
3839
3974
|
* @param curSqrtPrice
|
|
3840
3975
|
* @returns
|
|
3841
3976
|
*/
|
|
3842
|
-
static buildSwapTransactionForGas(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[], gasEstimateArg: {
|
|
3977
|
+
static buildSwapTransactionForGas(sdk: MagmaClmmSDK, params: SwapParams$1, allCoinAsset: CoinAsset[], gasEstimateArg: {
|
|
3843
3978
|
byAmountIn: boolean;
|
|
3844
3979
|
slippage: Percentage;
|
|
3845
3980
|
decimalsA: number;
|
|
@@ -3853,7 +3988,7 @@ declare class TransactionUtil {
|
|
|
3853
3988
|
* @param packageId
|
|
3854
3989
|
* @returns
|
|
3855
3990
|
*/
|
|
3856
|
-
static buildSwapTransaction(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[]): Transaction;
|
|
3991
|
+
static buildSwapTransaction(sdk: MagmaClmmSDK, params: SwapParams$1, allCoinAsset: CoinAsset[]): Transaction;
|
|
3857
3992
|
static buildCreateLockTransaction(sdk: MagmaClmmSDK, params: CreateLockParams, allCoinAsset: CoinAsset[]): Transaction;
|
|
3858
3993
|
static buildCreateTransactionArgs(tx: Transaction, params: CreateLockParams, sdkOptions: SdkOptions, lockCoinInput: BuildCoinResult): Transaction;
|
|
3859
3994
|
static buildIncreaseLockAmountTransaction(sdk: MagmaClmmSDK, params: IncreaseLockAmountParams, allCoinAsset: CoinAsset[]): Transaction;
|
|
@@ -3877,7 +4012,7 @@ declare class TransactionUtil {
|
|
|
3877
4012
|
* @param packageId
|
|
3878
4013
|
* @returns
|
|
3879
4014
|
*/
|
|
3880
|
-
static buildSwapTransactionArgs(tx: Transaction, params: SwapParams, sdkOptions: SdkOptions, primaryCoinInputA: BuildCoinResult, primaryCoinInputB: BuildCoinResult): Transaction;
|
|
4015
|
+
static buildSwapTransactionArgs(tx: Transaction, params: SwapParams$1, sdkOptions: SdkOptions, primaryCoinInputA: BuildCoinResult, primaryCoinInputB: BuildCoinResult): Transaction;
|
|
3881
4016
|
/**
|
|
3882
4017
|
* build add liquidity transaction with out transfer coins
|
|
3883
4018
|
* @param params
|
|
@@ -3885,7 +4020,7 @@ declare class TransactionUtil {
|
|
|
3885
4020
|
* @param curSqrtPrice
|
|
3886
4021
|
* @returns
|
|
3887
4022
|
*/
|
|
3888
|
-
static buildSwapTransactionWithoutTransferCoinsForGas(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[], gasEstimateArg: {
|
|
4023
|
+
static buildSwapTransactionWithoutTransferCoinsForGas(sdk: MagmaClmmSDK, params: SwapParams$1, allCoinAsset: CoinAsset[], gasEstimateArg: {
|
|
3889
4024
|
byAmountIn: boolean;
|
|
3890
4025
|
slippage: Percentage;
|
|
3891
4026
|
decimalsA: number;
|
|
@@ -3902,7 +4037,7 @@ declare class TransactionUtil {
|
|
|
3902
4037
|
* @param packageId
|
|
3903
4038
|
* @returns
|
|
3904
4039
|
*/
|
|
3905
|
-
static buildSwapTransactionWithoutTransferCoins(sdk: MagmaClmmSDK, params: SwapParams, allCoinAsset: CoinAsset[]): {
|
|
4040
|
+
static buildSwapTransactionWithoutTransferCoins(sdk: MagmaClmmSDK, params: SwapParams$1, allCoinAsset: CoinAsset[]): {
|
|
3906
4041
|
tx: Transaction;
|
|
3907
4042
|
coinABs: TransactionObjectArgument[];
|
|
3908
4043
|
};
|
|
@@ -3912,18 +4047,18 @@ declare class TransactionUtil {
|
|
|
3912
4047
|
* @param packageId
|
|
3913
4048
|
* @returns
|
|
3914
4049
|
*/
|
|
3915
|
-
static buildSwapTransactionWithoutTransferCoinArgs(sdk: MagmaClmmSDK, tx: Transaction, params: SwapParams, sdkOptions: SdkOptions, primaryCoinInputA: BuildCoinResult, primaryCoinInputB: BuildCoinResult): {
|
|
4050
|
+
static buildSwapTransactionWithoutTransferCoinArgs(sdk: MagmaClmmSDK, tx: Transaction, params: SwapParams$1, sdkOptions: SdkOptions, primaryCoinInputA: BuildCoinResult, primaryCoinInputB: BuildCoinResult): {
|
|
3916
4051
|
tx: Transaction;
|
|
3917
4052
|
txRes: TransactionObjectArgument[];
|
|
3918
4053
|
};
|
|
3919
|
-
static fixSwapParams(sdk: MagmaClmmSDK, params: SwapParams, gasEstimateArg: {
|
|
4054
|
+
static fixSwapParams(sdk: MagmaClmmSDK, params: SwapParams$1, gasEstimateArg: {
|
|
3920
4055
|
byAmountIn: boolean;
|
|
3921
4056
|
slippage: Percentage;
|
|
3922
4057
|
decimalsA: number;
|
|
3923
4058
|
decimalsB: number;
|
|
3924
4059
|
swapTicks: Array<TickData>;
|
|
3925
4060
|
currentPool: Pool;
|
|
3926
|
-
}): Promise<SwapParams>;
|
|
4061
|
+
}): Promise<SwapParams$1>;
|
|
3927
4062
|
static syncBuildCoinInputForAmount(sdk: MagmaClmmSDK, tx: Transaction, amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): Promise<TransactionObjectArgument | undefined>;
|
|
3928
4063
|
static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
3929
4064
|
private static buildVectorCoin;
|
|
@@ -4103,4 +4238,4 @@ interface InitMagmaSDKOptions {
|
|
|
4103
4238
|
*/
|
|
4104
4239
|
declare function initMagmaSDK(options: InitMagmaSDKOptions): MagmaClmmSDK;
|
|
4105
4240
|
|
|
4106
|
-
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, 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, EpochEmission, FEE_RATE_DENOMINATOR, FaucetCoin, FetchParams, GAS_SYMBOL, GAS_TYPE_ARG, GAS_TYPE_ARG_LONG, Gauge, GetRewardByPosition, IncreaseLockAmountParams, IncreaseUnlockTimeParams, LaunchpadPoolConfig, 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_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, 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, 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, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
|
|
4241
|
+
export { AMM_SWAP_MODULE, AddBribeReward, AddLiquidityCommonParams, AddLiquidityFixTokenParams, AddLiquidityParams, AddLiquidityWithProtectionParams, AddressAndDirection, AdjustResult, AggregatorResult, AmountSpecified, BasePath, BigNumber, 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, 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_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, 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, 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, getDefaultSuiInputType, getDeltaA, getDeltaB, getDeltaDownFromOutput, getDeltaUpFromInput, getFutureTime, getLiquidityFromCoinA, getLiquidityFromCoinB, getLowerSqrtPriceFromCoinA, getLowerSqrtPriceFromCoinB, getMoveObject, getMoveObjectType, getMovePackageContent, getNearestTickByTick, getNextSqrtPriceAUp, getNextSqrtPriceBDown, getNextSqrtPriceFromInput, getNextSqrtPriceFromOutput, getObjectDeletedResponse, getObjectDisplay, getObjectFields, getObjectId, getObjectNotExistsResponse, getObjectOwner, getObjectPreviousTransactionDigest, getObjectReference, getObjectType, getObjectVersion, getPackagerConfigs, getRewardInTickRange, getSuiObjectData, getTickDataFromUrlData, getUpperSqrtPriceFromCoinA, getUpperSqrtPriceFromCoinB, hasPublicTransfer, hexToNumber, hexToString, initMagmaSDK, initMainnetSDK, initTestnetSDK, isSortedSymbols, isSuiObjectResponse, newBits, normalizeCoinType, patchFixSuiObjectId, printTransaction, removeHexPrefix, secretKeyToEd25519Keypair, secretKeyToSecp256k1Keypair, shortAddress, shortString, tickScore, toBuffer, toCoinAmount, toDecimalsAmount, transClmmpoolDataWithoutTicks, utf8to16 };
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
DeepbookCustodianV2Moudle: () => DeepbookCustodianV2Moudle,
|
|
65
65
|
DeepbookEndpointsV2Moudle: () => DeepbookEndpointsV2Moudle,
|
|
66
66
|
DeepbookUtils: () => DeepbookUtils,
|
|
67
|
+
DlmmScript: () => DlmmScript,
|
|
67
68
|
FEE_RATE_DENOMINATOR: () => FEE_RATE_DENOMINATOR,
|
|
68
69
|
GAS_SYMBOL: () => GAS_SYMBOL,
|
|
69
70
|
GAS_TYPE_ARG: () => GAS_TYPE_ARG,
|
|
@@ -508,6 +509,7 @@ var Voter = "voter";
|
|
|
508
509
|
var RewardDistributor = "reward_distributor";
|
|
509
510
|
var Gauge = "gauge";
|
|
510
511
|
var Minter = "minter";
|
|
512
|
+
var DlmmScript = "dlmm_script";
|
|
511
513
|
var CoinInfoAddress = "0x1::coin::CoinInfo";
|
|
512
514
|
var CoinStoreAddress = "0x1::coin::CoinStore";
|
|
513
515
|
var DeepbookCustodianV2Moudle = "custodian_v2";
|
|
@@ -10049,6 +10051,277 @@ var GaugeModule = class {
|
|
|
10049
10051
|
}
|
|
10050
10052
|
};
|
|
10051
10053
|
|
|
10054
|
+
// src/modules/dlmm.ts
|
|
10055
|
+
var import_transactions12 = require("@mysten/sui/transactions");
|
|
10056
|
+
var import_decimal10 = __toESM(require("decimal.js"));
|
|
10057
|
+
var import_calc_dlmm = require("@magmaprotocol/calc_dlmm");
|
|
10058
|
+
var DlmmModule = class {
|
|
10059
|
+
_sdk;
|
|
10060
|
+
constructor(sdk) {
|
|
10061
|
+
this._sdk = sdk;
|
|
10062
|
+
}
|
|
10063
|
+
get sdk() {
|
|
10064
|
+
return this._sdk;
|
|
10065
|
+
}
|
|
10066
|
+
// eg: fetch pool active_index
|
|
10067
|
+
async fetchPairParams(params) {
|
|
10068
|
+
const tx = new import_transactions12.Transaction();
|
|
10069
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10070
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10071
|
+
const args = [tx.object(params.pair)];
|
|
10072
|
+
tx.moveCall({
|
|
10073
|
+
target: `${integrate.published_at}::${DlmmScript}::fetch_pair_params`,
|
|
10074
|
+
arguments: args,
|
|
10075
|
+
typeArguments
|
|
10076
|
+
});
|
|
10077
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10078
|
+
transactionBlock: tx,
|
|
10079
|
+
sender: simulationAccount.address
|
|
10080
|
+
});
|
|
10081
|
+
if (simulateRes.error != null) {
|
|
10082
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10083
|
+
}
|
|
10084
|
+
let res = {
|
|
10085
|
+
base_factor: 0,
|
|
10086
|
+
filter_period: 0,
|
|
10087
|
+
decay_period: 0,
|
|
10088
|
+
reduction_factor: 0,
|
|
10089
|
+
variable_fee_control: 0,
|
|
10090
|
+
protocol_share: 0,
|
|
10091
|
+
max_volatility_accumulator: 0,
|
|
10092
|
+
volatility_accumulator: 0,
|
|
10093
|
+
volatility_reference: 0,
|
|
10094
|
+
index_reference: 0,
|
|
10095
|
+
time_of_last_update: 0,
|
|
10096
|
+
oracle_index: 0,
|
|
10097
|
+
active_index: 0
|
|
10098
|
+
};
|
|
10099
|
+
simulateRes.events?.forEach((item) => {
|
|
10100
|
+
console.log(extractStructTagFromType(item.type).name);
|
|
10101
|
+
if (extractStructTagFromType(item.type).name === `EventPairParams`) {
|
|
10102
|
+
res = item.parsedJson.params;
|
|
10103
|
+
}
|
|
10104
|
+
});
|
|
10105
|
+
return res;
|
|
10106
|
+
}
|
|
10107
|
+
// params price: input (b/(10^b_decimal))/(a/(10^a_decimal))
|
|
10108
|
+
price_to_storage_id(price, bin_step, tokenADecimal, tokenBDecimal) {
|
|
10109
|
+
const priceDec = new import_decimal10.default(price);
|
|
10110
|
+
const tenDec = new import_decimal10.default(10);
|
|
10111
|
+
const twoDec = new import_decimal10.default(2);
|
|
10112
|
+
const price_x128 = priceDec.mul(tenDec.pow(tokenBDecimal)).div(tenDec.pow(tokenADecimal)).mul(twoDec.pow(128));
|
|
10113
|
+
const active_id = (0, import_calc_dlmm.get_real_id_from_price)(price_x128.toFixed(0).toString(), bin_step);
|
|
10114
|
+
return (0, import_calc_dlmm.get_storage_id_from_real_id)(active_id);
|
|
10115
|
+
}
|
|
10116
|
+
// NOTE: x, y should be sorted
|
|
10117
|
+
async createPairPayload(params) {
|
|
10118
|
+
const storage_id = this.price_to_storage_id(params.priceTokenBPerTokenA, params.bin_step, params.coinADecimal, params.coinBDecimal);
|
|
10119
|
+
const tx = new import_transactions12.Transaction();
|
|
10120
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10121
|
+
const { clmm_pool, dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10122
|
+
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10123
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10124
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10125
|
+
const args = [tx.object(dlmmConfig.factory), tx.object(global_config_id), tx.pure.u16(params.bin_step), tx.pure.u32(storage_id)];
|
|
10126
|
+
tx.moveCall({
|
|
10127
|
+
target: `${integrate.published_at}::${DlmmScript}::create_pair`,
|
|
10128
|
+
typeArguments,
|
|
10129
|
+
arguments: args
|
|
10130
|
+
});
|
|
10131
|
+
return tx;
|
|
10132
|
+
}
|
|
10133
|
+
async createAddLiquidityPayload() {
|
|
10134
|
+
const tx = new import_transactions12.Transaction();
|
|
10135
|
+
return tx;
|
|
10136
|
+
}
|
|
10137
|
+
// Create a position by percent
|
|
10138
|
+
async mintPercent(params) {
|
|
10139
|
+
const tx = new import_transactions12.Transaction();
|
|
10140
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10141
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10142
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10143
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10144
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10145
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10146
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10147
|
+
const args = [
|
|
10148
|
+
tx.object(params.pair),
|
|
10149
|
+
tx.object(dlmmConfig.factory),
|
|
10150
|
+
primaryCoinAInputs.targetCoin,
|
|
10151
|
+
primaryCoinBInputs.targetCoin,
|
|
10152
|
+
tx.pure.u64(params.amountATotal),
|
|
10153
|
+
tx.pure.u64(params.amountBTotal),
|
|
10154
|
+
tx.pure.vector("u32", params.storageIds),
|
|
10155
|
+
tx.pure.vector("u64", params.binsAPercent),
|
|
10156
|
+
tx.pure.vector("u64", params.binsBPercent),
|
|
10157
|
+
tx.pure.address(params.to),
|
|
10158
|
+
tx.object(CLOCK_ADDRESS)
|
|
10159
|
+
];
|
|
10160
|
+
tx.moveCall({
|
|
10161
|
+
target: `${integrate.published_at}::${DlmmScript}::mint_percent`,
|
|
10162
|
+
typeArguments,
|
|
10163
|
+
arguments: args
|
|
10164
|
+
});
|
|
10165
|
+
return tx;
|
|
10166
|
+
}
|
|
10167
|
+
// Create a position by amount
|
|
10168
|
+
async createPositionByAmount(params) {
|
|
10169
|
+
const tx = new import_transactions12.Transaction();
|
|
10170
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10171
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10172
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10173
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10174
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10175
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountATotal), params.coinTypeA, false, true);
|
|
10176
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(params.amountBTotal), params.coinTypeB, false, true);
|
|
10177
|
+
const args = [
|
|
10178
|
+
tx.object(params.pair),
|
|
10179
|
+
tx.object(dlmmConfig.factory),
|
|
10180
|
+
primaryCoinAInputs.targetCoin,
|
|
10181
|
+
primaryCoinBInputs.targetCoin,
|
|
10182
|
+
tx.pure.vector("u32", params.storageIds),
|
|
10183
|
+
tx.pure.vector("u64", params.amountsA),
|
|
10184
|
+
tx.pure.vector("u64", params.amountsB),
|
|
10185
|
+
tx.pure.address(params.to),
|
|
10186
|
+
tx.object(CLOCK_ADDRESS)
|
|
10187
|
+
];
|
|
10188
|
+
tx.moveCall({
|
|
10189
|
+
target: `${integrate.published_at}::${DlmmScript}::mint_amounts`,
|
|
10190
|
+
typeArguments,
|
|
10191
|
+
arguments: args
|
|
10192
|
+
});
|
|
10193
|
+
return tx;
|
|
10194
|
+
}
|
|
10195
|
+
async swap(params) {
|
|
10196
|
+
const tx = new import_transactions12.Transaction();
|
|
10197
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10198
|
+
const { clmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10199
|
+
const { global_config_id } = getPackagerConfigs(clmm_pool);
|
|
10200
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10201
|
+
const args = [
|
|
10202
|
+
tx.object(params.pair),
|
|
10203
|
+
tx.object(global_config_id),
|
|
10204
|
+
tx.object(params.coinTypeA),
|
|
10205
|
+
tx.object(params.coinTypeB),
|
|
10206
|
+
tx.pure.u64(params.amountIn),
|
|
10207
|
+
tx.pure.u64(params.minAmountOut),
|
|
10208
|
+
tx.pure.bool(params.swapForY),
|
|
10209
|
+
tx.pure.address(params.to),
|
|
10210
|
+
tx.object(CLOCK_ADDRESS)
|
|
10211
|
+
];
|
|
10212
|
+
tx.moveCall({
|
|
10213
|
+
target: `${integrate.published_at}::${DlmmScript}::swap`,
|
|
10214
|
+
typeArguments,
|
|
10215
|
+
arguments: args
|
|
10216
|
+
});
|
|
10217
|
+
return tx;
|
|
10218
|
+
}
|
|
10219
|
+
async fetchBins(params) {
|
|
10220
|
+
const tx = new import_transactions12.Transaction();
|
|
10221
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10222
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10223
|
+
const args = [tx.object(params.pair), tx.pure.u64(params.offset), tx.pure.u64(params.limit)];
|
|
10224
|
+
tx.moveCall({
|
|
10225
|
+
target: `${integrate.published_at}::${DlmmScript}::fetch_bins`,
|
|
10226
|
+
arguments: args,
|
|
10227
|
+
typeArguments
|
|
10228
|
+
});
|
|
10229
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10230
|
+
transactionBlock: tx,
|
|
10231
|
+
sender: simulationAccount.address
|
|
10232
|
+
});
|
|
10233
|
+
if (simulateRes.error != null) {
|
|
10234
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10235
|
+
}
|
|
10236
|
+
const res = [];
|
|
10237
|
+
simulateRes.events?.forEach((item) => {
|
|
10238
|
+
if (extractStructTagFromType(item.type).name === `EventFetchBins`) {
|
|
10239
|
+
}
|
|
10240
|
+
});
|
|
10241
|
+
return res;
|
|
10242
|
+
}
|
|
10243
|
+
async getPositionLiquidity(params) {
|
|
10244
|
+
const tx = new import_transactions12.Transaction();
|
|
10245
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10246
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10247
|
+
const args = [tx.object(params.pair), tx.object(params.positionId)];
|
|
10248
|
+
tx.moveCall({
|
|
10249
|
+
target: `${integrate.published_at}::${DlmmScript}::position_liquidity`,
|
|
10250
|
+
arguments: args,
|
|
10251
|
+
typeArguments
|
|
10252
|
+
});
|
|
10253
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10254
|
+
transactionBlock: tx,
|
|
10255
|
+
sender: simulationAccount.address
|
|
10256
|
+
});
|
|
10257
|
+
if (simulateRes.error != null) {
|
|
10258
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10259
|
+
}
|
|
10260
|
+
const out = {
|
|
10261
|
+
shares: 0,
|
|
10262
|
+
liquidity: 0,
|
|
10263
|
+
x_equivalent: 0,
|
|
10264
|
+
y_equivalent: 0,
|
|
10265
|
+
bin_ids: [],
|
|
10266
|
+
bin_x_eq: [],
|
|
10267
|
+
bin_y_eq: [],
|
|
10268
|
+
bin_liquidity: []
|
|
10269
|
+
};
|
|
10270
|
+
simulateRes.events?.forEach((item) => {
|
|
10271
|
+
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
10272
|
+
out.shares = item.parsedJson.shares;
|
|
10273
|
+
out.liquidity = item.parsedJson.liquidity;
|
|
10274
|
+
out.x_equivalent = item.parsedJson.x_equivalent;
|
|
10275
|
+
out.y_equivalent = item.parsedJson.y_equivalent;
|
|
10276
|
+
out.bin_ids = item.parsedJson.bin_id;
|
|
10277
|
+
out.bin_x_eq = item.parsedJson.bin_x_eq;
|
|
10278
|
+
out.bin_y_eq = item.parsedJson.bin_y_eq;
|
|
10279
|
+
out.bin_liquidity = item.parsedJson.bin_liquidity;
|
|
10280
|
+
}
|
|
10281
|
+
});
|
|
10282
|
+
return out;
|
|
10283
|
+
}
|
|
10284
|
+
async getPairLiquidity(params) {
|
|
10285
|
+
const tx = new import_transactions12.Transaction();
|
|
10286
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
10287
|
+
const typeArguments = [params.coinTypeA, params.coinTypeB];
|
|
10288
|
+
const args = [tx.object(params.pair)];
|
|
10289
|
+
tx.moveCall({
|
|
10290
|
+
target: `${integrate.published_at}::${DlmmScript}::pair_liquidity`,
|
|
10291
|
+
arguments: args,
|
|
10292
|
+
typeArguments
|
|
10293
|
+
});
|
|
10294
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
10295
|
+
transactionBlock: tx,
|
|
10296
|
+
sender: simulationAccount.address
|
|
10297
|
+
});
|
|
10298
|
+
if (simulateRes.error != null) {
|
|
10299
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10300
|
+
}
|
|
10301
|
+
const out = {
|
|
10302
|
+
shares: 0,
|
|
10303
|
+
liquidity: 0,
|
|
10304
|
+
x: 0,
|
|
10305
|
+
y: 0,
|
|
10306
|
+
bin_ids: [],
|
|
10307
|
+
bin_x: [],
|
|
10308
|
+
bin_y: []
|
|
10309
|
+
};
|
|
10310
|
+
simulateRes.events?.forEach((item) => {
|
|
10311
|
+
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
10312
|
+
out.shares = item.parsedJson.shares;
|
|
10313
|
+
out.liquidity = item.parsedJson.liquidity;
|
|
10314
|
+
out.x = item.parsedJson.x;
|
|
10315
|
+
out.y = item.parsedJson.y;
|
|
10316
|
+
out.bin_ids = item.bin_ids;
|
|
10317
|
+
out.bin_x = item.bin_x;
|
|
10318
|
+
out.bin_y = item.bin_y;
|
|
10319
|
+
}
|
|
10320
|
+
});
|
|
10321
|
+
return out;
|
|
10322
|
+
}
|
|
10323
|
+
};
|
|
10324
|
+
|
|
10052
10325
|
// src/sdk.ts
|
|
10053
10326
|
var MagmaClmmSDK = class {
|
|
10054
10327
|
_cache = {};
|
|
@@ -10073,6 +10346,7 @@ var MagmaClmmSDK = class {
|
|
|
10073
10346
|
*/
|
|
10074
10347
|
_lock;
|
|
10075
10348
|
_gauge;
|
|
10349
|
+
_dlmm;
|
|
10076
10350
|
/**
|
|
10077
10351
|
* Provide interact with a position rewarder interface.
|
|
10078
10352
|
*/
|
|
@@ -10110,6 +10384,7 @@ var MagmaClmmSDK = class {
|
|
|
10110
10384
|
this._swap = new SwapModule(this);
|
|
10111
10385
|
this._lock = new LockModule(this);
|
|
10112
10386
|
this._gauge = new GaugeModule(this);
|
|
10387
|
+
this._dlmm = new DlmmModule(this);
|
|
10113
10388
|
this._pool = new PoolModule(this);
|
|
10114
10389
|
this._position = new PositionModule(this);
|
|
10115
10390
|
this._rewarder = new RewarderModule(this);
|
|
@@ -10147,6 +10422,9 @@ var MagmaClmmSDK = class {
|
|
|
10147
10422
|
get Gauge() {
|
|
10148
10423
|
return this._gauge;
|
|
10149
10424
|
}
|
|
10425
|
+
get Dlmm() {
|
|
10426
|
+
return this._dlmm;
|
|
10427
|
+
}
|
|
10150
10428
|
/**
|
|
10151
10429
|
* Getter for the fullClient property.
|
|
10152
10430
|
* @returns {RpcModule} The fullClient property value.
|
|
@@ -10320,6 +10598,7 @@ var main_default = MagmaClmmSDK;
|
|
|
10320
10598
|
var SDKConfig = {
|
|
10321
10599
|
clmmConfig: {
|
|
10322
10600
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
10601
|
+
// clmm and dlmm both use this global_config
|
|
10323
10602
|
global_config_id: "0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a",
|
|
10324
10603
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
10325
10604
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
@@ -10339,7 +10618,11 @@ var SDKConfig = {
|
|
|
10339
10618
|
distribution_cfg: "0xaff8d151ac29317201151f97d28c546b3c5923d8cfc5499f40dea61c4022c949",
|
|
10340
10619
|
magma_token: "0x7161c6c6bb65f852797c8f7f5c4f8d57adaf796e1b840921f9e23fabeadfd54e::magma::MAGMA",
|
|
10341
10620
|
minter_id: "0x4fa5766cd83b33b215b139fec27ac344040f3bbd84fcbee7b61fc671aadc51fa"
|
|
10342
|
-
}
|
|
10621
|
+
},
|
|
10622
|
+
dlmmConfig: {
|
|
10623
|
+
factory: ""
|
|
10624
|
+
},
|
|
10625
|
+
gaugeConfig: {}
|
|
10343
10626
|
};
|
|
10344
10627
|
var clmmMainnet = {
|
|
10345
10628
|
fullRpcUrl: (0, import_client2.getFullnodeUrl)("mainnet"),
|
|
@@ -10356,6 +10639,11 @@ var clmmMainnet = {
|
|
|
10356
10639
|
published_at: "0x4a35d3dfef55ed3631b7158544c6322a23bc434fe4fca1234cb680ce0505f82d",
|
|
10357
10640
|
config: SDKConfig.clmmConfig
|
|
10358
10641
|
},
|
|
10642
|
+
dlmm_pool: {
|
|
10643
|
+
package_id: "",
|
|
10644
|
+
published_at: "",
|
|
10645
|
+
config: SDKConfig.dlmmConfig
|
|
10646
|
+
},
|
|
10359
10647
|
distribution: {
|
|
10360
10648
|
package_id: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b",
|
|
10361
10649
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
@@ -10409,6 +10697,9 @@ var SDKConfig2 = {
|
|
|
10409
10697
|
distribution_cfg: "0x94e23846c975e2faf89a61bfc2b10ad64decab9069eb1f9fc39752b010868c74",
|
|
10410
10698
|
magma_token: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1::magma_token::MAGMA_TOKEN",
|
|
10411
10699
|
minter_id: "0x89435d6b2a510ba50ca23303f10e91ec058f138a88f69a43fe03cd22edb214c5"
|
|
10700
|
+
},
|
|
10701
|
+
dlmmConfig: {
|
|
10702
|
+
factory: ""
|
|
10412
10703
|
}
|
|
10413
10704
|
};
|
|
10414
10705
|
var clmmTestnet = {
|
|
@@ -10423,6 +10714,11 @@ var clmmTestnet = {
|
|
|
10423
10714
|
published_at: "0x23e0b5ab4aa63d0e6fd98fa5e247bcf9b36ad716b479d39e56b2ba9ff631e09d",
|
|
10424
10715
|
config: SDKConfig2.clmmConfig
|
|
10425
10716
|
},
|
|
10717
|
+
dlmm_pool: {
|
|
10718
|
+
package_id: "",
|
|
10719
|
+
published_at: "",
|
|
10720
|
+
config: SDKConfig2.dlmmConfig
|
|
10721
|
+
},
|
|
10426
10722
|
distribution: {
|
|
10427
10723
|
package_id: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1",
|
|
10428
10724
|
published_at: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1"
|
|
@@ -10498,6 +10794,7 @@ var src_default = MagmaClmmSDK;
|
|
|
10498
10794
|
DeepbookCustodianV2Moudle,
|
|
10499
10795
|
DeepbookEndpointsV2Moudle,
|
|
10500
10796
|
DeepbookUtils,
|
|
10797
|
+
DlmmScript,
|
|
10501
10798
|
FEE_RATE_DENOMINATOR,
|
|
10502
10799
|
GAS_SYMBOL,
|
|
10503
10800
|
GAS_TYPE_ARG,
|