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
|
@@ -17,7 +17,7 @@ export enum Mode {
|
|
|
17
17
|
ONLY_BLOCKCHAIN
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export class
|
|
20
|
+
export class Farm3Manager {
|
|
21
21
|
stackswap: StackswapAPI;
|
|
22
22
|
|
|
23
23
|
constructor(stackswap: StackswapAPI) {``
|
|
@@ -26,43 +26,21 @@ export class Farm2Manager {
|
|
|
26
26
|
|
|
27
27
|
async getFarmingRound3(bh: number) {
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
uintCV(bh)
|
|
31
|
-
]);
|
|
32
|
-
const result_raw = await callReadOnlyFunction(function_option);
|
|
33
|
-
const result = cvToValue(result_raw);
|
|
34
|
-
// console.log('farming round', result);
|
|
35
|
-
return result.value;
|
|
29
|
+
return Math.floor((Number(bh) - 70843) / 504);
|
|
36
30
|
} catch (e) {
|
|
37
31
|
return 0;
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const result_raw = await callReadOnlyFunction(function_option);
|
|
46
|
-
const result = cvToValue(result_raw);
|
|
47
|
-
// console.log(result);
|
|
48
|
-
return result;
|
|
35
|
+
|
|
36
|
+
async getCurrentFarmingRound3() {
|
|
37
|
+
const bh = await this.stackswap.getCurrentBlock();
|
|
38
|
+
return await this.getFarmingRound3(Number(bh));
|
|
49
39
|
}
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// contractPrincipalCV(address[0], address[1]),
|
|
55
|
-
// standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
56
|
-
// ]);
|
|
57
|
-
// try {
|
|
58
|
-
// const result_raw = await callReadOnlyFunction(function_option);
|
|
59
|
-
// const result = cvToValue(result_raw);
|
|
60
|
-
// // console.log('migrate' , result);
|
|
61
|
-
// return result;
|
|
62
|
-
// } catch (e) {
|
|
63
|
-
// return true;
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
41
|
+
async getFarmingRoundFirstBlock3(cycle: number) {
|
|
42
|
+
return 70843 + 504 * Number(cycle);
|
|
43
|
+
}
|
|
66
44
|
|
|
67
45
|
getPoolUSDPriceFarm(farm: any, farm_total: any, oracle_data: { oracle_stx: any, oracle_stsw: any, oracle_lbtc: any }) {
|
|
68
46
|
// BigNumber.config({ DECIMAL_PLACES: 6});
|
|
@@ -97,7 +75,7 @@ export class Farm2Manager {
|
|
|
97
75
|
|
|
98
76
|
async getFarmingStakerStatus3(pool_address: string, cur_round: number) {
|
|
99
77
|
const address = pool_address.split('.');
|
|
100
|
-
// console.log('getFarmingStakerStatus', farming_contract);
|
|
78
|
+
// // console.log('getFarmingStakerStatus', farming_contract);
|
|
101
79
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), 'getLPUserDataOrDefault', [
|
|
102
80
|
contractPrincipalCV(address[0], address[1]),
|
|
103
81
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
@@ -105,34 +83,34 @@ export class Farm2Manager {
|
|
|
105
83
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
106
84
|
const result = cvToValue(result_raw);
|
|
107
85
|
try {
|
|
108
|
-
// console.log('getFarmingStakerStatus', result);
|
|
86
|
+
// // console.log('getFarmingStakerStatus', result);
|
|
109
87
|
const pooledToken = result.value.amountLP.value;
|
|
110
88
|
const unclaimedList = [];
|
|
111
89
|
const stakedList = []
|
|
112
90
|
for (const unclaimedElement of result.value.unclaimedList.value) {
|
|
113
91
|
if (unclaimedElement.value < cur_round) {
|
|
114
92
|
unclaimedList.push(unclaimedElement.value);
|
|
115
|
-
// console.log('TTT', unclaimedElement.value)
|
|
93
|
+
// // console.log('TTT', unclaimedElement.value)
|
|
116
94
|
}
|
|
117
95
|
stakedList.push(unclaimedElement.value);
|
|
118
96
|
}
|
|
119
|
-
// console.log({pooledToken, unclaimedList, stakedList});
|
|
97
|
+
// // console.log({pooledToken, unclaimedList, stakedList});
|
|
120
98
|
return {pooledToken, unclaimedList, stakedList};
|
|
121
99
|
} catch (e) {
|
|
122
|
-
// console.log(e);
|
|
100
|
+
// // console.log(e);
|
|
123
101
|
return {pooledToken: 0, unclaimedList: [], stakedList: []}
|
|
124
102
|
}
|
|
125
103
|
}
|
|
126
104
|
|
|
127
105
|
async getFarmingTotalStatusCycle3(cycle: number, group: string| number) {
|
|
128
|
-
// console.log(cycle);
|
|
106
|
+
// // console.log(cycle);
|
|
129
107
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), 'getGroupRoundDataOrDefault', [
|
|
130
108
|
uintCV(cycle),
|
|
131
109
|
uintCV(group),
|
|
132
110
|
]);
|
|
133
111
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
134
112
|
const result = cvToValue(result_raw);
|
|
135
|
-
// console.log('FARMING TOTAL', result);
|
|
113
|
+
// // console.log('FARMING TOTAL', result);
|
|
136
114
|
try {
|
|
137
115
|
return {
|
|
138
116
|
reward: result.reward.value,
|
|
@@ -154,7 +132,7 @@ export class Farm2Manager {
|
|
|
154
132
|
]);
|
|
155
133
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
156
134
|
const result = cvToValue(result_raw);
|
|
157
|
-
// console.log('lp total data', result);
|
|
135
|
+
// // console.log('lp total data', result);
|
|
158
136
|
try {
|
|
159
137
|
return {amountLP: result.value.amountLP.value, weight: result.value.weight.value};
|
|
160
138
|
// return {amountLP: result.value.amountLP.value, weight: '3'};
|
|
@@ -171,7 +149,7 @@ export class Farm2Manager {
|
|
|
171
149
|
]);
|
|
172
150
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
173
151
|
const result = cvToValue(result_raw);
|
|
174
|
-
// console.log('lp round data', result);
|
|
152
|
+
// // console.log('lp round data', result);
|
|
175
153
|
try {
|
|
176
154
|
return result.value;
|
|
177
155
|
} catch (e) {
|
|
@@ -193,7 +171,7 @@ export class Farm2Manager {
|
|
|
193
171
|
]);
|
|
194
172
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
195
173
|
const result = cvToValue(result_raw);
|
|
196
|
-
// console.log('get_farming_total',result.value);
|
|
174
|
+
// // console.log('get_farming_total',result.value);
|
|
197
175
|
return result.value;
|
|
198
176
|
} catch (e) {
|
|
199
177
|
return 0;
|
|
@@ -209,7 +187,7 @@ export class Farm2Manager {
|
|
|
209
187
|
]);
|
|
210
188
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
211
189
|
const result = cvToValue(result_raw);
|
|
212
|
-
// console.log('reward', result);
|
|
190
|
+
// // console.log('reward', result);
|
|
213
191
|
return result;
|
|
214
192
|
}
|
|
215
193
|
|
|
@@ -222,99 +200,62 @@ export class Farm2Manager {
|
|
|
222
200
|
]);
|
|
223
201
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
224
202
|
const result = cvToValue(result_raw);
|
|
225
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
203
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
226
204
|
return result;
|
|
227
205
|
}
|
|
228
206
|
|
|
229
|
-
async
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// console.log(result);
|
|
239
|
-
return result.value.returnLP.value;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async getLPUserRoundData(pool_address: string, round: number) {
|
|
243
|
-
try{
|
|
244
|
-
|
|
245
|
-
const address = pool_address.split('.');
|
|
246
|
-
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), 'getLPUserRoundDataOrDefault', [
|
|
247
|
-
contractPrincipalCV(address[0], address[1]),
|
|
248
|
-
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
249
|
-
uintCV(round),
|
|
250
|
-
]);
|
|
251
|
-
const result_raw = await callReadOnlyFunction(function_option);
|
|
252
|
-
const result = cvToValue(result_raw);
|
|
253
|
-
// console.log(result);
|
|
254
|
-
return result.value;
|
|
255
|
-
}
|
|
256
|
-
catch (e) {
|
|
257
|
-
console.log(e);
|
|
258
|
-
return {
|
|
259
|
-
amountLP: {
|
|
260
|
-
value: '0'
|
|
261
|
-
},
|
|
262
|
-
returnLP: {
|
|
263
|
-
value: '0'
|
|
264
|
-
}
|
|
265
|
-
}
|
|
207
|
+
async getFarmBalance3(token: any) {
|
|
208
|
+
// // console.log("getBalance", token)
|
|
209
|
+
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
210
|
+
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3())]);
|
|
211
|
+
try {
|
|
212
|
+
const result = await callReadOnlyFunction(pair_details_options);
|
|
213
|
+
return cvToValue(result).value;
|
|
214
|
+
} catch (e) {
|
|
215
|
+
return 0;
|
|
266
216
|
}
|
|
267
217
|
}
|
|
268
218
|
|
|
269
|
-
// async migrateToVersion2(pool_address: string, farming_contract: string, callback: any) {
|
|
270
|
-
// const address = pool_address.split('.');
|
|
271
|
-
// // console.log(amountTokens);
|
|
272
|
-
// const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING3(), 'migrateFromVersion1', [
|
|
273
|
-
// contractPrincipalCV(address[0], address[1]),
|
|
274
|
-
// ], [], callback);
|
|
275
|
-
// await openContractCall(function_option);
|
|
276
|
-
// }
|
|
277
219
|
|
|
278
|
-
async stakeFarmingContract3(pool_address: string, amountTokens: string,
|
|
220
|
+
async stakeFarmingContract3(pool_address: string, amountTokens: string, callback: any) {
|
|
279
221
|
const address = pool_address.split('.');
|
|
280
|
-
// console.log(amountTokens);
|
|
222
|
+
// // console.log(amountTokens);
|
|
281
223
|
const amount = new BigNumber(amountTokens).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
282
224
|
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_LOGIC_3(), 'stakeTokens', [
|
|
283
225
|
uintCV(amount),
|
|
284
226
|
contractPrincipalCV(address[0], address[1]),
|
|
285
|
-
uintCV(lockPeriod),
|
|
286
227
|
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_ORACLE())
|
|
287
228
|
], [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), pool_address, amount, FungibleConditionCode.Equal)], callback);
|
|
288
229
|
await openContractCall(function_option);
|
|
289
230
|
}
|
|
290
231
|
|
|
291
|
-
async getFarmBalance3(token: any) {
|
|
292
|
-
// console.log("getBalance", token)
|
|
293
|
-
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
294
|
-
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3())]);
|
|
295
|
-
try {
|
|
296
|
-
const result = await callReadOnlyFunction(pair_details_options);
|
|
297
|
-
return cvToValue(result).value;
|
|
298
|
-
} catch (e) {
|
|
299
|
-
return 0;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
232
|
|
|
303
|
-
async claimFarmingContract3(pool_address: string, amount_STSW: string, amount_LP: string, callback: any) {
|
|
233
|
+
async claimFarmingContract3(pool_address: string, amount_STSW: string, amount_LP: string, callback: any, mode: boolean = false) {
|
|
304
234
|
const address = pool_address.split('.');
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
235
|
+
if(mode){
|
|
236
|
+
const post_condition = [];
|
|
237
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), this.stackswap.config.BASE_STSW_DATA().addr, amount_STSW, FungibleConditionCode.Equal));
|
|
238
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), pool_address, amount_LP, FungibleConditionCode.Equal));
|
|
239
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_REWARD_BALANCER(), this.stackswap.config.BASE_STSW_DATA().addr, 0, FungibleConditionCode.GreaterEqual));
|
|
240
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_REWARD_BALANCER(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, FungibleConditionCode.GreaterEqual));
|
|
241
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STSW_LBTC_LP() , this.stackswap.config.BASE_STSW_DATA().addr, 0, FungibleConditionCode.GreaterEqual));
|
|
242
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STSW_LBTC_LP() , this.stackswap.config.BASE_LBTC_DATA().addr, 0, FungibleConditionCode.GreaterEqual));
|
|
243
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount_STSW, FungibleConditionCode.Equal));
|
|
244
|
+
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_REWARD_BALANCER(), 'CLAIM_FROM_FARM', [
|
|
245
|
+
contractPrincipalCV(address[0], address[1]),
|
|
246
|
+
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_ORACLE())
|
|
247
|
+
], post_condition, callback);
|
|
248
|
+
await openContractCall(function_option);
|
|
249
|
+
}else {
|
|
250
|
+
const post_condition = [];
|
|
251
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), this.stackswap.config.BASE_STSW_DATA().addr, amount_STSW, FungibleConditionCode.Equal));
|
|
252
|
+
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_REWARD_BALANCER(), 'CLAIM_FROM_FARM', [
|
|
253
|
+
contractPrincipalCV(address[0], address[1]),
|
|
254
|
+
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_ORACLE())
|
|
255
|
+
], post_condition, callback);
|
|
256
|
+
await openContractCall(function_option);
|
|
257
|
+
}
|
|
258
|
+
|
|
318
259
|
}
|
|
319
260
|
|
|
320
261
|
// async claimFarmingRewardRound(pool_address: string, amount_STSW: string, amount_LP: string, round: number|string, callback: any) {
|
|
@@ -345,10 +286,6 @@ export class Farm2Manager {
|
|
|
345
286
|
await openContractCall(function_option);
|
|
346
287
|
}
|
|
347
288
|
|
|
348
|
-
async getCurrentFarmingRound3() {
|
|
349
|
-
const bh = await this.stackswap.getCurrentBlock();
|
|
350
|
-
return await this.getFarmingRound3(Number(bh));
|
|
351
|
-
}
|
|
352
289
|
|
|
353
290
|
async getRewardBalanceFromFarming3(pool_addr: string, unclaimed_list: any) {
|
|
354
291
|
// let reward_balance = new BigNumber(0);
|
|
@@ -357,41 +294,41 @@ export class Farm2Manager {
|
|
|
357
294
|
num_list.push(uintCV(unclaimed));
|
|
358
295
|
}
|
|
359
296
|
let reward_num = new BigNumber(0);
|
|
360
|
-
// console.log(pool_addr, num_list, farming_contract)
|
|
297
|
+
// // console.log(pool_addr, num_list, farming_contract)
|
|
361
298
|
try {
|
|
362
299
|
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);
|
|
300
|
+
// // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
364
301
|
const result = await this.getFarmingUserRewardList3(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length));
|
|
365
302
|
// rewardSum.value;
|
|
366
|
-
// console.log('temp result', result.rewardSum.value);
|
|
303
|
+
// // console.log('temp result', result.rewardSum.value);
|
|
367
304
|
reward_num = reward_num.plus(new BigNumber(result.rewardSum.value));
|
|
368
305
|
}
|
|
369
306
|
return num2decimal(reward_num.toString(), 6);
|
|
370
307
|
} catch (e) {
|
|
371
|
-
// console.log(e);
|
|
308
|
+
// // console.log(e);
|
|
372
309
|
return num2decimal(reward_num.toString(), 6);
|
|
373
310
|
}
|
|
374
311
|
}
|
|
375
312
|
|
|
376
313
|
|
|
377
314
|
getFarmingAPR(tvl: string, stsw_price: string, reward: string, weight: string) {
|
|
378
|
-
// console.log('farmingAPR');
|
|
379
|
-
// console.log({tvl, stsw_price, reward, weight})
|
|
315
|
+
// // console.log('farmingAPR');
|
|
316
|
+
// // console.log({tvl, stsw_price, reward, weight})
|
|
380
317
|
if (!tvl || new BigNumber(tvl) <= new BigNumber(0)) {
|
|
381
318
|
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);
|
|
319
|
+
// // console.log('reward_to_stx', temp.toFixed(3).toString());
|
|
320
|
+
// // console.log(typeof temp);
|
|
384
321
|
return temp.toFixed(3).toString();
|
|
385
322
|
} else {
|
|
386
323
|
// BigNumber.config({DECIMAL_PLACES: 10});
|
|
387
324
|
const tvl_bn = new BigNumber(tvl).multipliedBy(10 ** 12);
|
|
388
|
-
// console.log({tvl_bn: tvl_bn.toString()});
|
|
325
|
+
// // console.log({tvl_bn: tvl_bn.toString()});
|
|
389
326
|
const reward_usd = new BigNumber(reward).multipliedBy(stsw_price);
|
|
390
|
-
// console.log({reward_stx: reward_usd.toString()});
|
|
327
|
+
// // console.log({reward_stx: reward_usd.toString()});
|
|
391
328
|
const new_reward = reward_usd.div(tvl_bn);
|
|
392
|
-
// console.log({new_reward: new_reward.toString()});
|
|
329
|
+
// // console.log({new_reward: new_reward.toString()});
|
|
393
330
|
const new_reward_apr = new_reward.multipliedBy(5200).multipliedBy(weight);
|
|
394
|
-
// console.log({new_reward_apr: new_reward_apr.toString()});
|
|
331
|
+
// // console.log({new_reward_apr: new_reward_apr.toString()});
|
|
395
332
|
return new_reward_apr.toFixed(3).toString();
|
|
396
333
|
}
|
|
397
334
|
}
|
|
@@ -420,7 +357,7 @@ export class Farm2Manager {
|
|
|
420
357
|
break;
|
|
421
358
|
}
|
|
422
359
|
}
|
|
423
|
-
// console.log({tvls})
|
|
360
|
+
// // console.log({tvls})
|
|
424
361
|
for (const farm_temp of farms) {
|
|
425
362
|
switch (farm_temp.farm_group) {
|
|
426
363
|
case 1:
|
|
@@ -433,7 +370,7 @@ export class Farm2Manager {
|
|
|
433
370
|
farm_temp.APR = this.getFarmingAPR(tvls.group5, oracle_data.oracle_stsw, farm_temp.reward, farm_temp.weight);
|
|
434
371
|
break;
|
|
435
372
|
}
|
|
436
|
-
// console.log(farm_temp.APR)
|
|
373
|
+
// // console.log(farm_temp.APR)
|
|
437
374
|
}
|
|
438
375
|
}
|
|
439
376
|
return farms;
|
|
@@ -457,7 +394,7 @@ export class Farm2Manager {
|
|
|
457
394
|
}
|
|
458
395
|
farm_temp.value_per_1LP = new BigNumber(this.getPoolUSDPriceFarm(farm_temp, 1000000, oracle_data)).multipliedBy(farm_temp.weight).toString();
|
|
459
396
|
}
|
|
460
|
-
// console.log({tvls})
|
|
397
|
+
// // console.log({tvls})
|
|
461
398
|
for (const farm_temp of farms) {
|
|
462
399
|
switch (farm_temp.farm_group) {
|
|
463
400
|
case 1:
|
|
@@ -473,7 +410,7 @@ export class Farm2Manager {
|
|
|
473
410
|
farm_temp.group_value = tvls.group5;
|
|
474
411
|
break;
|
|
475
412
|
}
|
|
476
|
-
// console.log(farm_temp.APR)
|
|
413
|
+
// // console.log(farm_temp.APR)
|
|
477
414
|
}
|
|
478
415
|
}
|
|
479
416
|
return farms;
|
|
@@ -494,7 +431,7 @@ export class Farm2Manager {
|
|
|
494
431
|
farms.push(value);
|
|
495
432
|
this.checkAndSetFarmAPR(farms, farm_length, oracle_data);
|
|
496
433
|
|
|
497
|
-
// console.log("let's callback");
|
|
434
|
+
// // console.log("let's callback");
|
|
498
435
|
callback({farms, farm_round, oracle_data});
|
|
499
436
|
})
|
|
500
437
|
}
|
|
@@ -570,7 +507,7 @@ export class Farm2Manager {
|
|
|
570
507
|
const lpTotalData = await this.getFarmingTotalPoolStatus3(farm.pair.token_lp.addr);
|
|
571
508
|
farm.weight = lpTotalData.weight;
|
|
572
509
|
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);
|
|
510
|
+
// // console.log(farming_contract, farm.TVL, tvl_apr);
|
|
574
511
|
farm.valid = true;
|
|
575
512
|
|
|
576
513
|
return farm;
|
|
@@ -606,7 +543,7 @@ export class Farm2Manager {
|
|
|
606
543
|
// const farm_total_v2 = await this.getFarmBalance3(farm.pair.token_lp, farming_contract);
|
|
607
544
|
// const farm_total_v1 = await this.stackswap.farmManager.getFarmBalance(farm.pair.token_lp);
|
|
608
545
|
const temp_farm_round_data= await this.getFarmingTotalPoolStatusCycle3(farm.pair.token_lp.addr, farm_round);
|
|
609
|
-
// console.log(temp_farm_round_data);
|
|
546
|
+
// // console.log(temp_farm_round_data);
|
|
610
547
|
farm.total_locked_lp = temp_farm_round_data.amountLP.value;
|
|
611
548
|
farm.TVL = this.getPoolUSDPriceFarm(farm, farm.total_locked_lp, oracle_data);
|
|
612
549
|
|
|
@@ -639,7 +576,7 @@ export class Farm2Manager {
|
|
|
639
576
|
}
|
|
640
577
|
farm.weight = lpTotalData.weight; //TODO if weight chanages, use temp_farm_round_Data.weight
|
|
641
578
|
// 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);
|
|
579
|
+
// // console.log(farming_contract, farm.TVL, tvl_apr);
|
|
643
580
|
farm.valid = true;
|
|
644
581
|
|
|
645
582
|
return farm;
|
|
@@ -652,9 +589,9 @@ export class Farm2Manager {
|
|
|
652
589
|
farm.pooled_stsw = new BigNumber(status_v3.pooledToken).toString();
|
|
653
590
|
farm.stakedList = status_v3.stakedList;
|
|
654
591
|
farm.user_TVL = this.getPoolUSDPriceFarm(farm, farm.pooled_stsw, oracle_data);
|
|
655
|
-
// console.log('migrated', status_v2, status_v1);
|
|
592
|
+
// // console.log('migrated', status_v2, status_v1);
|
|
656
593
|
this.getRewardBalanceFromFarming3(farm.pair.token_lp.addr, status_v3.unclaimedList).then(reward_v2 => {
|
|
657
|
-
// console.log({reward_v2})
|
|
594
|
+
// // console.log({reward_v2})
|
|
658
595
|
farm.total_reward = new BigNumber(reward_v2).toString();
|
|
659
596
|
callback(farm);
|
|
660
597
|
}
|
|
@@ -43,7 +43,7 @@ export class GovernanceManager {
|
|
|
43
43
|
]);
|
|
44
44
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
45
45
|
const result = cvToValue(result_raw);
|
|
46
|
-
// console.log("TTT", cvToValue(result_raw))
|
|
46
|
+
// // // console.log("TTT", cvToValue(result_raw))
|
|
47
47
|
return [result['vote-count'].value, result.returned.value];
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -58,17 +58,17 @@ export class GovernanceManager {
|
|
|
58
58
|
standardPrincipalCV(this.stackswap.getSenderAddress())
|
|
59
59
|
], callback);
|
|
60
60
|
await openContractCall(function_option);
|
|
61
|
-
// console.log("TTT", cvToValue(result_raw))
|
|
61
|
+
// // console.log("TTT", cvToValue(result_raw))
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
async txVote(proposal_id:number, vote_mode:string, vote_amount:any, callback: any = null){
|
|
66
|
-
// console.log("TT", typeof(vote_mode), vote_mode)
|
|
67
|
-
// console.log("TT", typeof(vote_amount), vote_amount)
|
|
68
|
-
// console.log("TT", typeof(BASE_vSTSW_DATA().decimal), BASE_vSTSW_DATA().decimal)
|
|
66
|
+
// // console.log("TT", typeof(vote_mode), vote_mode)
|
|
67
|
+
// // console.log("TT", typeof(vote_amount), vote_amount)
|
|
68
|
+
// // console.log("TT", typeof(BASE_vSTSW_DATA().decimal), BASE_vSTSW_DATA().decimal)
|
|
69
69
|
|
|
70
70
|
const vote_amount_bn = new BigNumber(10 ** 6).multipliedBy(parseFloat(vote_amount)).toFixed(0).toString();
|
|
71
|
-
// console.log("TT", typeof(vote_amount_bn), vote_amount_bn)
|
|
71
|
+
// // console.log("TT", typeof(vote_amount_bn), vote_amount_bn)
|
|
72
72
|
|
|
73
73
|
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_vSTSW_DATA().addr, vote_amount_bn, FungibleConditionCode.Equal)];
|
|
74
74
|
|