stackswap-front-api-test-02 1.1.55 → 1.1.56

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.
Files changed (48) hide show
  1. package/dist/esm/stackswap/manager/bridge.manager.js +0 -10
  2. package/dist/esm/stackswap/manager/bridge.manager.js.map +1 -1
  3. package/dist/esm/stackswap/manager/farm2.manager.js +0 -1
  4. package/dist/esm/stackswap/manager/farm2.manager.js.map +1 -1
  5. package/dist/esm/stackswap/manager/farm3.manager.js +0 -1
  6. package/dist/esm/stackswap/manager/farm3.manager.js.map +1 -1
  7. package/dist/esm/stackswap/manager/groupfarm.manager.js +0 -7
  8. package/dist/esm/stackswap/manager/groupfarm.manager.js.map +1 -1
  9. package/dist/esm/stackswap/manager/lbtcstaking.manager.js +0 -3
  10. package/dist/esm/stackswap/manager/lbtcstaking.manager.js.map +1 -1
  11. package/dist/esm/stackswap/manager/staking.manager.js +0 -2
  12. package/dist/esm/stackswap/manager/staking.manager.js.map +1 -1
  13. package/dist/esm/stackswap/manager/swap.manager.js +0 -6
  14. package/dist/esm/stackswap/manager/swap.manager.js.map +1 -1
  15. package/dist/index.umd.js +1 -1
  16. package/dist/stackswap/manager/bridge.manager.js +0 -10
  17. package/dist/stackswap/manager/bridge.manager.js.map +1 -1
  18. package/dist/stackswap/manager/farm2.manager.js +0 -1
  19. package/dist/stackswap/manager/farm2.manager.js.map +1 -1
  20. package/dist/stackswap/manager/farm3.manager.js +0 -1
  21. package/dist/stackswap/manager/farm3.manager.js.map +1 -1
  22. package/dist/stackswap/manager/groupfarm.manager.js +0 -7
  23. package/dist/stackswap/manager/groupfarm.manager.js.map +1 -1
  24. package/dist/stackswap/manager/lbtcstaking.manager.js +0 -3
  25. package/dist/stackswap/manager/lbtcstaking.manager.js.map +1 -1
  26. package/dist/stackswap/manager/staking.manager.js +0 -2
  27. package/dist/stackswap/manager/staking.manager.js.map +1 -1
  28. package/dist/stackswap/manager/swap.manager.js +0 -6
  29. package/dist/stackswap/manager/swap.manager.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/stackswap/manager/bridge.manager.ts +48 -48
  32. package/src/stackswap/manager/farm.manager.ts +25 -25
  33. package/src/stackswap/manager/farm2.manager.ts +47 -47
  34. package/src/stackswap/manager/farm3.manager.ts +43 -43
  35. package/src/stackswap/manager/governance.manager.ts +6 -6
  36. package/src/stackswap/manager/groupfarm.manager.ts +25 -25
  37. package/src/stackswap/manager/launchpad.manager.ts +3 -3
  38. package/src/stackswap/manager/lbtc.manager.ts +5 -5
  39. package/src/stackswap/manager/lbtcstaking.manager.ts +25 -25
  40. package/src/stackswap/manager/multisig.manager.ts +9 -9
  41. package/src/stackswap/manager/nft.manager.ts +16 -16
  42. package/src/stackswap/manager/operator.manager.ts +2 -2
  43. package/src/stackswap/manager/other.manager.ts +2 -2
  44. package/src/stackswap/manager/pool.manager.ts +11 -11
  45. package/src/stackswap/manager/poxl.manager.ts +7 -7
  46. package/src/stackswap/manager/staking.manager.ts +26 -26
  47. package/src/stackswap/manager/swap.manager.ts +31 -31
  48. package/src/stackswap/manager/token.manager.ts +13 -13
@@ -82,7 +82,7 @@ export class OperatorManager {
82
82
  const options = getReadOptions(this.stackswap, 'distributor0001', 'get-invester',
83
83
  [ standardPrincipalCV(this.stackswap.getSenderAddress())]);
84
84
  const result = await callReadOnlyFunction(options);
85
- // console.log(cvToValue(result));
85
+ // // console.log(cvToValue(result));
86
86
 
87
87
  return cvToValue(result).value;
88
88
  }
@@ -90,7 +90,7 @@ export class OperatorManager {
90
90
  const options : any = getReadOptions(this.stackswap, 'distributor0001', 'get-claimable-amount',
91
91
  [ standardPrincipalCV(this.stackswap.getSenderAddress())]);
92
92
  const result = await callReadOnlyFunction(options);
93
- // console.log(cvToValue(result));
93
+ // // console.log(cvToValue(result));
94
94
 
95
95
  return cvToValue(result);
96
96
  }
