@aurigami/sdk 1.16.0 → 1.16.2

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.
@@ -35,6 +35,7 @@ export declare type MoneyMarketDetails = {
35
35
  depositMETAApy: number;
36
36
  depositNEARApy: number;
37
37
  borrowNEARApy: number;
38
+ staderDepositApy: number;
38
39
  };
39
40
  export declare type UserDetails = {
40
41
  markets: UserMarketDetails[];
package/package.json CHANGED
@@ -1,74 +1,73 @@
1
1
  {
2
- "version": "1.16.0",
3
- "license": "MIT",
4
- "main": "dist/index.js",
5
- "typings": "dist/index.d.ts",
6
- "files": [
7
- "dist",
8
- "src"
9
- ],
10
- "engines": {
11
- "node": ">=14"
12
- },
13
- "scripts": {
14
- "start": "tsdx watch",
15
- "build": "tsdx build",
16
- "test": "tsdx test --no-cache",
17
- "w-hardhat": "env TS_NODE_PROJECT=\"test-hardhat/tsconfig.json\" yarn hardhat",
18
- "lint": "prettier --check \"{src,test,test-hardhat}/**/*.{js,ts}\"",
19
- "format": "prettier --write \"{src,test,test-hardhat}/**/*.{js,ts}\"",
20
- "prepare": "tsdx build",
21
- "size": "size-limit",
22
- "analyze": "size-limit --why"
23
- },
24
- "peerDependencies": {},
25
- "husky": {
26
- "hooks": {
27
- "pre-commit": "tsdx lint"
28
- }
29
- },
30
- "name": "@aurigami/sdk",
31
- "author": "Aurigami Finance",
32
- "module": "dist/sdk.esm.js",
33
- "size-limit": [
34
- {
35
- "path": "dist/sdk.cjs.production.min.js",
36
- "limit": "300 KB"
37
- },
38
- {
39
- "path": "dist/sdk.esm.js",
40
- "limit": "300 KB"
41
- }
42
- ],
43
- "devDependencies": {
44
- "@nomiclabs/hardhat-ethers": "^2.0.5",
45
- "@nomiclabs/hardhat-etherscan": "^3.0.3",
46
- "@nomiclabs/hardhat-waffle": "^2.0.3",
47
- "@size-limit/preset-big-lib": "^7.0.8",
48
- "@size-limit/webpack-why": "^7.0.8",
49
- "@types/mocha": "^9.1.0",
50
- "chai": "^4.3.6",
51
- "dotenv": "^16.0.1",
52
- "eslint-config-prettier": "^8.3.0",
53
- "eslint-plugin-prettier": "^4.0.0",
54
- "ethereum-waffle": "^3.4.4",
55
- "hardhat": "^2.12.6",
56
- "husky": "^7.0.4",
57
- "prettier": "^2.5.1",
58
- "size-limit": "^7.0.5",
59
- "ts-node": "^10.7.0",
60
- "tsdx": "^0.14.1",
61
- "tslib": "^2.3.1",
62
- "typescript": "^4.5.4"
63
- },
64
- "dependencies": {
65
- "@aurigami/contracts": "3.17.0",
66
- "axios": "^0.26.1",
67
- "bignumber.js": "^9.0.2",
68
- "cache-decorator": "^0.1.6",
69
- "ethers": "^5.6.4"
2
+ "version": "1.16.2",
3
+ "license": "MIT",
4
+ "main": "dist/index.js",
5
+ "typings": "dist/index.d.ts",
6
+ "files": [
7
+ "dist",
8
+ "src"
9
+ ],
10
+ "engines": {
11
+ "node": ">=14"
12
+ },
13
+ "scripts": {
14
+ "start": "tsdx watch",
15
+ "build": "tsdx build",
16
+ "test": "tsdx test --no-cache",
17
+ "w-hardhat": "env TS_NODE_PROJECT=\"test-hardhat/tsconfig.json\" yarn hardhat",
18
+ "lint": "prettier --check \"{src,test,test-hardhat}/**/*.{js,ts}\"",
19
+ "format": "prettier --write \"{src,test,test-hardhat}/**/*.{js,ts}\"",
20
+ "prepare": "tsdx build",
21
+ "size": "size-limit",
22
+ "analyze": "size-limit --why"
23
+ },
24
+ "husky": {
25
+ "hooks": {
26
+ "pre-commit": "tsdx lint"
27
+ }
28
+ },
29
+ "name": "@aurigami/sdk",
30
+ "author": "Aurigami Finance",
31
+ "module": "dist/sdk.esm.js",
32
+ "size-limit": [
33
+ {
34
+ "path": "dist/sdk.cjs.production.min.js",
35
+ "limit": "300 KB"
70
36
  },
71
- "jest": {
72
- "testURL": "https://app.aurigami.finance"
37
+ {
38
+ "path": "dist/sdk.esm.js",
39
+ "limit": "300 KB"
73
40
  }
74
- }
41
+ ],
42
+ "devDependencies": {
43
+ "@nomiclabs/hardhat-ethers": "^2.0.5",
44
+ "@nomiclabs/hardhat-etherscan": "^3.0.3",
45
+ "@nomiclabs/hardhat-waffle": "^2.0.3",
46
+ "@size-limit/preset-big-lib": "^7.0.8",
47
+ "@size-limit/webpack-why": "^7.0.8",
48
+ "@types/mocha": "^9.1.0",
49
+ "chai": "^4.3.6",
50
+ "dotenv": "^16.0.1",
51
+ "eslint-config-prettier": "^8.3.0",
52
+ "eslint-plugin-prettier": "^4.0.0",
53
+ "ethereum-waffle": "^3.4.4",
54
+ "hardhat": "^2.12.6",
55
+ "husky": "^7.0.4",
56
+ "prettier": "^2.5.1",
57
+ "size-limit": "^7.0.5",
58
+ "ts-node": "^10.7.0",
59
+ "tsdx": "^0.14.1",
60
+ "tslib": "^2.3.1",
61
+ "typescript": "^4.5.4"
62
+ },
63
+ "dependencies": {
64
+ "@aurigami/contracts": "3.17.0",
65
+ "axios": "^0.26.1",
66
+ "bignumber.js": "^9.0.2",
67
+ "cache-decorator": "^0.1.6",
68
+ "ethers": "^5.6.4"
69
+ },
70
+ "jest": {
71
+ "testURL": "https://app.aurigami.finance"
72
+ }
73
+ }
@@ -105,6 +105,7 @@ export const networkAddresses = {
105
105
  PLY_WNEAR: '0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
106
106
  WNEAR_TRI: '0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
107
107
  AURORA_WNEAR: '0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase(),
108
+ NEARX: '0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase(),
108
109
  },
109
110
  } as const;
110
111
 
@@ -194,6 +194,31 @@ export class MoneyMarketRead extends BlockchainEntityRead {
194
194
  return depositMETAApy;
195
195
  }
196
196
 
197
+ @cache({ ttl: CACHE_TIMEOUT, type: CacheType.MEMO })
198
+ public async getDepositStaderAPY(): Promise<BigNumber> {
199
+ const rewardStartTime = 1675346400;
200
+ const currentTime = helpers.getCurrentTimestamp();
201
+ if (currentTime < rewardStartTime) {
202
+ return new BigNumber(0);
203
+ }
204
+ const [totalDeposited, underlyingPrice] = await Promise.all([
205
+ this.getTotalTokenDeposited(),
206
+ fetchPrice(this.underlying.address, this._networkConnection.provider),
207
+ ]);
208
+ let depositStaderApy;
209
+ if (helpers.isSameAddress(this.underlying.address, consts.networkAddresses.tokens.NEARX)) {
210
+ // 100$ a day
211
+ depositStaderApy = helpers.calcLMRewardApr(
212
+ new BigNumber(100),
213
+ underlyingPrice.multipliedBy(totalDeposited.formattedAmount()),
214
+ 365
215
+ );
216
+ } else {
217
+ depositStaderApy = new BigNumber(0);
218
+ }
219
+ return depositStaderApy;
220
+ }
221
+
197
222
  public async getDetails(): Promise<MoneyMarketDetails> {
198
223
  const [totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeeds] =
199
224
  await Promise.all([
@@ -204,14 +229,21 @@ export class MoneyMarketRead extends BlockchainEntityRead {
204
229
  this.getCollateralRatio(),
205
230
  this.getRewardSpeeds(),
206
231
  ]);
207
- const [depositPlyAPY, borrowPlyAPY, depositNearAPY, borrowNearAPY, depositMetaAPY] =
208
- await Promise.all([
209
- this.getDepositPlyAPY(),
210
- this.getBorrowPlyAPY(),
211
- this.getDepositNearAPY(),
212
- this.getBorrowNearAPY(),
213
- this.getDepositMetaAPY(),
214
- ]);
232
+ const [
233
+ depositPlyAPY,
234
+ borrowPlyAPY,
235
+ depositNearAPY,
236
+ borrowNearAPY,
237
+ depositMetaAPY,
238
+ staderDepositApy,
239
+ ] = await Promise.all([
240
+ this.getDepositPlyAPY(),
241
+ this.getBorrowPlyAPY(),
242
+ this.getDepositNearAPY(),
243
+ this.getBorrowNearAPY(),
244
+ this.getDepositMetaAPY(),
245
+ this.getDepositStaderAPY(),
246
+ ]);
215
247
  return {
216
248
  auTokenAddress: this.auToken.address,
217
249
  totalTokenDeposited: totalDeposited,
@@ -232,6 +264,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
232
264
  depositNEARApy: depositNearAPY.toNumber(),
233
265
  borrowNEARApy: borrowNearAPY.toNumber() * -1,
234
266
  depositMETAApy: depositMetaAPY.toNumber(),
267
+ staderDepositApy: staderDepositApy.toNumber(),
235
268
  };
236
269
  }
237
270
 
@@ -333,12 +366,15 @@ export class MoneyMarketRead extends BlockchainEntityRead {
333
366
  this.getBorrowNearAPY(),
334
367
  this.getBorrowPlyAPY(),
335
368
  ]);
369
+ // idk why i cannot put this to promise.all, txds keep getting error
370
+ const staderDepositApy = await this.getDepositStaderAPY();
336
371
  const suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
337
372
  const borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
338
373
  const totalDepositApy = depositApy
339
374
  .plus(nearDepositApy)
340
375
  .plus(plyDepositApy)
341
- .plus(metaDepositApy);
376
+ .plus(metaDepositApy)
377
+ .plus(staderDepositApy);
342
378
  const totalBorrowApy = borrowApy.plus(nearBorrowApy).plus(plyBorrowApy);
343
379
  const sum = helpers.calcNetApy(suppliedValue, totalDepositApy, borrowedValue, totalBorrowApy);
344
380
  return {
@@ -40,6 +40,7 @@ export type MoneyMarketDetails = {
40
40
  depositMETAApy: number;
41
41
  depositNEARApy: number;
42
42
  borrowNEARApy: number;
43
+ staderDepositApy: number;
43
44
  };
44
45
 
45
46
  export type UserDetails = {
package/src/.DS_Store DELETED
Binary file