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
|
@@ -20,7 +20,7 @@ export class BridgeManager {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
async get_voters() {
|
|
23
|
-
// console.log('getStakingSTSWBalance');
|
|
23
|
+
// // console.log('getStakingSTSWBalance');
|
|
24
24
|
|
|
25
25
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'get-voters',
|
|
26
26
|
[]);
|
|
@@ -30,148 +30,148 @@ export class BridgeManager {
|
|
|
30
30
|
for (const cvToValueElement of cvToValue(result)) {
|
|
31
31
|
temp2.push(cvToValueElement.value);
|
|
32
32
|
}
|
|
33
|
-
console.log('get_voters', temp2);
|
|
33
|
+
// console.log('get_voters', temp2);
|
|
34
34
|
return temp2;
|
|
35
35
|
} catch (e) {
|
|
36
|
-
// console.log(e);
|
|
36
|
+
// // console.log(e);
|
|
37
37
|
return '0';
|
|
38
38
|
}
|
|
39
|
-
// console.log(pair_details_result)
|
|
39
|
+
// // console.log(pair_details_result)
|
|
40
40
|
}
|
|
41
41
|
async getVoteRes() {
|
|
42
|
-
// console.log('getStakingSTSWBalance');
|
|
42
|
+
// // console.log('getStakingSTSWBalance');
|
|
43
43
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getVoteRes',
|
|
44
44
|
[]);
|
|
45
45
|
try {
|
|
46
46
|
const result = await callReadOnlyFunction(options);
|
|
47
|
-
console.log('getVoteRes', cvToValue(result));
|
|
47
|
+
// console.log('getVoteRes', cvToValue(result));
|
|
48
48
|
return cvToValue(result);
|
|
49
49
|
} catch (e) {
|
|
50
|
-
// console.log(e);
|
|
50
|
+
// // console.log(e);
|
|
51
51
|
return '0';
|
|
52
52
|
}
|
|
53
|
-
// console.log(pair_details_result)
|
|
53
|
+
// // console.log(pair_details_result)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
async GetFee() {
|
|
57
|
-
// console.log('getStakingSTSWBalance');
|
|
57
|
+
// // console.log('getStakingSTSWBalance');
|
|
58
58
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'GetFee',
|
|
59
59
|
[]);
|
|
60
60
|
try {
|
|
61
61
|
const result = await callReadOnlyFunction(options);
|
|
62
|
-
console.log('GetFee', cvToValue(result));
|
|
62
|
+
// console.log('GetFee', cvToValue(result));
|
|
63
63
|
return cvToValue(result);
|
|
64
64
|
} catch (e) {
|
|
65
|
-
// console.log(e);
|
|
65
|
+
// // console.log(e);
|
|
66
66
|
return '0';
|
|
67
67
|
}
|
|
68
|
-
// console.log(pair_details_result)
|
|
68
|
+
// // console.log(pair_details_result)
|
|
69
69
|
}
|
|
70
70
|
async getETHToken(token: string) {
|
|
71
|
-
// console.log('getStakingSTSWBalance');
|
|
71
|
+
// // console.log('getStakingSTSWBalance');
|
|
72
72
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getETHToken',
|
|
73
73
|
[parseAddressToCV(token)]);
|
|
74
74
|
try {
|
|
75
75
|
const result = await callReadOnlyFunction(options);
|
|
76
|
-
console.log('getETHToken', cvToValue(result));
|
|
76
|
+
// console.log('getETHToken', cvToValue(result));
|
|
77
77
|
return cvToValue(result);
|
|
78
78
|
} catch (e) {
|
|
79
|
-
// console.log(e);
|
|
79
|
+
// // console.log(e);
|
|
80
80
|
return '0';
|
|
81
81
|
}
|
|
82
|
-
// console.log(pair_details_result)
|
|
82
|
+
// // console.log(pair_details_result)
|
|
83
83
|
}
|
|
84
84
|
async getOrderIDInfo_From(id: string) {
|
|
85
|
-
// console.log('getStakingSTSWBalance');
|
|
85
|
+
// // console.log('getStakingSTSWBalance');
|
|
86
86
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getOrderIDInfo_From',
|
|
87
87
|
[uintCV(id)]);
|
|
88
88
|
try {
|
|
89
89
|
const result = await callReadOnlyFunction(options);
|
|
90
|
-
console.log('getOrderIDInfo_From', cvToValue(result));
|
|
90
|
+
// console.log('getOrderIDInfo_From', cvToValue(result));
|
|
91
91
|
return cvToValue(result);
|
|
92
92
|
} catch (e) {
|
|
93
|
-
// console.log(e);
|
|
93
|
+
// // console.log(e);
|
|
94
94
|
return '0';
|
|
95
95
|
}
|
|
96
|
-
// console.log(pair_details_result)
|
|
96
|
+
// // console.log(pair_details_result)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
async getOrderIDInfo_To(id: string) {
|
|
100
|
-
// console.log('getStakingSTSWBalance');
|
|
100
|
+
// // console.log('getStakingSTSWBalance');
|
|
101
101
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getOrderIDInfo_To',
|
|
102
102
|
[uintCV(id)]);
|
|
103
103
|
try {
|
|
104
104
|
const result = await callReadOnlyFunction(options);
|
|
105
|
-
console.log('getOrderIDInfo_To', cvToValue(result));
|
|
105
|
+
// console.log('getOrderIDInfo_To', cvToValue(result));
|
|
106
106
|
return cvToValue(result);
|
|
107
107
|
} catch (e) {
|
|
108
|
-
// console.log(e);
|
|
108
|
+
// // console.log(e);
|
|
109
109
|
return '0';
|
|
110
110
|
}
|
|
111
|
-
// console.log(pair_details_result)
|
|
111
|
+
// // console.log(pair_details_result)
|
|
112
112
|
}
|
|
113
113
|
async getOrderInfo_To(token: string, round: string|number) {
|
|
114
|
-
// console.log('getStakingSTSWBalance');
|
|
114
|
+
// // console.log('getStakingSTSWBalance');
|
|
115
115
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getOrderInfo_To',
|
|
116
116
|
[parseAddressToCV(token), uintCV(round)]);
|
|
117
117
|
try {
|
|
118
118
|
const result = await callReadOnlyFunction(options);
|
|
119
|
-
console.log('getOrderInfoWallet_From', cvToValue(result));
|
|
119
|
+
// console.log('getOrderInfoWallet_From', cvToValue(result));
|
|
120
120
|
return cvToValue(result);
|
|
121
121
|
} catch (e) {
|
|
122
|
-
// console.log(e);
|
|
122
|
+
// // console.log(e);
|
|
123
123
|
return '0';
|
|
124
124
|
}
|
|
125
|
-
// console.log(pair_details_result)
|
|
125
|
+
// // console.log(pair_details_result)
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
async getOrderInfo_From(token: string, round: string|number) {
|
|
129
|
-
// console.log('getStakingSTSWBalance');
|
|
129
|
+
// // console.log('getStakingSTSWBalance');
|
|
130
130
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getOrderInfo_From',
|
|
131
131
|
[parseAddressToCV(token), uintCV(round)]);
|
|
132
132
|
try {
|
|
133
133
|
const result = await callReadOnlyFunction(options);
|
|
134
|
-
console.log('getOrderInfoWallet_To', cvToValue(result));
|
|
134
|
+
// console.log('getOrderInfoWallet_To', cvToValue(result));
|
|
135
135
|
return cvToValue(result);
|
|
136
136
|
} catch (e) {
|
|
137
|
-
// console.log(e);
|
|
137
|
+
// // console.log(e);
|
|
138
138
|
return '0';
|
|
139
139
|
}
|
|
140
|
-
// console.log(pair_details_result)
|
|
140
|
+
// // console.log(pair_details_result)
|
|
141
141
|
}
|
|
142
142
|
async getOrderInfoWallet_From(token: string, round: string|number) {
|
|
143
|
-
// console.log('getStakingSTSWBalance');
|
|
143
|
+
// // console.log('getStakingSTSWBalance');
|
|
144
144
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getWithdrawInfo_Wallet',
|
|
145
145
|
[parseAddressToCV(this.stackswap.getSenderAddress()),parseAddressToCV(token), uintCV(round)]);
|
|
146
146
|
try {
|
|
147
147
|
const result = await callReadOnlyFunction(options);
|
|
148
|
-
console.log('getOrderInfoWallet_From', cvToValue(result));
|
|
148
|
+
// console.log('getOrderInfoWallet_From', cvToValue(result));
|
|
149
149
|
return cvToValue(result);
|
|
150
150
|
} catch (e) {
|
|
151
|
-
// console.log(e);
|
|
151
|
+
// // console.log(e);
|
|
152
152
|
return '0';
|
|
153
153
|
}
|
|
154
|
-
// console.log(pair_details_result)
|
|
154
|
+
// // console.log(pair_details_result)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
async getOrderInfoWallet_To(token: string, round: string|number) {
|
|
158
|
-
// console.log('getStakingSTSWBalance');
|
|
158
|
+
// // console.log('getStakingSTSWBalance');
|
|
159
159
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getDepositInfo_Wallet',
|
|
160
160
|
[parseAddressToCV(this.stackswap.getSenderAddress()), parseAddressToCV(token), uintCV(round)]);
|
|
161
161
|
try {
|
|
162
162
|
const result = await callReadOnlyFunction(options);
|
|
163
|
-
console.log('getOrderInfoWallet_To', cvToValue(result));
|
|
163
|
+
// console.log('getOrderInfoWallet_To', cvToValue(result));
|
|
164
164
|
return cvToValue(result);
|
|
165
165
|
} catch (e) {
|
|
166
|
-
// console.log(e);
|
|
166
|
+
// // console.log(e);
|
|
167
167
|
return '0';
|
|
168
168
|
}
|
|
169
|
-
// console.log(pair_details_result)
|
|
169
|
+
// // console.log(pair_details_result)
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
async withdrawFixFee(amount: string, callback : any = null){
|
|
173
173
|
|
|
174
|
-
// console.log({amount});
|
|
174
|
+
// // console.log({amount});
|
|
175
175
|
const post_condition = [
|
|
176
176
|
// await getPostConditionFromAsset(getSenderAddress(source), BASE_STSW_DATA().addr, new BigNumber(amount).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal),
|
|
177
177
|
await getPostConditionFromAsset(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), this.stackswap.config.BASE_WSTX_DATA().addr, new BigNumber(amount).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal)
|
|
@@ -195,7 +195,7 @@ export class BridgeManager {
|
|
|
195
195
|
functionName = 'WithdrawFee_RATIO_3';
|
|
196
196
|
break;
|
|
197
197
|
}
|
|
198
|
-
// console.log({amount});
|
|
198
|
+
// // console.log({amount});
|
|
199
199
|
const post_condition = [
|
|
200
200
|
await getPostConditionFromAsset(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), this.stackswap.config.BASE_STSW_DATA().addr, new BigNumber(amount).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal),
|
|
201
201
|
// await getPostConditionFromAsset(getSenderAddress(source), BASE_WSTX_DATA().addr, new BigNumber(10).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal)
|
|
@@ -222,7 +222,7 @@ export class BridgeManager {
|
|
|
222
222
|
|
|
223
223
|
async vote(vote: boolean, callback : any = null){
|
|
224
224
|
|
|
225
|
-
// console.log({amount});
|
|
225
|
+
// // console.log({amount});
|
|
226
226
|
const function_option : any = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'vote', [
|
|
227
227
|
vote? trueCV() : falseCV()
|
|
228
228
|
], [], callback);
|
|
@@ -231,7 +231,7 @@ export class BridgeManager {
|
|
|
231
231
|
|
|
232
232
|
async depositSTSW_SIP10_to_ERC20(addr: string, amount: string, fee: string, callback : any = null){
|
|
233
233
|
|
|
234
|
-
// console.log({amount});
|
|
234
|
+
// // console.log({amount});
|
|
235
235
|
const post_condition = [
|
|
236
236
|
await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, new BigNumber(amount).plus(fee).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal),
|
|
237
237
|
// await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, new BigNumber(10).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal)
|
|
@@ -249,7 +249,7 @@ export class BridgeManager {
|
|
|
249
249
|
|
|
250
250
|
async withdrawSTSW_ERC20_to_SIP10(orderID: string, amount: string, callback : any = null){
|
|
251
251
|
|
|
252
|
-
// console.log({amount});
|
|
252
|
+
// // console.log({amount});
|
|
253
253
|
const post_condition = [
|
|
254
254
|
await getPostConditionFromAsset(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), this.stackswap.config.BASE_STSW_DATA().addr, new BigNumber(amount).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal),
|
|
255
255
|
await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, new BigNumber(10).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal)
|
|
@@ -264,7 +264,7 @@ export class BridgeManager {
|
|
|
264
264
|
|
|
265
265
|
async cancel_depositSTSW_SIP10_to_ERC20(orderID: string, token: string, amount: string, callback : any = null){
|
|
266
266
|
|
|
267
|
-
// console.log({amount});
|
|
267
|
+
// // console.log({amount});
|
|
268
268
|
const post_condition = [
|
|
269
269
|
await getPostConditionFromAsset(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), this.stackswap.config.BASE_STSW_DATA().addr, new BigNumber(amount).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal),
|
|
270
270
|
// await getPostConditionFromAsset(getSenderAddress(source), BASE_WSTX_DATA().addr, new BigNumber(10).multipliedBy(10**6).toFixed(0), FungibleConditionCode.Equal)
|
|
@@ -279,7 +279,7 @@ export class BridgeManager {
|
|
|
279
279
|
|
|
280
280
|
async registerTokenPair(sip10Addr:string, ercAddr: string, min: string, max: string, callback : any = null){
|
|
281
281
|
|
|
282
|
-
// console.log({amount});
|
|
282
|
+
// // console.log({amount});
|
|
283
283
|
const post_condition: any = [
|
|
284
284
|
];
|
|
285
285
|
|
|
@@ -294,7 +294,7 @@ export class BridgeManager {
|
|
|
294
294
|
|
|
295
295
|
async update_depositSTSW_SIP10_to_ERC20(round: string, orders: string[], callback : any = null){
|
|
296
296
|
|
|
297
|
-
// console.log({amount});
|
|
297
|
+
// // console.log({amount});
|
|
298
298
|
const tempList = [];
|
|
299
299
|
for (const order of orders) {
|
|
300
300
|
tempList.push(uintCV(order));
|
|
@@ -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
|
}
|