@@ -48,7 +48,7 @@ export class OtherManager {
48
48
  const options = getReadOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'get-pox-info',
49
49
  [ ]);
50
50
  const result = await callReadOnlyFunction(options);
51
- // console.log(cvToValue(result).value);
51
+ // // console.log(cvToValue(result).value);
52
52
  return cvToValue(result).value;
53
53
  }
54
54
 
@@ -60,7 +60,7 @@ export class OtherManager {
60
60
  });
61
61
 
62
62
  const amount_str = new BigNumber(amount).multipliedBy(10**6).toFixed(0).toString()
63
- // console.log(addresss);
63
+ // // console.log(addresss);
64
64
  const options = getWriteOptions(this.stackswap, 'SP000000000000000000002Q6VF78.pox', 'stack-stx',
65
65
  [ uintCV(amount_str), addresss, uintCV(start_burn_ht), uintCV(lock_period)],[], callback);
66
66
  const result_raw = await openContractCall(options);
@@ -130,7 +130,7 @@ export class LiquidityPool {
130
130
  const token_in_pool = new BigNumber(inversed ? this.balance_x : this.balance_y);
131
131
  const token_in_pool_new = token_input.plus(token_in_pool);
132
132
  const temp = (token_input.dividedBy(token_in_pool_new).multipliedBy(100)).toNumber();
133
- // console.log(temp, isNaN(temp));
133
+ // // console.log(temp, isNaN(temp));
134
134
 
135
135
  if ( ! isNaN(temp) ) {
136
136
  return temp;
@@ -169,17 +169,17 @@ export class PoolManager {
169
169
  try {
170
170
  const result = await callReadOnlyFunction(pair_details_options);
171
171
  // @ts-ignore
172
- // console.log(result);
173
- // console.log(cvToValue(result));
172
+ // // console.log(result);
173
+ // // console.log(cvToValue(result));
174
174
  const result2 = await callReadOnlyFunction(getReadOptions(this.stackswap, cvToValue(result)['liquidity-token'].value, 'get-lp-data', []));
175
- // console.log('cv-to-value',cvToValue(result2)['value']);
176
- // console.log(cvToValue(result2).value);
175
+ // // console.log('cv-to-value',cvToValue(result2)['value']);
176
+ // // console.log(cvToValue(result2).value);
177
177
  return LiquidityPool.parsePoolsFromServerData(cvToValue(result2).value, token_x, token_y, true);
178
178
  } catch (e) {
179
- // console.log(e);
179
+ // // console.log(e);
180
180
  return null;
181
181
  }
182
- // console.log(pair_details_result)
182
+ // // console.log(pair_details_result)
183
183
  }
184
184
 
185
185
  async getPoolDatasLegacy( token_x: Token, token_y: Token, swap_contract: string) : Promise<LiquidityPool | null> {
@@ -189,14 +189,14 @@ export class PoolManager {
189
189
  const result = await callReadOnlyFunction(pair_details_options);
190
190
  // @ts-ignore
191
191
  const result2 = await callReadOnlyFunction(getReadOptions(this.stackswap, cvToValue(result)['liquidity-token'].value, 'get-lp-data', []));
192
- // console.log('cv-to-value',cvToValue(result2)['value']);
193
- // console.log(cvToValue(result2).value);
192
+ // // console.log('cv-to-value',cvToValue(result2)['value']);
193
+ // // console.log(cvToValue(result2).value);
194
194
  return LiquidityPool.parsePoolsFromServerData(cvToValue(result2).value, token_x, token_y, true);
195
195
  } catch (e) {
196
- // console.log(e);
196
+ // // console.log(e);
197
197
  return null;
198
198
  }
199
- // console.log(pair_details_result)
199
+ // // console.log(pair_details_result)
200
200
  }
201
201
 
202
202
  }
@@ -48,7 +48,7 @@ export class PoxlManager {
48
48
  async getRandomInt( contract_address: string, input: number) {
49
49
  await callReadOnlyFunction( getReadOptions(this.stackswap, contract_address, 'get-random-uint-at-block', [uintCV(input)]));
50
50
  // @ts-ignore
51
- // console.log(result['value'].value.toString());
51
+ // // console.log(result['value'].value.toString());
52
52
  }
53
53
 
54
54
  async getMinedBlock( contract_address: string, offset: number) {
@@ -61,23 +61,23 @@ export class PoxlManager {
61
61
  const total = get_result.data.total;
62
62
  const results = get_result.data.results;
63
63
  const mined_block: number[] = [];
64
- // console.log(results);
64
+ // // console.log(results);
65
65
  // @ts-ignore
66
66
  for (const item of results) {
67
- // console.log(item);
67
+ // // console.log(item);
68
68
  try {
69
69
  if (contract_address === item.contract_call.contract_id && item.contract_call.function_name === 'mine-tokens') {
70
70
  const temp = await this.canClaimCall(contract_address, item.block_height);
71
- // console.log(temp);
71
+ // // console.log(temp);
72
72
  if (temp) {
73
73
  mined_block.push(item.block_height);
74
74
  }
75
75
  }
76
76
  } catch (e) {
77
- // console.log(e);
77
+ // // console.log(e);
78
78
  }
79
79
  }
80
- // console.log(mined_block);
80
+ // // console.log(mined_block);
81
81
  return {total, mined_block};
82
82
  }
83
83
 
@@ -89,7 +89,7 @@ export class PoxlManager {
89
89
  uintCV(block),
90
90
  ]);
91
91
  const result = await callReadOnlyFunction(options);
92
- // console.log(cvToValue(result));
92
+ // // console.log(cvToValue(result));
93
93
  return cvToValue(result);
94
94
  }
95
95
 
@@ -32,18 +32,18 @@ export class StakingManager {
32
32
  }
33
33
 
34
34
  async getStakingSTSWBalance(source: any) {
35
- // console.log('getStakingSTSWBalance');
35
+ // // console.log('getStakingSTSWBalance');
36
36
  const pair_details_options : any = getReadOptions(source, this.stackswap.config.BASE_STSW_DATA().addr, 'get-balance',
37
37
  [contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(),this.stackswap.config.BASE_vSTSW_DATA().addr.split('.')[1])]);
38
38
  try {
39
39
  const result = await callReadOnlyFunction(pair_details_options);
40
- // console.log(cvToValue(result));
40
+ // // console.log(cvToValue(result));
41
41
  return cvToValue(result).value;
42
42
  } catch (e) {
43
- // console.log(e);
43
+ // // console.log(e);
44
44
  return 0;
45
45
  }
46
- // console.log(pair_details_result)
46
+ // // console.log(pair_details_result)
47
47
  }
