stackswap-front-api-test-02 1.1.23 → 1.1.24

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.
@@ -22,7 +22,7 @@ export class LBTCStakingManager {
22
22
 
23
23
  async getStackingRoundFirstBlock(cycle: number){
24
24
  const function_option = getReadOptions(this.stackswap,
25
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
25
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
26
26
  'get-first-stacks-block-in-reward-cycle', [
27
27
  uintCV(cycle)
28
28
  ]);
@@ -34,7 +34,7 @@ export class LBTCStakingManager {
34
34
  async getStakingRound(block: number | string) {
35
35
  try{
36
36
  // const poxl_token = contract_address.split('.');
37
- const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(), 'get-reward-cycle', [
37
+ const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(), 'get-reward-cycle', [
38
38
  uintCV(block),
39
39
  ]);
40
40
  const result = await callReadOnlyFunction(options);
@@ -53,7 +53,7 @@ export class LBTCStakingManager {
53
53
  async getStaker() : Promise<{ unclaimedList: string[], amount: string, stakedList: string[] }> {
54
54
  try{
55
55
  const round = Number(await this.getCurrentStakingRound());
56
- const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(), 'get-staker', [
56
+ const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3(), 'get-staker', [
57
57
  standardPrincipalCV(this.stackswap.getSenderAddress()),
58
58
  ]);
59
59
  const result = await callReadOnlyFunction(options);
@@ -78,7 +78,7 @@ export class LBTCStakingManager {
78
78
  async getRoundData(round: number) {
79
79
  try{
80
80
  // const round = Number(await this.getCurrentStakingRound());
81
- const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(), 'get-staking-stats-at-cycle', [
81
+ const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3(), 'get-staking-stats-at-cycle', [
82
82
  uintCV(round),
83
83
  ]);
84
84
  const result = await callReadOnlyFunction(options);
@@ -93,7 +93,7 @@ export class LBTCStakingManager {
93
93
 
94
94
  async getLBTCNFT() : Promise<string[]>{
95
95
  // console.log(tokenStr);
96
- const url = this.stackswap.config.STACKS_API_URL() + `/extended/v1/tokens/nft/holdings?principal=${this.stackswap.getSenderAddress()}&asset_identifiers=${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING()}::lBTC-staking-vault`
96
+ const url = this.stackswap.config.STACKS_API_URL() + `/extended/v1/tokens/nft/holdings?principal=${this.stackswap.getSenderAddress()}&asset_identifiers=${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3()}::lBTC-staking-vault`
97
97
 
98
98
  const result = await axios.get(url);
99
99
  // console.log(tokenStr,result);
@@ -110,7 +110,7 @@ export class LBTCStakingManager {
110
110
 
111
111
  async getReward(round_id:number): Promise<string>{
112
112
  const function_option : any = getReadOptions(this.stackswap,
113
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
113
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
114
114
  'get-staking-reward-per-user', [
115
115
  standardPrincipalCV(this.stackswap.getSenderAddress()),
116
116
  uintCV(round_id)
@@ -130,7 +130,7 @@ export class LBTCStakingManager {
130
130
 
131
131
  // const nfts = await this.getLBTCNFT();
132
132
  for (const nft of nfts) {
133
- const function_option : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
133
+ const function_option : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3(),
134
134
  'get-staking-vault',[
135
135
  uintCV(nft)]
136
136
  );
@@ -153,7 +153,7 @@ export class LBTCStakingManager {
153
153
  );
154
154
 
155
155
  const function_option : any = getWriteOptions(this.stackswap,
156
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
156
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
157
157
  'stake-tokens',[
158
158
  uintCV(invest_amt_bn),uintCV(period_month)],
159
159
  postConditions, callback
@@ -163,11 +163,11 @@ export class LBTCStakingManager {
163
163
 
164
164
  async txClaim(round_id: number, stsw_amount: string, callback : any = null){
165
165
  const post_condition = [ await getPostConditionFromAsset(this.stackswap,
166
- this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
166
+ this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3(),
167
167
  this.stackswap.config.BASE_STSW_DATA().addr, stsw_amount, FungibleConditionCode.Equal)];
168
168
  const function_option : any = getWriteOptions(
169
169
  this.stackswap,
170
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
170
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
171
171
  'claim-staking-reward',
172
172
  [uintCV(round_id)], post_condition, callback);
173
173
  await openContractCall(function_option);
@@ -176,7 +176,7 @@ export class LBTCStakingManager {
176
176
 
177
177
  async txUnstake(index:number, callback : any = null){
178
178
  const function_option : any = getWriteOptions(this.stackswap,
179
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
179
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
180
180
  'unstake-tokens', [uintCV(index)], [], callback);
181
181
  await openContractCall(function_option);
182
182
  }
@@ -184,12 +184,12 @@ export class LBTCStakingManager {
184
184
  async txReclaim(index:number, amountSTX:string, callback : any = null){
185
185
  // console.log("Unstaking", amountSTX)
186
186
  const post_conditions = [];
187
- const assetString = `${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING()}::lBTC-staking-vault`
187
+ const assetString = `${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3()}::lBTC-staking-vault`
188
188
  post_conditions.push(await makeStandardNonFungiblePostCondition(this.stackswap.getSenderAddress(), NonFungibleConditionCode.DoesNotOwn, assetString, uintCV(index)))
189
- post_conditions.push(await getPostConditionFromAsset(this.stackswap, `${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING()}`, this.stackswap.config.BASE_LBTC_DATA().addr, amountSTX, FungibleConditionCode.Equal))
189
+ post_conditions.push(await getPostConditionFromAsset(this.stackswap, `${this.stackswap.config.STACKSWAP_ADDRESS()}.${this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3()}`, this.stackswap.config.BASE_LBTC_DATA().addr, amountSTX, FungibleConditionCode.Equal))
190
190
  const function_option : any = getWriteOptions(
191
191
  this.stackswap,
192
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
192
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
193
193
  'reclaim-tokens',
194
194
  [uintCV(index)], post_conditions, callback
195
195
  );
@@ -205,7 +205,7 @@ export class LBTCStakingManager {
205
205
  // temp_list.push(uintCV(rewardListElement));
206
206
  // }
207
207
  const function_option : any = getReadOptions(this.stackswap,
208
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(),
208
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_LOGIC_V3(),
209
209
  'get-staking-reward-from-list', [
210
210
  standardPrincipalCV(this.stackswap.getSenderAddress()),
211
211
  listCV(reward_list),
@@ -259,7 +259,7 @@ export class LBTCStakingManager {
259
259
  const oracle_stsw = num2decimal( (await this.stackswap.lbtcManager.getPrice('STSW'))['last-price'].value,6);
260
260
  const oracle_lbtc = num2decimal( (await this.stackswap.lbtcManager.getPrice('lBTC'))['last-price'].value,6);
261
261
 
262
- const tvl_lbtc = await this.stackswap.tokenManager.getBalanceOf(Token.getBaseTokens(this.stackswap, BaseToken.lBTC), this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING());
262
+ const tvl_lbtc = await this.stackswap.tokenManager.getBalanceOf(Token.getBaseTokens(this.stackswap, BaseToken.lBTC), this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3());
263
263
 
264
264
  const apr_bn = new BigNumber(round_reward).multipliedBy(10**4).multipliedBy(oracle_stsw).dividedBy(new BigNumber(tvl_apr).plus(1)).dividedBy(oracle_lbtc);
265
265
  const max_apr = numFormat_(apr_bn.multipliedBy(8).toString(),3);
@@ -283,7 +283,7 @@ export class LBTCStakingManager {
283
283
  async getUserInfoRound(cycle: number | string, user: string) {
284
284
  try{
285
285
  // const poxl_token = contract_address.split('.');
286
- const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING(), 'get-staker-at-cycle', [
286
+ const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_LBTC_STACKING_DATA_V3(), 'get-staker-at-cycle', [
287
287
  uintCV(cycle),
288
288
  standardPrincipalCV(user),
289
289
  ]);
@@ -22,7 +22,7 @@ export class StakingManager {
22
22
 
23
23
  async getStackingRoundFirstBlock(cycle: number){
24
24
  const function_option = getReadOptions(this.stackswap,
25
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(),
25
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2(),
26
26
  'get-first-stacks-block-in-reward-cycle', [
27
27
  uintCV(cycle)
28
28
  ]);
@@ -48,9 +48,9 @@ export class StakingManager {
48
48
 
49
49
  async getRewardRoundID_V2(source: any) {
50
50
  try{
51
- const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING();
51
+ const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
52
52
  const round = Number(await this.getCurrentStakingRound(ADDR));
53
- const options : any = getReadOptions(source, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(), 'get-staker', [
53
+ const options : any = getReadOptions(source, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_DATA_V2(), 'get-staker', [
54
54
  standardPrincipalCV(this.stackswap.getSenderAddress()),
55
55
  ]);
56
56
  const result = await callReadOnlyFunction(options);
@@ -74,7 +74,8 @@ export class StakingManager {
74
74
  async getStakingRound(contract_address: string, block: number | string) {
75
75
  try{
76
76
  // const poxl_token = contract_address.split('.');
77
- const options = getReadOptions(this.stackswap, contract_address, 'get-reward-cycle', [
77
+ console.log(contract_address);
78
+ const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2(), 'get-reward-cycle', [
78
79
  uintCV(block),
79
80
  ]);
80
81
  const result = await callReadOnlyFunction(options);
@@ -88,7 +89,7 @@ export class StakingManager {
88
89
  async getRoundData(round: number) {
89
90
  try{
90
91
  // const round = Number(await this.getCurrentStakingRound());
91
- const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(), 'get-staking-stats-at-cycle', [
92
+ const options : any = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_DATA_V2(), 'get-staking-stats-at-cycle', [
92
93
  uintCV(round),
93
94
  ]);
94
95
  const result = await callReadOnlyFunction(options);
@@ -103,7 +104,7 @@ export class StakingManager {
103
104
  async getUserInfoRound(cycle: number | string, user: string) {
104
105
  try{
105
106
  // const poxl_token = contract_address.split('.');
106
- const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(), 'get-staker-at-cycle', [
107
+ const options = getReadOptions(this.stackswap, this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_DATA_V2(), 'get-staker-at-cycle', [
107
108
  uintCV(cycle),
108
109
  standardPrincipalCV(user),
109
110
  ]);
@@ -124,7 +125,7 @@ export class StakingManager {
124
125
  }
125
126
 
126
127
  async getRewardRoundID(offset: number) {
127
- const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING();
128
+ const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
128
129
  const get_result = await axios.get(this.stackswap.config.STACKS_API_URL() + '/extended/v1/address/' + this.stackswap.getSenderAddress() + '/transactions', {
129
130
  params: {
130
131
  limit: 50,
@@ -165,7 +166,7 @@ export class StakingManager {
165
166
  }
166
167
 
167
168
  async getReward(contract_addr:string, round_id:number){
168
- contract_addr = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING();
169
+ contract_addr = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
169
170
  const function_option : any = getReadOptions(this.stackswap,
170
171
  contract_addr,
171
172
  'get-staking-reward-per-user', [
@@ -180,11 +181,11 @@ export class StakingManager {
180
181
 
181
182
  async txClaimReward(round_id: number, stsw_amount: string, callback : any = null){
182
183
  const post_condition = [ await getPostConditionFromAsset(this.stackswap,
183
- this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(),
184
+ this.stackswap.config.STACKSWAP_ADDRESS() + '.' + this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_DATA_V2(),
184
185
  this.stackswap.config.BASE_STSW_DATA().addr, stsw_amount, FungibleConditionCode.Equal)];
185
186
  const function_option : any = getWriteOptions(
186
187
  this.stackswap,
187
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(),
188
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2(),
188
189
  'claim-staking-reward',
189
190
  [uintCV(round_id)], post_condition, callback);
190
191
  await openContractCall(function_option);
@@ -268,7 +269,7 @@ export class StakingManager {
268
269
  );
269
270
 
270
271
  const function_option : any = getWriteOptions(this.stackswap,
271
- this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING(),
272
+ this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2(),
272
273
  'stake-tokens',[
273
274
  uintCV(invest_amt_bn),uintCV(period_month)],
274
275
  postConditions, callback
@@ -299,7 +300,7 @@ export class StakingManager {
299
300
  }
300
301
 
301
302
  async getRewardBalanceFromStaking(){
302
- const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING();
303
+ const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
303
304
  let reward_balance = 0;
304
305
  const current_round = await this.getCurrentStakingRound(ADDR);
305
306
  // console.log(current_round)
@@ -312,7 +313,7 @@ export class StakingManager {
312
313
  return reward_balance;
313
314
  }
314
315
  async getRewardBalanceFromStakingFromList(unclaimed_list: any){
315
- const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING();
316
+ const ADDR = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
316
317
  let reward_balance = 0;
317
318
  const current_round = await this.getCurrentStakingRound(ADDR);
318
319
  // console.log(current_round)
@@ -331,7 +332,7 @@ export class StakingManager {
331
332
  return reward_balance;
332
333
  }
333
334
  async getRewardTotal(reward_list: any){
334
- const contract_addr = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STACKING();
335
+ const contract_addr = this.stackswap.config.STACKSWAP_ADDRESS()+'.'+this.stackswap.config.CONTRACT_NAME_STACKSWAP_STSW_STACKING_LOGIC_V2();
335
336
  if (reward_list.length === 0){
336
337
  return 0;
337
338
  }