stackswap-front-api-test-02 1.0.83 → 1.0.86
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 +84 -84
- package/dist/esm/index.js +143 -143
- package/dist/esm/stackswap/config.d.ts +112 -112
- package/dist/esm/stackswap/config.js +185 -185
- 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/farm2.manager.js.map +1 -1
- 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/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 -35
- package/dist/esm/stackswap/manager/swap.manager.js +331 -290
- package/dist/esm/stackswap/manager/swap.manager.js.map +1 -1
- 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/index.d.ts +84 -84
- package/dist/index.js +152 -152
- package/dist/index.umd.js +1 -1
- package/dist/stackswap/config.d.ts +112 -112
- package/dist/stackswap/config.js +190 -190
- 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/farm2.manager.js.map +1 -1
- 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/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 -35
- package/dist/stackswap/manager/swap.manager.js +338 -297
- package/dist/stackswap/manager/swap.manager.js.map +1 -1
- 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/package.json +43 -43
- package/src/index.ts +204 -204
- package/src/stackswap/config.ts +292 -292
- 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/multisig.manager.ts +87 -87
- package/src/stackswap/manager/nft.manager.ts +311 -311
- 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 +391 -351
- package/src/stackswap/manager/token.manager.ts +167 -167
- package/src/stackswap/util.ts +237 -237
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { openContractCall } from "@stacks/connect";
|
|
3
|
-
import { getPostConditionFromAsset, getReadOptions, getWriteOptions } from "../util";
|
|
4
|
-
import { callReadOnlyFunction, contractPrincipalCV, cvToValue, FungibleConditionCode, listCV, standardPrincipalCV, stringUtf8CV, uintCV } from "@stacks/transactions";
|
|
5
|
-
export class OperatorManager {
|
|
6
|
-
constructor(stackswap) {
|
|
7
|
-
this.stackswap = stackswap;
|
|
8
|
-
}
|
|
9
|
-
async collectSwapFees(token_x, token_y, token_liquidity, callback = null) {
|
|
10
|
-
const token_x_addr = token_x.split('.');
|
|
11
|
-
const token_y_addr = token_y.split('.');
|
|
12
|
-
const pair_addr = token_liquidity.split('.');
|
|
13
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP(), 'collect-fees', [
|
|
14
|
-
contractPrincipalCV(token_x_addr[0], token_x_addr[1]), contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
15
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
16
|
-
], [], callback);
|
|
17
|
-
openContractCall(options);
|
|
18
|
-
}
|
|
19
|
-
async add_liquidity_dist(contract_name, token_x_amount, token_y_amount, callback = null) {
|
|
20
|
-
const options = getWriteOptions(this.stackswap, contract_name, 'add-liquidity', [
|
|
21
|
-
uintCV(token_x_amount), uintCV(token_y_amount)
|
|
22
|
-
], [], callback);
|
|
23
|
-
openContractCall(options);
|
|
24
|
-
}
|
|
25
|
-
async invest_to_farm_dist(contract_name, callback = null) {
|
|
26
|
-
const options = getWriteOptions(this.stackswap, contract_name, 'invest-to-farm', [
|
|
27
|
-
uintCV(12)
|
|
28
|
-
], [], callback);
|
|
29
|
-
openContractCall(options);
|
|
30
|
-
}
|
|
31
|
-
async STSWInvestTx(invest_amount, callback = null) {
|
|
32
|
-
const invest_amount_str = new BigNumber(invest_amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
33
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, invest_amount_str, FungibleConditionCode.Equal)];
|
|
34
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'invest', [uintCV(invest_amount_str)], post_condition, callback);
|
|
35
|
-
const result_raw = await openContractCall(options);
|
|
36
|
-
return result_raw;
|
|
37
|
-
}
|
|
38
|
-
async farmClaimDistributor(round, callback = null) {
|
|
39
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-from-farm', [uintCV(round)], [], callback);
|
|
40
|
-
const result_raw = await openContractCall(options);
|
|
41
|
-
return result_raw;
|
|
42
|
-
}
|
|
43
|
-
async STSWAwdDistributor(amount, callback = null) {
|
|
44
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
45
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'awd-stsw', [standardPrincipalCV(this.stackswap.getSenderAddress()), uintCV(amount)], post_condition, callback);
|
|
46
|
-
const result_raw = await openContractCall(options);
|
|
47
|
-
return result_raw;
|
|
48
|
-
}
|
|
49
|
-
async STSWStaking(amount, month = '1', callback = null) {
|
|
50
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
51
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.BASE_vSTSW_DATA().addr, 'stake-tokens', [uintCV(amount), uintCV(month)], post_condition, callback);
|
|
52
|
-
const result_raw = await openContractCall(options);
|
|
53
|
-
return result_raw;
|
|
54
|
-
}
|
|
55
|
-
async distributorGetInvestor() {
|
|
56
|
-
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-invester', [standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
57
|
-
const result = await callReadOnlyFunction(options);
|
|
58
|
-
return cvToValue(result).value;
|
|
59
|
-
}
|
|
60
|
-
async distributorGetReclaim() {
|
|
61
|
-
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-claimable-amount', [standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
62
|
-
const result = await callReadOnlyFunction(options);
|
|
63
|
-
return cvToValue(result);
|
|
64
|
-
}
|
|
65
|
-
async distributorReclaimLP(amount, callback = null) {
|
|
66
|
-
const amount_str = new BigNumber(amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
67
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.distributor0001', this.stackswap.config.STX_STSW_LP(), amount_str, FungibleConditionCode.Equal)];
|
|
68
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'reclaim-lp-tokens', [uintCV(amount_str)], post_condition, callback);
|
|
69
|
-
const result_raw = await openContractCall(options);
|
|
70
|
-
return result_raw;
|
|
71
|
-
}
|
|
72
|
-
async distributorClaimSTSW(amount, callback = null) {
|
|
73
|
-
const amount_str = new BigNumber(amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
74
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount_str, FungibleConditionCode.Equal)];
|
|
75
|
-
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-stsw-tokens', [uintCV(amount_str)], post_condition, callback);
|
|
76
|
-
const result_raw = await openContractCall(options);
|
|
77
|
-
return result_raw;
|
|
78
|
-
}
|
|
79
|
-
async propose(start_block, title, url, changes, callback = null) {
|
|
80
|
-
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(), 'propose', [
|
|
81
|
-
uintCV(start_block), stringUtf8CV(title), stringUtf8CV(url), listCV(changes)
|
|
82
|
-
], [], callback);
|
|
83
|
-
await openContractCall(function_option);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { openContractCall } from "@stacks/connect";
|
|
3
|
+
import { getPostConditionFromAsset, getReadOptions, getWriteOptions } from "../util";
|
|
4
|
+
import { callReadOnlyFunction, contractPrincipalCV, cvToValue, FungibleConditionCode, listCV, standardPrincipalCV, stringUtf8CV, uintCV } from "@stacks/transactions";
|
|
5
|
+
export class OperatorManager {
|
|
6
|
+
constructor(stackswap) {
|
|
7
|
+
this.stackswap = stackswap;
|
|
8
|
+
}
|
|
9
|
+
async collectSwapFees(token_x, token_y, token_liquidity, callback = null) {
|
|
10
|
+
const token_x_addr = token_x.split('.');
|
|
11
|
+
const token_y_addr = token_y.split('.');
|
|
12
|
+
const pair_addr = token_liquidity.split('.');
|
|
13
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP(), 'collect-fees', [
|
|
14
|
+
contractPrincipalCV(token_x_addr[0], token_x_addr[1]), contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
15
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
16
|
+
], [], callback);
|
|
17
|
+
openContractCall(options);
|
|
18
|
+
}
|
|
19
|
+
async add_liquidity_dist(contract_name, token_x_amount, token_y_amount, callback = null) {
|
|
20
|
+
const options = getWriteOptions(this.stackswap, contract_name, 'add-liquidity', [
|
|
21
|
+
uintCV(token_x_amount), uintCV(token_y_amount)
|
|
22
|
+
], [], callback);
|
|
23
|
+
openContractCall(options);
|
|
24
|
+
}
|
|
25
|
+
async invest_to_farm_dist(contract_name, callback = null) {
|
|
26
|
+
const options = getWriteOptions(this.stackswap, contract_name, 'invest-to-farm', [
|
|
27
|
+
uintCV(12)
|
|
28
|
+
], [], callback);
|
|
29
|
+
openContractCall(options);
|
|
30
|
+
}
|
|
31
|
+
async STSWInvestTx(invest_amount, callback = null) {
|
|
32
|
+
const invest_amount_str = new BigNumber(invest_amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
33
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_WSTX_DATA().addr, invest_amount_str, FungibleConditionCode.Equal)];
|
|
34
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'invest', [uintCV(invest_amount_str)], post_condition, callback);
|
|
35
|
+
const result_raw = await openContractCall(options);
|
|
36
|
+
return result_raw;
|
|
37
|
+
}
|
|
38
|
+
async farmClaimDistributor(round, callback = null) {
|
|
39
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-from-farm', [uintCV(round)], [], callback);
|
|
40
|
+
const result_raw = await openContractCall(options);
|
|
41
|
+
return result_raw;
|
|
42
|
+
}
|
|
43
|
+
async STSWAwdDistributor(amount, callback = null) {
|
|
44
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
45
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'awd-stsw', [standardPrincipalCV(this.stackswap.getSenderAddress()), uintCV(amount)], post_condition, callback);
|
|
46
|
+
const result_raw = await openContractCall(options);
|
|
47
|
+
return result_raw;
|
|
48
|
+
}
|
|
49
|
+
async STSWStaking(amount, month = '1', callback = null) {
|
|
50
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
|
|
51
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.BASE_vSTSW_DATA().addr, 'stake-tokens', [uintCV(amount), uintCV(month)], post_condition, callback);
|
|
52
|
+
const result_raw = await openContractCall(options);
|
|
53
|
+
return result_raw;
|
|
54
|
+
}
|
|
55
|
+
async distributorGetInvestor() {
|
|
56
|
+
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-invester', [standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
57
|
+
const result = await callReadOnlyFunction(options);
|
|
58
|
+
return cvToValue(result).value;
|
|
59
|
+
}
|
|
60
|
+
async distributorGetReclaim() {
|
|
61
|
+
const options = getReadOptions(this.stackswap, 'distributor0001', 'get-claimable-amount', [standardPrincipalCV(this.stackswap.getSenderAddress())]);
|
|
62
|
+
const result = await callReadOnlyFunction(options);
|
|
63
|
+
return cvToValue(result);
|
|
64
|
+
}
|
|
65
|
+
async distributorReclaimLP(amount, callback = null) {
|
|
66
|
+
const amount_str = new BigNumber(amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
67
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.distributor0001', this.stackswap.config.STX_STSW_LP(), amount_str, FungibleConditionCode.Equal)];
|
|
68
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'reclaim-lp-tokens', [uintCV(amount_str)], post_condition, callback);
|
|
69
|
+
const result_raw = await openContractCall(options);
|
|
70
|
+
return result_raw;
|
|
71
|
+
}
|
|
72
|
+
async distributorClaimSTSW(amount, callback = null) {
|
|
73
|
+
const amount_str = new BigNumber(amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
74
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.config.STACKSWAP_ADDRESS() + '.distributor0001', this.stackswap.config.BASE_STSW_DATA().addr, amount_str, FungibleConditionCode.Equal)];
|
|
75
|
+
const options = getWriteOptions(this.stackswap, 'distributor0001', 'claim-stsw-tokens', [uintCV(amount_str)], post_condition, callback);
|
|
76
|
+
const result_raw = await openContractCall(options);
|
|
77
|
+
return result_raw;
|
|
78
|
+
}
|
|
79
|
+
async propose(start_block, title, url, changes, callback = null) {
|
|
80
|
+
const function_option = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(), 'propose', [
|
|
81
|
+
uintCV(start_block), stringUtf8CV(title), stringUtf8CV(url), listCV(changes)
|
|
82
|
+
], [], callback);
|
|
83
|
+
await openContractCall(function_option);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
86
|
//# sourceMappingURL=operator.manager.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { StackswapAPI } from "../../index";
|
|
2
|
-
export declare class OtherManager {
|
|
3
|
-
stackswap: StackswapAPI;
|
|
4
|
-
constructor(stackswap: StackswapAPI);
|
|
5
|
-
getUserBeta01Data(contract_address: string): Promise<any>;
|
|
6
|
-
claimUserBeta01Reward(contract_address: string, reward: string, callback?: any): Promise<void | 0>;
|
|
7
|
-
get_pox_info(): Promise<any>;
|
|
8
|
-
stack_stx_to_pox(amount: string, poxAddress: any, start_burn_ht: string, lock_period: string, callback?: any): Promise<void>;
|
|
9
|
-
}
|
|
1
|
+
import { StackswapAPI } from "../../index";
|
|
2
|
+
export declare class OtherManager {
|
|
3
|
+
stackswap: StackswapAPI;
|
|
4
|
+
constructor(stackswap: StackswapAPI);
|
|
5
|
+
getUserBeta01Data(contract_address: string): Promise<any>;
|
|
6
|
+
claimUserBeta01Reward(contract_address: string, reward: string, callback?: any): Promise<void | 0>;
|
|
7
|
+
get_pox_info(): Promise<any>;
|
|
8
|
+
stack_stx_to_pox(amount: string, poxAddress: any, start_burn_ht: string, lock_period: string, callback?: any): Promise<void>;
|
|
9
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { openContractCall } from "@stacks/connect";
|
|
2
|
-
import { bufferCV, callReadOnlyFunction, cvToValue, FungibleConditionCode, standardPrincipalCV, tupleCV, uintCV } from "@stacks/transactions";
|
|
3
|
-
import { getPostConditionFromAsset, getReadOptions, getWriteOptions } from "../util";
|
|
4
|
-
import BigNumber from "bignumber.js";
|
|
5
|
-
export class OtherManager {
|
|
6
|
-
constructor(stackswap) {
|
|
7
|
-
this.stackswap = stackswap;
|
|
8
|
-
}
|
|
9
|
-
async getUserBeta01Data(contract_address) {
|
|
10
|
-
try {
|
|
11
|
-
const options = getReadOptions(this.stackswap, contract_address, 'get-user-rewards', [
|
|
12
|
-
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
13
|
-
]);
|
|
14
|
-
const result = await callReadOnlyFunction(options);
|
|
15
|
-
return cvToValue(result).value;
|
|
16
|
-
}
|
|
17
|
-
catch (e) {
|
|
18
|
-
return 0;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
async claimUserBeta01Reward(contract_address, reward, callback = null) {
|
|
22
|
-
try {
|
|
23
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, contract_address, this.stackswap.config.BASE_STSW_DATA().addr, reward, FungibleConditionCode.Equal)];
|
|
24
|
-
const options = getWriteOptions(this.stackswap, contract_address, 'claim-reward', [], post_condition, callback);
|
|
25
|
-
const result_raw = await openContractCall(options);
|
|
26
|
-
return result_raw;
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async get_pox_info() {
|
|
33
|
-
const options = getReadOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'get-pox-info', []);
|
|
34
|
-
const result = await callReadOnlyFunction(options);
|
|
35
|
-
return cvToValue(result).value;
|
|
36
|
-
}
|
|
37
|
-
async stack_stx_to_pox(amount, poxAddress, start_burn_ht, lock_period, callback = null) {
|
|
38
|
-
const addresss = tupleCV({
|
|
39
|
-
hashbytes: bufferCV(poxAddress),
|
|
40
|
-
version: bufferCV(new Buffer(1)),
|
|
41
|
-
});
|
|
42
|
-
const amount_str = new BigNumber(amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
43
|
-
const options = getWriteOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'stack-stx', [uintCV(amount_str), addresss, uintCV(start_burn_ht), uintCV(lock_period)], [], callback);
|
|
44
|
-
const result_raw = await openContractCall(options);
|
|
45
|
-
return result_raw;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
import { openContractCall } from "@stacks/connect";
|
|
2
|
+
import { bufferCV, callReadOnlyFunction, cvToValue, FungibleConditionCode, standardPrincipalCV, tupleCV, uintCV } from "@stacks/transactions";
|
|
3
|
+
import { getPostConditionFromAsset, getReadOptions, getWriteOptions } from "../util";
|
|
4
|
+
import BigNumber from "bignumber.js";
|
|
5
|
+
export class OtherManager {
|
|
6
|
+
constructor(stackswap) {
|
|
7
|
+
this.stackswap = stackswap;
|
|
8
|
+
}
|
|
9
|
+
async getUserBeta01Data(contract_address) {
|
|
10
|
+
try {
|
|
11
|
+
const options = getReadOptions(this.stackswap, contract_address, 'get-user-rewards', [
|
|
12
|
+
standardPrincipalCV(this.stackswap.getSenderAddress()),
|
|
13
|
+
]);
|
|
14
|
+
const result = await callReadOnlyFunction(options);
|
|
15
|
+
return cvToValue(result).value;
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async claimUserBeta01Reward(contract_address, reward, callback = null) {
|
|
22
|
+
try {
|
|
23
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, contract_address, this.stackswap.config.BASE_STSW_DATA().addr, reward, FungibleConditionCode.Equal)];
|
|
24
|
+
const options = getWriteOptions(this.stackswap, contract_address, 'claim-reward', [], post_condition, callback);
|
|
25
|
+
const result_raw = await openContractCall(options);
|
|
26
|
+
return result_raw;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async get_pox_info() {
|
|
33
|
+
const options = getReadOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'get-pox-info', []);
|
|
34
|
+
const result = await callReadOnlyFunction(options);
|
|
35
|
+
return cvToValue(result).value;
|
|
36
|
+
}
|
|
37
|
+
async stack_stx_to_pox(amount, poxAddress, start_burn_ht, lock_period, callback = null) {
|
|
38
|
+
const addresss = tupleCV({
|
|
39
|
+
hashbytes: bufferCV(poxAddress),
|
|
40
|
+
version: bufferCV(new Buffer(1)),
|
|
41
|
+
});
|
|
42
|
+
const amount_str = new BigNumber(amount).multipliedBy(10 ** 6).toFixed(0).toString();
|
|
43
|
+
const options = getWriteOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'stack-stx', [uintCV(amount_str), addresss, uintCV(start_burn_ht), uintCV(lock_period)], [], callback);
|
|
44
|
+
const result_raw = await openContractCall(options);
|
|
45
|
+
return result_raw;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
48
|
//# sourceMappingURL=other.manager.js.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { StackswapAPI } from "../../index";
|
|
2
|
-
import { Token } from "./token.manager";
|
|
3
|
-
export declare class LiquidityPool {
|
|
4
|
-
name: string;
|
|
5
|
-
token_x: Token;
|
|
6
|
-
token_y: Token;
|
|
7
|
-
token_lp: Token;
|
|
8
|
-
loaded: boolean;
|
|
9
|
-
balance_x: string;
|
|
10
|
-
balance_y: string;
|
|
11
|
-
share_total: string;
|
|
12
|
-
constructor(name: string, token_x: Token, token_y: Token, token_lp: Token, balance_x?: string, balance_y?: string, share_total?: string);
|
|
13
|
-
getTokenX(direction?: boolean): Token;
|
|
14
|
-
getTokenY(direction?: boolean): Token;
|
|
15
|
-
toString(): string;
|
|
16
|
-
static parsePoolFromJson(data: any): LiquidityPool;
|
|
17
|
-
static parsePoolsFromJsonList(datas: any): LiquidityPool[];
|
|
18
|
-
static parsePoolsFromServerData(pair: any, token_x: Token, token_y: Token, direction?: boolean): LiquidityPool;
|
|
19
|
-
static parsePoolsFromServerData2(pair: any, token_x: Token, token_y: Token, direction?: boolean): LiquidityPool;
|
|
20
|
-
static parsePoolsFromDBData(data: any): LiquidityPool;
|
|
21
|
-
getPoolPrice(inverted?: boolean, amount?: string): {
|
|
22
|
-
dy: string;
|
|
23
|
-
output_price: string;
|
|
24
|
-
};
|
|
25
|
-
getPoolTVL(stackswap: StackswapAPI, pool: LiquidityPool, stx_usd: number, stsw_usd: number, btc_usd: number): number;
|
|
26
|
-
getNewPoolShareRatio(token_amount: any, inversed: boolean): number;
|
|
27
|
-
}
|
|
28
|
-
export declare class PoolManager {
|
|
29
|
-
stackswap: StackswapAPI;
|
|
30
|
-
constructor(stackswap: StackswapAPI);
|
|
31
|
-
getPoolLists(): Promise<LiquidityPool[]>;
|
|
32
|
-
getPairDataFromContract(token_x: Token, token_y: Token): Promise<LiquidityPool | null>;
|
|
33
|
-
getPoolDatasLegacy(token_x: Token, token_y: Token, swap_contract: string): Promise<LiquidityPool | null>;
|
|
34
|
-
}
|
|
1
|
+
import { StackswapAPI } from "../../index";
|
|
2
|
+
import { Token } from "./token.manager";
|
|
3
|
+
export declare class LiquidityPool {
|
|
4
|
+
name: string;
|
|
5
|
+
token_x: Token;
|
|
6
|
+
token_y: Token;
|
|
7
|
+
token_lp: Token;
|
|
8
|
+
loaded: boolean;
|
|
9
|
+
balance_x: string;
|
|
10
|
+
balance_y: string;
|
|
11
|
+
share_total: string;
|
|
12
|
+
constructor(name: string, token_x: Token, token_y: Token, token_lp: Token, balance_x?: string, balance_y?: string, share_total?: string);
|
|
13
|
+
getTokenX(direction?: boolean): Token;
|
|
14
|
+
getTokenY(direction?: boolean): Token;
|
|
15
|
+
toString(): string;
|
|
16
|
+
static parsePoolFromJson(data: any): LiquidityPool;
|
|
17
|
+
static parsePoolsFromJsonList(datas: any): LiquidityPool[];
|
|
18
|
+
static parsePoolsFromServerData(pair: any, token_x: Token, token_y: Token, direction?: boolean): LiquidityPool;
|
|
19
|
+
static parsePoolsFromServerData2(pair: any, token_x: Token, token_y: Token, direction?: boolean): LiquidityPool;
|
|
20
|
+
static parsePoolsFromDBData(data: any): LiquidityPool;
|
|
21
|
+
getPoolPrice(inverted?: boolean, amount?: string): {
|
|
22
|
+
dy: string;
|
|
23
|
+
output_price: string;
|
|
24
|
+
};
|
|
25
|
+
getPoolTVL(stackswap: StackswapAPI, pool: LiquidityPool, stx_usd: number, stsw_usd: number, btc_usd: number): number;
|
|
26
|
+
getNewPoolShareRatio(token_amount: any, inversed: boolean): number;
|
|
27
|
+
}
|
|
28
|
+
export declare class PoolManager {
|
|
29
|
+
stackswap: StackswapAPI;
|
|
30
|
+
constructor(stackswap: StackswapAPI);
|
|
31
|
+
getPoolLists(): Promise<LiquidityPool[]>;
|
|
32
|
+
getPairDataFromContract(token_x: Token, token_y: Token): Promise<LiquidityPool | null>;
|
|
33
|
+
getPoolDatasLegacy(token_x: Token, token_y: Token, swap_contract: string): Promise<LiquidityPool | null>;
|
|
34
|
+
}
|