@aurigami/sdk 1.15.3 → 1.16.1
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/consts/constants.d.ts +84 -9
- package/dist/interactors/MoneyMarket.d.ts +1 -0
- package/dist/sdk.cjs.development.js +210 -141
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +210 -141
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +70 -71
- package/src/consts/constants.ts +8 -11
- package/src/consts/decimals.ts +3 -2
- package/src/interactors/MoneyMarket.ts +46 -15
- package/src/types/index.ts +2 -1
- package/src/.DS_Store +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -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[];
|
|
@@ -175,5 +176,5 @@ export declare type UserNotification = {
|
|
|
175
176
|
mail: string;
|
|
176
177
|
utilisation: number;
|
|
177
178
|
liquidation: boolean;
|
|
178
|
-
};
|
|
179
|
+
}[];
|
|
179
180
|
};
|
package/package.json
CHANGED
|
@@ -1,74 +1,73 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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.9.3",
|
|
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.16.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.1",
|
|
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
|
-
|
|
72
|
-
|
|
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
|
+
}
|
package/src/consts/constants.ts
CHANGED
|
@@ -10,16 +10,7 @@ export const DECIMAL_PRECISION = 10;
|
|
|
10
10
|
|
|
11
11
|
export const AURORA_PLUS_API_PREFIX = 'https://aurora.plus/api/wallet/';
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
auTokens: {
|
|
15
|
-
name: string;
|
|
16
|
-
address: string;
|
|
17
|
-
underlying: string;
|
|
18
|
-
}[];
|
|
19
|
-
misc: Record<string, string>;
|
|
20
|
-
tokens: Record<string, string>;
|
|
21
|
-
};
|
|
22
|
-
export const networkAddresses: NetworkAddresses = {
|
|
13
|
+
export const networkAddresses = {
|
|
23
14
|
auTokens: [
|
|
24
15
|
{
|
|
25
16
|
name: 'auUSDC',
|
|
@@ -76,6 +67,11 @@ export const networkAddresses: NetworkAddresses = {
|
|
|
76
67
|
address: MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
|
|
77
68
|
underlying: '0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
|
|
78
69
|
},
|
|
70
|
+
{
|
|
71
|
+
name: 'auNEARX',
|
|
72
|
+
address: MAINNET_ADDRESSES.auTokens.NEARX.toLowerCase(),
|
|
73
|
+
underlying: '0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase(),
|
|
74
|
+
},
|
|
79
75
|
],
|
|
80
76
|
misc: {
|
|
81
77
|
COMPTROLLER: MAINNET_ADDRESSES.comptroller.toLowerCase(),
|
|
@@ -109,8 +105,9 @@ export const networkAddresses: NetworkAddresses = {
|
|
|
109
105
|
PLY_WNEAR: '0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
|
|
110
106
|
WNEAR_TRI: '0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
|
|
111
107
|
AURORA_WNEAR: '0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase(),
|
|
108
|
+
NEARX: '0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase(),
|
|
112
109
|
},
|
|
113
|
-
};
|
|
110
|
+
} as const;
|
|
114
111
|
|
|
115
112
|
export const DEPOSIT_ONLY_TOKENS = [
|
|
116
113
|
MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(),
|
package/src/consts/decimals.ts
CHANGED
|
@@ -22,6 +22,7 @@ export const decimalRecords: Record<string, number> = {
|
|
|
22
22
|
'0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18, // PULP
|
|
23
23
|
'0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18, // PLYWNEAR
|
|
24
24
|
'0x5183e1b1091804bc2602586919e6880ac1cf2896': 18, // USN
|
|
25
|
-
'0x84b123875f0f36b966d0b6ca14b31121bd9676ad': 18, //WNEAR_TRI,
|
|
26
|
-
'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18, //AURORA_WNEAR
|
|
25
|
+
'0x84b123875f0f36b966d0b6ca14b31121bd9676ad': 18, // WNEAR_TRI,
|
|
26
|
+
'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18, // AURORA_WNEAR
|
|
27
|
+
'0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375': 24, // NEARX
|
|
27
28
|
};
|
|
@@ -16,12 +16,7 @@ import {
|
|
|
16
16
|
} from '../entities';
|
|
17
17
|
import * as helpers from '../helpers';
|
|
18
18
|
import { calcValuation, fetchPrice, fetchValuation } from '../helpers/priceFetcher';
|
|
19
|
-
import {
|
|
20
|
-
Address,
|
|
21
|
-
Apy,
|
|
22
|
-
MoneyMarketDetails,
|
|
23
|
-
NetworkConnection
|
|
24
|
-
} from '../types';
|
|
19
|
+
import { Address, Apy, MoneyMarketDetails, NetworkConnection } from '../types';
|
|
25
20
|
|
|
26
21
|
type RewardSpeeds = {
|
|
27
22
|
plyRewardSupplySpeed: BN;
|
|
@@ -199,6 +194,31 @@ export class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
199
194
|
return depositMETAApy;
|
|
200
195
|
}
|
|
201
196
|
|
|
197
|
+
@cache({ ttl: CACHE_TIMEOUT, type: CacheType.MEMO })
|
|
198
|
+
public async getDepositStaderAPY(): Promise<BigNumber> {
|
|
199
|
+
const rewardStartTime = 1675371600;
|
|
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
|
+
|
|
202
222
|
public async getDetails(): Promise<MoneyMarketDetails> {
|
|
203
223
|
const [totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeeds] =
|
|
204
224
|
await Promise.all([
|
|
@@ -209,14 +229,21 @@ export class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
209
229
|
this.getCollateralRatio(),
|
|
210
230
|
this.getRewardSpeeds(),
|
|
211
231
|
]);
|
|
212
|
-
const [
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
+
]);
|
|
220
247
|
return {
|
|
221
248
|
auTokenAddress: this.auToken.address,
|
|
222
249
|
totalTokenDeposited: totalDeposited,
|
|
@@ -237,6 +264,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
237
264
|
depositNEARApy: depositNearAPY.toNumber(),
|
|
238
265
|
borrowNEARApy: borrowNearAPY.toNumber() * -1,
|
|
239
266
|
depositMETAApy: depositMetaAPY.toNumber(),
|
|
267
|
+
staderDepositApy: staderDepositApy.toNumber(),
|
|
240
268
|
};
|
|
241
269
|
}
|
|
242
270
|
|
|
@@ -338,12 +366,15 @@ export class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
338
366
|
this.getBorrowNearAPY(),
|
|
339
367
|
this.getBorrowPlyAPY(),
|
|
340
368
|
]);
|
|
369
|
+
// idk why i cannot put this to promise.all, txds keep getting error
|
|
370
|
+
const staderDepositApy = await this.getDepositStaderAPY();
|
|
341
371
|
const suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
342
372
|
const borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
343
373
|
const totalDepositApy = depositApy
|
|
344
374
|
.plus(nearDepositApy)
|
|
345
375
|
.plus(plyDepositApy)
|
|
346
|
-
.plus(metaDepositApy)
|
|
376
|
+
.plus(metaDepositApy)
|
|
377
|
+
.plus(staderDepositApy);
|
|
347
378
|
const totalBorrowApy = borrowApy.plus(nearBorrowApy).plus(plyBorrowApy);
|
|
348
379
|
const sum = helpers.calcNetApy(suppliedValue, totalDepositApy, borrowedValue, totalBorrowApy);
|
|
349
380
|
return {
|
package/src/types/index.ts
CHANGED
|
@@ -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 = {
|
|
@@ -197,5 +198,5 @@ export type UserNotification = {
|
|
|
197
198
|
mail: string;
|
|
198
199
|
utilisation: number;
|
|
199
200
|
liquidation: boolean;
|
|
200
|
-
};
|
|
201
|
+
}[];
|
|
201
202
|
};
|
package/src/.DS_Store
DELETED
|
Binary file
|