@magmaprotocol/magma-clmm-sdk 0.5.40 → 0.5.42
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 +79 -1
- package/dist/index.js +272 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +272 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3549,9 +3549,9 @@ type FetchBinsParams = {
|
|
|
3549
3549
|
};
|
|
3550
3550
|
type GetPositionLiquidityParams = {
|
|
3551
3551
|
pair: string;
|
|
3552
|
+
positionId: string;
|
|
3552
3553
|
coinTypeA: string;
|
|
3553
3554
|
coinTypeB: string;
|
|
3554
|
-
positionId: string;
|
|
3555
3555
|
};
|
|
3556
3556
|
type GetPairLiquidityParams = {
|
|
3557
3557
|
pair: string;
|
|
@@ -3616,6 +3616,72 @@ type DlmmPoolInfo = {
|
|
|
3616
3616
|
base_fee: number;
|
|
3617
3617
|
active_index: number;
|
|
3618
3618
|
};
|
|
3619
|
+
type DlmmAddLiquidityParams = {
|
|
3620
|
+
pool_id: string;
|
|
3621
|
+
coin_a: string;
|
|
3622
|
+
coin_b: string;
|
|
3623
|
+
position_id: string;
|
|
3624
|
+
amounts_a: number[];
|
|
3625
|
+
amounts_b: number[];
|
|
3626
|
+
receiver: string;
|
|
3627
|
+
rewards_token: string[];
|
|
3628
|
+
};
|
|
3629
|
+
type DlmmBurnPositionParams = {
|
|
3630
|
+
pool_id: string;
|
|
3631
|
+
position_id: string;
|
|
3632
|
+
coin_a: string;
|
|
3633
|
+
coin_b: string;
|
|
3634
|
+
rewards_token: string[];
|
|
3635
|
+
};
|
|
3636
|
+
type DlmmShrinkPosition = {
|
|
3637
|
+
pool_id: string;
|
|
3638
|
+
position_id: string;
|
|
3639
|
+
coin_a: string;
|
|
3640
|
+
coin_b: string;
|
|
3641
|
+
delta_percentage: number;
|
|
3642
|
+
rewards_token: string[];
|
|
3643
|
+
};
|
|
3644
|
+
type DlmmCollectRewardParams = {
|
|
3645
|
+
pool_id: string;
|
|
3646
|
+
coin_a: string;
|
|
3647
|
+
coin_b: string;
|
|
3648
|
+
position_id: string;
|
|
3649
|
+
rewards_token: string[];
|
|
3650
|
+
};
|
|
3651
|
+
type DlmmCollectFeeParams = {
|
|
3652
|
+
pool_id: string;
|
|
3653
|
+
coin_a: string;
|
|
3654
|
+
coin_b: string;
|
|
3655
|
+
position_id: string;
|
|
3656
|
+
};
|
|
3657
|
+
type DlmmRewardsParams = {
|
|
3658
|
+
pool_id: string;
|
|
3659
|
+
position_id: string;
|
|
3660
|
+
coin_a: string;
|
|
3661
|
+
coin_b: string;
|
|
3662
|
+
rewards_token: string[];
|
|
3663
|
+
};
|
|
3664
|
+
type DlmmEventEarnedFees = {
|
|
3665
|
+
position_id: string;
|
|
3666
|
+
x: string;
|
|
3667
|
+
y: string;
|
|
3668
|
+
fee_x: number;
|
|
3669
|
+
fee_y: number;
|
|
3670
|
+
};
|
|
3671
|
+
type DlmmEventEarnedRewards = {
|
|
3672
|
+
position_id: string;
|
|
3673
|
+
reward: string[];
|
|
3674
|
+
amount: number[];
|
|
3675
|
+
};
|
|
3676
|
+
type GetPairRewarderParams = {
|
|
3677
|
+
pool_id: string;
|
|
3678
|
+
coin_a: string;
|
|
3679
|
+
coin_b: string;
|
|
3680
|
+
};
|
|
3681
|
+
type DlmmEventPairRewardTypes = {
|
|
3682
|
+
pair_id: string;
|
|
3683
|
+
tokens: string[];
|
|
3684
|
+
};
|
|
3619
3685
|
|
|
3620
3686
|
declare class DlmmModule implements IModule {
|
|
3621
3687
|
protected _sdk: MagmaClmmSDK;
|
|
@@ -3628,10 +3694,22 @@ declare class DlmmModule implements IModule {
|
|
|
3628
3694
|
createAddLiquidityPayload(): Promise<Transaction>;
|
|
3629
3695
|
mintPercent(params: MintPercentParams): Promise<Transaction>;
|
|
3630
3696
|
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
3697
|
+
addLiquidity(params: DlmmAddLiquidityParams): Promise<Transaction>;
|
|
3698
|
+
private _raisePositionByAmounts;
|
|
3699
|
+
private _raisePositionByAmountsReward;
|
|
3700
|
+
burnPosition(params: DlmmBurnPositionParams): Promise<Transaction>;
|
|
3701
|
+
shrinkPosition(params: DlmmShrinkPosition): Promise<Transaction>;
|
|
3702
|
+
collectReward(params: DlmmCollectRewardParams): Promise<Transaction>;
|
|
3703
|
+
collectFees(params: DlmmCollectFeeParams): Promise<Transaction>;
|
|
3631
3704
|
swap(params: SwapParams): Promise<Transaction>;
|
|
3632
3705
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3633
3706
|
getPositionLiquidity(params: GetPositionLiquidityParams): Promise<EventPositionLiquidity>;
|
|
3634
3707
|
getPairLiquidity(params: GetPairLiquidityParams): Promise<EventPairLiquidity>;
|
|
3708
|
+
getEarnedFees(params: DlmmCollectFeeParams): Promise<DlmmEventEarnedFees>;
|
|
3709
|
+
getEarnedRewards(params: DlmmRewardsParams): Promise<DlmmEventEarnedRewards>;
|
|
3710
|
+
getPairRewarders(params: GetPairRewarderParams[]): Promise<Map<string, DlmmEventPairRewardTypes[]>>;
|
|
3711
|
+
private _getPairRewarders;
|
|
3712
|
+
private _parsePairRewarders;
|
|
3635
3713
|
}
|
|
3636
3714
|
|
|
3637
3715
|
/**
|
package/dist/index.js
CHANGED
|
@@ -10865,6 +10865,153 @@ var DlmmModule = class {
|
|
|
10865
10865
|
});
|
|
10866
10866
|
return tx;
|
|
10867
10867
|
}
|
|
10868
|
+
async addLiquidity(params) {
|
|
10869
|
+
if (params.rewards_token.length === 0) {
|
|
10870
|
+
return this._raisePositionByAmounts(params);
|
|
10871
|
+
}
|
|
10872
|
+
return this._raisePositionByAmountsReward(params);
|
|
10873
|
+
}
|
|
10874
|
+
async _raisePositionByAmounts(params) {
|
|
10875
|
+
const tx = new import_transactions12.Transaction();
|
|
10876
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10877
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10878
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10879
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
10880
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10881
|
+
const amountATotal = params.amounts_a.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10882
|
+
const amountBTotal = params.amounts_b.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10883
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coin_a, false, true);
|
|
10884
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coin_b, false, true);
|
|
10885
|
+
const args = [
|
|
10886
|
+
tx.object(params.pool_id),
|
|
10887
|
+
tx.object(dlmmConfig.factory),
|
|
10888
|
+
tx.object(params.position_id),
|
|
10889
|
+
primaryCoinAInputs.targetCoin,
|
|
10890
|
+
primaryCoinBInputs.targetCoin,
|
|
10891
|
+
tx.pure.vector("u64", params.amounts_a),
|
|
10892
|
+
tx.pure.vector("u64", params.amounts_b),
|
|
10893
|
+
tx.pure.address(params.receiver),
|
|
10894
|
+
tx.object(CLOCK_ADDRESS)
|
|
10895
|
+
];
|
|
10896
|
+
tx.moveCall({
|
|
10897
|
+
target: `${integrate.published_at}::${DlmmScript}::raise_position_by_amounts`,
|
|
10898
|
+
typeArguments,
|
|
10899
|
+
arguments: args
|
|
10900
|
+
});
|
|
10901
|
+
return tx;
|
|
10902
|
+
}
|
|
10903
|
+
async _raisePositionByAmountsReward(params) {
|
|
10904
|
+
const tx = new import_transactions12.Transaction();
|
|
10905
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10906
|
+
const { dlmm_pool, integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10907
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10908
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10909
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10910
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10911
|
+
const amountATotal = params.amounts_a.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10912
|
+
const amountBTotal = params.amounts_b.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10913
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coin_a, false, true);
|
|
10914
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coin_b, false, true);
|
|
10915
|
+
const args = [
|
|
10916
|
+
tx.object(params.pool_id),
|
|
10917
|
+
tx.object(dlmmConfig.factory),
|
|
10918
|
+
tx.object(clmmConfigs.global_vault_id),
|
|
10919
|
+
tx.object(params.position_id),
|
|
10920
|
+
primaryCoinAInputs.targetCoin,
|
|
10921
|
+
primaryCoinBInputs.targetCoin,
|
|
10922
|
+
tx.pure.vector("u64", params.amounts_a),
|
|
10923
|
+
tx.pure.vector("u64", params.amounts_b),
|
|
10924
|
+
tx.pure.address(params.receiver),
|
|
10925
|
+
tx.object(CLOCK_ADDRESS)
|
|
10926
|
+
];
|
|
10927
|
+
tx.moveCall({
|
|
10928
|
+
target: `${integrate.published_at}::${DlmmScript}::raise_position_by_amounts_reward${params.rewards_token.length}`,
|
|
10929
|
+
typeArguments,
|
|
10930
|
+
arguments: args
|
|
10931
|
+
});
|
|
10932
|
+
return tx;
|
|
10933
|
+
}
|
|
10934
|
+
async burnPosition(params) {
|
|
10935
|
+
const tx = new import_transactions12.Transaction();
|
|
10936
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10937
|
+
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10938
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10939
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10940
|
+
let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10941
|
+
let target = `${integrate.published_at}::${DlmmScript}::burn_position`;
|
|
10942
|
+
if (params.rewards_token.length > 0) {
|
|
10943
|
+
args = [tx.object(params.pool_id), tx.object(clmmConfigs.global_vault_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10944
|
+
target = `${integrate.published_at}::${DlmmScript}::burn_position_reward${params.rewards_token.length}`;
|
|
10945
|
+
}
|
|
10946
|
+
tx.moveCall({
|
|
10947
|
+
target,
|
|
10948
|
+
typeArguments,
|
|
10949
|
+
arguments: args
|
|
10950
|
+
});
|
|
10951
|
+
return tx;
|
|
10952
|
+
}
|
|
10953
|
+
async shrinkPosition(params) {
|
|
10954
|
+
const tx = new import_transactions12.Transaction();
|
|
10955
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10956
|
+
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10957
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10958
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10959
|
+
let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.pure.u64(params.delta_percentage), tx.object(CLOCK_ADDRESS)];
|
|
10960
|
+
let target = `${integrate.published_at}::${DlmmScript}::shrink_position`;
|
|
10961
|
+
if (params.rewards_token.length > 0) {
|
|
10962
|
+
args = [
|
|
10963
|
+
tx.object(params.pool_id),
|
|
10964
|
+
tx.object(clmmConfigs.global_vault_id),
|
|
10965
|
+
tx.object(params.position_id),
|
|
10966
|
+
tx.pure.u64(params.delta_percentage),
|
|
10967
|
+
tx.object(CLOCK_ADDRESS)
|
|
10968
|
+
];
|
|
10969
|
+
target = `${integrate.published_at}::${DlmmScript}::shrink_position_reward${params.rewards_token.length}`;
|
|
10970
|
+
}
|
|
10971
|
+
tx.moveCall({
|
|
10972
|
+
target,
|
|
10973
|
+
typeArguments,
|
|
10974
|
+
arguments: args
|
|
10975
|
+
});
|
|
10976
|
+
return tx;
|
|
10977
|
+
}
|
|
10978
|
+
async collectReward(params) {
|
|
10979
|
+
const tx = new import_transactions12.Transaction();
|
|
10980
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10981
|
+
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10982
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10983
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10984
|
+
const args = [
|
|
10985
|
+
tx.object(params.pool_id),
|
|
10986
|
+
tx.object(clmmConfigs.global_vault_id),
|
|
10987
|
+
tx.object(params.position_id),
|
|
10988
|
+
tx.object(CLOCK_ADDRESS)
|
|
10989
|
+
];
|
|
10990
|
+
let target = `${integrate.published_at}::${DlmmScript}::collect_reward`;
|
|
10991
|
+
if (params.rewards_token.length > 1) {
|
|
10992
|
+
target = `${integrate.published_at}::${DlmmScript}::collect_reward${params.rewards_token.length}`;
|
|
10993
|
+
}
|
|
10994
|
+
tx.moveCall({
|
|
10995
|
+
target,
|
|
10996
|
+
typeArguments,
|
|
10997
|
+
arguments: args
|
|
10998
|
+
});
|
|
10999
|
+
return tx;
|
|
11000
|
+
}
|
|
11001
|
+
async collectFees(params) {
|
|
11002
|
+
const tx = new import_transactions12.Transaction();
|
|
11003
|
+
tx.setSender(this.sdk.senderAddress);
|
|
11004
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
11005
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
11006
|
+
const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
11007
|
+
const target = `${integrate.published_at}::${DlmmScript}::collect_fees`;
|
|
11008
|
+
tx.moveCall({
|
|
11009
|
+
target,
|
|
11010
|
+
typeArguments,
|
|
11011
|
+
arguments: args
|
|
11012
|
+
});
|
|
11013
|
+
return tx;
|
|
11014
|
+
}
|
|
10868
11015
|
async swap(params) {
|
|
10869
11016
|
const tx = new import_transactions12.Transaction();
|
|
10870
11017
|
tx.setSender(this.sdk.senderAddress);
|
|
@@ -10906,9 +11053,11 @@ var DlmmModule = class {
|
|
|
10906
11053
|
if (simulateRes.error != null) {
|
|
10907
11054
|
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10908
11055
|
}
|
|
10909
|
-
|
|
11056
|
+
let res = [];
|
|
10910
11057
|
simulateRes.events?.forEach((item) => {
|
|
10911
11058
|
if (extractStructTagFromType(item.type).name === `EventFetchBins`) {
|
|
11059
|
+
const { bins } = item.parsedJson;
|
|
11060
|
+
res = bins;
|
|
10912
11061
|
}
|
|
10913
11062
|
});
|
|
10914
11063
|
return res;
|
|
@@ -10946,7 +11095,7 @@ var DlmmModule = class {
|
|
|
10946
11095
|
out.liquidity = item.parsedJson.liquidity;
|
|
10947
11096
|
out.x_equivalent = item.parsedJson.x_equivalent;
|
|
10948
11097
|
out.y_equivalent = item.parsedJson.y_equivalent;
|
|
10949
|
-
out.bin_ids = item.parsedJson.
|
|
11098
|
+
out.bin_ids = item.parsedJson.bin_ids;
|
|
10950
11099
|
out.bin_x_eq = item.parsedJson.bin_x_eq;
|
|
10951
11100
|
out.bin_y_eq = item.parsedJson.bin_y_eq;
|
|
10952
11101
|
out.bin_liquidity = item.parsedJson.bin_liquidity;
|
|
@@ -10993,6 +11142,127 @@ var DlmmModule = class {
|
|
|
10993
11142
|
});
|
|
10994
11143
|
return out;
|
|
10995
11144
|
}
|
|
11145
|
+
async getEarnedFees(params) {
|
|
11146
|
+
const tx = new import_transactions12.Transaction();
|
|
11147
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11148
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
11149
|
+
const args = [tx.object(params.pool_id), tx.object(params.position_id)];
|
|
11150
|
+
tx.moveCall({
|
|
11151
|
+
target: `${integrate.published_at}::${DlmmScript}::earned_fees`,
|
|
11152
|
+
arguments: args,
|
|
11153
|
+
typeArguments
|
|
11154
|
+
});
|
|
11155
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11156
|
+
transactionBlock: tx,
|
|
11157
|
+
sender: simulationAccount.address
|
|
11158
|
+
});
|
|
11159
|
+
const out = {
|
|
11160
|
+
position_id: "",
|
|
11161
|
+
x: "",
|
|
11162
|
+
y: "",
|
|
11163
|
+
fee_x: 0,
|
|
11164
|
+
fee_y: 0
|
|
11165
|
+
};
|
|
11166
|
+
if (simulateRes.error != null) {
|
|
11167
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11168
|
+
}
|
|
11169
|
+
simulateRes.events?.forEach((item) => {
|
|
11170
|
+
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
11171
|
+
out.position_id = item.parsedJson.position_id;
|
|
11172
|
+
out.x = item.parsedJson.x;
|
|
11173
|
+
out.y = item.parsedJson.y;
|
|
11174
|
+
out.fee_x = item.parsedJson.fee_x;
|
|
11175
|
+
out.fee_y = item.parsedJson.fee_y;
|
|
11176
|
+
}
|
|
11177
|
+
});
|
|
11178
|
+
return out;
|
|
11179
|
+
}
|
|
11180
|
+
async getEarnedRewards(params) {
|
|
11181
|
+
const tx = new import_transactions12.Transaction();
|
|
11182
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11183
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
11184
|
+
const args = [tx.object(params.pool_id), tx.object(params.position_id)];
|
|
11185
|
+
let target = `${integrate.published_at}::${DlmmScript}::earned_rewards`;
|
|
11186
|
+
if (params.rewards_token.length > 1) {
|
|
11187
|
+
target = `${integrate.published_at}::${DlmmScript}::earned_rewards${params.rewards_token.length}`;
|
|
11188
|
+
}
|
|
11189
|
+
tx.moveCall({
|
|
11190
|
+
target,
|
|
11191
|
+
arguments: args,
|
|
11192
|
+
typeArguments
|
|
11193
|
+
});
|
|
11194
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11195
|
+
transactionBlock: tx,
|
|
11196
|
+
sender: simulationAccount.address
|
|
11197
|
+
});
|
|
11198
|
+
const out = {
|
|
11199
|
+
position_id: "",
|
|
11200
|
+
reward: [],
|
|
11201
|
+
amount: []
|
|
11202
|
+
};
|
|
11203
|
+
if (simulateRes.error != null) {
|
|
11204
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11205
|
+
}
|
|
11206
|
+
simulateRes.events?.forEach((item) => {
|
|
11207
|
+
if (extractStructTagFromType(item.type).name === `DlmmEventEarnedRewards`) {
|
|
11208
|
+
out.position_id = item.parsedJson.position_id;
|
|
11209
|
+
out.reward = [item.parsedJson.reward];
|
|
11210
|
+
out.amount = [item.parsedJson.amount];
|
|
11211
|
+
} else if (extractStructTagFromType(item.type).name === `DlmmEventEarnedRewards2`) {
|
|
11212
|
+
out.position_id = item.parsedJson.position_id;
|
|
11213
|
+
out.reward = [item.parsedJson.reward1, item.parsedJson.reward2];
|
|
11214
|
+
out.amount = [item.parsedJson.amount1, item.parsedJson.amount2];
|
|
11215
|
+
} else if (extractStructTagFromType(item.type).name === `EventEarnedRewards3`) {
|
|
11216
|
+
out.position_id = item.parsedJson.position_id;
|
|
11217
|
+
out.reward = [item.parsedJson.reward1, item.parsedJson.reward2, item.parsedJson.reward3];
|
|
11218
|
+
out.amount = [item.parsedJson.amount1, item.parsedJson.amount2, item.parsedJson.amount3];
|
|
11219
|
+
}
|
|
11220
|
+
});
|
|
11221
|
+
return out;
|
|
11222
|
+
}
|
|
11223
|
+
async getPairRewarders(params) {
|
|
11224
|
+
let tx = new import_transactions12.Transaction();
|
|
11225
|
+
for (const param of params) {
|
|
11226
|
+
tx = await this._getPairRewarders(param, tx);
|
|
11227
|
+
}
|
|
11228
|
+
return this._parsePairRewarders(tx);
|
|
11229
|
+
}
|
|
11230
|
+
async _getPairRewarders(params, tx) {
|
|
11231
|
+
tx = tx || new import_transactions12.Transaction();
|
|
11232
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
11233
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
11234
|
+
const args = [tx.object(params.pool_id)];
|
|
11235
|
+
tx.moveCall({
|
|
11236
|
+
target: `${integrate.published_at}::${DlmmScript}::get_pair_rewarders`,
|
|
11237
|
+
arguments: args,
|
|
11238
|
+
typeArguments
|
|
11239
|
+
});
|
|
11240
|
+
return tx;
|
|
11241
|
+
}
|
|
11242
|
+
async _parsePairRewarders(tx) {
|
|
11243
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
11244
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11245
|
+
transactionBlock: tx,
|
|
11246
|
+
sender: simulationAccount.address
|
|
11247
|
+
});
|
|
11248
|
+
const out = /* @__PURE__ */ new Map();
|
|
11249
|
+
if (simulateRes.error != null) {
|
|
11250
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11251
|
+
}
|
|
11252
|
+
simulateRes.events?.forEach((item) => {
|
|
11253
|
+
if (extractStructTagFromType(item.type).name === `EventPairRewardTypes`) {
|
|
11254
|
+
const pairRewards = {
|
|
11255
|
+
pair_id: "",
|
|
11256
|
+
tokens: []
|
|
11257
|
+
};
|
|
11258
|
+
pairRewards.pair_id = item.parsedJson.pair_id;
|
|
11259
|
+
item.parsedJson.tokens.contents.forEach((token) => {
|
|
11260
|
+
pairRewards.tokens.push(token.name);
|
|
11261
|
+
});
|
|
11262
|
+
}
|
|
11263
|
+
});
|
|
11264
|
+
return out;
|
|
11265
|
+
}
|
|
10996
11266
|
};
|
|
10997
11267
|
|
|
10998
11268
|
// src/sdk.ts
|