stackswap-front-api-test-02 1.1.55 → 1.1.57
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.d.ts +8 -10
- package/dist/esm/stackswap/manager/farm3.manager.js +37 -72
- 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.d.ts +8 -10
- package/dist/stackswap/manager/farm3.manager.js +39 -74
- 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 +79 -142
- 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
|
@@ -61,7 +61,7 @@ export class FarmManager {
|
|
|
61
61
|
]);
|
|
62
62
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
63
63
|
const result = cvToValue(result_raw);
|
|
64
|
-
// console.log(result);
|
|
64
|
+
// // console.log(result);
|
|
65
65
|
return result;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -74,7 +74,7 @@ export class FarmManager {
|
|
|
74
74
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
75
75
|
const result = cvToValue(result_raw);
|
|
76
76
|
try{
|
|
77
|
-
// console.log('getFarmingStakerStatus', result);
|
|
77
|
+
// // console.log('getFarmingStakerStatus', result);
|
|
78
78
|
const pooledToken = result.value.amountUstx.value;
|
|
79
79
|
const unclaimedList = [];
|
|
80
80
|
const stakedList = []
|
|
@@ -86,14 +86,14 @@ export class FarmManager {
|
|
|
86
86
|
}
|
|
87
87
|
return {pooledToken, unclaimedList, stakedList}
|
|
88
88
|
} catch (e) {
|
|
89
|
-
// console.log(e);
|
|
89
|
+
// // console.log(e);
|
|
90
90
|
return {pooledToken: 0, unclaimedList: [], stakedList: []}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
async getFarmBalance( token: any) {
|
|
96
|
-
// console.log("getBalance", token)
|
|
96
|
+
// // console.log("getBalance", token)
|
|
97
97
|
const pair_details_options : any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
98
98
|
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING()) ]);
|
|
99
99
|
try {
|
|
@@ -107,28 +107,28 @@ export class FarmManager {
|
|
|
107
107
|
async getPoolSTXPriceFarm(pair: any ,token_x: any, token_y: any, farm_total: any){
|
|
108
108
|
// BigNumber.config({ DECIMAL_PLACES: 6});
|
|
109
109
|
const x_token_addr = token_x.addr;
|
|
110
|
-
// console.log(token_x.addr);
|
|
110
|
+
// // console.log(token_x.addr);
|
|
111
111
|
const y_token_addr = token_y.addr;
|
|
112
|
-
// console.log(token_y.addr);
|
|
112
|
+
// // console.log(token_y.addr);
|
|
113
113
|
let total_balacne = new BigNumber(-1);
|
|
114
114
|
if(x_token_addr === this.stackswap.config.BASE_WSTX_DATA().addr){
|
|
115
115
|
total_balacne = (new BigNumber(pair.balance_x).multipliedBy(farm_total).dividedBy(pair.share_total).dividedBy(new BigNumber(10 ** token_x.decimal))).multipliedBy(2);
|
|
116
116
|
}else if(y_token_addr === this.stackswap.config.BASE_WSTX_DATA().addr){
|
|
117
117
|
total_balacne = (new BigNumber(pair.balance_y).multipliedBy(farm_total).dividedBy(pair.share_total).dividedBy(new BigNumber(10 ** token_y.decimal))).multipliedBy(2);
|
|
118
118
|
}
|
|
119
|
-
// console.log('pool_stx_price', token_x.addr, token_y.addr,token_x.balance, token_y.balance,total_balacne.toNumber());
|
|
120
|
-
// console.log(pair["balance-x"].value, pair["balance-y"].value, total_balacne.toNumber());
|
|
119
|
+
// // console.log('pool_stx_price', token_x.addr, token_y.addr,token_x.balance, token_y.balance,total_balacne.toNumber());
|
|
120
|
+
// // console.log(pair["balance-x"].value, pair["balance-y"].value, total_balacne.toNumber());
|
|
121
121
|
return total_balacne;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
async getFarmingTotalStatusCycle( cycle: number){
|
|
125
|
-
// console.log(cycle);
|
|
125
|
+
// // console.log(cycle);
|
|
126
126
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING(), 'get-staking-stats-at-cycle', [
|
|
127
127
|
uintCV(cycle),
|
|
128
128
|
]);
|
|
129
129
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
130
130
|
const result = cvToValue(result_raw);
|
|
131
|
-
// console.log(result.value.amountUstx.value);
|
|
131
|
+
// // console.log(result.value.amountUstx.value);
|
|
132
132
|
try{
|
|
133
133
|
return new BigNumber(result.value.amountUstx.value).multipliedBy(2).toFixed(0).toString();
|
|
134
134
|
} catch (e) {
|
|
@@ -144,7 +144,7 @@ export class FarmManager {
|
|
|
144
144
|
]);
|
|
145
145
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
146
146
|
const result = cvToValue(result_raw);
|
|
147
|
-
// console.log('get_farming_total',result.value);
|
|
147
|
+
// // console.log('get_farming_total',result.value);
|
|
148
148
|
return result.value;
|
|
149
149
|
} catch (e) {
|
|
150
150
|
return 0;
|
|
@@ -161,7 +161,7 @@ export class FarmManager {
|
|
|
161
161
|
]);
|
|
162
162
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
163
163
|
const result = cvToValue(result_raw);
|
|
164
|
-
// console.log(result_raw);
|
|
164
|
+
// // console.log(result_raw);
|
|
165
165
|
return result;
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -173,7 +173,7 @@ export class FarmManager {
|
|
|
173
173
|
]);
|
|
174
174
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
175
175
|
const result = cvToValue(result_raw);
|
|
176
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
176
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
177
177
|
return result;
|
|
178
178
|
}
|
|
179
179
|
|
|
@@ -187,7 +187,7 @@ export class FarmManager {
|
|
|
187
187
|
]);
|
|
188
188
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
189
189
|
const result = cvToValue(result_raw);
|
|
190
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
190
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
191
191
|
return result;
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -201,7 +201,7 @@ export class FarmManager {
|
|
|
201
201
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
202
202
|
try{
|
|
203
203
|
const result = cvToValue(result_raw);
|
|
204
|
-
// console.log(result);
|
|
204
|
+
// // console.log(result);
|
|
205
205
|
return result.value.toReturn.value;
|
|
206
206
|
} catch (e) {
|
|
207
207
|
return '0';
|
|
@@ -211,7 +211,7 @@ export class FarmManager {
|
|
|
211
211
|
|
|
212
212
|
async stakeFarmingContract( pool_address: string, amountTokens: string, lockPeriod: number, callback: any = null){
|
|
213
213
|
const address = pool_address.split('.');
|
|
214
|
-
// console.log(amountTokens);
|
|
214
|
+
// // console.log(amountTokens);
|
|
215
215
|
const amount = new BigNumber(amountTokens).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
216
216
|
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING(), 'stake-tokens', [
|
|
217
217
|
uintCV(amount),
|
|
@@ -261,9 +261,9 @@ export class FarmManager {
|
|
|
261
261
|
}
|
|
262
262
|
const result = await this.getFarmingUserRewardList(pool_addr, num_list)
|
|
263
263
|
// rewardSum.value;
|
|
264
|
-
// console.log(result);
|
|
264
|
+
// // console.log(result);
|
|
265
265
|
const reward = numFormat_(num2decimal(result.rewardSum.value, 6));
|
|
266
|
-
// console.log({reward, reward_list, reward_balance});
|
|
266
|
+
// // console.log({reward, reward_list, reward_balance});
|
|
267
267
|
return reward;
|
|
268
268
|
}
|
|
269
269
|
|
|
@@ -277,15 +277,15 @@ export class FarmManager {
|
|
|
277
277
|
//
|
|
278
278
|
// try {
|
|
279
279
|
// for (let i = 0; i < num_list.length; i += 8) {
|
|
280
|
-
// // console.log(i, num_list.slice(i, i+4 < num_list.length ? i + 4 : num_list.length));
|
|
280
|
+
// // // console.log(i, num_list.slice(i, i+4 < num_list.length ? i + 4 : num_list.length));
|
|
281
281
|
// const result = await this.getFarmingUserRewardList(pool_addr, num_list.slice(i, i + 8 < num_list.length ? i + 8 : num_list.length));
|
|
282
282
|
// // rewardSum.value;
|
|
283
|
-
// // console.log('temp result', result);
|
|
283
|
+
// // // console.log('temp result', result);
|
|
284
284
|
// reward_num = reward_num.plus(new BigNumber(result.rewardSum.value));
|
|
285
285
|
// }
|
|
286
286
|
// return numFormat_(num2decimal(reward_num.toString(), 6));
|
|
287
287
|
// } catch (e) {
|
|
288
|
-
// // console.log(e);
|
|
288
|
+
// // // console.log(e);
|
|
289
289
|
// return numFormat_(num2decimal(reward_num.toString(), 6));
|
|
290
290
|
// }
|
|
291
291
|
// }
|
|
@@ -347,7 +347,7 @@ export class FarmManager {
|
|
|
347
347
|
farm.pair = (await this.stackswap.swapManager.findRouter(farm.token_x, farm.token_y, Number(bh))).pair;
|
|
348
348
|
break;
|
|
349
349
|
}
|
|
350
|
-
// console.log(isMigratable);
|
|
350
|
+
// // console.log(isMigratable);
|
|
351
351
|
this.getFarmBalance(farm.pair.token_lp).then(farm_total => {
|
|
352
352
|
this.getPoolSTXPriceFarm(farm.pair, farm.token_x, farm.token_y, farm_total).then(tvl_stx => {
|
|
353
353
|
farm.tvl = tvl_stx.multipliedBy(new BigNumber(usd_stx)).toNumber();
|
|
@@ -358,7 +358,7 @@ export class FarmManager {
|
|
|
358
358
|
this.getFarmingTotalStatusCycle(Number(farm.round)+1).then((value1) =>
|
|
359
359
|
{
|
|
360
360
|
const tvl = new BigNumber(num2decimal(value1,6)).toFixed(3).toString();
|
|
361
|
-
// console.log({tvl});
|
|
361
|
+
// // console.log({tvl});
|
|
362
362
|
if (farm.round > this.stackswap.config.FARM_V1_END_CYCLE()){
|
|
363
363
|
farm.apr = '0'
|
|
364
364
|
} else {
|
|
@@ -375,12 +375,12 @@ export class FarmManager {
|
|
|
375
375
|
farm.migratable = false; // migratable true V1 staking 했지만 Migration을 해야함
|
|
376
376
|
farm.isMigratable = await this.stackswap.farm2Manager.isUserMigratable2(farm.pair.token_lp.addr, farm.farm_contract); // 신규는 무조건 true
|
|
377
377
|
const status = await this.getFarmingStakerStatus(farm.pair.token_lp.addr, Number(farm.round))
|
|
378
|
-
// console.log('get farming staker status', status);
|
|
378
|
+
// // console.log('get farming staker status', status);
|
|
379
379
|
farm.claimable_list = status.unclaimedList;
|
|
380
380
|
farm.pooled_stsw = status.pooledToken;
|
|
381
381
|
farm.stakedList = status.stakedList;
|
|
382
382
|
for (const stakedListElement of status.stakedList) {
|
|
383
|
-
// console.log(stakedListElement);
|
|
383
|
+
// // console.log(stakedListElement);
|
|
384
384
|
if (stakedListElement > this.stackswap.config.FARM_V1_END_CYCLE() && farm.isMigratable) {
|
|
385
385
|
farm.migratable = true;
|
|
386
386
|
}
|
|
@@ -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
|
}
|