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,95 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
callReadOnlyFunction,
|
|
3
|
-
cvToValue,
|
|
4
|
-
FungibleConditionCode,
|
|
5
|
-
standardPrincipalCV,
|
|
6
|
-
uintCV
|
|
7
|
-
} from "@stacks/transactions";
|
|
8
|
-
import {openContractCall} from "@stacks/connect";
|
|
9
|
-
import BigNumber from "bignumber.js";
|
|
10
|
-
import {getPostConditionFromAsset, getReadOptions, getWriteOptions} from "../util";
|
|
11
|
-
import {StackswapAPI} from "../../index";
|
|
12
|
-
|
|
13
|
-
export class GovernanceManager {
|
|
14
|
-
stackswap: StackswapAPI;
|
|
15
|
-
|
|
16
|
-
constructor(stackswap: StackswapAPI) {
|
|
17
|
-
this.stackswap = stackswap;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
async getProposalsList(){
|
|
22
|
-
const function_option : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),'get-proposals',[]);
|
|
23
|
-
const result_raw = await callReadOnlyFunction(function_option);
|
|
24
|
-
|
|
25
|
-
const result = cvToValue(result_raw);
|
|
26
|
-
|
|
27
|
-
// tslint:disable-next-line:prefer-const
|
|
28
|
-
let res_list:any = [];
|
|
29
|
-
result.value.forEach((element:any) =>{
|
|
30
|
-
res_list.push(element.value);
|
|
31
|
-
});
|
|
32
|
-
return res_list;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async getNumVoting(proposal_id:number) {
|
|
36
|
-
const function_option : any = getReadOptions(
|
|
37
|
-
this.stackswap,
|
|
38
|
-
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
39
|
-
'get-votes-by-member-by-id',
|
|
40
|
-
[
|
|
41
|
-
uintCV(proposal_id),
|
|
42
|
-
standardPrincipalCV(this.stackswap.getSenderAddress())
|
|
43
|
-
]);
|
|
44
|
-
const result_raw = await callReadOnlyFunction(function_option);
|
|
45
|
-
const result = cvToValue(result_raw);
|
|
46
|
-
// console.log("TTT", cvToValue(result_raw))
|
|
47
|
-
return [result['vote-count'].value, result.returned.value];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
async txWithdrawVoting(proposal_id:number, callback: any = null) {
|
|
52
|
-
const function_option : any = getWriteOptions(
|
|
53
|
-
this.stackswap,
|
|
54
|
-
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
55
|
-
'return-votes-to-member',
|
|
56
|
-
[
|
|
57
|
-
uintCV(proposal_id),
|
|
58
|
-
standardPrincipalCV(this.stackswap.getSenderAddress())
|
|
59
|
-
], callback);
|
|
60
|
-
await openContractCall(function_option);
|
|
61
|
-
// console.log("TTT", cvToValue(result_raw))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
async txVote(proposal_id:number, vote_mode:string, vote_amount:any, callback: any = null){
|
|
66
|
-
// console.log("TT", typeof(vote_mode), vote_mode)
|
|
67
|
-
// console.log("TT", typeof(vote_amount), vote_amount)
|
|
68
|
-
// console.log("TT", typeof(BASE_vSTSW_DATA().decimal), BASE_vSTSW_DATA().decimal)
|
|
69
|
-
|
|
70
|
-
const vote_amount_bn = new BigNumber(10 ** 6).multipliedBy(parseFloat(vote_amount)).toFixed(0).toString();
|
|
71
|
-
// console.log("TT", typeof(vote_amount_bn), vote_amount_bn)
|
|
72
|
-
|
|
73
|
-
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_vSTSW_DATA().addr, vote_amount_bn, FungibleConditionCode.Equal)];
|
|
74
|
-
|
|
75
|
-
let function_option = null;
|
|
76
|
-
if(vote_mode==='For'){
|
|
77
|
-
function_option = getWriteOptions(
|
|
78
|
-
this.stackswap,
|
|
79
|
-
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
80
|
-
'vote-for',[
|
|
81
|
-
uintCV(proposal_id), uintCV(vote_amount_bn)],
|
|
82
|
-
post_condition, callback);
|
|
83
|
-
}else if (vote_mode === 'Against'){
|
|
84
|
-
function_option = getWriteOptions(
|
|
85
|
-
this.stackswap,
|
|
86
|
-
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
87
|
-
'vote-against',[
|
|
88
|
-
uintCV(proposal_id), uintCV(vote_amount_bn)],
|
|
89
|
-
post_condition, callback);
|
|
90
|
-
}
|
|
91
|
-
if(function_option !=null){
|
|
92
|
-
await openContractCall(function_option);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
callReadOnlyFunction,
|
|
3
|
+
cvToValue,
|
|
4
|
+
FungibleConditionCode,
|
|
5
|
+
standardPrincipalCV,
|
|
6
|
+
uintCV
|
|
7
|
+
} from "@stacks/transactions";
|
|
8
|
+
import {openContractCall} from "@stacks/connect";
|
|
9
|
+
import BigNumber from "bignumber.js";
|
|
10
|
+
import {getPostConditionFromAsset, getReadOptions, getWriteOptions} from "../util";
|
|
11
|
+
import {StackswapAPI} from "../../index";
|
|
12
|
+
|
|
13
|
+
export class GovernanceManager {
|
|
14
|
+
stackswap: StackswapAPI;
|
|
15
|
+
|
|
16
|
+
constructor(stackswap: StackswapAPI) {
|
|
17
|
+
this.stackswap = stackswap;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async getProposalsList(){
|
|
22
|
+
const function_option : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),'get-proposals',[]);
|
|
23
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
24
|
+
|
|
25
|
+
const result = cvToValue(result_raw);
|
|
26
|
+
|
|
27
|
+
// tslint:disable-next-line:prefer-const
|
|
28
|
+
let res_list:any = [];
|
|
29
|
+
result.value.forEach((element:any) =>{
|
|
30
|
+
res_list.push(element.value);
|
|
31
|
+
});
|
|
32
|
+
return res_list;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async getNumVoting(proposal_id:number) {
|
|
36
|
+
const function_option : any = getReadOptions(
|
|
37
|
+
this.stackswap,
|
|
38
|
+
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
39
|
+
'get-votes-by-member-by-id',
|
|
40
|
+
[
|
|
41
|
+
uintCV(proposal_id),
|
|
42
|
+
standardPrincipalCV(this.stackswap.getSenderAddress())
|
|
43
|
+
]);
|
|
44
|
+
const result_raw = await callReadOnlyFunction(function_option);
|
|
45
|
+
const result = cvToValue(result_raw);
|
|
46
|
+
// console.log("TTT", cvToValue(result_raw))
|
|
47
|
+
return [result['vote-count'].value, result.returned.value];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async txWithdrawVoting(proposal_id:number, callback: any = null) {
|
|
52
|
+
const function_option : any = getWriteOptions(
|
|
53
|
+
this.stackswap,
|
|
54
|
+
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
55
|
+
'return-votes-to-member',
|
|
56
|
+
[
|
|
57
|
+
uintCV(proposal_id),
|
|
58
|
+
standardPrincipalCV(this.stackswap.getSenderAddress())
|
|
59
|
+
], callback);
|
|
60
|
+
await openContractCall(function_option);
|
|
61
|
+
// console.log("TTT", cvToValue(result_raw))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async txVote(proposal_id:number, vote_mode:string, vote_amount:any, callback: any = null){
|
|
66
|
+
// console.log("TT", typeof(vote_mode), vote_mode)
|
|
67
|
+
// console.log("TT", typeof(vote_amount), vote_amount)
|
|
68
|
+
// console.log("TT", typeof(BASE_vSTSW_DATA().decimal), BASE_vSTSW_DATA().decimal)
|
|
69
|
+
|
|
70
|
+
const vote_amount_bn = new BigNumber(10 ** 6).multipliedBy(parseFloat(vote_amount)).toFixed(0).toString();
|
|
71
|
+
// console.log("TT", typeof(vote_amount_bn), vote_amount_bn)
|
|
72
|
+
|
|
73
|
+
const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_vSTSW_DATA().addr, vote_amount_bn, FungibleConditionCode.Equal)];
|
|
74
|
+
|
|
75
|
+
let function_option = null;
|
|
76
|
+
if(vote_mode==='For'){
|
|
77
|
+
function_option = getWriteOptions(
|
|
78
|
+
this.stackswap,
|
|
79
|
+
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
80
|
+
'vote-for',[
|
|
81
|
+
uintCV(proposal_id), uintCV(vote_amount_bn)],
|
|
82
|
+
post_condition, callback);
|
|
83
|
+
}else if (vote_mode === 'Against'){
|
|
84
|
+
function_option = getWriteOptions(
|
|
85
|
+
this.stackswap,
|
|
86
|
+
this.stackswap.config.CONTRACT_NAME_STACKSWAP_GOVERNANCE(),
|
|
87
|
+
'vote-against',[
|
|
88
|
+
uintCV(proposal_id), uintCV(vote_amount_bn)],
|
|
89
|
+
post_condition, callback);
|
|
90
|
+
}
|
|
91
|
+
if(function_option !=null){
|
|
92
|
+
await openContractCall(function_option);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAmountStringWithDecimal,
|
|
3
|
-
getAmountWithDecimalString,
|
|
4
|
-
getPostConditionFromAsset, getReadOptions,
|
|
5
|
-
getWriteOptions
|
|
6
|
-
} from "../util";
|
|
7
|
-
import {
|
|
8
|
-
callReadOnlyFunction, contractPrincipalCV,
|
|
9
|
-
cvToValue,
|
|
10
|
-
FungibleConditionCode,
|
|
11
|
-
stringAsciiCV,
|
|
12
|
-
stringUtf8CV,
|
|
13
|
-
uintCV
|
|
14
|
-
} from "@stacks/transactions";
|
|
15
|
-
import {openContractCall} from "@stacks/connect";
|
|
16
|
-
import {StackswapAPI} from "../../index";
|
|
17
|
-
|
|
18
|
-
export class LaunchpadManager {
|
|
19
|
-
stackswap: StackswapAPI;
|
|
20
|
-
|
|
21
|
-
constructor(stackswap: StackswapAPI) {
|
|
22
|
-
this.stackswap = stackswap;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
getRandomIntNum(min: number, max: number) {
|
|
27
|
-
min = Math.ceil(min);
|
|
28
|
-
max = Math.floor(max);
|
|
29
|
-
return Math.floor(Math.random() * (max - min)) + min; // 최댓값은 제외, 최솟값은 포함
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
async getLiquidityList() {
|
|
34
|
-
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(), 'get-liquidity-token-list', []);
|
|
35
|
-
try {
|
|
36
|
-
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
37
|
-
|
|
38
|
-
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
39
|
-
|
|
40
|
-
} catch (e) {
|
|
41
|
-
// console.log("no lists")
|
|
42
|
-
return('');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
async getSoftTokenList() {
|
|
48
|
-
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(), 'get-soft-token-list', []);
|
|
49
|
-
try {
|
|
50
|
-
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
51
|
-
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
52
|
-
} catch (e) {
|
|
53
|
-
return('');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
async getPOXLTokenList() {
|
|
59
|
-
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(), 'get-poxl-token-list', []);
|
|
60
|
-
try {
|
|
61
|
-
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
62
|
-
|
|
63
|
-
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return('');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
async mintSIPContractCall(soft_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
71
|
-
const token_y_addr = soft_token.split('.');
|
|
72
|
-
const pair_addr = liquidity_token.split('.');
|
|
73
|
-
const post_condition = [];
|
|
74
|
-
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));
|
|
75
|
-
// post_condition.push(await getPostConditionFromAsset(this.stackswap.getSenderAddress(), source.soft_token, getAmountWithDecimalString(source.initial_amount_y, source.token_decimal), FungibleConditionCode.GreaterEqual));
|
|
76
|
-
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), soft_token, 0, FungibleConditionCode.GreaterEqual));
|
|
77
|
-
// console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
78
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
79
|
-
'create-pair-new-sip10-token-with-stx',
|
|
80
|
-
[
|
|
81
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
82
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
83
|
-
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
84
|
-
uintCV(getAmountStringWithDecimal(data.initial_amount_x, 6)),
|
|
85
|
-
uintCV(getAmountStringWithDecimal(data.initial_amount_y, data.token_decimal)),
|
|
86
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
87
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
88
|
-
stringAsciiCV( data.token_name),
|
|
89
|
-
stringAsciiCV( data.token_symbol),
|
|
90
|
-
uintCV(data.token_decimal),
|
|
91
|
-
stringUtf8CV( data.token_uri),
|
|
92
|
-
stringUtf8CV( data.token_website),
|
|
93
|
-
uintCV( getAmountStringWithDecimal(data.initial_amount, data.token_decimal)),
|
|
94
|
-
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
95
|
-
], post_condition, callback);
|
|
96
|
-
openContractCall(options);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async mintPOXLContractCall(poxl_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
100
|
-
const token_y_addr = poxl_token.split('.');
|
|
101
|
-
const pair_addr = liquidity_token.split('.');
|
|
102
|
-
const post_condition = [];
|
|
103
|
-
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));
|
|
104
|
-
post_condition.push(await getPostConditionFromAsset(this.stackswap,this.stackswap.getSenderAddress(), poxl_token, 0, FungibleConditionCode.GreaterEqual));
|
|
105
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
106
|
-
'create-pair-new-poxl-token-with-stx',
|
|
107
|
-
[
|
|
108
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
109
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
110
|
-
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
111
|
-
uintCV(getAmountWithDecimalString(data.initial_amount_x, 6)),
|
|
112
|
-
uintCV(getAmountWithDecimalString(data.initial_amount_y, data.token_decimal)),
|
|
113
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
114
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
115
|
-
stringAsciiCV( data.token_name),
|
|
116
|
-
stringAsciiCV( data.token_symbol),
|
|
117
|
-
uintCV(data.token_decimal),
|
|
118
|
-
stringUtf8CV( data.token_uri),
|
|
119
|
-
stringUtf8CV( data.token_website),
|
|
120
|
-
uintCV( getAmountWithDecimalString(data.initial_amount, data.token_decimal)),
|
|
121
|
-
uintCV(data.first_stacking_block), // first stacking block
|
|
122
|
-
uintCV(data.reward_cycle_block), // reward cycle length
|
|
123
|
-
uintCV(data.token_reward_maturity), // token reward maturity
|
|
124
|
-
uintCV( getAmountWithDecimalString(data.coinbase_reward, data.token_decimal)), // coinbase reward
|
|
125
|
-
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
126
|
-
], post_condition, callback);
|
|
127
|
-
openContractCall(options);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
async mintSIPSTSWContractCall(soft_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
132
|
-
const token_y_addr = soft_token.split('.');
|
|
133
|
-
const pair_addr = liquidity_token.split('.');
|
|
134
|
-
const post_condition = [];
|
|
135
|
-
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));
|
|
136
|
-
// post_condition.push(await getPostConditionFromAsset(this.stackswap.getSenderAddress(), source.soft_token, getAmountWithDecimalString(source.initial_amount_y, source.token_decimal), FungibleConditionCode.GreaterEqual));
|
|
137
|
-
post_condition.push(await getPostConditionFromAsset(this.stackswap,this.stackswap.getSenderAddress(), soft_token, 0, FungibleConditionCode.GreaterEqual));
|
|
138
|
-
// console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
139
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
140
|
-
'create-pair-new-sip10-token-with-stsw',
|
|
141
|
-
[
|
|
142
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
143
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
144
|
-
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
145
|
-
uintCV(getAmountStringWithDecimal(data.initial_amount_x, 6)),
|
|
146
|
-
uintCV(getAmountStringWithDecimal(data.initial_amount_y, data.token_decimal)),
|
|
147
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
148
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
149
|
-
stringAsciiCV( data.token_name),
|
|
150
|
-
stringAsciiCV( data.token_symbol),
|
|
151
|
-
uintCV(data.token_decimal),
|
|
152
|
-
stringUtf8CV( data.token_uri),
|
|
153
|
-
stringUtf8CV( data.token_website),
|
|
154
|
-
uintCV( getAmountStringWithDecimal(data.initial_amount, data.token_decimal)),
|
|
155
|
-
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
156
|
-
], post_condition, callback);
|
|
157
|
-
openContractCall(options);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async mintPOXLSTSWContractCall(poxl_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
161
|
-
const token_y_addr = poxl_token.split('.');
|
|
162
|
-
const pair_addr = liquidity_token.split('.');
|
|
163
|
-
const post_condition = [];
|
|
164
|
-
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));
|
|
165
|
-
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), poxl_token, 0, FungibleConditionCode.GreaterEqual));
|
|
166
|
-
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
167
|
-
'create-pair-new-poxl-token-with-stsw',
|
|
168
|
-
[
|
|
169
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
170
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
171
|
-
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
172
|
-
uintCV(getAmountWithDecimalString(data.initial_amount_x, 6)),
|
|
173
|
-
uintCV(getAmountWithDecimalString(data.initial_amount_y, data.token_decimal)),
|
|
174
|
-
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
175
|
-
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
176
|
-
stringAsciiCV( data.token_name),
|
|
177
|
-
stringAsciiCV( data.token_symbol),
|
|
178
|
-
uintCV(data.token_decimal),
|
|
179
|
-
stringUtf8CV( data.token_uri),
|
|
180
|
-
stringUtf8CV( data.token_website),
|
|
181
|
-
uintCV( getAmountWithDecimalString(data.initial_amount, data.token_decimal)),
|
|
182
|
-
uintCV(data.first_stacking_block), // first stacking block
|
|
183
|
-
uintCV(data.reward_cycle_block), // reward cycle length
|
|
184
|
-
uintCV(data.token_reward_maturity), // token reward maturity
|
|
185
|
-
uintCV( getAmountWithDecimalString(data.coinbase_reward, data.token_decimal)), // coinbase reward
|
|
186
|
-
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
187
|
-
], post_condition, callback);
|
|
188
|
-
openContractCall(options);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
getAmountStringWithDecimal,
|
|
3
|
+
getAmountWithDecimalString,
|
|
4
|
+
getPostConditionFromAsset, getReadOptions,
|
|
5
|
+
getWriteOptions
|
|
6
|
+
} from "../util";
|
|
7
|
+
import {
|
|
8
|
+
callReadOnlyFunction, contractPrincipalCV,
|
|
9
|
+
cvToValue,
|
|
10
|
+
FungibleConditionCode,
|
|
11
|
+
stringAsciiCV,
|
|
12
|
+
stringUtf8CV,
|
|
13
|
+
uintCV
|
|
14
|
+
} from "@stacks/transactions";
|
|
15
|
+
import {openContractCall} from "@stacks/connect";
|
|
16
|
+
import {StackswapAPI} from "../../index";
|
|
17
|
+
|
|
18
|
+
export class LaunchpadManager {
|
|
19
|
+
stackswap: StackswapAPI;
|
|
20
|
+
|
|
21
|
+
constructor(stackswap: StackswapAPI) {
|
|
22
|
+
this.stackswap = stackswap;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
getRandomIntNum(min: number, max: number) {
|
|
27
|
+
min = Math.ceil(min);
|
|
28
|
+
max = Math.floor(max);
|
|
29
|
+
return Math.floor(Math.random() * (max - min)) + min; // 최댓값은 제외, 최솟값은 포함
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async getLiquidityList() {
|
|
34
|
+
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(), 'get-liquidity-token-list', []);
|
|
35
|
+
try {
|
|
36
|
+
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
37
|
+
|
|
38
|
+
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
39
|
+
|
|
40
|
+
} catch (e) {
|
|
41
|
+
// console.log("no lists")
|
|
42
|
+
return('');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
async getSoftTokenList() {
|
|
48
|
+
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(), 'get-soft-token-list', []);
|
|
49
|
+
try {
|
|
50
|
+
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
51
|
+
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return('');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async getPOXLTokenList() {
|
|
59
|
+
const pair_details_options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(), 'get-poxl-token-list', []);
|
|
60
|
+
try {
|
|
61
|
+
const result = cvToValue(await callReadOnlyFunction(pair_details_options)).value;
|
|
62
|
+
|
|
63
|
+
return result[this.getRandomIntNum(0, result.length-1)].value;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return('');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async mintSIPContractCall(soft_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
71
|
+
const token_y_addr = soft_token.split('.');
|
|
72
|
+
const pair_addr = liquidity_token.split('.');
|
|
73
|
+
const post_condition = [];
|
|
74
|
+
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));
|
|
75
|
+
// post_condition.push(await getPostConditionFromAsset(this.stackswap.getSenderAddress(), source.soft_token, getAmountWithDecimalString(source.initial_amount_y, source.token_decimal), FungibleConditionCode.GreaterEqual));
|
|
76
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), soft_token, 0, FungibleConditionCode.GreaterEqual));
|
|
77
|
+
// console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
78
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
79
|
+
'create-pair-new-sip10-token-with-stx',
|
|
80
|
+
[
|
|
81
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
82
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
83
|
+
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
84
|
+
uintCV(getAmountStringWithDecimal(data.initial_amount_x, 6)),
|
|
85
|
+
uintCV(getAmountStringWithDecimal(data.initial_amount_y, data.token_decimal)),
|
|
86
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
87
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
88
|
+
stringAsciiCV( data.token_name),
|
|
89
|
+
stringAsciiCV( data.token_symbol),
|
|
90
|
+
uintCV(data.token_decimal),
|
|
91
|
+
stringUtf8CV( data.token_uri),
|
|
92
|
+
stringUtf8CV( data.token_website),
|
|
93
|
+
uintCV( getAmountStringWithDecimal(data.initial_amount, data.token_decimal)),
|
|
94
|
+
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
95
|
+
], post_condition, callback);
|
|
96
|
+
openContractCall(options);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async mintPOXLContractCall(poxl_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
100
|
+
const token_y_addr = poxl_token.split('.');
|
|
101
|
+
const pair_addr = liquidity_token.split('.');
|
|
102
|
+
const post_condition = [];
|
|
103
|
+
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));
|
|
104
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap,this.stackswap.getSenderAddress(), poxl_token, 0, FungibleConditionCode.GreaterEqual));
|
|
105
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
106
|
+
'create-pair-new-poxl-token-with-stx',
|
|
107
|
+
[
|
|
108
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
109
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
110
|
+
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
111
|
+
uintCV(getAmountWithDecimalString(data.initial_amount_x, 6)),
|
|
112
|
+
uintCV(getAmountWithDecimalString(data.initial_amount_y, data.token_decimal)),
|
|
113
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
114
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
115
|
+
stringAsciiCV( data.token_name),
|
|
116
|
+
stringAsciiCV( data.token_symbol),
|
|
117
|
+
uintCV(data.token_decimal),
|
|
118
|
+
stringUtf8CV( data.token_uri),
|
|
119
|
+
stringUtf8CV( data.token_website),
|
|
120
|
+
uintCV( getAmountWithDecimalString(data.initial_amount, data.token_decimal)),
|
|
121
|
+
uintCV(data.first_stacking_block), // first stacking block
|
|
122
|
+
uintCV(data.reward_cycle_block), // reward cycle length
|
|
123
|
+
uintCV(data.token_reward_maturity), // token reward maturity
|
|
124
|
+
uintCV( getAmountWithDecimalString(data.coinbase_reward, data.token_decimal)), // coinbase reward
|
|
125
|
+
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
126
|
+
], post_condition, callback);
|
|
127
|
+
openContractCall(options);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
async mintSIPSTSWContractCall(soft_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
132
|
+
const token_y_addr = soft_token.split('.');
|
|
133
|
+
const pair_addr = liquidity_token.split('.');
|
|
134
|
+
const post_condition = [];
|
|
135
|
+
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));
|
|
136
|
+
// post_condition.push(await getPostConditionFromAsset(this.stackswap.getSenderAddress(), source.soft_token, getAmountWithDecimalString(source.initial_amount_y, source.token_decimal), FungibleConditionCode.GreaterEqual));
|
|
137
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap,this.stackswap.getSenderAddress(), soft_token, 0, FungibleConditionCode.GreaterEqual));
|
|
138
|
+
// console.log(getAmountStringWithDecimal(source.initial_amount, source.token_decimal));
|
|
139
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
140
|
+
'create-pair-new-sip10-token-with-stsw',
|
|
141
|
+
[
|
|
142
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
143
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
144
|
+
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
145
|
+
uintCV(getAmountStringWithDecimal(data.initial_amount_x, 6)),
|
|
146
|
+
uintCV(getAmountStringWithDecimal(data.initial_amount_y, data.token_decimal)),
|
|
147
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
148
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
149
|
+
stringAsciiCV( data.token_name),
|
|
150
|
+
stringAsciiCV( data.token_symbol),
|
|
151
|
+
uintCV(data.token_decimal),
|
|
152
|
+
stringUtf8CV( data.token_uri),
|
|
153
|
+
stringUtf8CV( data.token_website),
|
|
154
|
+
uintCV( getAmountStringWithDecimal(data.initial_amount, data.token_decimal)),
|
|
155
|
+
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
156
|
+
], post_condition, callback);
|
|
157
|
+
openContractCall(options);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async mintPOXLSTSWContractCall(poxl_token: string, liquidity_token: string, data : any, callback: any = null) {
|
|
161
|
+
const token_y_addr = poxl_token.split('.');
|
|
162
|
+
const pair_addr = liquidity_token.split('.');
|
|
163
|
+
const post_condition = [];
|
|
164
|
+
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));
|
|
165
|
+
post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), poxl_token, 0, FungibleConditionCode.GreaterEqual));
|
|
166
|
+
const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_ONE_STEP_MINT(),
|
|
167
|
+
'create-pair-new-poxl-token-with-stsw',
|
|
168
|
+
[
|
|
169
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
170
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
171
|
+
stringAsciiCV( 'STX-' + data.token_symbol),
|
|
172
|
+
uintCV(getAmountWithDecimalString(data.initial_amount_x, 6)),
|
|
173
|
+
uintCV(getAmountWithDecimalString(data.initial_amount_y, data.token_decimal)),
|
|
174
|
+
contractPrincipalCV(token_y_addr[0], token_y_addr[1]),
|
|
175
|
+
contractPrincipalCV(pair_addr[0], pair_addr[1]),
|
|
176
|
+
stringAsciiCV( data.token_name),
|
|
177
|
+
stringAsciiCV( data.token_symbol),
|
|
178
|
+
uintCV(data.token_decimal),
|
|
179
|
+
stringUtf8CV( data.token_uri),
|
|
180
|
+
stringUtf8CV( data.token_website),
|
|
181
|
+
uintCV( getAmountWithDecimalString(data.initial_amount, data.token_decimal)),
|
|
182
|
+
uintCV(data.first_stacking_block), // first stacking block
|
|
183
|
+
uintCV(data.reward_cycle_block), // reward cycle length
|
|
184
|
+
uintCV(data.token_reward_maturity), // token reward maturity
|
|
185
|
+
uintCV( getAmountWithDecimalString(data.coinbase_reward, data.token_decimal)), // coinbase reward
|
|
186
|
+
contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP())
|
|
187
|
+
], post_condition, callback);
|
|
188
|
+
openContractCall(options);
|
|
189
|
+
}
|
|
190
|
+
}
|