stackswap-front-api-test-02 1.1.55 → 1.1.56
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/esm/stackswap/manager/bridge.manager.js +0 -10
- package/dist/esm/stackswap/manager/bridge.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/farm2.manager.js +0 -1
- package/dist/esm/stackswap/manager/farm2.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/farm3.manager.js +0 -1
- package/dist/esm/stackswap/manager/farm3.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/groupfarm.manager.js +0 -7
- package/dist/esm/stackswap/manager/groupfarm.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js +0 -3
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/staking.manager.js +0 -2
- package/dist/esm/stackswap/manager/staking.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/swap.manager.js +0 -6
- package/dist/esm/stackswap/manager/swap.manager.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/stackswap/manager/bridge.manager.js +0 -10
- package/dist/stackswap/manager/bridge.manager.js.map +1 -1
- package/dist/stackswap/manager/farm2.manager.js +0 -1
- package/dist/stackswap/manager/farm2.manager.js.map +1 -1
- package/dist/stackswap/manager/farm3.manager.js +0 -1
- package/dist/stackswap/manager/farm3.manager.js.map +1 -1
- package/dist/stackswap/manager/groupfarm.manager.js +0 -7
- package/dist/stackswap/manager/groupfarm.manager.js.map +1 -1
- package/dist/stackswap/manager/lbtcstaking.manager.js +0 -3
- package/dist/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/stackswap/manager/staking.manager.js +0 -2
- package/dist/stackswap/manager/staking.manager.js.map +1 -1
- package/dist/stackswap/manager/swap.manager.js +0 -6
- package/dist/stackswap/manager/swap.manager.js.map +1 -1
- package/package.json +1 -1
- package/src/stackswap/manager/bridge.manager.ts +48 -48
- package/src/stackswap/manager/farm.manager.ts +25 -25
- package/src/stackswap/manager/farm2.manager.ts +47 -47
- package/src/stackswap/manager/farm3.manager.ts +43 -43
- package/src/stackswap/manager/governance.manager.ts +6 -6
- package/src/stackswap/manager/groupfarm.manager.ts +25 -25
- package/src/stackswap/manager/launchpad.manager.ts +3 -3
- package/src/stackswap/manager/lbtc.manager.ts +5 -5
- package/src/stackswap/manager/lbtcstaking.manager.ts +25 -25
- package/src/stackswap/manager/multisig.manager.ts +9 -9
- package/src/stackswap/manager/nft.manager.ts +16 -16
- package/src/stackswap/manager/operator.manager.ts +2 -2
- package/src/stackswap/manager/other.manager.ts +2 -2
- package/src/stackswap/manager/pool.manager.ts +11 -11
- package/src/stackswap/manager/poxl.manager.ts +7 -7
- package/src/stackswap/manager/staking.manager.ts +26 -26
- package/src/stackswap/manager/swap.manager.ts +31 -31
- package/src/stackswap/manager/token.manager.ts +13 -13
|
@@ -31,7 +31,7 @@ export class Farm2Manager {
|
|
|
31
31
|
]);
|
|
32
32
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
33
33
|
const result = cvToValue(result_raw);
|
|
34
|
-
// console.log('farming round', result);
|
|
34
|
+
// // console.log('farming round', result);
|
|
35
35
|
return result.value;
|
|
36
36
|
} catch (e) {
|
|
37
37
|
return 0;
|
|
@@ -44,7 +44,7 @@ export class Farm2Manager {
|
|
|
44
44
|
]);
|
|
45
45
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
46
46
|
const result = cvToValue(result_raw);
|
|
47
|
-
// console.log(result);
|
|
47
|
+
// // console.log(result);
|
|
48
48
|
return result;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -57,7 +57,7 @@ export class Farm2Manager {
|
|
|
57
57
|
try {
|
|
58
58
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
59
59
|
const result = cvToValue(result_raw);
|
|
60
|
-
// console.log('migrate' , result);
|
|
60
|
+
// // console.log('migrate' , result);
|
|
61
61
|
return result;
|
|
62
62
|
} catch (e) {
|
|
63
63
|
return true;
|
|
@@ -97,7 +97,7 @@ export class Farm2Manager {
|
|
|
97
97
|
|
|
98
98
|
async getFarmingStakerStatus2(pool_address: string, cur_round: number, farming_contract: string) {
|
|
99
99
|
const address = pool_address.split('.');
|
|
100
|
-
// console.log('getFarmingStakerStatus', farming_contract);
|
|
100
|
+
// // console.log('getFarmingStakerStatus', farming_contract);
|
|
101
101
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getLPUserData', [
|
|
102
102
|
contractPrincipalCV(address[0], address[1]),
|
|
103
103
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
@@ -105,33 +105,33 @@ export class Farm2Manager {
|
|
|
105
105
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
106
106
|
const result = cvToValue(result_raw);
|
|
107
107
|
try {
|
|
108
|
-
// console.log('getFarmingStakerStatus', result);
|
|
108
|
+
// // console.log('getFarmingStakerStatus', result);
|
|
109
109
|
const pooledToken = result.value.amountLP.value;
|
|
110
110
|
const unclaimedList = [];
|
|
111
111
|
const stakedList = []
|
|
112
112
|
for (const unclaimedElement of result.value.unclaimedList.value) {
|
|
113
113
|
if (unclaimedElement.value < cur_round) {
|
|
114
114
|
unclaimedList.push(unclaimedElement.value);
|
|
115
|
-
// console.log('TTT', unclaimedElement.value)
|
|
115
|
+
// // console.log('TTT', unclaimedElement.value)
|
|
116
116
|
}
|
|
117
117
|
stakedList.push(unclaimedElement.value);
|
|
118
118
|
}
|
|
119
|
-
// console.log({pooledToken, unclaimedList, stakedList});
|
|
119
|
+
// // console.log({pooledToken, unclaimedList, stakedList});
|
|
120
120
|
return {pooledToken, unclaimedList, stakedList};
|
|
121
121
|
} catch (e) {
|
|
122
|
-
// console.log(e);
|
|
122
|
+
// // console.log(e);
|
|
123
123
|
return {pooledToken: 0, unclaimedList: [], stakedList: []}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
async getFarmingTotalStatusCycle2(cycle: number, farming_contract: string) {
|
|
128
|
-
// console.log(cycle);
|
|
128
|
+
// // console.log(cycle);
|
|
129
129
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getTotalRoundDataOrDefault', [
|
|
130
130
|
uintCV(cycle),
|
|
131
131
|
]);
|
|
132
132
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
133
133
|
const result = cvToValue(result_raw);
|
|
134
|
-
// console.log('FARMING TOTAL', result);
|
|
134
|
+
// // console.log('FARMING TOTAL', result);
|
|
135
135
|
try {
|
|
136
136
|
return {
|
|
137
137
|
reward: result.reward.value,
|
|
@@ -153,7 +153,7 @@ export class Farm2Manager {
|
|
|
153
153
|
]);
|
|
154
154
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
155
155
|
const result = cvToValue(result_raw);
|
|
156
|
-
// console.log('lp total data', result);
|
|
156
|
+
// // console.log('lp total data', result);
|
|
157
157
|
try {
|
|
158
158
|
return {amountLP: result.value.amountLP.value, weight: result.value.weight.value};
|
|
159
159
|
// return {amountLP: result.value.amountLP.value, weight: '3'};
|
|
@@ -170,7 +170,7 @@ export class Farm2Manager {
|
|
|
170
170
|
]);
|
|
171
171
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
172
172
|
const result = cvToValue(result_raw);
|
|
173
|
-
// console.log('lp round data', result);
|
|
173
|
+
// // console.log('lp round data', result);
|
|
174
174
|
try {
|
|
175
175
|
return result.value;
|
|
176
176
|
} catch (e) {
|
|
@@ -191,7 +191,7 @@ export class Farm2Manager {
|
|
|
191
191
|
]);
|
|
192
192
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
193
193
|
const result = cvToValue(result_raw);
|
|
194
|
-
// console.log('get_farming_total',result.value);
|
|
194
|
+
// // console.log('get_farming_total',result.value);
|
|
195
195
|
return result.value;
|
|
196
196
|
} catch (e) {
|
|
197
197
|
return 0;
|
|
@@ -207,7 +207,7 @@ export class Farm2Manager {
|
|
|
207
207
|
]);
|
|
208
208
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
209
209
|
const result = cvToValue(result_raw);
|
|
210
|
-
// console.log('reward', result);
|
|
210
|
+
// // console.log('reward', result);
|
|
211
211
|
return result;
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -220,7 +220,7 @@ export class Farm2Manager {
|
|
|
220
220
|
]);
|
|
221
221
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
222
222
|
const result = cvToValue(result_raw);
|
|
223
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
223
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
224
224
|
return result;
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -233,7 +233,7 @@ export class Farm2Manager {
|
|
|
233
233
|
]);
|
|
234
234
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
235
235
|
const result = cvToValue(result_raw);
|
|
236
|
-
// console.log(result);
|
|
236
|
+
// // console.log(result);
|
|
237
237
|
return result.value.returnLP.value;
|
|
238
238
|
}
|
|
239
239
|
|
|
@@ -248,11 +248,11 @@ export class Farm2Manager {
|
|
|
248
248
|
]);
|
|
249
249
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
250
250
|
const result = cvToValue(result_raw);
|
|
251
|
-
// console.log(result);
|
|
251
|
+
// // console.log(result);
|
|
252
252
|
return result.value;
|
|
253
253
|
}
|
|
254
254
|
catch (e) {
|
|
255
|
-
console.log(e);
|
|
255
|
+
// // console.log(e);
|
|
256
256
|
return {
|
|
257
257
|
amountLP: {
|
|
258
258
|
value: '0'
|
|
@@ -266,7 +266,7 @@ export class Farm2Manager {
|
|
|
266
266
|
|
|
267
267
|
async migrateToVersion2(pool_address: string, farming_contract: string, callback: any) {
|
|
268
268
|
const address = pool_address.split('.');
|
|
269
|
-
// console.log(amountTokens);
|
|
269
|
+
// // console.log(amountTokens);
|
|
270
270
|
const function_option = getWriteOptions(this.stackswap, farming_contract, 'migrateFromVersion1', [
|
|
271
271
|
contractPrincipalCV(address[0], address[1]),
|
|
272
272
|
], [], callback);
|
|
@@ -275,7 +275,7 @@ export class Farm2Manager {
|
|
|
275
275
|
|
|
276
276
|
async stakeFarmingContract2(pool_address: string, amountTokens: string, lockPeriod: number, callback: any, farming_contract: string) {
|
|
277
277
|
const address = pool_address.split('.');
|
|
278
|
-
// console.log(amountTokens);
|
|
278
|
+
// // console.log(amountTokens);
|
|
279
279
|
const amount = new BigNumber(amountTokens).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
280
280
|
const function_option = getWriteOptions(this.stackswap, farming_contract, 'stakeTokens', [
|
|
281
281
|
uintCV(amount),
|
|
@@ -287,7 +287,7 @@ export class Farm2Manager {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
async getFarmBalance2(token: any, farming_contract: string) {
|
|
290
|
-
// console.log("getBalance", token)
|
|
290
|
+
// // console.log("getBalance", token)
|
|
291
291
|
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
292
292
|
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), farming_contract)]);
|
|
293
293
|
try {
|
|
@@ -352,41 +352,41 @@ export class Farm2Manager {
|
|
|
352
352
|
num_list.push(uintCV(unclaimed));
|
|
353
353
|
}
|
|
354
354
|
let reward_num = new BigNumber(0);
|
|
355
|
-
// console.log(pool_addr, num_list, farming_contract)
|
|
355
|
+
// // console.log(pool_addr, num_list, farming_contract)
|
|
356
356
|
try {
|
|
357
357
|
for (let i = 0; i < num_list.length; i += 4) {
|
|
358
|
-
// console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
358
|
+
// // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
359
359
|
const result = await this.getFarmingUserRewardList2(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
360
360
|
// rewardSum.value;
|
|
361
|
-
// console.log('temp result', result.rewardSum.value);
|
|
361
|
+
// // console.log('temp result', result.rewardSum.value);
|
|
362
362
|
reward_num = reward_num.plus(new BigNumber(result.rewardSum.value));
|
|
363
363
|
}
|
|
364
364
|
return num2decimal(reward_num.toString(), 6);
|
|
365
365
|
} catch (e) {
|
|
366
|
-
// console.log(e);
|
|
366
|
+
// // console.log(e);
|
|
367
367
|
return num2decimal(reward_num.toString(), 6);
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
|
|
372
372
|
getFarmingAPR(tvl: string, stsw_price: string, reward: string, weight: string) {
|
|
373
|
-
// console.log('farmingAPR');
|
|
374
|
-
// console.log({tvl, stsw_price, reward, weight})
|
|
373
|
+
// // console.log('farmingAPR');
|
|
374
|
+
// // console.log({tvl, stsw_price, reward, weight})
|
|
375
375
|
if (!tvl || new BigNumber(tvl) <= new BigNumber(0)) {
|
|
376
376
|
const temp = new BigNumber(reward).dividedBy(10 ** 12).multipliedBy(5200).multipliedBy(stsw_price);
|
|
377
|
-
// console.log('reward_to_stx', temp.toFixed(3).toString());
|
|
378
|
-
// console.log(typeof temp);
|
|
377
|
+
// // console.log('reward_to_stx', temp.toFixed(3).toString());
|
|
378
|
+
// // console.log(typeof temp);
|
|
379
379
|
return temp.toFixed(3).toString();
|
|
380
380
|
} else {
|
|
381
381
|
// BigNumber.config({DECIMAL_PLACES: 10});
|
|
382
382
|
const tvl_bn = new BigNumber(tvl).multipliedBy(10 ** 12);
|
|
383
|
-
// console.log({tvl_bn: tvl_bn.toString()});
|
|
383
|
+
// // console.log({tvl_bn: tvl_bn.toString()});
|
|
384
384
|
const reward_usd = new BigNumber(reward).multipliedBy(stsw_price);
|
|
385
|
-
// console.log({reward_stx: reward_usd.toString()});
|
|
385
|
+
// // console.log({reward_stx: reward_usd.toString()});
|
|
386
386
|
const new_reward = reward_usd.div(tvl_bn);
|
|
387
|
-
// console.log({new_reward: new_reward.toString()});
|
|
387
|
+
// // console.log({new_reward: new_reward.toString()});
|
|
388
388
|
const new_reward_apr = new_reward.multipliedBy(5200).multipliedBy(weight);
|
|
389
|
-
// console.log({new_reward_apr: new_reward_apr.toString()});
|
|
389
|
+
// // console.log({new_reward_apr: new_reward_apr.toString()});
|
|
390
390
|
return new_reward_apr.toFixed(3).toString();
|
|
391
391
|
}
|
|
392
392
|
}
|
|
@@ -415,7 +415,7 @@ export class Farm2Manager {
|
|
|
415
415
|
break;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
|
-
// console.log({tvls})
|
|
418
|
+
// // console.log({tvls})
|
|
419
419
|
for (const farm_temp of farms) {
|
|
420
420
|
switch (farm_temp.farm_group) {
|
|
421
421
|
case 1:
|
|
@@ -428,7 +428,7 @@ export class Farm2Manager {
|
|
|
428
428
|
farm_temp.APR = this.getFarmingAPR(tvls.group5, oracle_data.oracle_stsw, farm_temp.reward, farm_temp.weight);
|
|
429
429
|
break;
|
|
430
430
|
}
|
|
431
|
-
// console.log(farm_temp.APR)
|
|
431
|
+
// // console.log(farm_temp.APR)
|
|
432
432
|
}
|
|
433
433
|
}
|
|
434
434
|
return farms;
|
|
@@ -452,7 +452,7 @@ export class Farm2Manager {
|
|
|
452
452
|
}
|
|
453
453
|
farm_temp.value_per_1LP = new BigNumber(this.getPoolUSDPriceFarm(farm_temp, 1000000, oracle_data)).multipliedBy(farm_temp.weight).toString();
|
|
454
454
|
}
|
|
455
|
-
// console.log({tvls})
|
|
455
|
+
// // console.log({tvls})
|
|
456
456
|
for (const farm_temp of farms) {
|
|
457
457
|
switch (farm_temp.farm_group) {
|
|
458
458
|
case 1:
|
|
@@ -468,7 +468,7 @@ export class Farm2Manager {
|
|
|
468
468
|
farm_temp.group_value = tvls.group5;
|
|
469
469
|
break;
|
|
470
470
|
}
|
|
471
|
-
// console.log(farm_temp.APR)
|
|
471
|
+
// // console.log(farm_temp.APR)
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
return farms;
|
|
@@ -497,7 +497,7 @@ export class Farm2Manager {
|
|
|
497
497
|
farms.push(value);
|
|
498
498
|
this.checkAndSetFarmAPR(farms, farm_length, oracle_data);
|
|
499
499
|
|
|
500
|
-
// console.log("let's callback");
|
|
500
|
+
// // console.log("let's callback");
|
|
501
501
|
callback({farms, farm_round, oracle_data});
|
|
502
502
|
})
|
|
503
503
|
}
|
|
@@ -591,7 +591,7 @@ export class Farm2Manager {
|
|
|
591
591
|
const lpTotalData = await this.getFarmingTotalPoolStatus2(farm.pair.token_lp.addr, farming_contract);
|
|
592
592
|
farm.weight = lpTotalData.weight;
|
|
593
593
|
tvl_apr = tvl_apr.plus(new BigNumber(this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data)).multipliedBy(farm.weight));
|
|
594
|
-
// console.log(farming_contract, farm.TVL, tvl_apr);
|
|
594
|
+
// // console.log(farming_contract, farm.TVL, tvl_apr);
|
|
595
595
|
farm.valid = true;
|
|
596
596
|
|
|
597
597
|
return farm;
|
|
@@ -627,7 +627,7 @@ export class Farm2Manager {
|
|
|
627
627
|
// const farm_total_v2 = await this.getFarmBalance2(farm.pair.token_lp, farming_contract);
|
|
628
628
|
// const farm_total_v1 = await this.stackswap.farmManager.getFarmBalance(farm.pair.token_lp);
|
|
629
629
|
const temp_farm_round_data= await this.getFarmingTotalPoolStatusCycle2(farm.pair.token_lp.addr, farm_round, farming_contract);
|
|
630
|
-
// console.log(temp_farm_round_data);
|
|
630
|
+
// // console.log(temp_farm_round_data);
|
|
631
631
|
farm.total_locked_lp = temp_farm_round_data.amountLP.value;
|
|
632
632
|
farm.TVL = this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data);
|
|
633
633
|
|
|
@@ -660,7 +660,7 @@ export class Farm2Manager {
|
|
|
660
660
|
}
|
|
661
661
|
farm.weight = lpTotalData.weight; //TODO if weight chanages, use temp_farm_round_Data.weight
|
|
662
662
|
// tvl_apr = tvl_apr.plus(new BigNumber(this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data)).multipliedBy(farm.weight));
|
|
663
|
-
// console.log(farming_contract, farm.TVL, tvl_apr);
|
|
663
|
+
// // console.log(farming_contract, farm.TVL, tvl_apr);
|
|
664
664
|
farm.valid = true;
|
|
665
665
|
|
|
666
666
|
return farm;
|
|
@@ -675,10 +675,10 @@ export class Farm2Manager {
|
|
|
675
675
|
farm.pooled_stsw = new BigNumber(status_v2.pooledToken).plus(status_v1.pooledToken).toString();
|
|
676
676
|
farm.stakedList = status_v2.stakedList;
|
|
677
677
|
farm.user_TVL = this.getPoolUSDPriceFarm(farm, farm.pooled_stsw, oracle_data);
|
|
678
|
-
// console.log('migrated', status_v2, status_v1);
|
|
678
|
+
// // console.log('migrated', status_v2, status_v1);
|
|
679
679
|
this.getRewardBalanceFromFarming2(farm.pair.token_lp.addr, status_v2.unclaimedList, farming_contract).then(reward_v2 => {
|
|
680
680
|
this.stackswap.farmManager.getRewardBalanceFromFarming(farm.pair.token_lp.addr, status_v1.unclaimedList).then(reward_v1 => {
|
|
681
|
-
// console.log({reward_v2})
|
|
681
|
+
// // console.log({reward_v2})
|
|
682
682
|
farm.total_reward = new BigNumber(reward_v2).plus(reward_v1).toString();
|
|
683
683
|
callback(farm);
|
|
684
684
|
}
|
|
@@ -686,13 +686,13 @@ export class Farm2Manager {
|
|
|
686
686
|
});
|
|
687
687
|
});
|
|
688
688
|
} else {
|
|
689
|
-
// console.log('not yet migrated', status_v2);
|
|
689
|
+
// // console.log('not yet migrated', status_v2);
|
|
690
690
|
farm.claimable_list = status_v2.unclaimedList;
|
|
691
691
|
farm.pooled_stsw = status_v2.pooledToken;
|
|
692
692
|
farm.stakedList = status_v2.stakedList;
|
|
693
693
|
farm.user_TVL = this.getPoolUSDPriceFarm(farm, farm.pooled_stsw, oracle_data);
|
|
694
694
|
this.getRewardBalanceFromFarming2(farm.token_swapr, status_v2.unclaimedList, farming_contract).then(reward => {
|
|
695
|
-
// console.log({reward})
|
|
695
|
+
// // console.log({reward})
|
|
696
696
|
farm.total_reward = reward;
|
|
697
697
|
callback(farm);
|
|
698
698
|
});
|
|
@@ -717,10 +717,10 @@ export class Farm2Manager {
|
|
|
717
717
|
farm.pooled_stsw = new BigNumber(status_v2.pooledToken).plus(status_v1.pooledToken).toString();
|
|
718
718
|
farm.stakedList = status_v2.stakedList;
|
|
719
719
|
farm.user_TVL = this.getPoolUSDPriceFarm(farm, farm.pooled_stsw, oracle_data);
|
|
720
|
-
// console.log('migrated', status_v2, status_v1);
|
|
720
|
+
// // console.log('migrated', status_v2, status_v1);
|
|
721
721
|
this.getRewardBalanceFromFarming2(farm.pair.token_lp.addr, status_v2.unclaimedList, farming_contract).then(reward_v2 => {
|
|
722
722
|
this.stackswap.farmManager.getRewardBalanceFromFarming(farm.pair.token_lp.addr, status_v1.unclaimedList).then(reward_v1 => {
|
|
723
|
-
// console.log({reward_v2})
|
|
723
|
+
// // console.log({reward_v2})
|
|
724
724
|
farm.total_reward = new BigNumber(reward_v2).plus(reward_v1).toString();
|
|
725
725
|
callback(farm);
|
|
726
726
|
}
|
|
@@ -31,7 +31,7 @@ export class Farm2Manager {
|
|
|
31
31
|
]);
|
|
32
32
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
33
33
|
const result = cvToValue(result_raw);
|
|
34
|
-
// console.log('farming round', result);
|
|
34
|
+
// // console.log('farming round', result);
|
|
35
35
|
return result.value;
|
|
36
36
|
} catch (e) {
|
|
37
37
|
return 0;
|
|
@@ -44,7 +44,7 @@ export class Farm2Manager {
|
|
|
44
44
|
]);
|
|
45
45
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
46
46
|
const result = cvToValue(result_raw);
|
|
47
|
-
// console.log(result);
|
|
47
|
+
// // console.log(result);
|
|
48
48
|
return result;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -57,7 +57,7 @@ export class Farm2Manager {
|
|
|
57
57
|
// try {
|
|
58
58
|
// const result_raw = await callReadOnlyFunction(function_option);
|
|
59
59
|
// const result = cvToValue(result_raw);
|
|
60
|
-
// // console.log('migrate' , result);
|
|
60
|
+
// // // console.log('migrate' , result);
|
|
61
61
|
// return result;
|
|
62
62
|
// } catch (e) {
|
|
63
63
|
// return true;
|
|
@@ -97,7 +97,7 @@ export class Farm2Manager {
|
|
|
97
97
|
|
|
98
98
|
async getFarmingStakerStatus3(pool_address: string, cur_round: number) {
|
|
99
99
|
const address = pool_address.split('.');
|
|
100
|
-
// console.log('getFarmingStakerStatus', farming_contract);
|
|
100
|
+
// // console.log('getFarmingStakerStatus', farming_contract);
|
|
101
101
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), 'getLPUserDataOrDefault', [
|
|
102
102
|
contractPrincipalCV(address[0], address[1]),
|
|
103
103
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
@@ -105,34 +105,34 @@ export class Farm2Manager {
|
|
|
105
105
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
106
106
|
const result = cvToValue(result_raw);
|
|
107
107
|
try {
|
|
108
|
-
// console.log('getFarmingStakerStatus', result);
|
|
108
|
+
// // console.log('getFarmingStakerStatus', result);
|
|
109
109
|
const pooledToken = result.value.amountLP.value;
|
|
110
110
|
const unclaimedList = [];
|
|
111
111
|
const stakedList = []
|
|
112
112
|
for (const unclaimedElement of result.value.unclaimedList.value) {
|
|
113
113
|
if (unclaimedElement.value < cur_round) {
|
|
114
114
|
unclaimedList.push(unclaimedElement.value);
|
|
115
|
-
// console.log('TTT', unclaimedElement.value)
|
|
115
|
+
// // console.log('TTT', unclaimedElement.value)
|
|
116
116
|
}
|
|
117
117
|
stakedList.push(unclaimedElement.value);
|
|
118
118
|
}
|
|
119
|
-
// console.log({pooledToken, unclaimedList, stakedList});
|
|
119
|
+
// // console.log({pooledToken, unclaimedList, stakedList});
|
|
120
120
|
return {pooledToken, unclaimedList, stakedList};
|
|
121
121
|
} catch (e) {
|
|
122
|
-
// console.log(e);
|
|
122
|
+
// // console.log(e);
|
|
123
123
|
return {pooledToken: 0, unclaimedList: [], stakedList: []}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
async getFarmingTotalStatusCycle3(cycle: number, group: string| number) {
|
|
128
|
-
// console.log(cycle);
|
|
128
|
+
// // console.log(cycle);
|
|
129
129
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), 'getGroupRoundDataOrDefault', [
|
|
130
130
|
uintCV(cycle),
|
|
131
131
|
uintCV(group),
|
|
132
132
|
]);
|
|
133
133
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
134
134
|
const result = cvToValue(result_raw);
|
|
135
|
-
// console.log('FARMING TOTAL', result);
|
|
135
|
+
// // console.log('FARMING TOTAL', result);
|
|
136
136
|
try {
|
|
137
137
|
return {
|
|
138
138
|
reward: result.reward.value,
|
|
@@ -154,7 +154,7 @@ export class Farm2Manager {
|
|
|
154
154
|
]);
|
|
155
155
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
156
156
|
const result = cvToValue(result_raw);
|
|
157
|
-
// console.log('lp total data', result);
|
|
157
|
+
// // console.log('lp total data', result);
|
|
158
158
|
try {
|
|
159
159
|
return {amountLP: result.value.amountLP.value, weight: result.value.weight.value};
|
|
160
160
|
// return {amountLP: result.value.amountLP.value, weight: '3'};
|
|
@@ -171,7 +171,7 @@ export class Farm2Manager {
|
|
|
171
171
|
]);
|
|
172
172
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
173
173
|
const result = cvToValue(result_raw);
|
|
174
|
-
// console.log('lp round data', result);
|
|
174
|
+
// // console.log('lp round data', result);
|
|
175
175
|
try {
|
|
176
176
|
return result.value;
|
|
177
177
|
} catch (e) {
|
|
@@ -193,7 +193,7 @@ export class Farm2Manager {
|
|
|
193
193
|
]);
|
|
194
194
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
195
195
|
const result = cvToValue(result_raw);
|
|
196
|
-
// console.log('get_farming_total',result.value);
|
|
196
|
+
// // console.log('get_farming_total',result.value);
|
|
197
197
|
return result.value;
|
|
198
198
|
} catch (e) {
|
|
199
199
|
return 0;
|
|
@@ -209,7 +209,7 @@ export class Farm2Manager {
|
|
|
209
209
|
]);
|
|
210
210
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
211
211
|
const result = cvToValue(result_raw);
|
|
212
|
-
// console.log('reward', result);
|
|
212
|
+
// // console.log('reward', result);
|
|
213
213
|
return result;
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -222,7 +222,7 @@ export class Farm2Manager {
|
|
|
222
222
|
]);
|
|
223
223
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
224
224
|
const result = cvToValue(result_raw);
|
|
225
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
225
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
226
226
|
return result;
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -235,7 +235,7 @@ export class Farm2Manager {
|
|
|
235
235
|
]);
|
|
236
236
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
237
237
|
const result = cvToValue(result_raw);
|
|
238
|
-
// console.log(result);
|
|
238
|
+
// // console.log(result);
|
|
239
239
|
return result.value.returnLP.value;
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -250,11 +250,11 @@ export class Farm2Manager {
|
|
|
250
250
|
]);
|
|
251
251
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
252
252
|
const result = cvToValue(result_raw);
|
|
253
|
-
// console.log(result);
|
|
253
|
+
// // console.log(result);
|
|
254
254
|
return result.value;
|
|
255
255
|
}
|
|
256
256
|
catch (e) {
|
|
257
|
-
console.log(e);
|
|
257
|
+
// console.log(e);
|
|
258
258
|
return {
|
|
259
259
|
amountLP: {
|
|
260
260
|
value: '0'
|
|
@@ -268,7 +268,7 @@ export class Farm2Manager {
|
|
|
268
268
|
|
|
269
269
|
// async migrateToVersion2(pool_address: string, farming_contract: string, callback: any) {
|
|
270
270
|
// const address = pool_address.split('.');
|
|
271
|
-
// // console.log(amountTokens);
|
|
271
|
+
// // // console.log(amountTokens);
|
|
272
272
|
// const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING3(), 'migrateFromVersion1', [
|
|
273
273
|
// contractPrincipalCV(address[0], address[1]),
|
|
274
274
|
// ], [], callback);
|
|
@@ -277,7 +277,7 @@ export class Farm2Manager {
|
|
|
277
277
|
|
|
278
278
|
async stakeFarmingContract3(pool_address: string, amountTokens: string, lockPeriod: number, callback: any) {
|
|
279
279
|
const address = pool_address.split('.');
|
|
280
|
-
// console.log(amountTokens);
|
|
280
|
+
// // console.log(amountTokens);
|
|
281
281
|
const amount = new BigNumber(amountTokens).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
282
282
|
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_LOGIC_3(), 'stakeTokens', [
|
|
283
283
|
uintCV(amount),
|
|
@@ -289,7 +289,7 @@ export class Farm2Manager {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
async getFarmBalance3(token: any) {
|
|
292
|
-
// console.log("getBalance", token)
|
|
292
|
+
// // console.log("getBalance", token)
|
|
293
293
|
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
294
294
|
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3())]);
|
|
295
295
|
try {
|
|
@@ -357,41 +357,41 @@ export class Farm2Manager {
|
|
|
357
357
|
num_list.push(uintCV(unclaimed));
|
|
358
358
|
}
|
|
359
359
|
let reward_num = new BigNumber(0);
|
|
360
|
-
// console.log(pool_addr, num_list, farming_contract)
|
|
360
|
+
// // console.log(pool_addr, num_list, farming_contract)
|
|
361
361
|
try {
|
|
362
362
|
for (let i = 0; i < num_list.length; i += 4) {
|
|
363
|
-
// console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
363
|
+
// // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
364
364
|
const result = await this.getFarmingUserRewardList3(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length));
|
|
365
365
|
// rewardSum.value;
|
|
366
|
-
// console.log('temp result', result.rewardSum.value);
|
|
366
|
+
// // console.log('temp result', result.rewardSum.value);
|
|
367
367
|
reward_num = reward_num.plus(new BigNumber(result.rewardSum.value));
|
|
368
368
|
}
|
|
369
369
|
return num2decimal(reward_num.toString(), 6);
|
|
370
370
|
} catch (e) {
|
|
371
|
-
// console.log(e);
|
|
371
|
+
// // console.log(e);
|
|
372
372
|
return num2decimal(reward_num.toString(), 6);
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
|
|
377
377
|
getFarmingAPR(tvl: string, stsw_price: string, reward: string, weight: string) {
|
|
378
|
-
// console.log('farmingAPR');
|
|
379
|
-
// console.log({tvl, stsw_price, reward, weight})
|
|
378
|
+
// // console.log('farmingAPR');
|
|
379
|
+
// // console.log({tvl, stsw_price, reward, weight})
|
|
380
380
|
if (!tvl || new BigNumber(tvl) <= new BigNumber(0)) {
|
|
381
381
|
const temp = new BigNumber(reward).dividedBy(10 ** 12).multipliedBy(5200).multipliedBy(stsw_price);
|
|
382
|
-
// console.log('reward_to_stx', temp.toFixed(3).toString());
|
|
383
|
-
// console.log(typeof temp);
|
|
382
|
+
// // console.log('reward_to_stx', temp.toFixed(3).toString());
|
|
383
|
+
// // console.log(typeof temp);
|
|
384
384
|
return temp.toFixed(3).toString();
|
|
385
385
|
} else {
|
|
386
386
|
// BigNumber.config({DECIMAL_PLACES: 10});
|
|
387
387
|
const tvl_bn = new BigNumber(tvl).multipliedBy(10 ** 12);
|
|
388
|
-
// console.log({tvl_bn: tvl_bn.toString()});
|
|
388
|
+
// // console.log({tvl_bn: tvl_bn.toString()});
|
|
389
389
|
const reward_usd = new BigNumber(reward).multipliedBy(stsw_price);
|
|
390
|
-
// console.log({reward_stx: reward_usd.toString()});
|
|
390
|
+
// // console.log({reward_stx: reward_usd.toString()});
|
|
391
391
|
const new_reward = reward_usd.div(tvl_bn);
|
|
392
|
-
// console.log({new_reward: new_reward.toString()});
|
|
392
|
+
// // console.log({new_reward: new_reward.toString()});
|
|
393
393
|
const new_reward_apr = new_reward.multipliedBy(5200).multipliedBy(weight);
|
|
394
|
-
// console.log({new_reward_apr: new_reward_apr.toString()});
|
|
394
|
+
// // console.log({new_reward_apr: new_reward_apr.toString()});
|
|
395
395
|
return new_reward_apr.toFixed(3).toString();
|
|
396
396
|
}
|
|
397
397
|
}
|
|
@@ -420,7 +420,7 @@ export class Farm2Manager {
|
|
|
420
420
|
break;
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
// console.log({tvls})
|
|
423
|
+
// // console.log({tvls})
|
|
424
424
|
for (const farm_temp of farms) {
|
|
425
425
|
switch (farm_temp.farm_group) {
|
|
426
426
|
case 1:
|
|
@@ -433,7 +433,7 @@ export class Farm2Manager {
|
|
|
433
433
|
farm_temp.APR = this.getFarmingAPR(tvls.group5, oracle_data.oracle_stsw, farm_temp.reward, farm_temp.weight);
|
|
434
434
|
break;
|
|
435
435
|
}
|
|
436
|
-
// console.log(farm_temp.APR)
|
|
436
|
+
// // console.log(farm_temp.APR)
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
return farms;
|
|
@@ -457,7 +457,7 @@ export class Farm2Manager {
|
|
|
457
457
|
}
|
|
458
458
|
farm_temp.value_per_1LP = new BigNumber(this.getPoolUSDPriceFarm(farm_temp, 1000000, oracle_data)).multipliedBy(farm_temp.weight).toString();
|
|
459
459
|
}
|
|
460
|
-
// console.log({tvls})
|
|
460
|
+
// // console.log({tvls})
|
|
461
461
|
for (const farm_temp of farms) {
|
|
462
462
|
switch (farm_temp.farm_group) {
|
|
463
463
|
case 1:
|
|
@@ -473,7 +473,7 @@ export class Farm2Manager {
|
|
|
473
473
|
farm_temp.group_value = tvls.group5;
|
|
474
474
|
break;
|
|
475
475
|
}
|
|
476
|
-
// console.log(farm_temp.APR)
|
|
476
|
+
// // console.log(farm_temp.APR)
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
return farms;
|
|
@@ -494,7 +494,7 @@ export class Farm2Manager {
|
|
|
494
494
|
farms.push(value);
|
|
495
495
|
this.checkAndSetFarmAPR(farms, farm_length, oracle_data);
|
|
496
496
|
|
|
497
|
-
// console.log("let's callback");
|
|
497
|
+
// // console.log("let's callback");
|
|
498
498
|
callback({farms, farm_round, oracle_data});
|
|
499
499
|
})
|
|
500
500
|
}
|
|
@@ -570,7 +570,7 @@ export class Farm2Manager {
|
|
|
570
570
|
const lpTotalData = await this.getFarmingTotalPoolStatus3(farm.pair.token_lp.addr);
|
|
571
571
|
farm.weight = lpTotalData.weight;
|
|
572
572
|
tvl_apr = tvl_apr.plus(new BigNumber(this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data)).multipliedBy(farm.weight));
|
|
573
|
-
// console.log(farming_contract, farm.TVL, tvl_apr);
|
|
573
|
+
// // console.log(farming_contract, farm.TVL, tvl_apr);
|
|
574
574
|
farm.valid = true;
|
|
575
575
|
|
|
576
576
|
return farm;
|
|
@@ -606,7 +606,7 @@ export class Farm2Manager {
|
|
|
606
606
|
// const farm_total_v2 = await this.getFarmBalance3(farm.pair.token_lp, farming_contract);
|
|
607
607
|
// const farm_total_v1 = await this.stackswap.farmManager.getFarmBalance(farm.pair.token_lp);
|
|
608
608
|
const temp_farm_round_data= await this.getFarmingTotalPoolStatusCycle3(farm.pair.token_lp.addr, farm_round);
|
|
609
|
-
// console.log(temp_farm_round_data);
|
|
609
|
+
// // console.log(temp_farm_round_data);
|
|
610
610
|
farm.total_locked_lp = temp_farm_round_data.amountLP.value;
|
|
611
611
|
farm.TVL = this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data);
|
|
612
612
|
|
|
@@ -639,7 +639,7 @@ export class Farm2Manager {
|
|
|
639
639
|
}
|
|
640
640
|
farm.weight = lpTotalData.weight; //TODO if weight chanages, use temp_farm_round_Data.weight
|
|
641
641
|
// tvl_apr = tvl_apr.plus(new BigNumber(this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data)).multipliedBy(farm.weight));
|
|
642
|
-
// console.log(farming_contract, farm.TVL, tvl_apr);
|
|
642
|
+
// // console.log(farming_contract, farm.TVL, tvl_apr);
|
|
643
643
|
farm.valid = true;
|
|
644
644
|
|
|
645
645
|
return farm;
|
|
@@ -652,9 +652,9 @@ export class Farm2Manager {
|
|
|
652
652
|
farm.pooled_stsw = new BigNumber(status_v3.pooledToken).toString();
|
|
653
653
|
farm.stakedList = status_v3.stakedList;
|
|
654
654
|
farm.user_TVL = this.getPoolUSDPriceFarm(farm, farm.pooled_stsw, oracle_data);
|
|
655
|
-
// console.log('migrated', status_v2, status_v1);
|
|
655
|
+
// // console.log('migrated', status_v2, status_v1);
|
|
656
656
|
this.getRewardBalanceFromFarming3(farm.pair.token_lp.addr, status_v3.unclaimedList).then(reward_v2 => {
|
|
657
|
-
// console.log({reward_v2})
|
|
657
|
+
// // console.log({reward_v2})
|
|
658
658
|
farm.total_reward = new BigNumber(reward_v2).toString();
|
|
659
659
|
callback(farm);
|
|
660
660
|
}
|