48
48
 
49
49
  async getRewardRoundID_V2(source: any) {
@@ -54,16 +54,16 @@ export class StakingManager {
54
54
  standardPrincipalCV(this.stackswap.getSenderAddress()),
55
55
  ]);
56
56
  const result = await callReadOnlyFunction(options);
57
- // console.log('reward', round, cvToValue(result));
57
+ // // console.log('reward', round, cvToValue(result));
58
58
 
59
59
  const unclaimedList = [];
60
60
  for (const unclaimedElement of cvToValue(result).value) {
61
- // console.log('reward',unclaimedElement.value);
61
+ // // console.log('reward',unclaimedElement.value);
62
62
  if (unclaimedElement.value < round) {
63
63
  unclaimedList.push(unclaimedElement.value);
64
64
  }
65
65
  }
66
- // console.log('reward',unclaimedList);
66
+ // // console.log('reward',unclaimedList);
67
67
 
68
68
  return unclaimedList;
69
69
  } catch (e) {
@@ -78,7 +78,7 @@ export class StakingManager {
78
78
  uintCV(block),
79
79
  ]);
80
80
  const result = await callReadOnlyFunction(options);
81
- // console.log(cvToValue(result));
81
+ // // console.log(cvToValue(result));
82
82
  return cvToValue(result).value;
83
83
  } catch (e) {
84
84
  console.log(contract_address);
@@ -93,9 +93,9 @@ export class StakingManager {
93
93
  uintCV(round),
94
94
  ]);
95
95
  const result = await callReadOnlyFunction(options);
96
- // console.log('reward', round, cvToValue(result));
96
+ // // console.log('reward', round, cvToValue(result));
97
97
  const res = cvToValue(result).value;
98
- // console.log('getRoundData', res);
98
+ // // console.log('getRoundData', res);
99
99
  return {amount: res.amountSTSW.value, value: res.amountvSTSW.value, rewardBase: res.amountRewardBase.value};
100
100
  } catch (e) {
101
101
  return {amount: '0', value: '0', rewardBase: '0'};
@@ -108,9 +108,9 @@ export class StakingManager {
108
108
  uintCV(round),
109
109
  ]);
110
110
  const result = await callReadOnlyFunction(options);
111
- // console.log('reward', round, cvToValue(result));
111
+ // // console.log('reward', round, cvToValue(result));
112
112
  const res = cvToValue(result).value;
