stackswap-front-api-test-02 1.0.102 → 1.0.105
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/README.md +10 -10
- package/dist/esm/index.d.ts +86 -86
- package/dist/esm/index.js +145 -145
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stackswap/config.d.ts +117 -114
- package/dist/esm/stackswap/config.js +194 -188
- package/dist/esm/stackswap/config.js.map +1 -1
- package/dist/esm/stackswap/manager/farm.manager.d.ts +41 -41
- package/dist/esm/stackswap/manager/farm.manager.js +293 -293
- package/dist/esm/stackswap/manager/farm2.manager.d.ts +60 -60
- package/dist/esm/stackswap/manager/farm2.manager.js +403 -403
- package/dist/esm/stackswap/manager/governance.manager.d.ts +9 -9
- package/dist/esm/stackswap/manager/governance.manager.js +53 -53
- package/dist/esm/stackswap/manager/launchpad.manager.d.ts +13 -13
- package/dist/esm/stackswap/manager/launchpad.manager.js +147 -147
- package/dist/esm/stackswap/manager/lbtc.manager.d.ts +31 -31
- package/dist/esm/stackswap/manager/lbtc.manager.js +326 -326
- package/dist/esm/stackswap/manager/lbtcstaking.manager.d.ts +51 -51
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js +191 -191
- package/dist/esm/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/esm/stackswap/manager/multisig.manager.d.ts +11 -11
- package/dist/esm/stackswap/manager/multisig.manager.js +51 -51
- package/dist/esm/stackswap/manager/nft.manager.d.ts +52 -52
- package/dist/esm/stackswap/manager/nft.manager.js +243 -243
- package/dist/esm/stackswap/manager/operator.manager.d.ts +17 -17
- package/dist/esm/stackswap/manager/operator.manager.js +85 -85
- package/dist/esm/stackswap/manager/other.manager.d.ts +9 -9
- package/dist/esm/stackswap/manager/other.manager.js +47 -47
- package/dist/esm/stackswap/manager/pool.manager.d.ts +34 -34
- package/dist/esm/stackswap/manager/pool.manager.js +171 -171
- package/dist/esm/stackswap/manager/poxl.manager.d.ts +16 -16
- package/dist/esm/stackswap/manager/poxl.manager.js +71 -71
- package/dist/esm/stackswap/manager/staking.manager.d.ts +25 -25
- package/dist/esm/stackswap/manager/staking.manager.js +233 -233
- package/dist/esm/stackswap/manager/swap.manager.d.ts +39 -39
- package/dist/esm/stackswap/manager/swap.manager.js +332 -332
- package/dist/esm/stackswap/manager/token.manager.d.ts +31 -31
- package/dist/esm/stackswap/manager/token.manager.js +133 -133
- package/dist/esm/stackswap/util.d.ts +35 -35
- package/dist/esm/stackswap/util.js +201 -201
- package/dist/esm/stackswap/util.js.map +1 -1
- package/dist/index.d.ts +86 -86
- package/dist/index.js +154 -154
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/stackswap/config.d.ts +117 -114
- package/dist/stackswap/config.js +199 -193
- package/dist/stackswap/config.js.map +1 -1
- package/dist/stackswap/manager/farm.manager.d.ts +41 -41
- package/dist/stackswap/manager/farm.manager.js +301 -301
- package/dist/stackswap/manager/farm2.manager.d.ts +60 -60
- package/dist/stackswap/manager/farm2.manager.js +410 -410
- package/dist/stackswap/manager/governance.manager.d.ts +9 -9
- package/dist/stackswap/manager/governance.manager.js +60 -60
- package/dist/stackswap/manager/launchpad.manager.d.ts +13 -13
- package/dist/stackswap/manager/launchpad.manager.js +151 -151
- package/dist/stackswap/manager/lbtc.manager.d.ts +31 -31
- package/dist/stackswap/manager/lbtc.manager.js +333 -333
- package/dist/stackswap/manager/lbtcstaking.manager.d.ts +51 -51
- package/dist/stackswap/manager/lbtcstaking.manager.js +198 -198
- package/dist/stackswap/manager/lbtcstaking.manager.js.map +1 -1
- package/dist/stackswap/manager/multisig.manager.d.ts +11 -11
- package/dist/stackswap/manager/multisig.manager.js +55 -55
- package/dist/stackswap/manager/nft.manager.d.ts +52 -52
- package/dist/stackswap/manager/nft.manager.js +250 -250
- package/dist/stackswap/manager/operator.manager.d.ts +17 -17
- package/dist/stackswap/manager/operator.manager.js +92 -92
- package/dist/stackswap/manager/other.manager.d.ts +9 -9
- package/dist/stackswap/manager/other.manager.js +54 -54
- package/dist/stackswap/manager/pool.manager.d.ts +34 -34
- package/dist/stackswap/manager/pool.manager.js +179 -179
- package/dist/stackswap/manager/poxl.manager.d.ts +16 -16
- package/dist/stackswap/manager/poxl.manager.js +78 -78
- package/dist/stackswap/manager/staking.manager.d.ts +25 -25
- package/dist/stackswap/manager/staking.manager.js +240 -240
- package/dist/stackswap/manager/swap.manager.d.ts +39 -39
- package/dist/stackswap/manager/swap.manager.js +339 -339
- package/dist/stackswap/manager/token.manager.d.ts +31 -31
- package/dist/stackswap/manager/token.manager.js +141 -141
- package/dist/stackswap/util.d.ts +35 -35
- package/dist/stackswap/util.js +218 -218
- package/dist/stackswap/util.js.map +1 -1
- package/package.json +43 -43
- package/src/index.ts +207 -207
- package/src/stackswap/config.ts +305 -297
- package/src/stackswap/manager/farm.manager.ts +399 -399
- package/src/stackswap/manager/farm2.manager.ts +463 -463
- package/src/stackswap/manager/governance.manager.ts +95 -95
- package/src/stackswap/manager/launchpad.manager.ts +190 -190
- package/src/stackswap/manager/lbtcstaking.manager.ts +277 -277
- package/src/stackswap/manager/multisig.manager.ts +87 -87
- package/src/stackswap/manager/nft.manager.ts +307 -307
- package/src/stackswap/manager/operator.manager.ts +123 -123
- package/src/stackswap/manager/other.manager.ts +71 -71
- package/src/stackswap/manager/pool.manager.ts +202 -202
- package/src/stackswap/manager/poxl.manager.ts +99 -99
- package/src/stackswap/manager/staking.manager.ts +321 -321
- package/src/stackswap/manager/swap.manager.ts +392 -392
- package/src/stackswap/manager/token.manager.ts +167 -167
- package/src/stackswap/util.ts +237 -237
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import {openContractCall} from "@stacks/connect";
|
|
4
|
-
import {getPostConditionFromAsset, getReadOptions, getWriteOptions} from "../util";
|
|
5
|
-
import {
|
|
6
|
-
callReadOnlyFunction, contractPrincipalCV,
|
|
7
|
-
cvToValue,
|
|
8
|
-
FungibleConditionCode, listCV,
|
|
9
|
-
standardPrincipalCV, stringUtf8CV,
|
|
10
|
-
uintCV
|
|
11
|
-
} from "@stacks/transactions";
|
|
12
|
-
import {StackswapAPI} from "../../index";
|
|
13
|
-
|
|
14
|
-
export class OperatorManager {
|
|
15
|
-
stackswap: StackswapAPI;
|
|
16
|
-
|
|
17
|
-
constructor(stackswap: StackswapAPI) {
|
|
18
|
-
this.stackswap = stackswap;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async collectSwapFees( token_x: any, token_y: any, token_liquidity: any, callback : any = null) {
|
|
22
|
-
const token_x_addr = token_x.split('.');
|
|
23
|
-
const token_y_addr = token_y.split('.');
|
|
24
|
-
const pair_addr = token_liquidity.split('.');
|
|
25
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP(), 'collect-fees', [
|
|
26
|
-
contractPrincipalCV(token_x_addr[0], token_x_addr[1]), contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
27
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
28
|
-
],[], callback);
|
|
29
|
-
|
|
30
|
-
openContractCall(options);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async add_liquidity_dist( contract_name: string, token_x_amount: string, token_y_amount: string, callback : any = null) {
|
|
34
|
-
const options = getWriteOptions(this.stackswap, contract_name, 'add-liquidity', [
|
|
35
|
-
uintCV(token_x_amount), uintCV(token_y_amount)
|
|
36
|
-
], [], callback);
|
|
37
|
-
openContractCall(options);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async invest_to_farm_dist( contract_name: string, callback : any = null) {
|
|
41
|
-
const options = getWriteOptions(this.stackswap, contract_name, 'invest-to-farm', [
|
|
42
|
-
uintCV(12)
|
|
43
|
-
], [], callback);
|
|
44
|
-
openContractCall(options);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async STSWInvestTx(invest_amount:string, callback : any = null){
|
|
48
|
-
const invest_amount_str = new BigNumber(invest_amount).multipliedBy(10**6).toFixed(0).toString()
|
|
49
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, invest_amount_str, FungibleConditionCode.Equal)];
|
|
50
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'invest', [uintCV(invest_amount_str)], post_condition, callback);
|
|
51
|
-
const result_raw = await openContractCall(options);
|
|
52
|
-
return result_raw;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async farmClaimDistributor(round:string, callback : any = null){
|
|
56
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-from-farm',
|
|
57
|
-
[ uintCV(round)], [], callback);
|
|
58
|
-
const result_raw = await openContractCall(options);
|
|
59
|
-
return result_raw;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async STSWAwdDistributor( amount: string, callback : any = null){
|
|
63
|
-
// const invest_amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
64
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS()+'.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
65
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'awd-stsw',
|
|
66
|
-
[ standardPrincipalCV(this.stackswap.getSenderAddress()), uintCV(amount)], post_condition, callback);
|
|
67
|
-
const result_raw = await openContractCall(options);
|
|
68
|
-
return result_raw;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async STSWStaking( amount: string, month: string = '1', callback : any = null){
|
|
72
|
-
// const invest_amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
73
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
74
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.BASE_vSTSW_DATA().addr, 'stake-tokens',
|
|
75
|
-
[ uintCV(amount), uintCV(month)], post_condition, callback);
|
|
76
|
-
const result_raw = await openContractCall(options);
|
|
77
|
-
return result_raw;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// (ok (tuple (claimable_stsw u0) (claimed_lp u0) (claimed_stsw u0) (invested_lp u1209782750210) (invested_stx u355150000000)))
|
|
81
|
-
async distributorGetInvestor(){
|
|
82
|
-
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-invester',
|
|
83
|
-
[ standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
84
|
-
const result = await callReadOnlyFunction(options);
|
|
85
|
-
// console.log(cvToValue(result));
|
|
86
|
-
|
|
87
|
-
return cvToValue(result).value;
|
|
88
|
-
}
|
|
89
|
-
async distributorGetReclaim(){
|
|
90
|
-
const options : any = getReadOptions(this.stackswap, 'distributor0001', 'get-claimable-amount',
|
|
91
|
-
[ standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
92
|
-
const result = await callReadOnlyFunction(options);
|
|
93
|
-
// console.log(cvToValue(result));
|
|
94
|
-
|
|
95
|
-
return cvToValue(result);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
async distributorReclaimLP(amount:string, callback : any = null){
|
|
100
|
-
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
101
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS()+'.distributor0001', this.stackswap.config.STX_STSW_LP(), amount_str, FungibleConditionCode.Equal)];
|
|
102
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'reclaim-lp-tokens',
|
|
103
|
-
[ uintCV(amount_str)], post_condition, callback);
|
|
104
|
-
const result_raw = await openContractCall(options);
|
|
105
|
-
return result_raw;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async distributorClaimSTSW(amount:string, callback : any = null){
|
|
109
|
-
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
110
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS()+'.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount_str, FungibleConditionCode.Equal)];
|
|
111
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-stsw-tokens',
|
|
112
|
-
[ uintCV(amount_str)], post_condition, callback);
|
|
113
|
-
const result_raw = await openContractCall(options);
|
|
114
|
-
return result_raw;
|
|
115
|
-
}
|
|
116
|
-
async propose( start_block: string, title: string, url: string, changes: any, callback : any = null){
|
|
117
|
-
|
|
118
|
-
const function_option : any = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(), 'propose', [
|
|
119
|
-
uintCV(start_block), stringUtf8CV(title), stringUtf8CV(url), listCV(changes)
|
|
120
|
-
],[], callback);
|
|
121
|
-
await openContractCall(function_option);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import {openContractCall} from "@stacks/connect";
|
|
4
|
+
import {getPostConditionFromAsset, getReadOptions, getWriteOptions} from "../util";
|
|
5
|
+
import {
|
|
6
|
+
callReadOnlyFunction, contractPrincipalCV,
|
|
7
|
+
cvToValue,
|
|
8
|
+
FungibleConditionCode, listCV,
|
|
9
|
+
standardPrincipalCV, stringUtf8CV,
|
|
10
|
+
uintCV
|
|
11
|
+
} from "@stacks/transactions";
|
|
12
|
+
import {StackswapAPI} from "../../index";
|
|
13
|
+
|
|
14
|
+
export class OperatorManager {
|
|
15
|
+
stackswap: StackswapAPI;
|
|
16
|
+
|
|
17
|
+
constructor(stackswap: StackswapAPI) {
|
|
18
|
+
this.stackswap = stackswap;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async collectSwapFees( token_x: any, token_y: any, token_liquidity: any, callback : any = null) {
|
|
22
|
+
const token_x_addr = token_x.split('.');
|
|
23
|
+
const token_y_addr = token_y.split('.');
|
|
24
|
+
const pair_addr = token_liquidity.split('.');
|
|
25
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP(), 'collect-fees', [
|
|
26
|
+
contractPrincipalCV(token_x_addr[0], token_x_addr[1]), contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
27
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
28
|
+
],[], callback);
|
|
29
|
+
|
|
30
|
+
openContractCall(options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async add_liquidity_dist( contract_name: string, token_x_amount: string, token_y_amount: string, callback : any = null) {
|
|
34
|
+
const options = getWriteOptions(this.stackswap, contract_name, 'add-liquidity', [
|
|
35
|
+
uintCV(token_x_amount), uintCV(token_y_amount)
|
|
36
|
+
], [], callback);
|
|
37
|
+
openContractCall(options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async invest_to_farm_dist( contract_name: string, callback : any = null) {
|
|
41
|
+
const options = getWriteOptions(this.stackswap, contract_name, 'invest-to-farm', [
|
|
42
|
+
uintCV(12)
|
|
43
|
+
], [], callback);
|
|
44
|
+
openContractCall(options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async STSWInvestTx(invest_amount:string, callback : any = null){
|
|
48
|
+
const invest_amount_str = new BigNumber(invest_amount).multipliedBy(10**6).toFixed(0).toString()
|
|
49
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, invest_amount_str, FungibleConditionCode.Equal)];
|
|
50
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'invest', [uintCV(invest_amount_str)], post_condition, callback);
|
|
51
|
+
const result_raw = await openContractCall(options);
|
|
52
|
+
return result_raw;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async farmClaimDistributor(round:string, callback : any = null){
|
|
56
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-from-farm',
|
|
57
|
+
[ uintCV(round)], [], callback);
|
|
58
|
+
const result_raw = await openContractCall(options);
|
|
59
|
+
return result_raw;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async STSWAwdDistributor( amount: string, callback : any = null){
|
|
63
|
+
// const invest_amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
64
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS()+'.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
65
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'awd-stsw',
|
|
66
|
+
[ standardPrincipalCV(this.stackswap.getSenderAddress()), uintCV(amount)], post_condition, callback);
|
|
67
|
+
const result_raw = await openContractCall(options);
|
|
68
|
+
return result_raw;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async STSWStaking( amount: string, month: string = '1', callback : any = null){
|
|
72
|
+
// const invest_amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
73
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
74
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.BASE_vSTSW_DATA().addr, 'stake-tokens',
|
|
75
|
+
[ uintCV(amount), uintCV(month)], post_condition, callback);
|
|
76
|
+
const result_raw = await openContractCall(options);
|
|
77
|
+
return result_raw;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// (ok (tuple (claimable_stsw u0) (claimed_lp u0) (claimed_stsw u0) (invested_lp u1209782750210) (invested_stx u355150000000)))
|
|
81
|
+
async distributorGetInvestor(){
|
|
82
|
+
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-invester',
|
|
83
|
+
[ standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
84
|
+
const result = await callReadOnlyFunction(options);
|
|
85
|
+
// console.log(cvToValue(result));
|
|
86
|
+
|
|
87
|
+
return cvToValue(result).value;
|
|
88
|
+
}
|
|
89
|
+
async distributorGetReclaim(){
|
|
90
|
+
const options : any = getReadOptions(this.stackswap, 'distributor0001', 'get-claimable-amount',
|
|
91
|
+
[ standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
92
|
+
const result = await callReadOnlyFunction(options);
|
|
93
|
+
// console.log(cvToValue(result));
|
|
94
|
+
|
|
95
|
+
return cvToValue(result);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async distributorReclaimLP(amount:string, callback : any = null){
|
|
100
|
+
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
101
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS()+'.distributor0001', this.stackswap.config.STX_STSW_LP(), amount_str, FungibleConditionCode.Equal)];
|
|
102
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'reclaim-lp-tokens',
|
|
103
|
+
[ uintCV(amount_str)], post_condition, callback);
|
|
104
|
+
const result_raw = await openContractCall(options);
|
|
105
|
+
return result_raw;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async distributorClaimSTSW(amount:string, callback : any = null){
|
|
109
|
+
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
110
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS()+'.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount_str, FungibleConditionCode.Equal)];
|
|
111
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-stsw-tokens',
|
|
112
|
+
[ uintCV(amount_str)], post_condition, callback);
|
|
113
|
+
const result_raw = await openContractCall(options);
|
|
114
|
+
return result_raw;
|
|
115
|
+
}
|
|
116
|
+
async propose( start_block: string, title: string, url: string, changes: any, callback : any = null){
|
|
117
|
+
|
|
118
|
+
const function_option : any = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(), 'propose', [
|
|
119
|
+
uintCV(start_block), stringUtf8CV(title), stringUtf8CV(url), listCV(changes)
|
|
120
|
+
],[], callback);
|
|
121
|
+
await openContractCall(function_option);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import {openContractCall} from "@stacks/connect";
|
|
2
|
-
import {
|
|
3
|
-
bufferCV,
|
|
4
|
-
callReadOnlyFunction,
|
|
5
|
-
cvToValue,
|
|
6
|
-
FungibleConditionCode,
|
|
7
|
-
standardPrincipalCV,
|
|
8
|
-
tupleCV,
|
|
9
|
-
uintCV
|
|
10
|
-
} from "@stacks/transactions";
|
|
11
|
-
import {getPostConditionFromAsset, getReadOptions, getWriteOptions} from "../util";
|
|
12
|
-
import {StackswapAPI} from "../../index";
|
|
13
|
-
import BigNumber from "bignumber.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export class OtherManager {
|
|
17
|
-
stackswap: StackswapAPI;
|
|
18
|
-
|
|
19
|
-
constructor(stackswap: StackswapAPI) {
|
|
20
|
-
this.stackswap = stackswap;
|
|
21
|
-
}
|
|
22
|
-
async getUserBeta01Data( contract_address: string) {
|
|
23
|
-
try{
|
|
24
|
-
const options = getReadOptions(this.stackswap, contract_address, 'get-user-rewards', [
|
|
25
|
-
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
26
|
-
]);
|
|
27
|
-
const result = await callReadOnlyFunction(options);
|
|
28
|
-
return cvToValue(result).value;
|
|
29
|
-
} catch (e) {
|
|
30
|
-
return 0;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async claimUserBeta01Reward( contract_address: string, reward : string, callback : any = null) {
|
|
35
|
-
try{
|
|
36
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, contract_address, this.stackswap.config.BASE_STSW_DATA().addr, reward, FungibleConditionCode.Equal)];
|
|
37
|
-
|
|
38
|
-
const options = getWriteOptions(this.stackswap, contract_address, 'claim-reward', [
|
|
39
|
-
], post_condition, callback);
|
|
40
|
-
const result_raw = await openContractCall(options);
|
|
41
|
-
return result_raw;
|
|
42
|
-
} catch (e) {
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async get_pox_info(){
|
|
48
|
-
const options = getReadOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'get-pox-info',
|
|
49
|
-
[ ]);
|
|
50
|
-
const result = await callReadOnlyFunction(options);
|
|
51
|
-
// console.log(cvToValue(result).value);
|
|
52
|
-
return cvToValue(result).value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async stack_stx_to_pox(amount:string, poxAddress: any, start_burn_ht: string, lock_period: string, callback : any = null){
|
|
56
|
-
// const hashbytes = bufferCV(address.fromBase58Check(poxAddress).hash);
|
|
57
|
-
const addresss = tupleCV({
|
|
58
|
-
hashbytes: bufferCV(poxAddress),
|
|
59
|
-
version: bufferCV(new Buffer(1)),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
63
|
-
// console.log(addresss);
|
|
64
|
-
const options = getWriteOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'stack-stx',
|
|
65
|
-
[ uintCV(amount_str), addresss, uintCV(start_burn_ht), uintCV(lock_period)],[], callback);
|
|
66
|
-
const result_raw = await openContractCall(options);
|
|
67
|
-
return result_raw;
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
1
|
+
import {openContractCall} from "@stacks/connect";
|
|
2
|
+
import {
|
|
3
|
+
bufferCV,
|
|
4
|
+
callReadOnlyFunction,
|
|
5
|
+
cvToValue,
|
|
6
|
+
FungibleConditionCode,
|
|
7
|
+
standardPrincipalCV,
|
|
8
|
+
tupleCV,
|
|
9
|
+
uintCV
|
|
10
|
+
} from "@stacks/transactions";
|
|
11
|
+
import {getPostConditionFromAsset, getReadOptions, getWriteOptions} from "../util";
|
|
12
|
+
import {StackswapAPI} from "../../index";
|
|
13
|
+
import BigNumber from "bignumber.js";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export class OtherManager {
|
|
17
|
+
stackswap: StackswapAPI;
|
|
18
|
+
|
|
19
|
+
constructor(stackswap: StackswapAPI) {
|
|
20
|
+
this.stackswap = stackswap;
|
|
21
|
+
}
|
|
22
|
+
async getUserBeta01Data( contract_address: string) {
|
|
23
|
+
try{
|
|
24
|
+
const options = getReadOptions(this.stackswap, contract_address, 'get-user-rewards', [
|
|
25
|
+
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
26
|
+
]);
|
|
27
|
+
const result = await callReadOnlyFunction(options);
|
|
28
|
+
return cvToValue(result).value;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async claimUserBeta01Reward( contract_address: string, reward : string, callback : any = null) {
|
|
35
|
+
try{
|
|
36
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, contract_address, this.stackswap.config.BASE_STSW_DATA().addr, reward, FungibleConditionCode.Equal)];
|
|
37
|
+
|
|
38
|
+
const options = getWriteOptions(this.stackswap, contract_address, 'claim-reward', [
|
|
39
|
+
], post_condition, callback);
|
|
40
|
+
const result_raw = await openContractCall(options);
|
|
41
|
+
return result_raw;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async get_pox_info(){
|
|
48
|
+
const options = getReadOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'get-pox-info',
|
|
49
|
+
[ ]);
|
|
50
|
+
const result = await callReadOnlyFunction(options);
|
|
51
|
+
// console.log(cvToValue(result).value);
|
|
52
|
+
return cvToValue(result).value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async stack_stx_to_pox(amount:string, poxAddress: any, start_burn_ht: string, lock_period: string, callback : any = null){
|
|
56
|
+
// const hashbytes = bufferCV(address.fromBase58Check(poxAddress).hash);
|
|
57
|
+
const addresss = tupleCV({
|
|
58
|
+
hashbytes: bufferCV(poxAddress),
|
|
59
|
+
version: bufferCV(new Buffer(1)),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
|
|
63
|
+
// console.log(addresss);
|
|
64
|
+
const options = getWriteOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'stack-stx',
|
|
65
|
+
[ uintCV(amount_str), addresss, uintCV(start_burn_ht), uintCV(lock_period)],[], callback);
|
|
66
|
+
const result_raw = await openContractCall(options);
|
|
67
|
+
return result_raw;
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|