@aurigami/sdk 1.6.2 → 1.6.4

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.2",
2
+ "version": "1.6.4",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -60,7 +60,7 @@
60
60
  "typescript": "^4.5.4"
61
61
  },
62
62
  "dependencies": {
63
- "@aurigami/contracts": "3.5.0",
63
+ "@aurigami/contracts": "3.6.0",
64
64
  "axios": "^0.26.1",
65
65
  "bignumber.js": "^9.0.2",
66
66
  "dotenv": "^16.0.0",
@@ -70,6 +70,11 @@ export const networkAddresses: NetworkAddresses = {
70
70
  address: MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(),
71
71
  underlying: '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
72
72
  },
73
+ {
74
+ name: 'auUSN',
75
+ address: MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
76
+ underlying: '0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
77
+ },
73
78
  ],
74
79
  misc: {
75
80
  COMPTROLLER: MAINNET_ADDRESSES.comptroller.toLowerCase(),
@@ -90,9 +95,10 @@ export const networkAddresses: NetworkAddresses = {
90
95
  USDC: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
91
96
  WNEAR: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
92
97
  TRI: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
93
- META: '0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
98
+ META: '0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLowerCase(),
94
99
  PULP: MAINNET_ADDRESSES.PULP.toLowerCase(),
95
100
  PLYWNEAR: MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
101
+ USN: '0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
96
102
  },
97
103
  };
98
104
 
@@ -145,3 +151,6 @@ export const DEPOSIT_NEAR_REWARDS_PER_WEEK: { [k: string]: string } =
145
151
  export const BORROW_NEAR_REWARDS_PER_WEEK: { [k: string]: string } = {
146
152
  // currently 0 for all markets
147
153
  };
154
+
155
+ export const HARDCODE_PRICE_TOKENS: { [k: string]: string } =
156
+ Object.fromEntries([[networkAddresses.tokens.USN.toLowerCase(), '1']]);
@@ -21,4 +21,5 @@ export const decimalRecords: Record<string, number> = {
21
21
  '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
22
22
  '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18, // PULP
23
23
  '0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18, // PLYWNEAR
24
+ '0x5183e1b1091804bc2602586919e6880ac1cf2896': 18, // USN
24
25
  };
@@ -53,9 +53,12 @@ export function calcLMRewardApr(
53
53
  totalStakeValue: BigNumber,
54
54
  frequencyPerYear: number
55
55
  ): BigNumber {
56
+ if (rewardsValue.isZero()) {
57
+ return new BigNumber(0);
58
+ }
56
59
  if (totalStakeValue.lte(0)) {
57
60
  // avoid division by zero when there is no stake
58
- return new BigNumber('999999999');
61
+ return rewardsValue;
59
62
  }
60
63
  return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
61
64
  }
@@ -2,6 +2,7 @@ import BigNumber from 'bignumber.js';
2
2
  import { Contract, providers, BigNumber as BN, ethers } from 'ethers';
3
3
  import {
4
4
  DECIMAL_PRECISION,
5
+ HARDCODE_PRICE_TOKENS,
5
6
  networkAddresses,
6
7
  PRICE_WHITELISTED,
7
8
  } from '../consts/constants';
@@ -243,7 +244,9 @@ export async function fetchPrice(
243
244
  address: Address,
244
245
  provider: providers.Provider
245
246
  ): Promise<BigNumber> {
246
- if (isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
247
+ if (address.toLowerCase() in HARDCODE_PRICE_TOKENS) {
248
+ return new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]);
249
+ } else if (isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
247
250
  return fetchLPPrice(address, provider);
248
251
  } else if (isSameAddress(address, networkAddresses.tokens.PLY)) {
249
252
  return fetchPLYPrice(provider);