113
- console.log('getRoundData', res);
113
+ // console.log('getRoundData', res);
114
114
  return {amount: res.amountSTSW.value, value: res.amountvSTSW.value, rewardBase: res.amountRewardBase.value};
115
115
  } catch (e) {
116
116
  return {amount: '0', value: '0', rewardBase: '0'};
@@ -123,13 +123,13 @@ export class StakingManager {
123
123
  uintCV(cycle),
124
124
  standardPrincipalCV(user),
125
125
  ]);
126
- // console.log(cvToValue(result));ss
126
+ // // console.log(cvToValue(result));ss
127
127
  const result = await callReadOnlyFunction(options);
128
- // console.log(cvToValue(result));
128
+ // // console.log(cvToValue(result));
129
129
  const res = cvToValue(result).value;
130
130
  return {amount: res.amountSTSW.value, value: res.amountvSTSW.value};
131
131
  } catch (e) {
132
- console.log(e);
132
+ // console.log(e);
133
133
  return {amount: '0', value: '0'};
134
134
  }
135
135
  }
@@ -190,7 +190,7 @@ export class StakingManager {
190
190
  ]);
191
191
  const result_raw = await callReadOnlyFunction(function_option);
192
192
  const result = cvToValue(result_raw);
193
- // console.log("reward", round_id, result, result_raw)
193
+ // // console.log("reward", round_id, result, result_raw)
194
194
  return Number(result);
195
195
  }
196
196
 
@@ -233,7 +233,7 @@ export class StakingManager {
233
233
  const function_option : any = getReadOptions(this.stackswap, this.stackswap.config.BASE_vSTSW_DATA().addr,'get-user-count',[standardPrincipalCV(this.stackswap.getSenderAddress()) ]);
234
234
  const result_raw = await callReadOnlyFunction(function_option);
235
235
  const result = cvToValue(result_raw);
236
- // console.log("V2", result)
236
+ // // console.log("V2", result)
237
237
  if(result == null){return 0}
238
238
  else{return new BigNumber(result.value.stakedSTX.value).dividedBy(new BigNumber(10).exponentiatedBy(this.stackswap.config.BASE_vSTSW_DATA().decimal))}
239
239
  }
@@ -257,7 +257,7 @@ export class StakingManager {
257
257
  if ( !result.value.returned.value ){
258
258
  res_dict[i] = result;
259
259
  id_list.push(i);
260
- // console.log(result);
260
+ // // console.log(result);
261
261
  }
262
262
  }
263
263
  return [id_list, res_dict];
@@ -311,7 +311,7 @@ export class StakingManager {
311
311
 
312
312
 
313
313
  async txUnstakingFromVSTSW(index:number, amountSTX:string, amountvSTX:string, callback : any = null){
314
- // console.log("Unstaking", amountSTX)
314
+ // // console.log("Unstaking", amountSTX)
315
315
  const post_conditions = [];
316
316
  post_conditions.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_vSTSW_DATA().addr,amountvSTX, FungibleConditionCode.Equal))
317
317
  post_conditions.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.config.BASE_vSTSW_DATA().addr, this.stackswap.config.BASE_STSW_DATA().addr, amountSTX, FungibleConditionCode.Equal))
