@magmaprotocol/magma-clmm-sdk 0.5.40 → 0.5.41
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 +80 -1
- package/dist/index.js +292 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +292 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3493,6 +3493,7 @@ declare class GaugeModule implements IModule {
|
|
|
3493
3493
|
getEmissions(): Promise<EpochEmission>;
|
|
3494
3494
|
getRewardByPosition(params: GetRewardByPosition): Promise<Transaction>;
|
|
3495
3495
|
getAllRewardByPositions(paramsList: GetRewardByPosition[]): Promise<Transaction>;
|
|
3496
|
+
testTeacherCap(): Promise<Transaction>;
|
|
3496
3497
|
getEpochRewardByPool(pool: string, incentive_tokens: string[]): Promise<Map<string, string>>;
|
|
3497
3498
|
}
|
|
3498
3499
|
|
|
@@ -3549,9 +3550,9 @@ type FetchBinsParams = {
|
|
|
3549
3550
|
};
|
|
3550
3551
|
type GetPositionLiquidityParams = {
|
|
3551
3552
|
pair: string;
|
|
3553
|
+
positionId: string;
|
|
3552
3554
|
coinTypeA: string;
|
|
3553
3555
|
coinTypeB: string;
|
|
3554
|
-
positionId: string;
|
|
3555
3556
|
};
|
|
3556
3557
|
type GetPairLiquidityParams = {
|
|
3557
3558
|
pair: string;
|
|
@@ -3616,6 +3617,72 @@ type DlmmPoolInfo = {
|
|
|
3616
3617
|
base_fee: number;
|
|
3617
3618
|
active_index: number;
|
|
3618
3619
|
};
|
|
3620
|
+
type DlmmAddLiquidityParams = {
|
|
3621
|
+
pool_id: string;
|
|
3622
|
+
coin_a: string;
|
|
3623
|
+
coin_b: string;
|
|
3624
|
+
position_id: string;
|
|
3625
|
+
amounts_a: number[];
|
|
3626
|
+
amounts_b: number[];
|
|
3627
|
+
receiver: string;
|
|
3628
|
+
rewards_token: string[];
|
|
3629
|
+
};
|
|
3630
|
+
type DlmmBurnPositionParams = {
|
|
3631
|
+
pool_id: string;
|
|
3632
|
+
position_id: string;
|
|
3633
|
+
coin_a: string;
|
|
3634
|
+
coin_b: string;
|
|
3635
|
+
rewards_token: string[];
|
|
3636
|
+
};
|
|
3637
|
+
type DlmmShrinkPosition = {
|
|
3638
|
+
pool_id: string;
|
|
3639
|
+
position_id: string;
|
|
3640
|
+
coin_a: string;
|
|
3641
|
+
coin_b: string;
|
|
3642
|
+
delta_percentage: number;
|
|
3643
|
+
rewards_token: string[];
|
|
3644
|
+
};
|
|
3645
|
+
type DlmmCollectRewardParams = {
|
|
3646
|
+
pool_id: string;
|
|
3647
|
+
coin_a: string;
|
|
3648
|
+
coin_b: string;
|
|
3649
|
+
position_id: string;
|
|
3650
|
+
rewards_token: string[];
|
|
3651
|
+
};
|
|
3652
|
+
type DlmmCollectFeeParams = {
|
|
3653
|
+
pool_id: string;
|
|
3654
|
+
coin_a: string;
|
|
3655
|
+
coin_b: string;
|
|
3656
|
+
position_id: string;
|
|
3657
|
+
};
|
|
3658
|
+
type DlmmRewardsParams = {
|
|
3659
|
+
pool_id: string;
|
|
3660
|
+
position_id: string;
|
|
3661
|
+
coin_a: string;
|
|
3662
|
+
coin_b: string;
|
|
3663
|
+
rewards_token: string[];
|
|
3664
|
+
};
|
|
3665
|
+
type DlmmEventEarnedFees = {
|
|
3666
|
+
position_id: string;
|
|
3667
|
+
x: string;
|
|
3668
|
+
y: string;
|
|
3669
|
+
fee_x: number;
|
|
3670
|
+
fee_y: number;
|
|
3671
|
+
};
|
|
3672
|
+
type DlmmEventEarnedRewards = {
|
|
3673
|
+
position_id: string;
|
|
3674
|
+
reward: string[];
|
|
3675
|
+
amount: number[];
|
|
3676
|
+
};
|
|
3677
|
+
type GetPairRewarderParams = {
|
|
3678
|
+
pool_id: string;
|
|
3679
|
+
coin_a: string;
|
|
3680
|
+
coin_b: string;
|
|
3681
|
+
};
|
|
3682
|
+
type DlmmEventPairRewardTypes = {
|
|
3683
|
+
pair_id: string;
|
|
3684
|
+
tokens: string[];
|
|
3685
|
+
};
|
|
3619
3686
|
|
|
3620
3687
|
declare class DlmmModule implements IModule {
|
|
3621
3688
|
protected _sdk: MagmaClmmSDK;
|
|
@@ -3628,10 +3695,22 @@ declare class DlmmModule implements IModule {
|
|
|
3628
3695
|
createAddLiquidityPayload(): Promise<Transaction>;
|
|
3629
3696
|
mintPercent(params: MintPercentParams): Promise<Transaction>;
|
|
3630
3697
|
createPositionByAmount(params: MintAmountParams): Promise<Transaction>;
|
|
3698
|
+
addLiquidity(params: DlmmAddLiquidityParams): Promise<Transaction>;
|
|
3699
|
+
private _raisePositionByAmounts;
|
|
3700
|
+
private _raisePositionByAmountsReward;
|
|
3701
|
+
burnPosition(params: DlmmBurnPositionParams): Promise<Transaction>;
|
|
3702
|
+
shrinkPosition(params: DlmmShrinkPosition): Promise<Transaction>;
|
|
3703
|
+
collectReward(params: DlmmCollectRewardParams): Promise<Transaction>;
|
|
3704
|
+
collectFees(params: DlmmCollectFeeParams): Promise<Transaction>;
|
|
3631
3705
|
swap(params: SwapParams): Promise<Transaction>;
|
|
3632
3706
|
fetchBins(params: FetchBinsParams): Promise<EventBin[]>;
|
|
3633
3707
|
getPositionLiquidity(params: GetPositionLiquidityParams): Promise<EventPositionLiquidity>;
|
|
3634
3708
|
getPairLiquidity(params: GetPairLiquidityParams): Promise<EventPairLiquidity>;
|
|
3709
|
+
getEarnedFees(params: DlmmCollectFeeParams): Promise<DlmmEventEarnedFees>;
|
|
3710
|
+
getEarnedRewards(params: DlmmRewardsParams): Promise<DlmmEventEarnedRewards>;
|
|
3711
|
+
getPairRewarders(params: GetPairRewarderParams[]): Promise<Map<string, DlmmEventPairRewardTypes[]>>;
|
|
3712
|
+
private _getPairRewarders;
|
|
3713
|
+
private _parsePairRewarders;
|
|
3635
3714
|
}
|
|
3636
3715
|
|
|
3637
3716
|
/**
|
package/dist/index.js
CHANGED
|
@@ -10672,6 +10672,20 @@ var GaugeModule = class {
|
|
|
10672
10672
|
});
|
|
10673
10673
|
return tx;
|
|
10674
10674
|
}
|
|
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
|
+
}
|
|
10675
10689
|
async getEpochRewardByPool(pool, incentive_tokens) {
|
|
10676
10690
|
const tx = new import_transactions11.Transaction();
|
|
10677
10691
|
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
@@ -10865,6 +10879,153 @@ var DlmmModule = class {
|
|
|
10865
10879
|
});
|
|
10866
10880
|
return tx;
|
|
10867
10881
|
}
|
|
10882
|
+
async addLiquidity(params) {
|
|
10883
|
+
if (params.rewards_token.length === 0) {
|
|
10884
|
+
return this._raisePositionByAmounts(params);
|
|
10885
|
+
}
|
|
10886
|
+
return this._raisePositionByAmountsReward(params);
|
|
10887
|
+
}
|
|
10888
|
+
async _raisePositionByAmounts(params) {
|
|
10889
|
+
const tx = new import_transactions12.Transaction();
|
|
10890
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10891
|
+
const { dlmm_pool, integrate } = this.sdk.sdkOptions;
|
|
10892
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10893
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
10894
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10895
|
+
const amountATotal = params.amounts_a.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10896
|
+
const amountBTotal = params.amounts_b.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10897
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coin_a, false, true);
|
|
10898
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coin_b, false, true);
|
|
10899
|
+
const args = [
|
|
10900
|
+
tx.object(params.pool_id),
|
|
10901
|
+
tx.object(dlmmConfig.factory),
|
|
10902
|
+
tx.object(params.position_id),
|
|
10903
|
+
primaryCoinAInputs.targetCoin,
|
|
10904
|
+
primaryCoinBInputs.targetCoin,
|
|
10905
|
+
tx.pure.vector("u64", params.amounts_a),
|
|
10906
|
+
tx.pure.vector("u64", params.amounts_b),
|
|
10907
|
+
tx.pure.address(params.receiver),
|
|
10908
|
+
tx.object(CLOCK_ADDRESS)
|
|
10909
|
+
];
|
|
10910
|
+
tx.moveCall({
|
|
10911
|
+
target: `${integrate.published_at}::${DlmmScript}::raise_position_by_amounts`,
|
|
10912
|
+
typeArguments,
|
|
10913
|
+
arguments: args
|
|
10914
|
+
});
|
|
10915
|
+
return tx;
|
|
10916
|
+
}
|
|
10917
|
+
async _raisePositionByAmountsReward(params) {
|
|
10918
|
+
const tx = new import_transactions12.Transaction();
|
|
10919
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10920
|
+
const { dlmm_pool, integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10921
|
+
const dlmmConfig = getPackagerConfigs(dlmm_pool);
|
|
10922
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10923
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10924
|
+
const allCoins = await this._sdk.getOwnerCoinAssets(this._sdk.senderAddress);
|
|
10925
|
+
const amountATotal = params.amounts_a.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10926
|
+
const amountBTotal = params.amounts_b.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
|
|
10927
|
+
const primaryCoinAInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountATotal), params.coin_a, false, true);
|
|
10928
|
+
const primaryCoinBInputs = TransactionUtil.buildCoinForAmount(tx, allCoins, BigInt(amountBTotal), params.coin_b, false, true);
|
|
10929
|
+
const args = [
|
|
10930
|
+
tx.object(params.pool_id),
|
|
10931
|
+
tx.object(dlmmConfig.factory),
|
|
10932
|
+
tx.object(clmmConfigs.global_vault_id),
|
|
10933
|
+
tx.object(params.position_id),
|
|
10934
|
+
primaryCoinAInputs.targetCoin,
|
|
10935
|
+
primaryCoinBInputs.targetCoin,
|
|
10936
|
+
tx.pure.vector("u64", params.amounts_a),
|
|
10937
|
+
tx.pure.vector("u64", params.amounts_b),
|
|
10938
|
+
tx.pure.address(params.receiver),
|
|
10939
|
+
tx.object(CLOCK_ADDRESS)
|
|
10940
|
+
];
|
|
10941
|
+
tx.moveCall({
|
|
10942
|
+
target: `${integrate.published_at}::${DlmmScript}::raise_position_by_amounts_reward${params.rewards_token.length}`,
|
|
10943
|
+
typeArguments,
|
|
10944
|
+
arguments: args
|
|
10945
|
+
});
|
|
10946
|
+
return tx;
|
|
10947
|
+
}
|
|
10948
|
+
async burnPosition(params) {
|
|
10949
|
+
const tx = new import_transactions12.Transaction();
|
|
10950
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10951
|
+
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10952
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10953
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10954
|
+
let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10955
|
+
let target = `${integrate.published_at}::${DlmmScript}::burn_position`;
|
|
10956
|
+
if (params.rewards_token.length > 0) {
|
|
10957
|
+
args = [tx.object(params.pool_id), tx.object(clmmConfigs.global_vault_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
10958
|
+
target = `${integrate.published_at}::${DlmmScript}::burn_position_reward${params.rewards_token.length}`;
|
|
10959
|
+
}
|
|
10960
|
+
tx.moveCall({
|
|
10961
|
+
target,
|
|
10962
|
+
typeArguments,
|
|
10963
|
+
arguments: args
|
|
10964
|
+
});
|
|
10965
|
+
return tx;
|
|
10966
|
+
}
|
|
10967
|
+
async shrinkPosition(params) {
|
|
10968
|
+
const tx = new import_transactions12.Transaction();
|
|
10969
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10970
|
+
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10971
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10972
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10973
|
+
let args = [tx.object(params.pool_id), tx.object(params.position_id), tx.pure.u64(params.delta_percentage), tx.object(CLOCK_ADDRESS)];
|
|
10974
|
+
let target = `${integrate.published_at}::${DlmmScript}::shrink_position`;
|
|
10975
|
+
if (params.rewards_token.length > 0) {
|
|
10976
|
+
args = [
|
|
10977
|
+
tx.object(params.pool_id),
|
|
10978
|
+
tx.object(clmmConfigs.global_vault_id),
|
|
10979
|
+
tx.object(params.position_id),
|
|
10980
|
+
tx.pure.u64(params.delta_percentage),
|
|
10981
|
+
tx.object(CLOCK_ADDRESS)
|
|
10982
|
+
];
|
|
10983
|
+
target = `${integrate.published_at}::${DlmmScript}::shrink_position_reward${params.rewards_token.length}`;
|
|
10984
|
+
}
|
|
10985
|
+
tx.moveCall({
|
|
10986
|
+
target,
|
|
10987
|
+
typeArguments,
|
|
10988
|
+
arguments: args
|
|
10989
|
+
});
|
|
10990
|
+
return tx;
|
|
10991
|
+
}
|
|
10992
|
+
async collectReward(params) {
|
|
10993
|
+
const tx = new import_transactions12.Transaction();
|
|
10994
|
+
tx.setSender(this.sdk.senderAddress);
|
|
10995
|
+
const { integrate, clmm_pool } = this.sdk.sdkOptions;
|
|
10996
|
+
const clmmConfigs = getPackagerConfigs(clmm_pool);
|
|
10997
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
10998
|
+
const args = [
|
|
10999
|
+
tx.object(params.pool_id),
|
|
11000
|
+
tx.object(clmmConfigs.global_vault_id),
|
|
11001
|
+
tx.object(params.position_id),
|
|
11002
|
+
tx.object(CLOCK_ADDRESS)
|
|
11003
|
+
];
|
|
11004
|
+
let target = `${integrate.published_at}::${DlmmScript}::collect_reward`;
|
|
11005
|
+
if (params.rewards_token.length > 1) {
|
|
11006
|
+
target = `${integrate.published_at}::${DlmmScript}::collect_reward${params.rewards_token.length}`;
|
|
11007
|
+
}
|
|
11008
|
+
tx.moveCall({
|
|
11009
|
+
target,
|
|
11010
|
+
typeArguments,
|
|
11011
|
+
arguments: args
|
|
11012
|
+
});
|
|
11013
|
+
return tx;
|
|
11014
|
+
}
|
|
11015
|
+
async collectFees(params) {
|
|
11016
|
+
const tx = new import_transactions12.Transaction();
|
|
11017
|
+
tx.setSender(this.sdk.senderAddress);
|
|
11018
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
11019
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
11020
|
+
const args = [tx.object(params.pool_id), tx.object(params.position_id), tx.object(CLOCK_ADDRESS)];
|
|
11021
|
+
const target = `${integrate.published_at}::${DlmmScript}::collect_fees`;
|
|
11022
|
+
tx.moveCall({
|
|
11023
|
+
target,
|
|
11024
|
+
typeArguments,
|
|
11025
|
+
arguments: args
|
|
11026
|
+
});
|
|
11027
|
+
return tx;
|
|
11028
|
+
}
|
|
10868
11029
|
async swap(params) {
|
|
10869
11030
|
const tx = new import_transactions12.Transaction();
|
|
10870
11031
|
tx.setSender(this.sdk.senderAddress);
|
|
@@ -10906,9 +11067,11 @@ var DlmmModule = class {
|
|
|
10906
11067
|
if (simulateRes.error != null) {
|
|
10907
11068
|
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
10908
11069
|
}
|
|
10909
|
-
|
|
11070
|
+
let res = [];
|
|
10910
11071
|
simulateRes.events?.forEach((item) => {
|
|
10911
11072
|
if (extractStructTagFromType(item.type).name === `EventFetchBins`) {
|
|
11073
|
+
const { bins } = item.parsedJson;
|
|
11074
|
+
res = bins;
|
|
10912
11075
|
}
|
|
10913
11076
|
});
|
|
10914
11077
|
return res;
|
|
@@ -10946,7 +11109,7 @@ var DlmmModule = class {
|
|
|
10946
11109
|
out.liquidity = item.parsedJson.liquidity;
|
|
10947
11110
|
out.x_equivalent = item.parsedJson.x_equivalent;
|
|
10948
11111
|
out.y_equivalent = item.parsedJson.y_equivalent;
|
|
10949
|
-
out.bin_ids = item.parsedJson.
|
|
11112
|
+
out.bin_ids = item.parsedJson.bin_ids;
|
|
10950
11113
|
out.bin_x_eq = item.parsedJson.bin_x_eq;
|
|
10951
11114
|
out.bin_y_eq = item.parsedJson.bin_y_eq;
|
|
10952
11115
|
out.bin_liquidity = item.parsedJson.bin_liquidity;
|
|
@@ -10993,6 +11156,127 @@ var DlmmModule = class {
|
|
|
10993
11156
|
});
|
|
10994
11157
|
return out;
|
|
10995
11158
|
}
|
|
11159
|
+
async getEarnedFees(params) {
|
|
11160
|
+
const tx = new import_transactions12.Transaction();
|
|
11161
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11162
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
11163
|
+
const args = [tx.object(params.pool_id), tx.object(params.position_id)];
|
|
11164
|
+
tx.moveCall({
|
|
11165
|
+
target: `${integrate.published_at}::${DlmmScript}::earned_fees`,
|
|
11166
|
+
arguments: args,
|
|
11167
|
+
typeArguments
|
|
11168
|
+
});
|
|
11169
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11170
|
+
transactionBlock: tx,
|
|
11171
|
+
sender: simulationAccount.address
|
|
11172
|
+
});
|
|
11173
|
+
const out = {
|
|
11174
|
+
position_id: "",
|
|
11175
|
+
x: "",
|
|
11176
|
+
y: "",
|
|
11177
|
+
fee_x: 0,
|
|
11178
|
+
fee_y: 0
|
|
11179
|
+
};
|
|
11180
|
+
if (simulateRes.error != null) {
|
|
11181
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11182
|
+
}
|
|
11183
|
+
simulateRes.events?.forEach((item) => {
|
|
11184
|
+
if (extractStructTagFromType(item.type).name === `EventPositionLiquidity`) {
|
|
11185
|
+
out.position_id = item.parsedJson.position_id;
|
|
11186
|
+
out.x = item.parsedJson.x;
|
|
11187
|
+
out.y = item.parsedJson.y;
|
|
11188
|
+
out.fee_x = item.parsedJson.fee_x;
|
|
11189
|
+
out.fee_y = item.parsedJson.fee_y;
|
|
11190
|
+
}
|
|
11191
|
+
});
|
|
11192
|
+
return out;
|
|
11193
|
+
}
|
|
11194
|
+
async getEarnedRewards(params) {
|
|
11195
|
+
const tx = new import_transactions12.Transaction();
|
|
11196
|
+
const { integrate, simulationAccount } = this.sdk.sdkOptions;
|
|
11197
|
+
const typeArguments = [params.coin_a, params.coin_b, ...params.rewards_token];
|
|
11198
|
+
const args = [tx.object(params.pool_id), tx.object(params.position_id)];
|
|
11199
|
+
let target = `${integrate.published_at}::${DlmmScript}::earned_rewards`;
|
|
11200
|
+
if (params.rewards_token.length > 1) {
|
|
11201
|
+
target = `${integrate.published_at}::${DlmmScript}::earned_rewards${params.rewards_token.length}`;
|
|
11202
|
+
}
|
|
11203
|
+
tx.moveCall({
|
|
11204
|
+
target,
|
|
11205
|
+
arguments: args,
|
|
11206
|
+
typeArguments
|
|
11207
|
+
});
|
|
11208
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11209
|
+
transactionBlock: tx,
|
|
11210
|
+
sender: simulationAccount.address
|
|
11211
|
+
});
|
|
11212
|
+
const out = {
|
|
11213
|
+
position_id: "",
|
|
11214
|
+
reward: [],
|
|
11215
|
+
amount: []
|
|
11216
|
+
};
|
|
11217
|
+
if (simulateRes.error != null) {
|
|
11218
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11219
|
+
}
|
|
11220
|
+
simulateRes.events?.forEach((item) => {
|
|
11221
|
+
if (extractStructTagFromType(item.type).name === `DlmmEventEarnedRewards`) {
|
|
11222
|
+
out.position_id = item.parsedJson.position_id;
|
|
11223
|
+
out.reward = [item.parsedJson.reward];
|
|
11224
|
+
out.amount = [item.parsedJson.amount];
|
|
11225
|
+
} else if (extractStructTagFromType(item.type).name === `DlmmEventEarnedRewards2`) {
|
|
11226
|
+
out.position_id = item.parsedJson.position_id;
|
|
11227
|
+
out.reward = [item.parsedJson.reward1, item.parsedJson.reward2];
|
|
11228
|
+
out.amount = [item.parsedJson.amount1, item.parsedJson.amount2];
|
|
11229
|
+
} else if (extractStructTagFromType(item.type).name === `EventEarnedRewards3`) {
|
|
11230
|
+
out.position_id = item.parsedJson.position_id;
|
|
11231
|
+
out.reward = [item.parsedJson.reward1, item.parsedJson.reward2, item.parsedJson.reward3];
|
|
11232
|
+
out.amount = [item.parsedJson.amount1, item.parsedJson.amount2, item.parsedJson.amount3];
|
|
11233
|
+
}
|
|
11234
|
+
});
|
|
11235
|
+
return out;
|
|
11236
|
+
}
|
|
11237
|
+
async getPairRewarders(params) {
|
|
11238
|
+
let tx = new import_transactions12.Transaction();
|
|
11239
|
+
for (const param of params) {
|
|
11240
|
+
tx = await this._getPairRewarders(param, tx);
|
|
11241
|
+
}
|
|
11242
|
+
return this._parsePairRewarders(tx);
|
|
11243
|
+
}
|
|
11244
|
+
async _getPairRewarders(params, tx) {
|
|
11245
|
+
tx = tx || new import_transactions12.Transaction();
|
|
11246
|
+
const { integrate } = this.sdk.sdkOptions;
|
|
11247
|
+
const typeArguments = [params.coin_a, params.coin_b];
|
|
11248
|
+
const args = [tx.object(params.pool_id)];
|
|
11249
|
+
tx.moveCall({
|
|
11250
|
+
target: `${integrate.published_at}::${DlmmScript}::get_pair_rewarders`,
|
|
11251
|
+
arguments: args,
|
|
11252
|
+
typeArguments
|
|
11253
|
+
});
|
|
11254
|
+
return tx;
|
|
11255
|
+
}
|
|
11256
|
+
async _parsePairRewarders(tx) {
|
|
11257
|
+
const { simulationAccount } = this.sdk.sdkOptions;
|
|
11258
|
+
const simulateRes = await this.sdk.fullClient.devInspectTransactionBlock({
|
|
11259
|
+
transactionBlock: tx,
|
|
11260
|
+
sender: simulationAccount.address
|
|
11261
|
+
});
|
|
11262
|
+
const out = /* @__PURE__ */ new Map();
|
|
11263
|
+
if (simulateRes.error != null) {
|
|
11264
|
+
throw new Error(`fetchBins error code: ${simulateRes.error ?? "unknown error"}`);
|
|
11265
|
+
}
|
|
11266
|
+
simulateRes.events?.forEach((item) => {
|
|
11267
|
+
if (extractStructTagFromType(item.type).name === `EventPairRewardTypes`) {
|
|
11268
|
+
const pairRewards = {
|
|
11269
|
+
pair_id: "",
|
|
11270
|
+
tokens: []
|
|
11271
|
+
};
|
|
11272
|
+
pairRewards.pair_id = item.parsedJson.pair_id;
|
|
11273
|
+
item.parsedJson.tokens.contents.forEach((token) => {
|
|
11274
|
+
pairRewards.tokens.push(token.name);
|
|
11275
|
+
});
|
|
11276
|
+
}
|
|
11277
|
+
});
|
|
11278
|
+
return out;
|
|
11279
|
+
}
|
|
10996
11280
|
};
|
|
10997
11281
|
|
|
10998
11282
|
// src/sdk.ts
|
|
@@ -11272,7 +11556,7 @@ var SDKConfig = {
|
|
|
11272
11556
|
clmmConfig: {
|
|
11273
11557
|
pools_id: "0xfa145b9de10fe858be81edd1c6cdffcf27be9d016de02a1345eb1009a68ba8b2",
|
|
11274
11558
|
// clmm and dlmm both use this global_config
|
|
11275
|
-
global_config_id: "
|
|
11559
|
+
global_config_id: "0x4e39044c21fe04e27c67b110dec37807ad439516a1701cf2e0dc842e9e20f1f3",
|
|
11276
11560
|
global_vault_id: "0xa7e1102f222b6eb81ccc8a126e7feb2353342be9df6f6646a77c4519da29c071",
|
|
11277
11561
|
admin_cap_id: "0x89c1a321291d15ddae5a086c9abc533dff697fde3d89e0ca836c41af73e36a75"
|
|
11278
11562
|
},
|
|
@@ -11293,7 +11577,7 @@ var SDKConfig = {
|
|
|
11293
11577
|
minter_id: "0x4fa5766cd83b33b215b139fec27ac344040f3bbd84fcbee7b61fc671aadc51fa"
|
|
11294
11578
|
},
|
|
11295
11579
|
dlmmConfig: {
|
|
11296
|
-
factory: ""
|
|
11580
|
+
factory: "0xb7d4f7281bc604981e2caaa5d2af875b66f9422fcdbf6e310d8ed16b854a5d3e"
|
|
11297
11581
|
},
|
|
11298
11582
|
gaugeConfig: {}
|
|
11299
11583
|
};
|
|
@@ -11313,8 +11597,8 @@ var clmmMainnet = {
|
|
|
11313
11597
|
config: SDKConfig.clmmConfig
|
|
11314
11598
|
},
|
|
11315
11599
|
dlmm_pool: {
|
|
11316
|
-
package_id: "",
|
|
11317
|
-
published_at: "",
|
|
11600
|
+
package_id: "0xb3a44310c59536782d1b5c29d01a066798750ff0c15242a7f3eb7e55d188cfc3",
|
|
11601
|
+
published_at: "0xb3a44310c59536782d1b5c29d01a066798750ff0c15242a7f3eb7e55d188cfc3",
|
|
11318
11602
|
config: SDKConfig.dlmmConfig
|
|
11319
11603
|
},
|
|
11320
11604
|
distribution: {
|
|
@@ -11322,8 +11606,8 @@ var clmmMainnet = {
|
|
|
11322
11606
|
published_at: "0xee4a1f231dc45a303389998fe26c4e39278cf68b404b32e4f0b9769129b8267b"
|
|
11323
11607
|
},
|
|
11324
11608
|
integrate: {
|
|
11325
|
-
package_id: "
|
|
11326
|
-
published_at: "
|
|
11609
|
+
package_id: "0x228638b6ea17788e34971afee4b4580dbc4dcaa847ef62604d858ef5d3beb5a6",
|
|
11610
|
+
published_at: "0x228638b6ea17788e34971afee4b4580dbc4dcaa847ef62604d858ef5d3beb5a6"
|
|
11327
11611
|
},
|
|
11328
11612
|
deepbook: {
|
|
11329
11613
|
package_id: "0x000000000000000000000000000000000000000000000000000000000000dee9",
|