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
|
@@ -47,7 +47,7 @@ export class GroupFarmManager {
|
|
|
47
47
|
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_GROUP_FARM(), 'get-farms', [listCV(listTemp)]);
|
|
48
48
|
try {
|
|
49
49
|
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
50
|
-
console.log('farmLists', result);
|
|
50
|
+
// console.log('farmLists', result);
|
|
51
51
|
return result;
|
|
52
52
|
} catch (e) {
|
|
53
53
|
return('');
|
|
@@ -59,7 +59,7 @@ export class GroupFarmManager {
|
|
|
59
59
|
]);
|
|
60
60
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
61
61
|
const result = cvToValue(result_raw);
|
|
62
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
62
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
63
63
|
return result;
|
|
64
64
|
}
|
|
65
65
|
async getRewardData(farming_contract: string) {
|
|
@@ -67,7 +67,7 @@ export class GroupFarmManager {
|
|
|
67
67
|
]);
|
|
68
68
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
69
69
|
const result = cvToValue(result_raw);
|
|
70
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
70
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
71
71
|
return result;
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -78,7 +78,7 @@ export class GroupFarmManager {
|
|
|
78
78
|
]);
|
|
79
79
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
80
80
|
const result = cvToValue(result_raw);
|
|
81
|
-
// console.log('farming round', result);
|
|
81
|
+
// // console.log('farming round', result);
|
|
82
82
|
return result.value;
|
|
83
83
|
} catch (e) {
|
|
84
84
|
return 0;
|
|
@@ -97,14 +97,14 @@ export class GroupFarmManager {
|
|
|
97
97
|
]);
|
|
98
98
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
99
99
|
const result = cvToValue(result_raw);
|
|
100
|
-
// console.log(result);
|
|
100
|
+
// // console.log(result);
|
|
101
101
|
return result;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
async getFarmingStakerStatus(stakingToken: string, cur_round: number, farming_contract: string) {
|
|
106
106
|
const address = stakingToken.split('.');
|
|
107
|
-
console.log('getFarmingStakerStatus', farming_contract);
|
|
107
|
+
// console.log('getFarmingStakerStatus', farming_contract);
|
|
108
108
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getUserData', [
|
|
109
109
|
contractPrincipalCV(address[0], address[1]),
|
|
110
110
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
@@ -112,21 +112,21 @@ export class GroupFarmManager {
|
|
|
112
112
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
113
113
|
const result = cvToValue(result_raw);
|
|
114
114
|
try {
|
|
115
|
-
console.log('getFarmingStakerStatus', result);
|
|
115
|
+
// console.log('getFarmingStakerStatus', result);
|
|
116
116
|
const pooledToken = result.value.amountLP.value;
|
|
117
117
|
const unclaimedList = [];
|
|
118
118
|
const stakedList = []
|
|
119
119
|
for (const unclaimedElement of result.value.unclaimedList.value) {
|
|
120
120
|
if (unclaimedElement.value < cur_round) {
|
|
121
121
|
unclaimedList.push(unclaimedElement.value);
|
|
122
|
-
// console.log('TTT', unclaimedElement.value)
|
|
122
|
+
// // console.log('TTT', unclaimedElement.value)
|
|
123
123
|
}
|
|
124
124
|
stakedList.push(unclaimedElement.value);
|
|
125
125
|
}
|
|
126
|
-
// console.log({pooledToken, unclaimedList, stakedList});
|
|
126
|
+
// // console.log({pooledToken, unclaimedList, stakedList});
|
|
127
127
|
return {pooledToken, unclaimedList, stakedList};
|
|
128
128
|
} catch (e) {
|
|
129
|
-
console.log(e);
|
|
129
|
+
// console.log(e);
|
|
130
130
|
return {amountToken: {type: 'uint', value: '0'}, unclaimedList: {type: "(list 0 uint)", value: []}}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -139,7 +139,7 @@ export class GroupFarmManager {
|
|
|
139
139
|
]);
|
|
140
140
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
141
141
|
const result = cvToValue(result_raw);
|
|
142
|
-
// console.log('lp total data', result);
|
|
142
|
+
// // console.log('lp total data', result);
|
|
143
143
|
try {
|
|
144
144
|
return result.value;
|
|
145
145
|
// return {amountLP: result.value.amountLP.value, weight: '3'};
|
|
@@ -156,7 +156,7 @@ export class GroupFarmManager {
|
|
|
156
156
|
]);
|
|
157
157
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
158
158
|
const result = cvToValue(result_raw);
|
|
159
|
-
// console.log('lp round data', result);
|
|
159
|
+
// // console.log('lp round data', result);
|
|
160
160
|
try {
|
|
161
161
|
return result.value;
|
|
162
162
|
} catch (e) {
|
|
@@ -173,7 +173,7 @@ export class GroupFarmManager {
|
|
|
173
173
|
]);
|
|
174
174
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
175
175
|
const result = cvToValue(result_raw);
|
|
176
|
-
// console.log('get_farming_total',result.value);
|
|
176
|
+
// // console.log('get_farming_total',result.value);
|
|
177
177
|
return result.value;
|
|
178
178
|
} catch (e) {
|
|
179
179
|
return {amountToken: {type: 'uint', value: '0'}, unclaimedList: {type: "(list 0 uint)", value: []}}
|
|
@@ -187,7 +187,7 @@ export class GroupFarmManager {
|
|
|
187
187
|
]);
|
|
188
188
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
189
189
|
const result = cvToValue(result_raw);
|
|
190
|
-
// console.log('get_farming_total',result.value);
|
|
190
|
+
// // console.log('get_farming_total',result.value);
|
|
191
191
|
return result.value;
|
|
192
192
|
} catch (e) {
|
|
193
193
|
return {
|
|
@@ -221,7 +221,7 @@ export class GroupFarmManager {
|
|
|
221
221
|
]);
|
|
222
222
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
223
223
|
const result = cvToValue(result_raw);
|
|
224
|
-
// console.log('reward', result);
|
|
224
|
+
// // console.log('reward', result);
|
|
225
225
|
return result;
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -234,7 +234,7 @@ export class GroupFarmManager {
|
|
|
234
234
|
]);
|
|
235
235
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
236
236
|
const result = cvToValue(result_raw);
|
|
237
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
237
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
238
238
|
return result;
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -244,7 +244,7 @@ export class GroupFarmManager {
|
|
|
244
244
|
]);
|
|
245
245
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
246
246
|
const result = cvToValue(result_raw);
|
|
247
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
247
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
248
248
|
return result;
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -257,12 +257,12 @@ export class GroupFarmManager {
|
|
|
257
257
|
]);
|
|
258
258
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
259
259
|
const result = cvToValue(result_raw);
|
|
260
|
-
// console.log('getFarmingUserRewardTotal', result);
|
|
260
|
+
// // console.log('getFarmingUserRewardTotal', result);
|
|
261
261
|
return result;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
async getFarmBalance(token: any, farming_contract: string) {
|
|
265
|
-
// console.log("getBalance", token)
|
|
265
|
+
// // console.log("getBalance", token)
|
|
266
266
|
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
267
267
|
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), farming_contract)]);
|
|
268
268
|
try {
|
|
@@ -335,12 +335,12 @@ export class GroupFarmManager {
|
|
|
335
335
|
parseAddressToCV(rewardToken3),
|
|
336
336
|
parseAddressToCV(rewardToken4),
|
|
337
337
|
], post_condition, callback, false);
|
|
338
|
-
console.log(rewardList);
|
|
338
|
+
// console.log(rewardList);
|
|
339
339
|
await openContractCall(function_option);
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
async getNFTAsset(tokenStr: string) {
|
|
343
|
-
// console.log(tokenStr);
|
|
343
|
+
// // console.log(tokenStr);
|
|
344
344
|
const token_addr = tokenStr.split('.');
|
|
345
345
|
const url = this.stackswap.config.STACKS_API_URL() + '/v2/contracts/interface/' + token_addr[0] + '/' + token_addr[1];
|
|
346
346
|
const result = await axios.get(url);
|
|
@@ -352,7 +352,7 @@ export class GroupFarmManager {
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
async stakeNFTs(goldList: number[], silverList: number[], callback: any, farming_contract: string) {
|
|
355
|
-
// console.log(amountTokens);
|
|
355
|
+
// // console.log(amountTokens);
|
|
356
356
|
const gold_list = [];
|
|
357
357
|
const silver_list = [];
|
|
358
358
|
const post_condition : any = [];
|
|
@@ -382,7 +382,7 @@ export class GroupFarmManager {
|
|
|
382
382
|
const post_condition: any = [];
|
|
383
383
|
const gold_asset_string = await this.getNFTAsset(this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_GOLD_PASS());
|
|
384
384
|
for (const gold of rewardList.returnNFTS.value) {
|
|
385
|
-
console.log(gold);
|
|
385
|
+
// console.log(gold);
|
|
386
386
|
post_condition.push(
|
|
387
387
|
makeContractNonFungiblePostCondition(farming_contract.split('.')[0],farming_contract.split('.')[1], NonFungibleConditionCode.Sends, gold_asset_string, uintCV(gold.value)),
|
|
388
388
|
)
|
|
@@ -403,7 +403,7 @@ export class GroupFarmManager {
|
|
|
403
403
|
parseAddressToCV(rewardToken3),
|
|
404
404
|
parseAddressToCV(rewardToken4),
|
|
405
405
|
], post_condition, callback, false);
|
|
406
|
-
// console.log(rewardList, reclaimList);
|
|
406
|
+
// // console.log(rewardList, reclaimList);
|
|
407
407
|
await openContractCall(function_option);
|
|
408
408
|
}
|
|
409
409
|
|
|
@@ -444,7 +444,7 @@ export class GroupFarmManager {
|
|
|
444
444
|
}
|
|
445
445
|
return tempRewardDict;
|
|
446
446
|
} catch (e) {
|
|
447
|
-
console.log(e);
|
|
447
|
+
// console.log(e);
|
|
448
448
|
return {
|
|
449
449
|
returnToken: {
|
|
450
450
|
type: "uint",
|
|
@@ -38,7 +38,7 @@ export class LaunchpadManager {
|
|
|
38
38
|
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
39
39
|
|
|
40
40
|
} catch (e) {
|
|
41
|
-
// console.log("no lists")
|
|
41
|
+
// // console.log("no lists")
|
|
42
42
|
return('');
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -95,7 +95,7 @@ export class LaunchpadManager {
|
|
|
95
95
|
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, getAmountWithDecimalString(data.initial_amount_x, 6), FungibleConditionCode.Equal));
|
|
96
96
|
// post_condition.push(await getPostConditionFromAsset(this.stackswap.getSenderAddress(), source.soft_token, getAmountWithDecimalString(source.initial_amount_y, source.token_decimal), FungibleConditionCode.GreaterEqual));
|
|
97
97
|
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), soft_token, 0, FungibleConditionCode.GreaterEqual));
|
|
98
|
-
// console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
98
|
+
// // console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
99
99
|
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
100
100
|
'create-pair-new-sip10-token-with-stx',
|
|
101
101
|
[
|
|
@@ -188,7 +188,7 @@ export class LaunchpadManager {
|
|
|
188
188
|
post_condition.push(await getPostConditionFromAsset(this.stackswap,this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, getAmountWithDecimalString(data.initial_amount_x, 6), FungibleConditionCode.Equal));
|
|
189
189
|
// post_condition.push(await getPostConditionFromAsset(this.stackswap.getSenderAddress(), source.soft_token, getAmountWithDecimalString(source.initial_amount_y, source.token_decimal), FungibleConditionCode.GreaterEqual));
|
|
190
190
|
post_condition.push(await getPostConditionFromAsset(this.stackswap,this.stackswap.getSenderAddress(), soft_token, 0, FungibleConditionCode.GreaterEqual));
|
|
191
|
-
// console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
191
|
+
// // console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
192
192
|
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
193
193
|
'create-pair-new-sip10-token-with-stsw',
|
|
194
194
|
[
|
|
@@ -70,7 +70,7 @@ export class LbtcManager {
|
|
|
70
70
|
[standardPrincipalCV(this.stackswap.getSenderAddress())]
|
|
71
71
|
);
|
|
72
72
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
73
|
-
// console.log('getVaultIDFromUser2', cvToValue(result_raw))
|
|
73
|
+
// // console.log('getVaultIDFromUser2', cvToValue(result_raw))
|
|
74
74
|
return cvToValue(result_raw);
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -143,7 +143,7 @@ export class LbtcManager {
|
|
|
143
143
|
|
|
144
144
|
async txDepositCollateral(vault_id: number, coll_amt: BigNumber, coll_token: string, callback: any = null) {
|
|
145
145
|
let reserve = this.stackswap.config.CONTRACT_NAME_SIP10_RESERVE();
|
|
146
|
-
// console.log(coll_token,coll_token === 'STX' )
|
|
146
|
+
// // console.log(coll_token,coll_token === 'STX' )
|
|
147
147
|
if (coll_token === 'STX') {
|
|
148
148
|
reserve = this.stackswap.config.CONTRACT_NAME_STX_RESERVE();
|
|
149
149
|
}
|
|
@@ -324,7 +324,7 @@ export class LbtcManager {
|
|
|
324
324
|
async txCloseVault(vault_id: number, coll_token: string, coll_amount: string, debt_amount: string, callback: any = null) {
|
|
325
325
|
let reserve = this.stackswap.config.CONTRACT_NAME_SIP10_RESERVE();
|
|
326
326
|
|
|
327
|
-
// console.log(coll_token, debt_amount);
|
|
327
|
+
// // console.log(coll_token, debt_amount);
|
|
328
328
|
const post_condition: any = [];
|
|
329
329
|
|
|
330
330
|
if (coll_token === 'STX') {
|
|
@@ -544,7 +544,7 @@ export class LbtcManager {
|
|
|
544
544
|
]
|
|
545
545
|
);
|
|
546
546
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
547
|
-
// console.log(cvToValue(result_raw))
|
|
547
|
+
// // console.log(cvToValue(result_raw))
|
|
548
548
|
return cvToValue(result_raw);
|
|
549
549
|
}
|
|
550
550
|
|
|
@@ -559,7 +559,7 @@ export class LbtcManager {
|
|
|
559
559
|
]
|
|
560
560
|
);
|
|
561
561
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
562
|
-
// console.log(cvToValue(result_raw))
|
|
562
|
+
// // console.log(cvToValue(result_raw))
|
|
563
563
|
return cvToValue(result_raw);
|
|
564
564
|
}
|
|
565
565
|
|
|
@@ -38,7 +38,7 @@ export class LBTCStakingManager {
|
|
|
38
38
|
uintCV(block),
|
|
39
39
|
]);
|
|
40
40
|
const result = await callReadOnlyFunction(options);
|
|
41
|
-
// console.log(cvToValue(result));
|
|
41
|
+
// // console.log(cvToValue(result));
|
|
42
42
|
return cvToValue(result).value;
|
|
43
43
|
} catch (e) {
|
|
44
44
|
return 0;
|
|
@@ -57,13 +57,13 @@ export class LBTCStakingManager {
|
|
|
57
57
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
58
58
|
]);
|
|
59
59
|
const result = await callReadOnlyFunction(options);
|
|
60
|
-
// console.log('reward', round, cvToValue(result));
|
|
60
|
+
// // console.log('reward', round, cvToValue(result));
|
|
61
61
|
const res = cvToValue(result).value;
|
|
62
|
-
// console.log('getStaker', res);
|
|
62
|
+
// // console.log('getStaker', res);
|
|
63
63
|
const unclaimedList = [];
|
|
64
64
|
const stakedList = [];
|
|
65
65
|
for (const unclaimedElement of res.staked_list.value) {
|
|
66
|
-
// console.log('reward',unclaimedElement.value);
|
|
66
|
+
// // console.log('reward',unclaimedElement.value);
|
|
67
67
|
if (Number(unclaimedElement.value) < Number(round)) {
|
|
68
68
|
unclaimedList.push(unclaimedElement.value);
|
|
69
69
|
}
|
|
@@ -82,9 +82,9 @@ export class LBTCStakingManager {
|
|
|
82
82
|
uintCV(round),
|
|
83
83
|
]);
|
|
84
84
|
const result = await callReadOnlyFunction(options);
|
|
85
|
-
// console.log('reward', round, cvToValue(result));
|
|
85
|
+
// // console.log('reward', round, cvToValue(result));
|
|
86
86
|
const res = cvToValue(result).value;
|
|
87
|
-
// console.log('getRoundData', res);
|
|
87
|
+
// // console.log('getRoundData', res);
|
|
88
88
|
return {rewardBase: res.amountRewardBase.value, amount: res.amountReturn.value, value: res.amountlBTC.value};
|
|
89
89
|
} catch (e) {
|
|
90
90
|
return {rewardBase: '0', amount: '0', value: '0'};
|
|
@@ -98,9 +98,9 @@ export class LBTCStakingManager {
|
|
|
98
98
|
uintCV(round),
|
|
99
99
|
]);
|
|
100
100
|
const result = await callReadOnlyFunction(options);
|
|
101
|
-
// console.log('reward', round, cvToValue(result));
|
|
101
|
+
// // console.log('reward', round, cvToValue(result));
|
|
102
102
|
const res = cvToValue(result).value;
|
|
103
|
-
// console.log('getRoundData', res);
|
|
103
|
+
// // console.log('getRoundData', res);
|
|
104
104
|
return {rewardBase: res.amountRewardBase.value, amount: res.amountReturn.value, value: res.amountlBTC.value};
|
|
105
105
|
} catch (e) {
|
|
106
106
|
return {amount: '0', value: '0', rewardBase: '0'};
|
|
@@ -108,11 +108,11 @@ export class LBTCStakingManager {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
async getLBTCNFT() : Promise<string[]>{
|
|
111
|
-
// console.log(tokenStr);
|
|
111
|
+
// // console.log(tokenStr);
|
|
112
112
|
const url = this.stackswap.config.STACKS_API_URL() + `/extended/v1/tokens/nft/holdings?principal=${this.stackswap.getSenderAddress()}&asset_identifiers=${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3()}::lBTC-staking-vault`
|
|
113
113
|
|
|
114
114
|
const result = await axios.get(url);
|
|
115
|
-
// console.log(tokenStr,result);
|
|
115
|
+
// // console.log(tokenStr,result);
|
|
116
116
|
const nfts = [];
|
|
117
117
|
try{
|
|
118
118
|
for (const resultElement of result.data.results) {
|
|
@@ -133,7 +133,7 @@ export class LBTCStakingManager {
|
|
|
133
133
|
]);
|
|
134
134
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
135
135
|
const result = cvToValue(result_raw);
|
|
136
|
-
// console.log("reward", round_id, result, result_raw)
|
|
136
|
+
// // console.log("reward", round_id, result, result_raw)
|
|
137
137
|
return result;
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -208,7 +208,7 @@ export class LBTCStakingManager {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
async txReclaim(index:number, amountSTX:string, callback : any = null){
|
|
211
|
-
// console.log("Unstaking", amountSTX)
|
|
211
|
+
// // console.log("Unstaking", amountSTX)
|
|
212
212
|
const post_conditions = [];
|
|
213
213
|
const assetString = `${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3()}::lBTC-staking-vault`
|
|
214
214
|
post_conditions.push(await makeStandardNonFungiblePostCondition(this.stackswap.getSenderAddress(), NonFungibleConditionCode.Sends, assetString, uintCV(index)))
|
|
@@ -238,7 +238,7 @@ export class LBTCStakingManager {
|
|
|
238
238
|
]);
|
|
239
239
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
240
240
|
const result = cvToValue(result_raw);
|
|
241
|
-
// console.log("reward", result.rewardSum.value, result_raw)
|
|
241
|
+
// // console.log("reward", result.rewardSum.value, result_raw)
|
|
242
242
|
return result.rewardSum.value;
|
|
243
243
|
}
|
|
244
244
|
|
|
@@ -248,18 +248,18 @@ export class LBTCStakingManager {
|
|
|
248
248
|
num_list.push(uintCV(unclaimed));
|
|
249
249
|
}
|
|
250
250
|
let reward_num = new BigNumber(0);
|
|
251
|
-
// console.log(pool_addr, num_list, farming_contract)
|
|
251
|
+
// // console.log(pool_addr, num_list, farming_contract)
|
|
252
252
|
try {
|
|
253
253
|
for (let i = 0; i < num_list.length; i++) {
|
|
254
|
-
// console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
254
|
+
// // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
255
255
|
const result = await this.getRewardFromList(num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length));
|
|
256
256
|
// rewardSum.value;
|
|
257
|
-
// console.log('temp result', result);
|
|
257
|
+
// // console.log('temp result', result);
|
|
258
258
|
reward_num = reward_num.plus(result);
|
|
259
259
|
}
|
|
260
260
|
return num2decimal(reward_num.toString(), 6);
|
|
261
261
|
} catch (e) {
|
|
262
|
-
// console.log(e);
|
|
262
|
+
// // console.log(e);
|
|
263
263
|
return num2decimal(reward_num.toString(), 6);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -270,18 +270,18 @@ export class LBTCStakingManager {
|
|
|
270
270
|
num_list.push(uintCV(unclaimed));
|
|
271
271
|
}
|
|
272
272
|
let reward_num = new BigNumber(0);
|
|
273
|
-
// console.log(pool_addr, num_list, farming_contract)
|
|
273
|
+
// // console.log(pool_addr, num_list, farming_contract)
|
|
274
274
|
try {
|
|
275
275
|
for (let i = 0; i < num_list.length; i += once) {
|
|
276
|
-
// console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
276
|
+
// // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
|
|
277
277
|
const result = await this.getRewardFromList(num_list.slice(i, i + once < num_list.length ? i + once : num_list.length));
|
|
278
278
|
// rewardSum.value;
|
|
279
|
-
// console.log('temp result', result);
|
|
279
|
+
// // console.log('temp result', result);
|
|
280
280
|
reward_num = reward_num.plus(result);
|
|
281
281
|
}
|
|
282
282
|
return num2decimal(reward_num.toString(), 6);
|
|
283
283
|
} catch (e) {
|
|
284
|
-
// console.log(e);
|
|
284
|
+
// // console.log(e);
|
|
285
285
|
return num2decimal(reward_num.toString(), 6);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
@@ -323,12 +323,12 @@ export class LBTCStakingManager {
|
|
|
323
323
|
}
|
|
324
324
|
async getUserStakingData(){
|
|
325
325
|
const staker_info = await this.getStaker();
|
|
326
|
-
console.log('get staker', staker_info);
|
|
326
|
+
// console.log('get staker', staker_info);
|
|
327
327
|
const user_staked_amount = staker_info.amount;
|
|
328
328
|
const stake_lbtc_claim_round_list = staker_info.unclaimedList;
|
|
329
329
|
// stake_lbtc_claim_round.set(staker_info.unclaimedList[0]);
|
|
330
330
|
const total_reward = await this.getRewardTotal(staker_info.unclaimedList)
|
|
331
|
-
console.log('total reward', total_reward);
|
|
331
|
+
// console.log('total reward', total_reward);
|
|
332
332
|
return {user_staked_amount, stake_lbtc_claim_round_list, total_reward};
|
|
333
333
|
}
|
|
334
334
|
|
|
@@ -341,12 +341,12 @@ export class LBTCStakingManager {
|
|
|
341
341
|
standardPrincipalCV(user),
|
|
342
342
|
]);
|
|
343
343
|
const result = await callReadOnlyFunction(options);
|
|
344
|
-
// console.log(cvToValue(result));
|
|
344
|
+
// // console.log(cvToValue(result));
|
|
345
345
|
const res = cvToValue(result).value;
|
|
346
346
|
|
|
347
347
|
return {amount: res.amountReturn.value, value: res.amountlBTC.value};
|
|
348
348
|
} catch (e) {
|
|
349
|
-
console.log(e);
|
|
349
|
+
// console.log(e);
|
|
350
350
|
return {amount: '0', value: '0'};
|
|
351
351
|
}
|
|
352
352
|
}
|
|
@@ -20,7 +20,7 @@ export class MultisigManager {
|
|
|
20
20
|
|
|
21
21
|
async deposit_vote_multisig(vote: boolean){
|
|
22
22
|
|
|
23
|
-
// console.log({amount});
|
|
23
|
+
// // console.log({amount});
|
|
24
24
|
const function_option : any = getWriteOptions(this.stackswap, 'SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01', 'deposit-vote', [
|
|
25
25
|
vote? trueCV() : falseCV()
|
|
26
26
|
], []);
|
|
@@ -29,7 +29,7 @@ export class MultisigManager {
|
|
|
29
29
|
|
|
30
30
|
async withdraw_vote_multisig(vote: boolean){
|
|
31
31
|
|
|
32
|
-
// console.log({amount});
|
|
32
|
+
// // console.log({amount});
|
|
33
33
|
const function_option : any = getWriteOptions(this.stackswap, 'SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01', 'withdraw-vote', [
|
|
34
34
|
vote? trueCV() : falseCV()
|
|
35
35
|
], []);
|
|
@@ -38,7 +38,7 @@ export class MultisigManager {
|
|
|
38
38
|
|
|
39
39
|
async deposit_multisig(amount: string){
|
|
40
40
|
|
|
41
|
-
// console.log({amount});
|
|
41
|
+
// // console.log({amount});
|
|
42
42
|
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
43
43
|
const function_option : any = getWriteOptions(this.stackswap, 'SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01', 'deposit', [
|
|
44
44
|
uintCV(amount)
|
|
@@ -48,7 +48,7 @@ export class MultisigManager {
|
|
|
48
48
|
|
|
49
49
|
async withdraw_multisig(addr: string, amount: string){
|
|
50
50
|
|
|
51
|
-
// console.log({amount});
|
|
51
|
+
// // console.log({amount});
|
|
52
52
|
const post_condition = [await getPostConditionFromAsset(this.stackswap, 'SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01', this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
53
53
|
|
|
54
54
|
const function_option: any = getWriteOptions(this.stackswap, 'SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01', 'withdraw', [
|
|
@@ -58,25 +58,25 @@ export class MultisigManager {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async getMultisigSTSWAmount() {
|
|
61
|
-
// console.log('getStakingSTSWBalance');
|
|
61
|
+
// // console.log('getStakingSTSWBalance');
|
|
62
62
|
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.BASE_STSW_DATA().addr, 'get-balance',
|
|
63
63
|
[parseAddressToCV('SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01')]);
|
|
64
64
|
try {
|
|
65
65
|
const result = await callReadOnlyFunction(pair_details_options);
|
|
66
|
-
// console.log('get-balance', cvToValue(result));
|
|
66
|
+
// // console.log('get-balance', cvToValue(result));
|
|
67
67
|
return cvToValue(result).value;
|
|
68
68
|
} catch (e) {
|
|
69
|
-
// console.log(e);
|
|
69
|
+
// // console.log(e);
|
|
70
70
|
return '0';
|
|
71
71
|
}
|
|
72
|
-
// console.log(pair_details_result)
|
|
72
|
+
// // console.log(pair_details_result)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
async getMultisigResult(functionName: string) {
|
|
76
76
|
const pair_details_options : any = getReadOptions(this.stackswap, 'SPVRC3RHFD58B2PY1HZD2V71THPW7G445WBRCQYW.octopus_v01', functionName,
|
|
77
77
|
[]);
|
|
78
78
|
const result = await callReadOnlyFunction(pair_details_options);
|
|
79
|
-
// console.log(functionName, cvToValue(result));
|
|
79
|
+
// // console.log(functionName, cvToValue(result));
|
|
80
80
|
return cvToValue(result);
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -25,7 +25,7 @@ export class NftManager {
|
|
|
25
25
|
contract_address: string,
|
|
26
26
|
holderAddress: string = this.stackswap.getSenderAddress(),
|
|
27
27
|
): Promise<string[]>{
|
|
28
|
-
// console.log(tokenStr);
|
|
28
|
+
// // console.log(tokenStr);
|
|
29
29
|
const nft_asset_name = await this.getNFTAsset(contract_address);
|
|
30
30
|
|
|
31
31
|
return await this.getUserNFTList(nft_asset_name, holderAddress);
|
|
@@ -35,11 +35,11 @@ export class NftManager {
|
|
|
35
35
|
nft_asset_name: string,
|
|
36
36
|
holderAddress: string = this.stackswap.getSenderAddress()
|
|
37
37
|
) : Promise<string[]>{
|
|
38
|
-
// console.log(tokenStr);
|
|
38
|
+
// // console.log(tokenStr);
|
|
39
39
|
const url = this.stackswap.config.STACKS_API_URL() + `/extended/v1/tokens/nft/holdings?principal=${holderAddress}&asset_identifiers=${nft_asset_name}`
|
|
40
40
|
|
|
41
41
|
const result = await axios.get(url);
|
|
42
|
-
// console.log(tokenStr,result);
|
|
42
|
+
// // console.log(tokenStr,result);
|
|
43
43
|
const nfts = [];
|
|
44
44
|
try{
|
|
45
45
|
for (const resultElement of result.data.results) {
|
|
@@ -51,17 +51,17 @@ export class NftManager {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
async getNFTAsset(tokenStr: string) {
|
|
54
|
-
// console.log(tokenStr);
|
|
54
|
+
// // console.log(tokenStr);
|
|
55
55
|
const token_addr = tokenStr.split('.');
|
|
56
56
|
const url = this.stackswap.config.STACKS_API_URL() + '/v2/contracts/interface/' + token_addr[0] + '/' + token_addr[1];
|
|
57
57
|
const result = await axios.get(url);
|
|
58
|
-
// console.log(tokenStr,result);
|
|
58
|
+
// // console.log(tokenStr,result);
|
|
59
59
|
if (result.data.non_fungible_tokens.length === 1) {
|
|
60
|
-
// console.log(tokenStr+'::'+result.data.non_fungible_tokens[0].name);
|
|
60
|
+
// // console.log(tokenStr+'::'+result.data.non_fungible_tokens[0].name);
|
|
61
61
|
return tokenStr + '::' + result.data.non_fungible_tokens[0].name;
|
|
62
62
|
} else {
|
|
63
63
|
// TODO one contract with more than one ft
|
|
64
|
-
// console.log(tokenStr+'::'+result.data.non_fungible_tokens[0].name);
|
|
64
|
+
// // console.log(tokenStr+'::'+result.data.non_fungible_tokens[0].name);
|
|
65
65
|
return tokenStr + '::' + result.data.non_fungible_tokens[0].name;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -140,7 +140,7 @@ export class NftManager {
|
|
|
140
140
|
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STSW_LBTC_LP(), this.stackswap.config.BASE_LBTC_DATA().addr, 0, FungibleConditionCode.GreaterEqual));
|
|
141
141
|
// post_condition.push(await getPostConditionFromAssetNFT(owner, STACKSWAP_ADDRESS()+'.'+CONTRACT_NAME_AINFT(), NonFungibleConditionCode.Sends, id));
|
|
142
142
|
post_condition.push(await this.getPostConditionFromAssetNFT(owner, this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_AINFT(), NonFungibleConditionCode.Sends, ''+id));
|
|
143
|
-
// console.log(await getNFTAsset(STACKSWAP_ADDRESS()+'.'+CONTRACT_NAME_AINFT()))
|
|
143
|
+
// // console.log(await getNFTAsset(STACKSWAP_ADDRESS()+'.'+CONTRACT_NAME_AINFT()))
|
|
144
144
|
const function_option : any = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_AINFT(), 'buy-in-ustx', [
|
|
145
145
|
uintCV(id),
|
|
146
146
|
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(),comm),
|
|
@@ -182,7 +182,7 @@ export class NftManager {
|
|
|
182
182
|
]);
|
|
183
183
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
184
184
|
const result = cvToValue(result_raw);
|
|
185
|
-
// console.log(result);
|
|
185
|
+
// // console.log(result);
|
|
186
186
|
return result.value;
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -218,9 +218,9 @@ export class NftManager {
|
|
|
218
218
|
]);
|
|
219
219
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
220
220
|
try{
|
|
221
|
-
// console.log('result_raw', result_raw);
|
|
221
|
+
// // console.log('result_raw', result_raw);
|
|
222
222
|
// const result = cvToValue(result_raw);
|
|
223
|
-
// console.log(result);
|
|
223
|
+
// // console.log(result);
|
|
224
224
|
// return result;
|
|
225
225
|
return cvToValue(result_raw);
|
|
226
226
|
}catch (e) {
|
|
@@ -234,7 +234,7 @@ export class NftManager {
|
|
|
234
234
|
]);
|
|
235
235
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
236
236
|
const result = cvToValue(result_raw);
|
|
237
|
-
// console.log(result);
|
|
237
|
+
// // console.log(result);
|
|
238
238
|
return result.value;
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -244,7 +244,7 @@ export class NftManager {
|
|
|
244
244
|
]);
|
|
245
245
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
246
246
|
const result = cvToValue(result_raw);
|
|
247
|
-
// console.log(result);
|
|
247
|
+
// // console.log(result);
|
|
248
248
|
return result.value;
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -279,7 +279,7 @@ export class NftManager {
|
|
|
279
279
|
const result_raw = await callReadOnlyFunction(function_option);
|
|
280
280
|
const result = cvToValue(result_raw);
|
|
281
281
|
try{
|
|
282
|
-
// console.log(result.value.price.value);
|
|
282
|
+
// // console.log(result.value.price.value);
|
|
283
283
|
return result.value.price.value;
|
|
284
284
|
} catch (e) {
|
|
285
285
|
return 0;
|
|
@@ -305,7 +305,7 @@ export class NftManager {
|
|
|
305
305
|
contract_name : this.stackswap.config.STACKSWAP_ADDRESS() + '.' + contractaddr
|
|
306
306
|
};
|
|
307
307
|
const json_result = await axios.get(temp.json_url);
|
|
308
|
-
// console.log(json_result.data);
|
|
308
|
+
// // console.log(json_result.data);
|
|
309
309
|
temp.desc = json_result.data.description;
|
|
310
310
|
temp.name = json_result.data.name;
|
|
311
311
|
temp.img_url = 'https://gateway.ipfs/ipfs/'+json_result.data.image.substr(7, json_result.data.image.length);
|
|
@@ -334,7 +334,7 @@ export class NftManager {
|
|
|
334
334
|
contract_name : this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_AINFT()
|
|
335
335
|
};
|
|
336
336
|
const json_result = await axios.get(`https://gateway.ipfs.io/ipfs/Qmaa5RRUMa9HQRHWJw3HWG3i1NUmb5VgJXT9Zqqg5VHQjX/${id_}.json`);
|
|
337
|
-
// console.log(json_result.data);
|
|
337
|
+
// // console.log(json_result.data);
|
|
338
338
|
temp.img_url = 'https://gateway.ipfs.io/ipfs/'+json_result.data.image.substr(7, json_result.data.image.length);
|
|
339
339
|
temp.desc = json_result.data.description;
|
|
340
340
|
temp.name = json_result.data.name;
|
|
@@ -82,7 +82,7 @@ export class OperatorManager {
|
|
|
82
82
|
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-invester',
|
|
83
83
|
[ standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
84
84
|
const result = await callReadOnlyFunction(options);
|
|
85
|
-
// console.log(cvToValue(result));
|
|
85
|
+
// // console.log(cvToValue(result));
|
|
86
86
|
|
|
87
87
|
return cvToValue(result).value;
|
|
88
88
|
}
|
|
@@ -90,7 +90,7 @@ export class OperatorManager {
|
|
|
90
90
|
const options : any = getReadOptions(this.stackswap, 'distributor0001', 'get-claimable-amount',
|
|
91
91
|
[ standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
92
92
|
const result = await callReadOnlyFunction(options);
|
|
93
|
-
// console.log(cvToValue(result));
|
|
93
|
+
// // console.log(cvToValue(result));
|
|
94
94
|
|
|
95
95
|
return cvToValue(result);
|
|
96
96
|
}
|
|
@@ -48,7 +48,7 @@ export class OtherManager {
|
|
|
48
48
|
const options = getReadOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'get-pox-info',
|
|
49
49
|
[ ]);
|
|
50
50
|
const result = await callReadOnlyFunction(options);
|
|
51
|
-
// console.log(cvToValue(result).value);
|
|
51
|
+
// // console.log(cvToValue(result).value);
|
|
52
52
|
return cvToValue(result).value;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -60,7 +60,7 @@ export class OtherManager {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
63
|
-
// console.log(addresss);
|
|
63
|
+
// // console.log(addresss);
|
|
64
64
|
const options = getWriteOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'stack-stx',
|
|
65
65
|
[ uintCV(amount_str), addresss, uintCV(start_burn_ht), uintCV(lock_period)],[], callback);
|
|
66
66
|
const result_raw = await openContractCall(options);
|