@aurigami/sdk 1.5.0-dummy-2 → 1.5.0

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/dist/token.d.ts CHANGED
@@ -4,4 +4,4 @@ export declare class Token {
4
4
  constructor(address: string, decimals: number);
5
5
  }
6
6
  export declare const PLYToken: Token;
7
- export declare const PLYUSDCToken: Token;
7
+ export declare const PLYWNEARToken: Token;
package/dist/types.d.ts CHANGED
@@ -57,7 +57,7 @@ export declare type UserMarketDetails = {
57
57
  collateralRatio: number;
58
58
  underlyingPrice: string;
59
59
  };
60
- export declare type PlyUsdcPoolDetails = {
60
+ export declare type PLYWNEARPoolDetails = {
61
61
  totalStakedLiquidity: TokenValuation;
62
62
  apy: string;
63
63
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0-dummy-2",
2
+ "version": "1.5.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/SDK.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
2
2
  import {
3
- PlyUsdcPoolDetails,
3
+ PLYWNEARPoolDetails,
4
4
  NetworkConnection,
5
5
  UserDetails,
6
6
  UserMarketDetails,
@@ -15,9 +15,9 @@ import {
15
15
  BORROW_LIMIT_BUFFER,
16
16
  DECIMAL_PRECISION,
17
17
  ONE_DAY,
18
- PlyUsdcPid,
18
+ PLYWNEAR_POOL_ID,
19
19
  ALL_STAKING_POOLS,
20
- PLYUSDCRewardTokens,
20
+ PLYWNEAR_REWARD_TOKENS,
21
21
  } from './constants';
22
22
  import { TransactionResponse } from '@ethersproject/abstract-provider';
23
23
  import { Contract, BigNumber as BN } from 'ethers';
@@ -41,7 +41,7 @@ import {
41
41
  IERC20,
42
42
  } from '@aurigami/contracts/typechain';
43
43
  import { TokenAmount } from './tokenAmount';
44
- import { PLYUSDCToken, PLYToken, Token } from './token';
44
+ import { PLYWNEARToken, PLYToken, Token } from './token';
45
45
  import BigNumber from 'bignumber.js';
46
46
  import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
47
47
  import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
@@ -224,21 +224,23 @@ export class SdkRead extends BlockchainEntityRead {
224
224
  };
225
225
  }
226
226
 
227
- public async getPlyUsdcPoolDetails(): Promise<PlyUsdcPoolDetails> {
227
+ public async getPLYWNEARPoolDetails(): Promise<PLYWNEARPoolDetails> {
228
228
  var stakedLiquidity: BN, rewardPerSeconds: BN[];
229
- await this._auriFairLaunch.getPoolInfo(PlyUsdcPid).then((res) => {
229
+ await this._auriFairLaunch.getPoolInfo(PLYWNEAR_POOL_ID).then((res) => {
230
230
  stakedLiquidity = res.totalStake;
231
231
  rewardPerSeconds = res.rewardPerSeconds;
232
232
  });
233
233
 
234
234
  let stakedLiquidityAmount = new TokenAmount(
235
- PLYUSDCToken,
235
+ PLYWNEARToken,
236
236
  stakedLiquidity!.toString()
237
237
  );
238
238
 
239
239
  var promises = [];
240
+
241
+ // Calculate the reward per second in USD
240
242
  for (let i = 0; i < rewardPerSeconds!.length; i++) {
241
- let rewardTokenAddress = PLYUSDCRewardTokens[i];
243
+ let rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
242
244
  let rewardToken = new Token(
243
245
  rewardTokenAddress,
244
246
  getDecimal(rewardTokenAddress)
@@ -293,8 +295,14 @@ export class SdkRead extends BlockchainEntityRead {
293
295
  * Get amount and value in $ of staked LP tokens
294
296
  */
295
297
  public async stakeBalanceOf(user: string): Promise<TokenValuation> {
296
- const userInfo = await this._auriFairLaunch.getUserInfo(PlyUsdcPid, user);
297
- let stakeAmount = new TokenAmount(PLYUSDCToken, userInfo.amount.toString());
298
+ const userInfo = await this._auriFairLaunch.getUserInfo(
299
+ PLYWNEAR_POOL_ID,
300
+ user
301
+ );
302
+ let stakeAmount = new TokenAmount(
303
+ PLYWNEARToken,
304
+ userInfo.amount.toString()
305
+ );
298
306
 
299
307
  return valuateToken(stakeAmount, this._networkConnection.provider);
300
308
  }
@@ -303,15 +311,15 @@ export class SdkRead extends BlockchainEntityRead {
303
311
  * Get amount and value in $ of LP token in user wallet
304
312
  */
305
313
  public async LpBalanceOf(user: string): Promise<TokenValuation> {
306
- let lpERC20 = new Contract(
307
- networkAddresses.tokens.PLYUSDC,
314
+ let lpContract = new Contract(
315
+ networkAddresses.tokens.PLYWNEAR,
308
316
  EIP20InterfaceABI.abi,
309
317
  this._networkConnection.provider
310
318
  ) as IERC20;
311
- let balance = await lpERC20.balanceOf(user);
319
+ let balance = await lpContract.balanceOf(user);
312
320
 
313
321
  return valuateToken(
314
- new TokenAmount(PLYUSDCToken, balance.toString()),
322
+ new TokenAmount(PLYWNEARToken, balance.toString()),
315
323
  this._networkConnection.provider
316
324
  );
317
325
  }
@@ -403,13 +411,13 @@ export class SdkReadWrite extends SdkRead {
403
411
  public async stake(amount: TokenAmount): Promise<TransactionResponse> {
404
412
  return this._auriFairLaunch
405
413
  .connect(this._networkConnection.signer!)
406
- .deposit(PlyUsdcPid, amount.rawAmount());
414
+ .deposit(PLYWNEAR_POOL_ID, amount.rawAmount());
407
415
  }
408
416
 
409
417
  public async unstake(amount: TokenAmount): Promise<TransactionResponse> {
410
418
  return this._auriFairLaunch
411
419
  .connect(this._networkConnection.signer!)
412
- .withdraw(PlyUsdcPid, amount.rawAmount());
420
+ .withdraw(PLYWNEAR_POOL_ID, amount.rawAmount());
413
421
  }
414
422
 
415
423
  public async faucetDrip(): Promise<TransactionResponse> {
package/src/constants.ts CHANGED
@@ -83,7 +83,7 @@ export const networkAddresses: NetworkAddresses = {
83
83
  TRI: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
84
84
  META: '0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
85
85
  PULP: '0x04Ac48711BCdc45b4d223fb021E09DA73c71095e'.toLowerCase(),
86
- PLYUSDC: '0x37cae2b29c18e05ece60111fa01d3ca217046016'.toLowerCase(),
86
+ PLYWNEAR: '0x044b6B0CD3Bb13D2b9057781Df4459C66781dCe7'.toLowerCase(), //TODO: changes this
87
87
  },
88
88
  };
89
89
 
@@ -104,15 +104,15 @@ export const ONE_DAY = 86400;
104
104
  export const ONE_WEEK = ONE_DAY * 7;
105
105
  export const ONE_YEAR = ONE_DAY * 365;
106
106
 
107
- export const PlyUsdcPid = 0;
108
- export const PLYUSDCRewardTokens = [
107
+ export const PLYWNEAR_POOL_ID = 0;
108
+ export const PLYWNEAR_REWARD_TOKENS = [
109
109
  '0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', // PLY
110
110
  '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', // WNEAR
111
111
  '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', // AURORA
112
112
  '0xFa94348467f64D5A457F75F8bc40495D33c65aBB', // TRI
113
113
  ];
114
114
  // could call RPC to get all the staking pools but it's not necessary for now
115
- // export const ALL_STAKING_POOLS = [PlyUsdcPid];
115
+ // export const ALL_STAKING_POOLS = [PLYWNEAR_POOL_ID];
116
116
  // TODO: fix this
117
117
  export const ALL_STAKING_POOLS = [];
118
118
  export const INF = BN.from(2).pow(256).sub(1);
package/src/decimals.ts CHANGED
@@ -20,5 +20,5 @@ export const decimalRecords: Record<string, number> = {
20
20
  '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
21
21
  '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
22
22
  '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18, // PULP
23
- '0x37cae2b29c18e05ece60111fa01d3ca217046016': 18, // PLYUSDC
23
+ '0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18, // PLYWNEAR
24
24
  };
@@ -24,7 +24,7 @@
24
24
  "configReader": "0x347B321c466663D6A0fE9C0ccfCF8cEa86F8ecD3",
25
25
  "auriAirdropImpl": "0x94cdA0Da833b384B901d33D5c56FccDE21D5E6e7",
26
26
  "auriAirdrop": "0x6C42aA5b128B62D6CCf357726D7d13F3888335EC",
27
- "ply_usdc_lp": "0x37cAe2B29c18E05ece60111Fa01d3ca217046016",
27
+ "ply_wnear_lp": "0x044b6B0CD3Bb13D2b9057781Df4459C66781dCe7",
28
28
  "PULP": "0x04Ac48711BCdc45b4d223fb021E09DA73c71095e",
29
29
  "test": {}
30
30
  }
@@ -233,7 +233,7 @@ export async function fetchPrice(
233
233
  address: Address,
234
234
  provider: providers.Provider
235
235
  ): Promise<BigNumber> {
236
- if (isSameAddress(address, networkAddresses.tokens.PLYUSDC)) {
236
+ if (isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
237
237
  return fetchLPPrice(address, provider);
238
238
  } else if (isSameAddress(address, networkAddresses.tokens.PLY)) {
239
239
  return fetchPLYPrice(provider);
@@ -244,8 +244,10 @@ export async function fetchPrice(
244
244
  export async function fetchPLYPrice(
245
245
  provider: providers.Provider
246
246
  ): Promise<BigNumber> {
247
+ //TODO: Fetch PLY price from CEX?
248
+ return new BigNumber(0);
247
249
  const LPInfo = await fetchLPPositions(
248
- networkAddresses.tokens.PLYUSDC,
250
+ networkAddresses.tokens.PLYWNEAR,
249
251
  provider
250
252
  );
251
253
 
@@ -257,16 +259,16 @@ export async function fetchPLYPrice(
257
259
  assert(isSameAddress(plyAddress, networkAddresses.tokens.PLY));
258
260
  const plyDecimal = getDecimal(plyAddress);
259
261
 
260
- const usdcAddress = LPInfo.token1;
261
- assert(isSameAddress(usdcAddress, networkAddresses.tokens.USDC));
262
- const usdcDecimal = getDecimal(usdcAddress);
262
+ const wnearAddress = LPInfo.token1;
263
+ assert(isSameAddress(wnearAddress, networkAddresses.tokens.WNEAR));
264
+ const wnearDecimal = getDecimal(wnearAddress);
263
265
 
264
266
  // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
265
267
  // token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
266
- return (await fetchPrice(usdcAddress, provider))
268
+ return (await fetchPrice(wnearAddress, provider))
267
269
  .multipliedBy(LPInfo.reserve1.toString())
268
270
  .multipliedBy(decimalFactor(plyDecimal))
269
- .dividedBy(decimalFactor(usdcDecimal))
271
+ .dividedBy(decimalFactor(wnearDecimal))
270
272
  .dividedBy(LPInfo.reserve0.toString());
271
273
  }
272
274
 
package/src/token.ts CHANGED
@@ -15,7 +15,7 @@ export const PLYToken = new Token(
15
15
  getDecimal(networkAddresses.tokens.PLY)
16
16
  );
17
17
 
18
- export const PLYUSDCToken = new Token(
19
- networkAddresses.tokens.PLYUSDC,
20
- getDecimal(networkAddresses.tokens.PLYUSDC)
18
+ export const PLYWNEARToken = new Token(
19
+ networkAddresses.tokens.PLYWNEAR,
20
+ getDecimal(networkAddresses.tokens.PLYWNEAR)
21
21
  );
package/src/types.ts CHANGED
@@ -81,7 +81,7 @@ export type UserMarketDetails = {
81
81
  underlyingPrice: string;
82
82
  };
83
83
 
84
- export type PlyUsdcPoolDetails = {
84
+ export type PLYWNEARPoolDetails = {
85
85
  totalStakedLiquidity: TokenValuation;
86
86
  apy: string;
87
87
  };