@@ -328,7 +328,7 @@ export class StakingManager {
328
328
  const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
329
329
  let reward_balance = 0;
330
330
  const current_round = await this.getCurrentStakingRound(ADDR);
331
- // console.log(current_round)
331
+ // // console.log(current_round)
332
332
  for (let i = 0; i <= current_round; i++) {
333
333
 
334
334
  const result = await this.getReward( ADDR, i);
@@ -341,7 +341,7 @@ export class StakingManager {
341
341
  const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
342
342
  let reward_balance = 0;
343
343
  const current_round = await this.getCurrentStakingRound(ADDR);
344
- // console.log(current_round)
344
+ // // console.log(current_round)
345
345
  const temp = [];
346
346
  for (const unclaimed of unclaimed_list) {
347
347
  if ( unclaimed < Number(current_round) ) {
@@ -375,7 +375,7 @@ export class StakingManager {
375
375
  ]);
376
376
  const result_raw = await callReadOnlyFunction(function_option);
377
377
  const result = cvToValue(result_raw);
378
- // console.log("reward", result.rewardSum.value, result_raw)
378
+ // // console.log("reward", result.rewardSum.value, result_raw)
379
379
  return result.rewardSum.value;
380
380
  }
381
381
  async getRewardTotal(unclaimed_list: string[], once: number = 4){
@@ -384,18 +384,18 @@ export class StakingManager {
384
384
  num_list.push(uintCV(unclaimed));
385
385
  }
386
386
  let reward_num = new BigNumber(0);
387
- // console.log(pool_addr, num_list, farming_contract)
387
+ // // console.log(pool_addr, num_list, farming_contract)
388
388
  try {
389
389
  for (let i = 0; i < num_list.length; i += once) {
390
- // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
390
+ // // console.log(pool_addr, num_list.slice(i, i + 4 < num_list.length ? i + 4 : num_list.length), farming_contract);
391
391
  const result = await this.getRewardFromList(num_list.slice(i, i + once < num_list.length ? i + once : num_list.length));
392
392
  // rewardSum.value;
393
- // console.log('temp result', result);
393
+ // // console.log('temp result', result);
394
394
  reward_num = reward_num.plus(result);
395
395
  }
396
396
  return num2decimal(reward_num.toString(), 6);
397
397
  } catch (e) {
398
- // console.log(e);
398
+ // // console.log(e);
399
399
  return num2decimal(reward_num.toString(), 6);
400
400
  }
401
401
  }
@@ -29,7 +29,7 @@ export class SwapManager {
29
29
  const url = this.stackswap.config.STACKS_BACKEND_URL() + '/api/v1/swap_v4/' + token_x.addr +'/'+token_y.addr + '/' + current_block;
30
30
  const result = await axios.get ( url,
31
31
  {timeout: 50000,});
32
- // console.log('swap router : ', value)
32
+ // // console.log('swap router : ', value)
33
33
  const res = result.data;
34
34
  if(Object.keys(res).length === 0){
35
35
  return {valid : SwapType.NO_ROUTE}
@@ -95,7 +95,7 @@ export class SwapManager {
95
95
  const url = this.stackswap.config.STACKS_BACKEND_URL() + '/api/v1/swap_v3/' + token_x.addr +'/'+token_y.addr + '/' + current_block;
96
96
  const result = await axios.get ( url,
97
97
  {timeout: 50000,});
98
- // console.log('swap router : ', value)
98
+ // // console.log('swap router : ', value)
99
99
  const res = result.data;
100
100
  if(Object.keys(res).length === 0){
101
101
  return {valid : SwapType.NO_ROUTE}
@@ -161,7 +161,7 @@ export class SwapManager {
161
161
  const url = this.stackswap.config.STACKS_BACKEND_URL() + '/api/v1/swap_v2/' + token_x.addr +'/'+token_y.addr + '/' + current_block;
162
162
  const result = await axios.get ( url,
163
163
  {timeout: 50000,});
164
- // console.log('swap router : ', value)
164
+ // // console.log('swap router : ', value)
165
165
  const res = result.data;
166
166
  if(Object.keys(res).length === 0){
167
167
  return {valid : SwapType.NO_ROUTE}
@@ -201,7 +201,7 @@ export class SwapManager {
201
201
  const url = this.stackswap.config.STACKS_BACKEND_URL() + '/api/v1/swap/' + token_x.addr +'/'+token_y.addr + '/' + current_block;
202
202
  const result = await axios.get ( url,
203
203
  {timeout: 50000,});
204
- // console.log('swap router : ', value)
204
+ // // console.log('swap router : ', value)
205
205
  const res = result.data;
206
206
  if(Object.keys(res).length === 0){
207
207
  return {valid : SwapType.NO_ROUTE}
@@ -355,7 +355,7 @@ export class SwapManager {
355
355
  const post_condition = [];
356
356
  post_condition.push(await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), token_x.addr, dx, FungibleConditionCode.Equal));
357
357
  post_condition.push(await getPostConditionFromAsset(this.stackswap, pair.token_lp.addr, token_y.addr, dy_min, FungibleConditionCode.GreaterEqual));
358
- // console.log(post_condition);
358
+ // // console.log(post_condition);
359
359
  const options = getWriteOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_SWAP(), functionName, [
360
360
  parseAddressToCV(token_x_addr), parseAddressToCV(token_y_addr),
361
361
  parseAddressToCV(pair.token_lp.addr), uintCV(dx), uintCV(dy_min) ], post_condition, callback);
@@ -368,13 +368,13 @@ export class SwapManager {
368
368
  const dx_temp = new BigNumber(10 ** token_x.decimal).multipliedBy(amount_x);
369
369
  const dy_temp = new BigNumber(10 ** token_y.decimal).multipliedBy(amount_y) ;
370
370
 
371
- // console.log(dx_temp.toNumber(), dy_temp.toNumber())
371
+ // // console.log(dx_temp.toNumber(), dy_temp.toNumber())
372
372
  const dx = x_to_y ? dx_temp : dy_temp;
373
373
  const dy = x_to_y ? dy_temp : dx_temp ;
374
374
 
375
375
  const dx_out = dx_temp.multipliedBy(1.2).toFixed(0).toString();
376
376
  const dy_out = dy_temp.multipliedBy(1.2).toFixed(0).toString();
377
- // console.log(dx_out, dy_out)
377
+ // // console.log(dx_out, dy_out)
378
378
 
379
379
  const token_x_addr = x_to_y ? (token_x.addr) : (token_y.addr);
380
380
  const token_y_addr = x_to_y ? (token_y.addr) : (token_x.addr);
@@ -422,42 +422,42 @@ export class SwapManager {
422
422
  }
423
423
 
424
424
  price_impact(x_to_y: boolean, pair: LiquidityPool, token_x_amount: string) {
425
- // console.log('price impact');
425
+ // // console.log('price impact');
426
426
  // (dy (/ (* u997 balance-y dx) (+ (* u1000 balance-x) (* u997 dx)))) ;; overall fee is 30 bp, either all for the pool, or 25 bp for pool and 5 bp for operator
427
427
  // dy = balancey * dx / balancex + dx
428
428
  try {
429
429
  const balance_x = x_to_y ? pair.balance_x : pair.balance_y;
430
430
  const token_x_decimal: number = x_to_y ? pair.token_x.decimal : pair.token_y.decimal;
431
- // console.log('balance_x',balance_x, typeof(balance_x));
431
+ // // console.log('balance_x',balance_x, typeof(balance_x));
432
432
 
433
433
  const balance_y = x_to_y ? pair.balance_y : pair.balance_y;
434
- // console.log('balance_y',balance_y);
434
+ // // console.log('balance_y',balance_y);
435
435
  const dx = new BigNumber(token_x_amount).multipliedBy(10 ** token_x_decimal);
436
- // console.log('dx',dx.toString(), typeof(dx));
436
+ // // console.log('dx',dx.toString(), typeof(dx));
437
437
  if (dx.toNumber() > new BigNumber(balance_x).toNumber()) {
438
- // console.log('dx is bigger than dy');
438
+ // // console.log('dx is bigger than dy');
439
439
  return 100;
440
440
  }
441
441
  const dy_1 = new BigNumber(balance_y).multipliedBy(dx);
442
- // console.log('dy_1', dy_1.toString());
442
+ // // console.log('dy_1', dy_1.toString());
443
443
  const dy_2 = new BigNumber(balance_x).plus(dx);
444
- // console.log('dy_2', dy_2.toString());
444
+ // // console.log('dy_2', dy_2.toString());
445
445
  const dy = (dy_1.toNumber()) / (dy_2.toNumber());
446
- // console.log('dy',dy.toString());
446
+ // // console.log('dy',dy.toString());
447
447
  const input_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(balance_x)).dividedBy(new BigNumber(balance_y));
448
- // console.log('input_price',input_price.toString());
448
+ // // console.log('input_price',input_price.toString());
449
449
  const output_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(balance_x)).plus(dx).dividedBy(new BigNumber(balance_y).minus(dy));
450
- // console.log('output_price',output_price.toString());
450
+ // // console.log('output_price',output_price.toString());
451
451
  const price_impact2 = output_price.minus(input_price).multipliedBy(10000).dividedBy(input_price);
452
- // console.log('price_impact2',price_impact2.toString());
452
+ // // console.log('price_impact2',price_impact2.toString());
453
453
  let price_impact = price_impact2.toNumber();
454
454
  if (price_impact >= 10000) {
455
455
  price_impact = 9999;
456
456
  }
457
- // console.log('price impact : ', (price_impact/100))
457
+ // // console.log('price impact : ', (price_impact/100))
458
458
  return (price_impact / 100).toFixed(5);
459
459
  } catch (e) {
460
- // console.log(e);
460
+ // // console.log(e);
461
461
  return 0;
462
462
  }
463
463
  }
@@ -465,7 +465,7 @@ export class SwapManager {
465
465
 
466
466
  price_impact_router(router_from_mode: boolean, router_to_mode: boolean,
467
467
  pair_from:LiquidityPool, pair_to:LiquidityPool , token_from_amount: string) {
468
- // console.log('price impact');
468
+ // // console.log('price impact');
469
469
  // (dy (/ (* u997 balance-y dx) (+ (* u1000 balance-x) (* u997 dx)))) ;; overall fee is 30 bp, either all for the pool, or 25 bp for pool and 5 bp for operator
470
470
  // dy = balancey * dx / balancex + dx
471
471
  try {
@@ -485,7 +485,7 @@ export class SwapManager {
485
485
  const from_output_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(from_input_balance)).plus(from_input_dx).dividedBy(new BigNumber(from_output_balance).minus(from_dy));
486
486
  const from_price_impact = from_output_price.minus(from_input_price).multipliedBy(10000).dividedBy(from_input_price);
487
487
 
488
- console.log("FROM : ", token_from_amount, from_dy, from_price_impact.toNumber())
488
+ // console.log("FROM : ", token_from_amount, from_dy, from_price_impact.toNumber())
489
489
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
490
490
  const to_input_balance = router_to_mode ? pair_to.balance_x : pair_to.balance_y;
491
491
  const to_input_decimal = router_to_mode ? pair_to.token_x.decimal : pair_to.token_y.decimal;
@@ -503,23 +503,23 @@ export class SwapManager {
503
503
  const to_output_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(to_input_balance)).plus(to_input_dx).dividedBy(new BigNumber(to_output_balance).minus(to_dy));
504
504
  const to_price_impact = to_output_price.minus(to_input_price).multipliedBy(10000).dividedBy(to_input_price);
505
505
 
506
- // console.log("TO : ", bridge_dy, to_dy, to_price_impact.toNumber())
506
+ // // console.log("TO : ", bridge_dy, to_dy, to_price_impact.toNumber())
507
507
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
508
508
  let price_impact = from_price_impact.toNumber() * to_price_impact.toNumber();
509
509
  if (price_impact >= 10000) {
510
510
  price_impact = 9999;
511
511
  }
512
- console.log("TOTAL : ", price_impact)
512
+ // console.log("TOTAL : ", price_impact)
513
513
  return (price_impact / 100).toFixed(5);
514
514
  } catch (e) {
515
- // console.log(e);
515
+ // // console.log(e);
516
516
  return 0;
517
517
  }
518
518
  }
519
519
 
520
520
  price_impact_router2(router_from_mode: boolean, router_bridge_mode: boolean, router_to_mode: boolean,
521
521
  pair_from:LiquidityPool, pair_bridge:LiquidityPool, pair_to:LiquidityPool , token_from_amount:string) {
522
- // console.log('price impact');
522
+ // // console.log('price impact');
523
523
  // (dy (/ (* u997 balance-y dx) (+ (* u1000 balance-x) (* u997 dx)))) ;; overall fee is 30 bp, either all for the pool, or 25 bp for pool and 5 bp for operator
524
524
  // dy = balancey * dx / balancex + dx
525
525
  try {
@@ -538,7 +538,7 @@ export class SwapManager {
538
538
  const from_output_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(from_input_balance)).plus(from_input_dx).dividedBy(new BigNumber(from_output_balance).minus(from_dy));
539
539
  const from_price_impact = from_output_price.minus(from_input_price).multipliedBy(10000).dividedBy(from_input_price);
540
540
 
541
- console.log("FROM : ", token_from_amount, from_dy, from_price_impact.toNumber())
541
+ // console.log("FROM : ", token_from_amount, from_dy, from_price_impact.toNumber())
542
542
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
543
543
  const bridge_input_balance = router_bridge_mode ? pair_bridge.balance_x : pair_bridge.balance_y;
544
544
  const bridge_input_decimal = router_bridge_mode ? pair_bridge.token_x.decimal : pair_bridge.token_y.decimal;
@@ -556,7 +556,7 @@ export class SwapManager {
556
556
  const bridge_output_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(bridge_input_balance)).plus(bridge_input_dx).dividedBy(new BigNumber(bridge_output_balance).minus(bridge_dy));
557
557
  const bridge_price_impact = bridge_output_price.minus(bridge_input_price).multipliedBy(10000).dividedBy(bridge_input_price);
558
558
 
559
- console.log("BRIDGE : ", from_dy, bridge_dy, bridge_price_impact.toNumber())
559
+ // console.log("BRIDGE : ", from_dy, bridge_dy, bridge_price_impact.toNumber())
560
560
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
561
561
  const to_input_balance = router_to_mode ? pair_to.balance_x : pair_to.balance_y;
562
562
  const to_input_decimal = router_to_mode ? pair_to.token_x.decimal : pair_to.token_y.decimal;
@@ -574,16 +574,16 @@ export class SwapManager {
574
574
  const to_output_price = new BigNumber(10 ** 10).multipliedBy(new BigNumber(to_input_balance)).plus(to_input_dx).dividedBy(new BigNumber(to_output_balance).minus(to_dy));
575
575
  const to_price_impact = to_output_price.minus(to_input_price).multipliedBy(10000).dividedBy(to_input_price);
576
576
 
577
- console.log("TO : ", bridge_dy, to_dy, to_price_impact.toNumber())
577
+ // console.log("TO : ", bridge_dy, to_dy, to_price_impact.toNumber())
578
578
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
579
579
  let price_impact = from_price_impact.toNumber() * bridge_price_impact.toNumber() * to_price_impact.toNumber();
580
580
  if (price_impact >= 10000) {
581
581
  price_impact = 9999;
582
582
  }
583
- console.log("TOTAL : ", price_impact)
583
+ // console.log("TOTAL : ", price_impact)
584
584
  return (price_impact / 100).toFixed(5);
585
585
  } catch (e) {
586
- // console.log(e);
586
+ // // console.log(e);
587
587
  return 0;
588
588
  }
589
589
  }
@@ -96,7 +96,7 @@ export class TokenManager {
96
96
 
97
97
  async transferSTSW( toAddr: string, amount: string, callback : any = null){
98
98
 
99
- // console.log({amount});
99
+ // // console.log({amount});
100
100
  const post_condition = [await getPostConditionFromAsset(this.stackswap, this.stackswap.getSenderAddress(), this.stackswap.config.BASE_STSW_DATA().addr, amount, FungibleConditionCode.Equal)];
101
101
  const function_option : any = getWriteOptions(this.stackswap, this.stackswap.config.BASE_STSW_DATA().addr, 'transfer', [
102
102
  uintCV(amount), standardPrincipalCV(this.stackswap.getSenderAddress()), contractPrincipalCV(this.stackswap.config.STACKSWAP_ADDRESS(), toAddr), noneCV()
@@ -105,10 +105,10 @@ export class TokenManager {
105
105
  }
106
106
 
107
107
  async getTokenData( token_addr: string) : Promise<Token | null> {
108
- // console.log('finding '+ tokenstr);
108
+ // // console.log('finding '+ tokenstr);
109
109
  try {
110
110
  const name_result = await callReadOnlyFunction( getReadOptions(this.stackswap, token_addr, 'get-name', []));
111
- // console.log(cvToValue(name_result));
111
+ // // console.log(cvToValue(name_result));
112
112
  let token_name = cvToValue(name_result).value;
113
113
 
114
114
  const symbol_result = await callReadOnlyFunction( getReadOptions(this.stackswap, token_addr, 'get-symbol', []));
@@ -119,35 +119,35 @@ export class TokenManager {
119
119
 
120
120
  const uri_result = await callReadOnlyFunction( getReadOptions(this.stackswap, token_addr, 'get-token-uri', []));
121
121
  const token_uri = cvToValue(uri_result).value.value;
122
- // console.log(token_uri);
122
+ // // console.log(token_uri);
123
123
  let token_icon = 'https://app.stackswap.org/icon/blank.svg';
124
124
  try {
125
125
  const uri_result = await axios.get(token_uri);
126
- // console.log(uri_result);
127
- // console.log(uri_result.data);
128
- // console.log(uri_result.data.properties);
126
+ // // console.log(uri_result);
127
+ // // console.log(uri_result.data);
128
+ // // console.log(uri_result.data.properties);
129
129
  try {
130
130
  token_icon = uri_result.data.image;
131
131
  } catch (e) {
132
- // console.log('no img file');
132
+ // // console.log('no img file');
133
133
  }
134
134
  try {
135
135
  token_icon = uri_result.data.vector;
136
136
  } catch (e) {
137
- // console.log('no svg file');
137
+ // // console.log('no svg file');
138
138
  }
139
139
  try {
140
140
  token_icon = uri_result.data.properties.image.description;
141
141
  } catch (e) {
142
- // console.log('no img file');
142
+ // // console.log('no img file');
143
143
  }
144
144
  try {
145
145
  token_icon = uri_result.data.properties.vector.description;
146
146
  } catch (e) {
147
- // console.log('no svg file');
147
+ // // console.log('no svg file');
148
148
  }
149
149
  } catch (e) {
150
- // console.log(e);
150
+ // // console.log(e);
151
151
  }
152
152
  if (token_name === 'wSTX') {token_name = 'STX'; }
153
153
  return new Token(token_name, token_decimal, token_icon, token_addr, token_symbol);
@@ -157,7 +157,7 @@ export class TokenManager {
157
157
  }
158
158
 
159
159
  async getBalanceOf( token: Token, address: string) : Promise<string> {
160
- // console.log("getBalance", token)
160
+ // // console.log("getBalance", token)
161
161
  const pair_details_options : any = getReadOptions(this.stackswap, token.addr, 'get-balance',
162
162
  [parseAddressToCV(address) ]);
163
163
  try {