stackswap-front-api-test-02 1.2.12 → 1.2.13
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/index.d.ts +1 -0
- package/dist/esm/index.js +4 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stackswap/manager/bridge.manager.js +11 -11
- package/dist/esm/stackswap/manager/bridge.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/farm.manager.js +15 -15
- package/dist/esm/stackswap/manager/farm.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/farm2.manager.js +18 -18
- package/dist/esm/stackswap/manager/farm2.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/farm3.manager.js +14 -14
- package/dist/esm/stackswap/manager/farm3.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/governance.manager.js +3 -3
- package/dist/esm/stackswap/manager/governance.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/groupfarm.manager.d.ts +1 -2
- package/dist/esm/stackswap/manager/groupfarm.manager.js +23 -23
- package/dist/esm/stackswap/manager/groupfarm.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/launchpad.manager.js +6 -6
- package/dist/esm/stackswap/manager/launchpad.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/lbtc.manager.js +9 -9
- package/dist/esm/stackswap/manager/lbtc.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js +15 -15
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/multisig.manager.js +3 -3
- package/dist/esm/stackswap/manager/multisig.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/nft.manager.js +12 -12
- package/dist/esm/stackswap/manager/nft.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/operator.manager.js +3 -3
- package/dist/esm/stackswap/manager/operator.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/other.manager.js +3 -3
- package/dist/esm/stackswap/manager/other.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/pool.manager.js +5 -5
- package/dist/esm/stackswap/manager/pool.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/poxl.manager.js +3 -3
- package/dist/esm/stackswap/manager/poxl.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/staking.manager.js +16 -16
- package/dist/esm/stackswap/manager/staking.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/token.manager.js +6 -6
- package/dist/esm/stackswap/manager/token.manager.js.map +1 -1
- package/dist/esm/stackswap/util.d.ts +3 -8
- package/dist/esm/stackswap/util.js +10 -63
- package/dist/esm/stackswap/util.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/stackswap/manager/bridge.manager.js +10 -10
- package/dist/stackswap/manager/bridge.manager.js.map +1 -1
- package/dist/stackswap/manager/farm.manager.js +14 -14
- package/dist/stackswap/manager/farm.manager.js.map +1 -1
- package/dist/stackswap/manager/farm2.manager.js +17 -17
- package/dist/stackswap/manager/farm2.manager.js.map +1 -1
- package/dist/stackswap/manager/farm3.manager.js +13 -13
- package/dist/stackswap/manager/farm3.manager.js.map +1 -1
- package/dist/stackswap/manager/governance.manager.js +2 -2
- package/dist/stackswap/manager/governance.manager.js.map +1 -1
- package/dist/stackswap/manager/groupfarm.manager.d.ts +1 -2
- package/dist/stackswap/manager/groupfarm.manager.js +21 -21
- package/dist/stackswap/manager/groupfarm.manager.js.map +1 -1
- package/dist/stackswap/manager/launchpad.manager.js +5 -5
- package/dist/stackswap/manager/launchpad.manager.js.map +1 -1
- package/dist/stackswap/manager/lbtc.manager.js +8 -8
- package/dist/stackswap/manager/lbtc.manager.js.map +1 -1
- package/dist/stackswap/manager/lbtcstaking.manager.js +13 -13
- package/dist/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/stackswap/manager/multisig.manager.js +2 -2
- package/dist/stackswap/manager/multisig.manager.js.map +1 -1
- package/dist/stackswap/manager/nft.manager.js +10 -10
- package/dist/stackswap/manager/nft.manager.js.map +1 -1
- package/dist/stackswap/manager/operator.manager.js +2 -2
- package/dist/stackswap/manager/operator.manager.js.map +1 -1
- package/dist/stackswap/manager/other.manager.js +2 -2
- package/dist/stackswap/manager/other.manager.js.map +1 -1
- package/dist/stackswap/manager/pool.manager.js +4 -4
- package/dist/stackswap/manager/pool.manager.js.map +1 -1
- package/dist/stackswap/manager/poxl.manager.js +2 -2
- package/dist/stackswap/manager/poxl.manager.js.map +1 -1
- package/dist/stackswap/manager/staking.manager.js +15 -15
- package/dist/stackswap/manager/staking.manager.js.map +1 -1
- package/dist/stackswap/manager/token.manager.js +5 -5
- package/dist/stackswap/manager/token.manager.js.map +1 -1
- package/dist/stackswap/util.d.ts +3 -8
- package/dist/stackswap/util.js +11 -67
- package/dist/stackswap/util.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +7 -9
- package/src/stackswap/manager/bridge.manager.ts +11 -11
- package/src/stackswap/manager/farm.manager.ts +15 -15
- package/src/stackswap/manager/farm2.manager.ts +18 -18
- package/src/stackswap/manager/farm3.manager.ts +14 -14
- package/src/stackswap/manager/governance.manager.ts +3 -3
- package/src/stackswap/manager/groupfarm.manager.ts +24 -26
- package/src/stackswap/manager/launchpad.manager.ts +6 -6
- package/src/stackswap/manager/lbtc.manager.ts +9 -9
- package/src/stackswap/manager/lbtcstaking.manager.ts +16 -17
- package/src/stackswap/manager/multisig.manager.ts +3 -3
- package/src/stackswap/manager/nft.manager.ts +13 -14
- package/src/stackswap/manager/operator.manager.ts +3 -3
- package/src/stackswap/manager/other.manager.ts +3 -3
- package/src/stackswap/manager/pool.manager.ts +5 -5
- package/src/stackswap/manager/poxl.manager.ts +3 -3
- package/src/stackswap/manager/staking.manager.ts +16 -16
- package/src/stackswap/manager/token.manager.ts +6 -6
- package/src/stackswap/util.ts +51 -74
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stackswap-front-api-test-02",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "tsc -b tsconfig.build.json --watch --verbose",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@stacks/connect": "^7.
|
|
22
|
-
"@stacks/transactions": "^
|
|
23
|
-
"@stacks/network": "^
|
|
21
|
+
"@stacks/connect": "^7.7.1",
|
|
22
|
+
"@stacks/transactions": "^6.16.1",
|
|
23
|
+
"@stacks/network": "^6.16.1",
|
|
24
24
|
"axios": "^1.7.7",
|
|
25
25
|
"bignumber.js": "^9.0.1"
|
|
26
26
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {StacksMainnet, StacksMocknet, StacksNetwork, StacksTestnet} from "@stacks/network";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import {
|
|
4
4
|
StackswapConfig,
|
|
@@ -52,7 +52,7 @@ export interface StackswapAPI {
|
|
|
52
52
|
getSenderAddress: () => string;
|
|
53
53
|
getQualifiedAddress: (address: string) => string;
|
|
54
54
|
getCurrentBlock: () => Promise<string>;
|
|
55
|
-
getCurrentBlocks: () => Promise<{ block_height : string, burn_block_height: string }>;
|
|
55
|
+
getCurrentBlocks: () => Promise<{ block_height : string, burn_block_height: string, tenure_block_height: string }>;
|
|
56
56
|
walletConnect: (callback: (arg: any) => void) => void;
|
|
57
57
|
getConnectedWallet: (callback: (arg: any) => void) => void;
|
|
58
58
|
signOut: (callback: (arg: any) => void) => void;
|
|
@@ -88,9 +88,7 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
88
88
|
this.fixedSenderAddress = fixedSenderAddress;
|
|
89
89
|
|
|
90
90
|
this.config = new StackswapMainetConfig(farm_end_cycle, fixedSTSWAPIAddress, networkAddress);
|
|
91
|
-
this.network =
|
|
92
|
-
this.network.client.baseUrl = api_url? api_url : this.config.STACKS_API_URL();
|
|
93
|
-
// new StacksMainnet({url: api_url? api_url : this.config.STACKS_API_URL()});
|
|
91
|
+
this.network = new StacksMainnet({url: api_url? api_url : this.config.STACKS_API_URL()});
|
|
94
92
|
this.senderAdderss = this.config.NULL_ADDRESS();
|
|
95
93
|
this.getConnectedWallet(((_err, _result) => {
|
|
96
94
|
}));
|
|
@@ -254,7 +252,7 @@ export class StackswapTestnetAPI extends StackswapMainnetAPI {
|
|
|
254
252
|
constructor(farm_end_cycle: string = '99999', fixedSenderAddress: string|null = null, api_url: string| null) {
|
|
255
253
|
super(farm_end_cycle, fixedSenderAddress, api_url);
|
|
256
254
|
this.config = new StackswapTestnetConfig(farm_end_cycle);
|
|
257
|
-
this.network =
|
|
255
|
+
this.network = new StacksTestnet();
|
|
258
256
|
}
|
|
259
257
|
|
|
260
258
|
}
|
|
@@ -262,12 +260,12 @@ export class StackswapTestnetAPI extends StackswapMainnetAPI {
|
|
|
262
260
|
|
|
263
261
|
export class StackswapDevnetAPI extends StackswapMainnetAPI {
|
|
264
262
|
|
|
265
|
-
constructor(farm_end_cycle: string = '99999', fixedSenderAddress: string
|
|
263
|
+
constructor(farm_end_cycle: string = '99999', fixedSenderAddress: string|null = null, api_url: string| null) {
|
|
266
264
|
super(farm_end_cycle, fixedSenderAddress, api_url);
|
|
267
265
|
this.config = new StackswapDevnetConfig(farm_end_cycle);
|
|
268
|
-
this.network =
|
|
269
|
-
|
|
266
|
+
this.network = new StacksMocknet();
|
|
270
267
|
}
|
|
268
|
+
|
|
271
269
|
}
|
|
272
270
|
|
|
273
271
|
export class StackswapConfigAPI extends StackswapMainnetAPI {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
callReadOnlyFunction,
|
|
4
4
|
cvToValue, falseCV,
|
|
5
5
|
FungibleConditionCode, listCV,
|
|
6
6
|
stringAsciiCV, trueCV,
|
|
@@ -25,7 +25,7 @@ export class BridgeManager {
|
|
|
25
25
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'get-voters',
|
|
26
26
|
[]);
|
|
27
27
|
try {
|
|
28
|
-
const result = await
|
|
28
|
+
const result = await callReadOnlyFunction(options);
|
|
29
29
|
const temp2 = [];
|
|
30
30
|
for (const cvToValueElement of cvToValue(result)) {
|
|
31
31
|
temp2.push(cvToValueElement.value);
|
|
@@ -43,7 +43,7 @@ export class BridgeManager {
|
|
|
43
43
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getVoteRes',
|
|
44
44
|
[]);
|
|
45
45
|
try {
|
|
46
|
-
const result = await
|
|
46
|
+
const result = await callReadOnlyFunction(options);
|
|
47
47
|
// console.log('getVoteRes', cvToValue(result));
|
|
48
48
|
return cvToValue(result);
|
|
49
49
|
} catch (e) {
|
|
@@ -58,7 +58,7 @@ export class BridgeManager {
|
|
|
58
58
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'GetFee',
|
|
59
59
|
[]);
|
|
60
60
|
try {
|
|
61
|
-
const result = await
|
|
61
|
+
const result = await callReadOnlyFunction(options);
|
|
62
62
|
// console.log('GetFee', cvToValue(result));
|
|
63
63
|
return cvToValue(result);
|
|
64
64
|
} catch (e) {
|
|
@@ -72,7 +72,7 @@ export class BridgeManager {
|
|
|
72
72
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getETHToken',
|
|
73
73
|
[parseAddressToCV(token)]);
|
|
74
74
|
try {
|
|
75
|
-
const result = await
|
|
75
|
+
const result = await callReadOnlyFunction(options);
|
|
76
76
|
// console.log('getETHToken', cvToValue(result));
|
|
77
77
|
return cvToValue(result);
|
|
78
78
|
} catch (e) {
|
|
@@ -86,7 +86,7 @@ export class BridgeManager {
|
|
|
86
86
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getOrderIDInfo_From',
|
|
87
87
|
[uintCV(id)]);
|
|
88
88
|
try {
|
|
89
|
-
const result = await
|
|
89
|
+
const result = await callReadOnlyFunction(options);
|
|
90
90
|
// console.log('getOrderIDInfo_From', cvToValue(result));
|
|
91
91
|
return cvToValue(result);
|
|
92
92
|
} catch (e) {
|
|
@@ -101,7 +101,7 @@ export class BridgeManager {
|
|
|
101
101
|
const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_BRIDGE(), 'getOrderIDInfo_To',
|
|
102
102
|
[uintCV(id)]);
|
|
103
103
|
try {
|
|
104
|
-
const result = await
|
|
104
|
+
const result = await callReadOnlyFunction(options);
|
|
105
105
|
// console.log('getOrderIDInfo_To', cvToValue(result));
|
|
106
106
|
return cvToValue(result);
|
|
107
107
|
} catch (e) {
|
|
@@ -115,7 +115,7 @@ export class BridgeManager {
|
|
|
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
|
-
const result = await
|
|
118
|
+
const result = await callReadOnlyFunction(options);
|
|
119
119
|
// console.log('getOrderInfoWallet_From', cvToValue(result));
|
|
120
120
|
return cvToValue(result);
|
|
121
121
|
} catch (e) {
|
|
@@ -130,7 +130,7 @@ export class BridgeManager {
|
|
|
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
|
-
const result = await
|
|
133
|
+
const result = await callReadOnlyFunction(options);
|
|
134
134
|
// console.log('getOrderInfoWallet_To', cvToValue(result));
|
|
135
135
|
return cvToValue(result);
|
|
136
136
|
} catch (e) {
|
|
@@ -144,7 +144,7 @@ export class BridgeManager {
|
|
|
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
|
-
const result = await
|
|
147
|
+
const result = await callReadOnlyFunction(options);
|
|
148
148
|
// console.log('getOrderInfoWallet_From', cvToValue(result));
|
|
149
149
|
return cvToValue(result);
|
|
150
150
|
} catch (e) {
|
|
@@ -159,7 +159,7 @@ export class BridgeManager {
|
|
|
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
|
-
const result = await
|
|
162
|
+
const result = await callReadOnlyFunction(options);
|
|
163
163
|
// console.log('getOrderInfoWallet_To', cvToValue(result));
|
|
164
164
|
return cvToValue(result);
|
|
165
165
|
} catch (e) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
callReadOnlyFunction,
|
|
4
4
|
contractPrincipalCV,
|
|
5
5
|
cvToValue, FungibleConditionCode,
|
|
6
6
|
listCV,
|
|
@@ -47,7 +47,7 @@ export class FarmManager {
|
|
|
47
47
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING(), 'get-reward-cycle', [
|
|
48
48
|
uintCV(bh)
|
|
49
49
|
]);
|
|
50
|
-
const result_raw = await
|
|
50
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
51
51
|
const result = cvToValue(result_raw);
|
|
52
52
|
return result.value;
|
|
53
53
|
} catch (e) {
|
|
@@ -59,7 +59,7 @@ export class FarmManager {
|
|
|
59
59
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING(), 'get-first-stacks-block-in-reward-cycle', [
|
|
60
60
|
uintCV(cycle)
|
|
61
61
|
]);
|
|
62
|
-
const result_raw = await
|
|
62
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
63
63
|
const result = cvToValue(result_raw);
|
|
64
64
|
// // console.log(result);
|
|
65
65
|
return result;
|
|
@@ -71,7 +71,7 @@ export class FarmManager {
|
|
|
71
71
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
72
72
|
contractPrincipalCV(address[0],address[1]),
|
|
73
73
|
]);
|
|
74
|
-
const result_raw = await
|
|
74
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
75
75
|
const result = cvToValue(result_raw);
|
|
76
76
|
try{
|
|
77
77
|
// // console.log('getFarmingStakerStatus', result);
|
|
@@ -97,7 +97,7 @@ export class FarmManager {
|
|
|
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 {
|
|
100
|
-
const result = await
|
|
100
|
+
const result = await callReadOnlyFunction(pair_details_options);
|
|
101
101
|
return cvToValue(result).value;
|
|
102
102
|
} catch (e) {
|
|
103
103
|
return 0;
|
|
@@ -126,7 +126,7 @@ export class FarmManager {
|
|
|
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
|
-
const result_raw = await
|
|
129
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
130
130
|
const result = cvToValue(result_raw);
|
|
131
131
|
// // console.log(result.value.amountUstx.value);
|
|
132
132
|
try{
|
|
@@ -142,7 +142,7 @@ export class FarmManager {
|
|
|
142
142
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING(), 'get-farm-info', [
|
|
143
143
|
contractPrincipalCV(address[0],address[1]),
|
|
144
144
|
]);
|
|
145
|
-
const result_raw = await
|
|
145
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
146
146
|
const result = cvToValue(result_raw);
|
|
147
147
|
// // console.log('get_farming_total',result.value);
|
|
148
148
|
return result.value;
|
|
@@ -159,7 +159,7 @@ export class FarmManager {
|
|
|
159
159
|
contractPrincipalCV(address[0],address[1]),
|
|
160
160
|
uintCV(cycle),
|
|
161
161
|
]);
|
|
162
|
-
const result_raw = await
|
|
162
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
163
163
|
const result = cvToValue(result_raw);
|
|
164
164
|
// // console.log(result_raw);
|
|
165
165
|
return result;
|
|
@@ -171,7 +171,7 @@ export class FarmManager {
|
|
|
171
171
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
172
172
|
contractPrincipalCV(address[0],address[1]),
|
|
173
173
|
]);
|
|
174
|
-
const result_raw = await
|
|
174
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
175
175
|
const result = cvToValue(result_raw);
|
|
176
176
|
// // console.log('getFarmingUserRewardTotal', result);
|
|
177
177
|
return result;
|
|
@@ -185,7 +185,7 @@ export class FarmManager {
|
|
|
185
185
|
contractPrincipalCV(address[0],address[1]),
|
|
186
186
|
listCV(unclaimed_list),
|
|
187
187
|
]);
|
|
188
|
-
const result_raw = await
|
|
188
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
189
189
|
const result = cvToValue(result_raw);
|
|
190
190
|
// // console.log('getFarmingUserRewardTotal', result);
|
|
191
191
|
return result;
|
|
@@ -198,7 +198,7 @@ export class FarmManager {
|
|
|
198
198
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
199
199
|
contractPrincipalCV(address[0],address[1]),
|
|
200
200
|
]);
|
|
201
|
-
const result_raw = await
|
|
201
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
202
202
|
try{
|
|
203
203
|
const result = cvToValue(result_raw);
|
|
204
204
|
// // console.log(result);
|
|
@@ -248,8 +248,8 @@ export class FarmManager {
|
|
|
248
248
|
|
|
249
249
|
|
|
250
250
|
async getCurrentFarmingRound() {
|
|
251
|
-
const bh = await this.stackswap.
|
|
252
|
-
return await this.getFarmingRound(bh);
|
|
251
|
+
const bh = await this.stackswap.getCurrentBlocks();
|
|
252
|
+
return await this.getFarmingRound(bh.tenure_block_height);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
|
|
@@ -315,11 +315,11 @@ export class FarmManager {
|
|
|
315
315
|
const oracle_stsw = (await this.stackswap.lbtcManager.getPrice('STSW'))['last-price'].value;
|
|
316
316
|
const oracle_stx = (await this.stackswap.lbtcManager.getPrice('STX'))['last-price'].value;
|
|
317
317
|
// const oracle_lbtc = (await this.stackswap.lbtcManager.getPrice('lBTC'))['last-price'].value;
|
|
318
|
-
const bh = await this.stackswap.
|
|
318
|
+
const bh = await this.stackswap.getCurrentBlocks();
|
|
319
319
|
|
|
320
320
|
const usd_stx = new BigNumber(oracle_stx).dividedBy(10**6).toNumber();
|
|
321
321
|
const stsw_stx = new BigNumber(oracle_stsw).dividedBy(oracle_stx).toNumber();
|
|
322
|
-
const cur_round = await this.getFarmingRound(bh);
|
|
322
|
+
const cur_round = await this.getFarmingRound(bh.tenure_block_height);
|
|
323
323
|
const farms: any[] = [];
|
|
324
324
|
data.forEach((farm: any) => {
|
|
325
325
|
if (farm.farm_group === 1) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
callReadOnlyFunction,
|
|
3
3
|
contractPrincipalCV,
|
|
4
4
|
cvToValue, FungibleConditionCode,
|
|
5
5
|
listCV,
|
|
@@ -29,7 +29,7 @@ export class Farm2Manager {
|
|
|
29
29
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getRewardRound', [
|
|
30
30
|
uintCV(bh)
|
|
31
31
|
]);
|
|
32
|
-
const result_raw = await
|
|
32
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
33
33
|
const result = cvToValue(result_raw);
|
|
34
34
|
// // console.log('farming round', result);
|
|
35
35
|
return result.value;
|
|
@@ -42,7 +42,7 @@ export class Farm2Manager {
|
|
|
42
42
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getFirstBlockOfRound', [
|
|
43
43
|
uintCV(cycle)
|
|
44
44
|
]);
|
|
45
|
-
const result_raw = await
|
|
45
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
46
46
|
const result = cvToValue(result_raw);
|
|
47
47
|
// // console.log(result);
|
|
48
48
|
return result;
|
|
@@ -55,7 +55,7 @@ export class Farm2Manager {
|
|
|
55
55
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
56
56
|
]);
|
|
57
57
|
try {
|
|
58
|
-
const result_raw = await
|
|
58
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
59
59
|
const result = cvToValue(result_raw);
|
|
60
60
|
// // console.log('migrate' , result);
|
|
61
61
|
return result;
|
|
@@ -102,7 +102,7 @@ export class Farm2Manager {
|
|
|
102
102
|
contractPrincipalCV(address[0], address[1]),
|
|
103
103
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
104
104
|
]);
|
|
105
|
-
const result_raw = await
|
|
105
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
106
106
|
const result = cvToValue(result_raw);
|
|
107
107
|
try {
|
|
108
108
|
// // console.log('getFarmingStakerStatus', result);
|
|
@@ -129,7 +129,7 @@ export class Farm2Manager {
|
|
|
129
129
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getTotalRoundDataOrDefault', [
|
|
130
130
|
uintCV(cycle),
|
|
131
131
|
]);
|
|
132
|
-
const result_raw = await
|
|
132
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
133
133
|
const result = cvToValue(result_raw);
|
|
134
134
|
// // console.log('FARMING TOTAL', result);
|
|
135
135
|
try {
|
|
@@ -151,7 +151,7 @@ export class Farm2Manager {
|
|
|
151
151
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getLPTotalData', [
|
|
152
152
|
contractPrincipalCV(address[0], address[1]),
|
|
153
153
|
]);
|
|
154
|
-
const result_raw = await
|
|
154
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
155
155
|
const result = cvToValue(result_raw);
|
|
156
156
|
// // console.log('lp total data', result);
|
|
157
157
|
try {
|
|
@@ -168,7 +168,7 @@ export class Farm2Manager {
|
|
|
168
168
|
contractPrincipalCV(address[0], address[1]),
|
|
169
169
|
uintCV(cycle),
|
|
170
170
|
]);
|
|
171
|
-
const result_raw = await
|
|
171
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
172
172
|
const result = cvToValue(result_raw);
|
|
173
173
|
// // console.log('lp round data', result);
|
|
174
174
|
try {
|
|
@@ -189,7 +189,7 @@ export class Farm2Manager {
|
|
|
189
189
|
const function_option = getReadOptions(this.stackswap, farming_contract, 'getLPTotalData', [
|
|
190
190
|
contractPrincipalCV(address[0], address[1]),
|
|
191
191
|
]);
|
|
192
|
-
const result_raw = await
|
|
192
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
193
193
|
const result = cvToValue(result_raw);
|
|
194
194
|
// // console.log('get_farming_total',result.value);
|
|
195
195
|
return result.value;
|
|
@@ -205,7 +205,7 @@ export class Farm2Manager {
|
|
|
205
205
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
206
206
|
uintCV(cycle),
|
|
207
207
|
]);
|
|
208
|
-
const result_raw = await
|
|
208
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
209
209
|
const result = cvToValue(result_raw);
|
|
210
210
|
// // console.log('reward', result);
|
|
211
211
|
return result;
|
|
@@ -218,7 +218,7 @@ export class Farm2Manager {
|
|
|
218
218
|
contractPrincipalCV(address[0], address[1]),
|
|
219
219
|
listCV(unclaimed_list),
|
|
220
220
|
]);
|
|
221
|
-
const result_raw = await
|
|
221
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
222
222
|
const result = cvToValue(result_raw);
|
|
223
223
|
// // console.log('getFarmingUserRewardTotal', result);
|
|
224
224
|
return result;
|
|
@@ -231,7 +231,7 @@ export class Farm2Manager {
|
|
|
231
231
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
232
232
|
uintCV(round),
|
|
233
233
|
]);
|
|
234
|
-
const result_raw = await
|
|
234
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
235
235
|
const result = cvToValue(result_raw);
|
|
236
236
|
// // console.log(result);
|
|
237
237
|
return result.value.returnLP.value;
|
|
@@ -246,7 +246,7 @@ export class Farm2Manager {
|
|
|
246
246
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
247
247
|
uintCV(round),
|
|
248
248
|
]);
|
|
249
|
-
const result_raw = await
|
|
249
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
250
250
|
const result = cvToValue(result_raw);
|
|
251
251
|
// // console.log(result);
|
|
252
252
|
return result.value;
|
|
@@ -291,7 +291,7 @@ export class Farm2Manager {
|
|
|
291
291
|
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
292
292
|
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), farming_contract)]);
|
|
293
293
|
try {
|
|
294
|
-
const result = await
|
|
294
|
+
const result = await callReadOnlyFunction(pair_details_options);
|
|
295
295
|
return cvToValue(result).value;
|
|
296
296
|
} catch (e) {
|
|
297
297
|
return 0;
|
|
@@ -341,8 +341,8 @@ export class Farm2Manager {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
async getCurrentFarmingRound2(farming_contract: string) {
|
|
344
|
-
const bh = await this.stackswap.
|
|
345
|
-
return await this.getFarmingRound2(Number(bh), farming_contract);
|
|
344
|
+
const bh = await this.stackswap.getCurrentBlocks();
|
|
345
|
+
return await this.getFarmingRound2(Number(bh.tenure_block_height), farming_contract);
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
async getRewardBalanceFromFarming2(pool_addr: string, unclaimed_list: any, farming_contract: string) {
|
|
@@ -395,8 +395,8 @@ export class Farm2Manager {
|
|
|
395
395
|
const oracle_stsw = (await this.stackswap.lbtcManager.getPrice('STSW'))['last-price'].value;
|
|
396
396
|
const oracle_stx = (await this.stackswap.lbtcManager.getPrice('STX'))['last-price'].value;
|
|
397
397
|
const oracle_lbtc = (await this.stackswap.lbtcManager.getPrice('lBTC'))['last-price'].value;
|
|
398
|
-
const bh = await this.stackswap.
|
|
399
|
-
return await this.getEachFarmData(data, bh, {oracle_stsw, oracle_lbtc, oracle_stx}, type, callback)
|
|
398
|
+
const bh = await this.stackswap.getCurrentBlocks();
|
|
399
|
+
return await this.getEachFarmData(data, bh.tenure_block_height, {oracle_stsw, oracle_lbtc, oracle_stx}, type, callback)
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
checkAndSetFarmAPR(farms : any, farm_length: number, oracle_data: any){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
callReadOnlyFunction,
|
|
3
3
|
contractPrincipalCV,
|
|
4
4
|
cvToValue, FungibleConditionCode,
|
|
5
5
|
listCV,
|
|
@@ -34,8 +34,8 @@ export class Farm3Manager {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
async getCurrentFarmingRound3() {
|
|
37
|
-
const bh = await this.stackswap.
|
|
38
|
-
return await this.getFarmingRound3(Number(bh));
|
|
37
|
+
const bh = await this.stackswap.getCurrentBlocks();
|
|
38
|
+
return await this.getFarmingRound3(Number(bh.tenure_block_height));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async getFarmingRoundFirstBlock3(cycle: number) {
|
|
@@ -88,7 +88,7 @@ export class Farm3Manager {
|
|
|
88
88
|
contractPrincipalCV(address[0], address[1]),
|
|
89
89
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
90
90
|
]);
|
|
91
|
-
const result_raw = await
|
|
91
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
92
92
|
const result = cvToValue(result_raw);
|
|
93
93
|
try {
|
|
94
94
|
/*
|
|
@@ -122,7 +122,7 @@ export class Farm3Manager {
|
|
|
122
122
|
contractPrincipalCV(address[0], address[1]),
|
|
123
123
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
124
124
|
]);
|
|
125
|
-
const result_raw = await
|
|
125
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
126
126
|
const result = cvToValue(result_raw);
|
|
127
127
|
try {
|
|
128
128
|
/*
|
|
@@ -164,7 +164,7 @@ export class Farm3Manager {
|
|
|
164
164
|
uintCV(cycle),
|
|
165
165
|
uintCV(group),
|
|
166
166
|
]);
|
|
167
|
-
const result_raw = await
|
|
167
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
168
168
|
const result = cvToValue(result_raw);
|
|
169
169
|
// // console.log('FARMING TOTAL', result);
|
|
170
170
|
try {
|
|
@@ -186,7 +186,7 @@ export class Farm3Manager {
|
|
|
186
186
|
const function_option = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3(), 'getLPOrDefault', [
|
|
187
187
|
contractPrincipalCV(address[0], address[1]),
|
|
188
188
|
]);
|
|
189
|
-
const result_raw = await
|
|
189
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
190
190
|
const result = cvToValue(result_raw);
|
|
191
191
|
// // console.log('lp total data', result);
|
|
192
192
|
try {
|
|
@@ -202,7 +202,7 @@ export class Farm3Manager {
|
|
|
202
202
|
contractPrincipalCV(address[0], address[1]),
|
|
203
203
|
uintCV(cycle),
|
|
204
204
|
]);
|
|
205
|
-
const result_raw = await
|
|
205
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
206
206
|
const result = cvToValue(result_raw);
|
|
207
207
|
// // console.log('lp round data', result);
|
|
208
208
|
try {
|
|
@@ -229,7 +229,7 @@ export class Farm3Manager {
|
|
|
229
229
|
// contractPrincipalCV(address[0], address[1]),
|
|
230
230
|
uintCV(group)
|
|
231
231
|
]);
|
|
232
|
-
const result_raw = await
|
|
232
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
233
233
|
const result = cvToValue(result_raw);
|
|
234
234
|
// // console.log('get_farming_total',result.value);
|
|
235
235
|
return result.CurRewardAmt.value;
|
|
@@ -244,7 +244,7 @@ export class Farm3Manager {
|
|
|
244
244
|
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
245
245
|
uintCV(cycle),
|
|
246
246
|
]);
|
|
247
|
-
const result_raw = await
|
|
247
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
248
248
|
const result = cvToValue(result_raw);
|
|
249
249
|
// console.log('reward', result, pool_address, this.stackswap.getSenderAddress(), cycle);
|
|
250
250
|
return result;
|
|
@@ -262,7 +262,7 @@ export class Farm3Manager {
|
|
|
262
262
|
pool_address,
|
|
263
263
|
unclaimed_list,
|
|
264
264
|
})
|
|
265
|
-
const result_raw = await
|
|
265
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
266
266
|
const result = cvToValue(result_raw);
|
|
267
267
|
console.log('getFarmingUserRewardTotal', result);
|
|
268
268
|
return result;
|
|
@@ -273,7 +273,7 @@ export class Farm3Manager {
|
|
|
273
273
|
const pair_details_options: any = getReadOptions(this.stackswap, token.addr, 'get-balance',
|
|
274
274
|
[contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_FARMING_DATA_3())]);
|
|
275
275
|
try {
|
|
276
|
-
const result = await
|
|
276
|
+
const result = await callReadOnlyFunction(pair_details_options);
|
|
277
277
|
return cvToValue(result).value;
|
|
278
278
|
} catch (e) {
|
|
279
279
|
return 0;
|
|
@@ -408,8 +408,8 @@ export class Farm3Manager {
|
|
|
408
408
|
const oracle_stsw = (await this.stackswap.lbtcManager.getPrice('STSW'))['last-price'].value;
|
|
409
409
|
const oracle_stx = (await this.stackswap.lbtcManager.getPrice('STX'))['last-price'].value;
|
|
410
410
|
const oracle_lbtc = (await this.stackswap.lbtcManager.getPrice('lBTC'))['last-price'].value;
|
|
411
|
-
const bh = await this.stackswap.
|
|
412
|
-
return await this.getEachFarmData(data, bh, {oracle_stsw, oracle_lbtc, oracle_stx}, type, callback)
|
|
411
|
+
const bh = await this.stackswap.getCurrentBlocks();
|
|
412
|
+
return await this.getEachFarmData(data, bh.tenure_block_height, {oracle_stsw, oracle_lbtc, oracle_stx}, type, callback)
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
checkAndSetFarmAPR(farms : any, farm_length: number, oracle_data: any){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
callReadOnlyFunction,
|
|
3
3
|
cvToValue,
|
|
4
4
|
FungibleConditionCode, listCV,
|
|
5
5
|
standardPrincipalCV,
|
|
@@ -31,7 +31,7 @@ export class GovernanceManager {
|
|
|
31
31
|
args.push(listCV(arg2))
|
|
32
32
|
}
|
|
33
33
|
const function_option : any = getReadOptions(this.stackswap, governance.name,'get-proposals',args);
|
|
34
|
-
const result_raw = await
|
|
34
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
35
35
|
|
|
36
36
|
const result = cvToValue(result_raw);
|
|
37
37
|
|
|
@@ -55,7 +55,7 @@ export class GovernanceManager {
|
|
|
55
55
|
uintCV(proposal_id),
|
|
56
56
|
standardPrincipalCV(this.stackswap.getSenderAddress())
|
|
57
57
|
]);
|
|
58
|
-
const result_raw = await
|
|
58
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
59
59
|
const result = cvToValue(result_raw);
|
|
60
60
|
// // // console.log("TTT", cvToValue(result_raw))
|
|
61
61
|
return [result['vote-count'].value, result.returned.value];
|