@magmaprotocol/magma-clmm-sdk 0.5.6 → 0.5.8
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 +8 -3
- package/dist/index.js +171 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +171 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1318,6 +1318,7 @@ type MagmaConfigs = {
|
|
|
1318
1318
|
voting_escrow_id: SuiObjectIdType;
|
|
1319
1319
|
magma_token: SuiAddressType;
|
|
1320
1320
|
reward_distributor_id: SuiObjectIdType;
|
|
1321
|
+
distribution_cfg: SuiObjectIdType;
|
|
1321
1322
|
minter_id: SuiObjectIdType;
|
|
1322
1323
|
};
|
|
1323
1324
|
/**
|
|
@@ -3045,6 +3046,7 @@ declare class LockModule implements IModule {
|
|
|
3045
3046
|
pokePayload(params: PokeParams): Promise<Transaction>;
|
|
3046
3047
|
claimVotingBribe(locks: string[], incentive_tokens: string[]): Promise<Transaction>;
|
|
3047
3048
|
locksOfUser(user: string): Promise<LocksInfo>;
|
|
3049
|
+
aLockInfo(lockId: string): Promise<LockInfo>;
|
|
3048
3050
|
aLockSummary(lock_id: string): Promise<ALockSummary>;
|
|
3049
3051
|
allLockSummary(): Promise<AllLockSummary>;
|
|
3050
3052
|
poolWeights(pools: string[]): Promise<PoolWeight[]>;
|
|
@@ -3722,7 +3724,7 @@ declare class TransactionUtil {
|
|
|
3722
3724
|
* @returns
|
|
3723
3725
|
*/
|
|
3724
3726
|
static buildAddLiquidityWithProtectionFixToken(sdk: MagmaClmmSDK, allCoinAsset: CoinAsset[], params: AddLiquidityFixTokenParams, tx?: Transaction, inputCoinA?: TransactionObjectArgument, inputCoinB?: TransactionObjectArgument): Promise<Transaction>;
|
|
3725
|
-
static buildAddLiquidityFixTokenCoinInput(tx: Transaction, need_interval_amount: boolean, amount: number | string, slippage: number, coinType: string, allCoinAsset: CoinAsset[], buildVector?: boolean): BuildCoinResult;
|
|
3727
|
+
static buildAddLiquidityFixTokenCoinInput(tx: Transaction, need_interval_amount: boolean, amount: number | string, slippage: number, coinType: string, allCoinAsset: CoinAsset[], buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
3726
3728
|
/**
|
|
3727
3729
|
* fix add liquidity fix token for coin amount
|
|
3728
3730
|
* @param params
|
|
@@ -3823,11 +3825,14 @@ declare class TransactionUtil {
|
|
|
3823
3825
|
swapTicks: Array<TickData>;
|
|
3824
3826
|
currentPool: Pool;
|
|
3825
3827
|
}): Promise<SwapParams>;
|
|
3826
|
-
static syncBuildCoinInputForAmount(sdk: MagmaClmmSDK, tx: Transaction, amount: bigint, coinType: string, buildVector?: boolean): Promise<TransactionObjectArgument | undefined>;
|
|
3828
|
+
static syncBuildCoinInputForAmount(sdk: MagmaClmmSDK, tx: Transaction, amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): Promise<TransactionObjectArgument | undefined>;
|
|
3827
3829
|
static buildCoinForAmount(tx: Transaction, allCoins: CoinAsset[], amount: bigint, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
3830
|
+
private static buildVectorCoin;
|
|
3831
|
+
private static buildOneCoin;
|
|
3832
|
+
private static buildSpitTargeCoin;
|
|
3828
3833
|
private static buildCoin;
|
|
3829
3834
|
private static buildZeroValueCoin;
|
|
3830
|
-
static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean): BuildCoinResult;
|
|
3835
|
+
static buildCoinForAmountInterval(tx: Transaction, allCoins: CoinAsset[], amounts: CoinInputInterval, coinType: string, buildVector?: boolean, fixAmount?: boolean): BuildCoinResult;
|
|
3831
3836
|
static callMintZeroValueCoin: (txb: Transaction, coinType: string) => _mysten_sui_transactions.TransactionResult;
|
|
3832
3837
|
static buildRouterSwapTransaction(sdk: MagmaClmmSDK, params: SwapWithRouterParams, byAmountIn: boolean, allCoinAsset: CoinAsset[], recipient?: string): Promise<Transaction>;
|
|
3833
3838
|
static buildRouterBasePathTx(sdk: MagmaClmmSDK, params: SwapWithRouterParams, byAmountIn: boolean, allCoinAsset: CoinAsset[], tx: Transaction, recipient?: string): Promise<Transaction>;
|
package/dist/index.js
CHANGED
|
@@ -2723,7 +2723,8 @@ var _TransactionUtil = class {
|
|
|
2723
2723
|
params.slippage,
|
|
2724
2724
|
params.coinTypeA,
|
|
2725
2725
|
allCoins,
|
|
2726
|
-
false
|
|
2726
|
+
false,
|
|
2727
|
+
true
|
|
2727
2728
|
);
|
|
2728
2729
|
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
2729
2730
|
newTx,
|
|
@@ -2732,7 +2733,8 @@ var _TransactionUtil = class {
|
|
|
2732
2733
|
params.slippage,
|
|
2733
2734
|
params.coinTypeB,
|
|
2734
2735
|
allCoins,
|
|
2735
|
-
false
|
|
2736
|
+
false,
|
|
2737
|
+
true
|
|
2736
2738
|
);
|
|
2737
2739
|
} else {
|
|
2738
2740
|
params.amount_b = Number(fixAmount);
|
|
@@ -2743,7 +2745,8 @@ var _TransactionUtil = class {
|
|
|
2743
2745
|
params.slippage,
|
|
2744
2746
|
params.coinTypeA,
|
|
2745
2747
|
allCoins,
|
|
2746
|
-
false
|
|
2748
|
+
false,
|
|
2749
|
+
true
|
|
2747
2750
|
);
|
|
2748
2751
|
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
2749
2752
|
newTx,
|
|
@@ -2752,10 +2755,11 @@ var _TransactionUtil = class {
|
|
|
2752
2755
|
params.slippage,
|
|
2753
2756
|
params.coinTypeB,
|
|
2754
2757
|
allCoins,
|
|
2755
|
-
false
|
|
2758
|
+
false,
|
|
2759
|
+
true
|
|
2756
2760
|
);
|
|
2757
2761
|
params = _TransactionUtil.fixAddLiquidityFixTokenParams(params, gasEstimateArg.slippage, gasEstimateArg.curSqrtPrice);
|
|
2758
|
-
tx =
|
|
2762
|
+
tx = _TransactionUtil.buildAddLiquidityFixTokenArgs(newTx, sdk, allCoins, params, primaryCoinAInputs, primaryCoinBInputs);
|
|
2759
2763
|
return tx;
|
|
2760
2764
|
}
|
|
2761
2765
|
}
|
|
@@ -2782,7 +2786,8 @@ var _TransactionUtil = class {
|
|
|
2782
2786
|
params.slippage,
|
|
2783
2787
|
params.coinTypeA,
|
|
2784
2788
|
allCoinAsset,
|
|
2785
|
-
false
|
|
2789
|
+
false,
|
|
2790
|
+
true
|
|
2786
2791
|
);
|
|
2787
2792
|
primaryCoinBInputs = _TransactionUtil.buildAddLiquidityFixTokenCoinInput(
|
|
2788
2793
|
tx,
|
|
@@ -2791,7 +2796,8 @@ var _TransactionUtil = class {
|
|
|
2791
2796
|
params.slippage,
|
|
2792
2797
|
params.coinTypeB,
|
|
2793
2798
|
allCoinAsset,
|
|
2794
|
-
false
|
|
2799
|
+
false,
|
|
2800
|
+
true
|
|
2795
2801
|
);
|
|
2796
2802
|
} else {
|
|
2797
2803
|
primaryCoinAInputs = {
|
|
@@ -2873,14 +2879,15 @@ var _TransactionUtil = class {
|
|
|
2873
2879
|
);
|
|
2874
2880
|
return tx;
|
|
2875
2881
|
}
|
|
2876
|
-
static buildAddLiquidityFixTokenCoinInput(tx, need_interval_amount, amount, slippage, coinType, allCoinAsset, buildVector = true) {
|
|
2882
|
+
static buildAddLiquidityFixTokenCoinInput(tx, need_interval_amount, amount, slippage, coinType, allCoinAsset, buildVector = true, fixAmount = true) {
|
|
2877
2883
|
return need_interval_amount ? _TransactionUtil.buildCoinForAmountInterval(
|
|
2878
2884
|
tx,
|
|
2879
2885
|
allCoinAsset,
|
|
2880
2886
|
{ amountSecond: BigInt(reverSlippageAmount(amount, slippage)), amountFirst: BigInt(amount) },
|
|
2881
2887
|
coinType,
|
|
2882
|
-
buildVector
|
|
2883
|
-
|
|
2888
|
+
buildVector,
|
|
2889
|
+
fixAmount
|
|
2890
|
+
) : _TransactionUtil.buildCoinForAmount(tx, allCoinAsset, BigInt(amount), coinType, buildVector, fixAmount);
|
|
2884
2891
|
}
|
|
2885
2892
|
/**
|
|
2886
2893
|
* fix add liquidity fix token for coin amount
|
|
@@ -2975,11 +2982,6 @@ var _TransactionUtil = class {
|
|
|
2975
2982
|
max_amount_a = params.amount_a;
|
|
2976
2983
|
min_amount_a = new import_decimal7.default(params.amount_a).div(new import_decimal7.default(1).plus(new import_decimal7.default(params.slippage))).mul(new import_decimal7.default(1).minus(new import_decimal7.default(params.slippage))).toDecimalPlaces(0).toNumber();
|
|
2977
2984
|
}
|
|
2978
|
-
console.log("min_amount_a", min_amount_a);
|
|
2979
|
-
console.log("max_amount_a", max_amount_a);
|
|
2980
|
-
console.log("min_amount_b", min_amount_b);
|
|
2981
|
-
console.log("max_amount_b", max_amount_b);
|
|
2982
|
-
console.log("params.fix_amount_a", params.fix_amount_a);
|
|
2983
2985
|
const args = params.is_open ? [
|
|
2984
2986
|
tx.object(clmmConfig.global_config_id),
|
|
2985
2987
|
tx.object(params.pool_id),
|
|
@@ -3217,7 +3219,7 @@ var _TransactionUtil = class {
|
|
|
3217
3219
|
tx.setSender(sdk.senderAddress);
|
|
3218
3220
|
tx.setGasBudget(1e8);
|
|
3219
3221
|
const { integrate } = sdk.sdkOptions;
|
|
3220
|
-
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3222
|
+
const { distribution_cfg, voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3221
3223
|
const typeArguments = [magma_token];
|
|
3222
3224
|
const functionName = "vote";
|
|
3223
3225
|
const pools = tx.pure.vector("id", params.pools);
|
|
@@ -3225,7 +3227,15 @@ var _TransactionUtil = class {
|
|
|
3225
3227
|
elements: params.weights.map((weight) => tx.pure.u64(weight)),
|
|
3226
3228
|
type: "u64"
|
|
3227
3229
|
});
|
|
3228
|
-
const args = [
|
|
3230
|
+
const args = [
|
|
3231
|
+
tx.object(distribution_cfg),
|
|
3232
|
+
tx.object(voter_id),
|
|
3233
|
+
tx.object(voting_escrow_id),
|
|
3234
|
+
tx.object(params.lockId),
|
|
3235
|
+
pools,
|
|
3236
|
+
weights,
|
|
3237
|
+
tx.object(CLOCK_ADDRESS)
|
|
3238
|
+
];
|
|
3229
3239
|
tx.moveCall({
|
|
3230
3240
|
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
3231
3241
|
typeArguments,
|
|
@@ -3287,10 +3297,16 @@ var _TransactionUtil = class {
|
|
|
3287
3297
|
const tx = new import_transactions.Transaction();
|
|
3288
3298
|
tx.setSender(sdk.senderAddress);
|
|
3289
3299
|
const { integrate } = sdk.sdkOptions;
|
|
3290
|
-
const { voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3300
|
+
const { distribution_cfg, voting_escrow_id, magma_token, voter_id } = getPackagerConfigs(sdk.sdkOptions.magma_config);
|
|
3291
3301
|
const typeArguments = [magma_token];
|
|
3292
3302
|
const functionName = "poke";
|
|
3293
|
-
const args = [
|
|
3303
|
+
const args = [
|
|
3304
|
+
tx.object(distribution_cfg),
|
|
3305
|
+
tx.object(voter_id),
|
|
3306
|
+
tx.object(voting_escrow_id),
|
|
3307
|
+
tx.object(params.lockId),
|
|
3308
|
+
tx.object(CLOCK_ADDRESS)
|
|
3309
|
+
];
|
|
3294
3310
|
tx.moveCall({
|
|
3295
3311
|
target: `${integrate.published_at}::${Voter}::${functionName}`,
|
|
3296
3312
|
typeArguments,
|
|
@@ -3534,17 +3550,17 @@ var _TransactionUtil = class {
|
|
|
3534
3550
|
}
|
|
3535
3551
|
return params;
|
|
3536
3552
|
}
|
|
3537
|
-
static async syncBuildCoinInputForAmount(sdk, tx, amount, coinType, buildVector = true) {
|
|
3553
|
+
static async syncBuildCoinInputForAmount(sdk, tx, amount, coinType, buildVector = true, fixAmount = true) {
|
|
3538
3554
|
if (sdk.senderAddress.length === 0) {
|
|
3539
3555
|
throw Error("this config sdk senderAddress is empty");
|
|
3540
3556
|
}
|
|
3541
3557
|
const allCoins = await sdk.getOwnerCoinAssets(sdk.senderAddress, coinType);
|
|
3542
|
-
const primaryCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoins, amount, coinType, buildVector).targetCoin;
|
|
3558
|
+
const primaryCoinInput = _TransactionUtil.buildCoinForAmount(tx, allCoins, amount, coinType, buildVector, fixAmount).targetCoin;
|
|
3543
3559
|
return primaryCoinInput;
|
|
3544
3560
|
}
|
|
3545
|
-
static buildCoinForAmount(tx, allCoins, amount, coinType, buildVector = true, fixAmount =
|
|
3561
|
+
static buildCoinForAmount(tx, allCoins, amount, coinType, buildVector = true, fixAmount = true) {
|
|
3546
3562
|
const coinAssets = CoinAssist.getCoinAssets(coinType, allCoins);
|
|
3547
|
-
if (amount === BigInt(0)
|
|
3563
|
+
if (amount === BigInt(0)) {
|
|
3548
3564
|
return _TransactionUtil.buildZeroValueCoin(allCoins, tx, coinType, buildVector);
|
|
3549
3565
|
}
|
|
3550
3566
|
const amountTotal = CoinAssist.calculateTotalBalance(coinAssets);
|
|
@@ -3556,18 +3572,41 @@ var _TransactionUtil = class {
|
|
|
3556
3572
|
}
|
|
3557
3573
|
return _TransactionUtil.buildCoin(tx, allCoins, coinAssets, amount, coinType, buildVector, fixAmount);
|
|
3558
3574
|
}
|
|
3559
|
-
static
|
|
3575
|
+
static buildVectorCoin(tx, allCoins, coinAssets, amount, coinType, fixAmount = true) {
|
|
3576
|
+
if (CoinAssist.isSuiCoin(coinType)) {
|
|
3577
|
+
const amountCoin = tx.splitCoins(tx.gas, [tx.pure.u64(amount)]);
|
|
3578
|
+
return {
|
|
3579
|
+
targetCoin: tx.makeMoveVec({ elements: [amountCoin] }),
|
|
3580
|
+
remainCoins: allCoins,
|
|
3581
|
+
tragetCoinAmount: amount.toString(),
|
|
3582
|
+
isMintZeroCoin: false,
|
|
3583
|
+
originalSplitedCoin: tx.gas
|
|
3584
|
+
};
|
|
3585
|
+
}
|
|
3586
|
+
const { targetCoin, originalSplitedCoin, tragetCoinAmount, selectedCoinsResult, coinObjectIds } = this.buildSpitTargeCoin(
|
|
3587
|
+
tx,
|
|
3588
|
+
amount,
|
|
3589
|
+
coinAssets,
|
|
3590
|
+
fixAmount
|
|
3591
|
+
);
|
|
3592
|
+
if (fixAmount) {
|
|
3593
|
+
return {
|
|
3594
|
+
targetCoin: tx.makeMoveVec({ elements: [targetCoin] }),
|
|
3595
|
+
remainCoins: selectedCoinsResult.remainCoins,
|
|
3596
|
+
originalSplitedCoin,
|
|
3597
|
+
tragetCoinAmount,
|
|
3598
|
+
isMintZeroCoin: false
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
return {
|
|
3602
|
+
targetCoin: tx.makeMoveVec({ elements: coinObjectIds.map((id) => tx.object(id)) }),
|
|
3603
|
+
remainCoins: selectedCoinsResult.remainCoins,
|
|
3604
|
+
tragetCoinAmount: selectedCoinsResult.amountArray.reduce((a, b) => Number(a) + Number(b), 0).toString(),
|
|
3605
|
+
isMintZeroCoin: false
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
static buildOneCoin(tx, coinAssets, amount, coinType, fixAmount = true) {
|
|
3560
3609
|
if (CoinAssist.isSuiCoin(coinType)) {
|
|
3561
|
-
if (buildVector) {
|
|
3562
|
-
const amountCoin2 = tx.splitCoins(tx.gas, [tx.pure.u64(amount)]);
|
|
3563
|
-
return {
|
|
3564
|
-
targetCoin: tx.makeMoveVec({ elements: [amountCoin2] }),
|
|
3565
|
-
remainCoins: allCoins,
|
|
3566
|
-
tragetCoinAmount: amount.toString(),
|
|
3567
|
-
isMintZeroCoin: false,
|
|
3568
|
-
originalSplitedCoin: tx.gas
|
|
3569
|
-
};
|
|
3570
|
-
}
|
|
3571
3610
|
if (amount === 0n && coinAssets.length > 1) {
|
|
3572
3611
|
const selectedCoinsResult3 = CoinAssist.selectCoinObjectIdGreaterThanOrEqual(coinAssets, amount);
|
|
3573
3612
|
return {
|
|
@@ -3587,17 +3626,24 @@ var _TransactionUtil = class {
|
|
|
3587
3626
|
originalSplitedCoin: tx.gas
|
|
3588
3627
|
};
|
|
3589
3628
|
}
|
|
3629
|
+
const { targetCoin, originalSplitedCoin, tragetCoinAmount, selectedCoinsResult } = this.buildSpitTargeCoin(
|
|
3630
|
+
tx,
|
|
3631
|
+
amount,
|
|
3632
|
+
coinAssets,
|
|
3633
|
+
fixAmount
|
|
3634
|
+
);
|
|
3635
|
+
return {
|
|
3636
|
+
targetCoin,
|
|
3637
|
+
remainCoins: selectedCoinsResult.remainCoins,
|
|
3638
|
+
originalSplitedCoin,
|
|
3639
|
+
tragetCoinAmount,
|
|
3640
|
+
isMintZeroCoin: false
|
|
3641
|
+
};
|
|
3642
|
+
}
|
|
3643
|
+
static buildSpitTargeCoin(tx, amount, coinAssets, fixAmount) {
|
|
3590
3644
|
const selectedCoinsResult = CoinAssist.selectCoinObjectIdGreaterThanOrEqual(coinAssets, amount);
|
|
3591
3645
|
const totalSelectedCoinAmount = selectedCoinsResult.amountArray.reduce((a, b) => Number(a) + Number(b), 0).toString();
|
|
3592
3646
|
const coinObjectIds = selectedCoinsResult.objectArray;
|
|
3593
|
-
if (buildVector) {
|
|
3594
|
-
return {
|
|
3595
|
-
targetCoin: tx.makeMoveVec({ elements: coinObjectIds.map((id) => tx.object(id)) }),
|
|
3596
|
-
remainCoins: selectedCoinsResult.remainCoins,
|
|
3597
|
-
tragetCoinAmount: selectedCoinsResult.amountArray.reduce((a, b) => Number(a) + Number(b), 0).toString(),
|
|
3598
|
-
isMintZeroCoin: false
|
|
3599
|
-
};
|
|
3600
|
-
}
|
|
3601
3647
|
const [primaryCoinA, ...mergeCoinAs] = coinObjectIds;
|
|
3602
3648
|
const primaryCoinAObject = tx.object(primaryCoinA);
|
|
3603
3649
|
let targetCoin = primaryCoinAObject;
|
|
@@ -3614,13 +3660,19 @@ var _TransactionUtil = class {
|
|
|
3614
3660
|
originalSplitedCoin = primaryCoinAObject;
|
|
3615
3661
|
}
|
|
3616
3662
|
return {
|
|
3617
|
-
targetCoin,
|
|
3618
|
-
remainCoins: selectedCoinsResult.remainCoins,
|
|
3619
3663
|
originalSplitedCoin,
|
|
3664
|
+
targetCoin,
|
|
3620
3665
|
tragetCoinAmount,
|
|
3621
|
-
|
|
3666
|
+
selectedCoinsResult,
|
|
3667
|
+
coinObjectIds
|
|
3622
3668
|
};
|
|
3623
3669
|
}
|
|
3670
|
+
static buildCoin(tx, allCoins, coinAssets, amount, coinType, buildVector = true, fixAmount = true) {
|
|
3671
|
+
if (buildVector) {
|
|
3672
|
+
return this.buildVectorCoin(tx, allCoins, coinAssets, amount, coinType, fixAmount);
|
|
3673
|
+
}
|
|
3674
|
+
return this.buildOneCoin(tx, coinAssets, amount, coinType, fixAmount);
|
|
3675
|
+
}
|
|
3624
3676
|
static buildZeroValueCoin(allCoins, tx, coinType, buildVector = true) {
|
|
3625
3677
|
const zeroCoin = _TransactionUtil.callMintZeroValueCoin(tx, coinType);
|
|
3626
3678
|
let targetCoin;
|
|
@@ -3636,17 +3688,17 @@ var _TransactionUtil = class {
|
|
|
3636
3688
|
tragetCoinAmount: "0"
|
|
3637
3689
|
};
|
|
3638
3690
|
}
|
|
3639
|
-
static buildCoinForAmountInterval(tx, allCoins, amounts, coinType, buildVector = true) {
|
|
3691
|
+
static buildCoinForAmountInterval(tx, allCoins, amounts, coinType, buildVector = true, fixAmount = true) {
|
|
3640
3692
|
const coinAssets = CoinAssist.getCoinAssets(coinType, allCoins);
|
|
3641
3693
|
if (amounts.amountFirst === BigInt(0)) {
|
|
3642
3694
|
if (coinAssets.length > 0) {
|
|
3643
|
-
return _TransactionUtil.buildCoin(tx, [...allCoins], [...coinAssets], amounts.amountFirst, coinType, buildVector);
|
|
3695
|
+
return _TransactionUtil.buildCoin(tx, [...allCoins], [...coinAssets], amounts.amountFirst, coinType, buildVector, fixAmount);
|
|
3644
3696
|
}
|
|
3645
3697
|
return _TransactionUtil.buildZeroValueCoin(allCoins, tx, coinType, buildVector);
|
|
3646
3698
|
}
|
|
3647
3699
|
const amountTotal = CoinAssist.calculateTotalBalance(coinAssets);
|
|
3648
3700
|
if (amountTotal >= amounts.amountFirst) {
|
|
3649
|
-
return _TransactionUtil.buildCoin(tx, [...allCoins], [...coinAssets], amounts.amountFirst, coinType, buildVector);
|
|
3701
|
+
return _TransactionUtil.buildCoin(tx, [...allCoins], [...coinAssets], amounts.amountFirst, coinType, buildVector, fixAmount);
|
|
3650
3702
|
}
|
|
3651
3703
|
if (amountTotal < amounts.amountSecond) {
|
|
3652
3704
|
throw new ClmmpoolsError(
|
|
@@ -3654,7 +3706,7 @@ var _TransactionUtil = class {
|
|
|
3654
3706
|
"InsufficientBalance" /* InsufficientBalance */
|
|
3655
3707
|
);
|
|
3656
3708
|
}
|
|
3657
|
-
return _TransactionUtil.buildCoin(tx, [...allCoins], [...coinAssets], amounts.amountSecond, coinType, buildVector);
|
|
3709
|
+
return _TransactionUtil.buildCoin(tx, [...allCoins], [...coinAssets], amounts.amountSecond, coinType, buildVector, fixAmount);
|
|
3658
3710
|
}
|
|
3659
3711
|
// ------------------------------------------router-v1-------------------------------------------------//
|
|
3660
3712
|
static async buildRouterSwapTransaction(sdk, params, byAmountIn, allCoinAsset, recipient) {
|
|
@@ -5622,8 +5674,8 @@ var PositionModule = class {
|
|
|
5622
5674
|
let primaryCoinBInputs;
|
|
5623
5675
|
if (inputCoinA == null || inputCoinB == null) {
|
|
5624
5676
|
const allCoinAsset = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
5625
|
-
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, max_amount_a, params.coinTypeA, false);
|
|
5626
|
-
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, max_amount_b, params.coinTypeB, false);
|
|
5677
|
+
primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, max_amount_a, params.coinTypeA, false, true);
|
|
5678
|
+
primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoinAsset, max_amount_b, params.coinTypeB, false, true);
|
|
5627
5679
|
} else {
|
|
5628
5680
|
primaryCoinAInputs = {
|
|
5629
5681
|
targetCoin: inputCoinA,
|
|
@@ -7453,6 +7505,62 @@ var LockModule = class {
|
|
|
7453
7505
|
}
|
|
7454
7506
|
return locksInfo;
|
|
7455
7507
|
}
|
|
7508
|
+
async aLockInfo(lockId) {
|
|
7509
|
+
const aLockSummary = await this.aLockSummary(lockId);
|
|
7510
|
+
const lockObj = await this._sdk.fullClient.getObject({
|
|
7511
|
+
id: lockId,
|
|
7512
|
+
options: {
|
|
7513
|
+
showContent: true,
|
|
7514
|
+
showDisplay: true,
|
|
7515
|
+
showOwner: true,
|
|
7516
|
+
showPreviousTransaction: true,
|
|
7517
|
+
showStorageRebate: true,
|
|
7518
|
+
showType: true
|
|
7519
|
+
}
|
|
7520
|
+
});
|
|
7521
|
+
const { magma_token } = getPackagerConfigs(this.sdk.sdkOptions.magma_config);
|
|
7522
|
+
const poolIncentiveTokens = await this.getVotingBribeRewardTokens(lockId);
|
|
7523
|
+
const incentiveTokens = [];
|
|
7524
|
+
poolIncentiveTokens.forEach((value, key) => {
|
|
7525
|
+
incentiveTokens.push(...value);
|
|
7526
|
+
});
|
|
7527
|
+
const poolIncentiveRewards = await this.getPoolIncentiveRewrads(incentiveTokens, lockId);
|
|
7528
|
+
const votingRewards = /* @__PURE__ */ new Map();
|
|
7529
|
+
poolIncentiveRewards.forEach((value, coin) => {
|
|
7530
|
+
value.forEach((amount, pool) => {
|
|
7531
|
+
if (!votingRewards.has(pool)) {
|
|
7532
|
+
votingRewards.set(pool, []);
|
|
7533
|
+
}
|
|
7534
|
+
votingRewards.get(pool)?.push({
|
|
7535
|
+
kind: "incentiveCoin" /* Incentive */,
|
|
7536
|
+
token_addr: coin,
|
|
7537
|
+
amount: amount.toString()
|
|
7538
|
+
});
|
|
7539
|
+
});
|
|
7540
|
+
});
|
|
7541
|
+
if (lockObj.error != null || lockObj.data?.content?.dataType !== "moveObject") {
|
|
7542
|
+
throw new ClmmpoolsError(
|
|
7543
|
+
`getPool error code: ${lockObj.error?.code ?? "unknown error"}, please check config and object id`,
|
|
7544
|
+
"InvalidLockObject" /* InvalidLockObject */
|
|
7545
|
+
);
|
|
7546
|
+
}
|
|
7547
|
+
const fields = getObjectFields(lockObj);
|
|
7548
|
+
const lockInfo = {
|
|
7549
|
+
lock_id: lockId,
|
|
7550
|
+
amount: fields.amount,
|
|
7551
|
+
start: fields.start,
|
|
7552
|
+
end: fields.end,
|
|
7553
|
+
permanent: fields.permanent,
|
|
7554
|
+
rebase_amount: {
|
|
7555
|
+
kind: "rebaseCoin" /* RebaseCoin */,
|
|
7556
|
+
token_addr: magma_token,
|
|
7557
|
+
amount: aLockSummary.reward_distributor_claimable
|
|
7558
|
+
},
|
|
7559
|
+
voting_power: aLockSummary.voting_power,
|
|
7560
|
+
voting_rewards: votingRewards
|
|
7561
|
+
};
|
|
7562
|
+
return lockInfo;
|
|
7563
|
+
}
|
|
7456
7564
|
async aLockSummary(lock_id) {
|
|
7457
7565
|
const tx = new import_transactions9.Transaction();
|
|
7458
7566
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -8803,6 +8911,7 @@ var ConfigModule = class {
|
|
|
8803
8911
|
voter_id: "",
|
|
8804
8912
|
minter_id: "",
|
|
8805
8913
|
reward_distributor_id: "",
|
|
8914
|
+
distribution_cfg: "",
|
|
8806
8915
|
magma_token: "",
|
|
8807
8916
|
voting_escrow_id: ""
|
|
8808
8917
|
};
|
|
@@ -9354,11 +9463,12 @@ var SDKConfig = {
|
|
|
9354
9463
|
launchpad_pools_handle: "0x5e194a8efcf653830daf85a85b52e3ae8f65dc39481d54b2382acda25068375c",
|
|
9355
9464
|
clmm_pools_handle: "0x37f60eb2d9d227949b95da8fea810db3c32d1e1fa8ed87434fc51664f87d83cb",
|
|
9356
9465
|
global_config_id: "0x4f32c00706e7bdbce532acdcfc0afd91b14defd5ffc9e2723a0ce7ed84f5d380",
|
|
9357
|
-
voter_id: "
|
|
9358
|
-
voting_escrow_id: "
|
|
9359
|
-
reward_distributor_id: "
|
|
9360
|
-
|
|
9361
|
-
|
|
9466
|
+
voter_id: "0xe8e0c266602404caa463f85bee4ccf6000c8c2566204a3949400a06857295ceb",
|
|
9467
|
+
voting_escrow_id: "0x143aab8c7c13c58a94d99ae281b4226f1877abc21bc01b9d75b58a7217fc3b2c",
|
|
9468
|
+
reward_distributor_id: "0x93bf24d3db08f93a02ba90abc7095f8d8086e5a1f72bac8bd866df21defe83ab",
|
|
9469
|
+
distribution_cfg: "0x94e23846c975e2faf89a61bfc2b10ad64decab9069eb1f9fc39752b010868c74",
|
|
9470
|
+
magma_token: "0x3abcdefce1a0ec1252237b69efc6dc3881325d543fceaad2e2f360a02d2f5bd9::magma_token::MAGMA_TOKEN",
|
|
9471
|
+
minter_id: "0x92877b638c3febf8576d0d7caebf9a2c43753b2e441669fb434e709458ece345"
|
|
9362
9472
|
}
|
|
9363
9473
|
};
|
|
9364
9474
|
var clmmMainnet = {
|
|
@@ -9377,12 +9487,12 @@ var clmmMainnet = {
|
|
|
9377
9487
|
config: SDKConfig.clmmConfig
|
|
9378
9488
|
},
|
|
9379
9489
|
distribution: {
|
|
9380
|
-
package_id: "
|
|
9381
|
-
published_at: "
|
|
9490
|
+
package_id: "0x3abcdefce1a0ec1252237b69efc6dc3881325d543fceaad2e2f360a02d2f5bd9",
|
|
9491
|
+
published_at: "0x3abcdefce1a0ec1252237b69efc6dc3881325d543fceaad2e2f360a02d2f5bd9"
|
|
9382
9492
|
},
|
|
9383
9493
|
integrate: {
|
|
9384
|
-
package_id: "
|
|
9385
|
-
published_at: "
|
|
9494
|
+
package_id: "0x6e3ae31a16362c563c0fef5293348d262646882a10c307f20f6be8577960f1ef",
|
|
9495
|
+
published_at: "0x6e3ae31a16362c563c0fef5293348d262646882a10c307f20f6be8577960f1ef"
|
|
9386
9496
|
},
|
|
9387
9497
|
deepbook: {
|
|
9388
9498
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|
|
@@ -9426,6 +9536,7 @@ var SDKConfig2 = {
|
|
|
9426
9536
|
voter_id: "0x59571991a5c7041c4376d980061af5c7a6d8345006d6b5167bd1f00fc17b8ddb",
|
|
9427
9537
|
voting_escrow_id: "0x9081c8044719135da4ff2d52907fcd40c19e2a40750cbba4c1d6a59610ae1446",
|
|
9428
9538
|
reward_distributor_id: "0xdf213d8e0ca49c8f4a508e7d3b3a6983c4aafd639f7c99479fc75fb4451d752e",
|
|
9539
|
+
distribution_cfg: "0x94e23846c975e2faf89a61bfc2b10ad64decab9069eb1f9fc39752b010868c74",
|
|
9429
9540
|
magma_token: "0x45ac2371c33ca0df8dc784d62c8ce5126d42edd8c56820396524dff2ae0619b1::magma_token::MAGMA_TOKEN",
|
|
9430
9541
|
minter_id: "0x89435d6b2a510ba50ca23303f10e91ec058f138a88f69a43fe03cd22edb214c5"
|
|
9431
9542
|
}
|