@aurigami/sdk 1.13.1 → 1.14.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/ChangeLog.md +376 -0
- package/dist/helpers/helpers.d.ts +0 -1
- package/dist/sdk.cjs.development.js +87 -59
- 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 +88 -59
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/.DS_Store +0 -0
- package/src/consts/constants.ts +0 -1
- package/src/helpers/helpers.ts +19 -19
- package/src/helpers/priceFetcher.ts +3 -1
- package/src/interactors/MoneyMarket.ts +15 -14
- package/src/interactors/PlyGame.ts +1 -1
package/ChangeLog.md
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# Change Logs
|
|
2
|
+
# 1.13.1
|
|
3
|
+
- Add `PlyGameRead(...).overallLeaderboard(): Promise<PlyGameLeaderboardItem[]>`: overall ranking of the top 50 users by amount of PULP unlocked
|
|
4
|
+
|
|
5
|
+
# 1.13.0
|
|
6
|
+
- Add `SdkRead(...).getNetApyWithIncentive` and `getNetApyWithoutIncentive`.
|
|
7
|
+
|
|
8
|
+
# 1.12.8:
|
|
9
|
+
|
|
10
|
+
- Add `mintCap(): Promise<TokenAmount>` return the mint cap of the autoken
|
|
11
|
+
- Add `borrowCap(): Promise<TokenAmount>)` return the borrow cap of the autoken
|
|
12
|
+
|
|
13
|
+
# 1.12.7:
|
|
14
|
+
|
|
15
|
+
- Add `(...).queuePosition(address: Address): Promise<number>` return the position of the address in referral queue. -1 if not in queue,
|
|
16
|
+
999 if not in top 600.
|
|
17
|
+
- `slotsInUse()` now will not accept any param, and return the total slots in total.
|
|
18
|
+
|
|
19
|
+
## 1.12.6:
|
|
20
|
+
|
|
21
|
+
- Remove `getJackpotResult`, use `getLastJackpotResult` instead.
|
|
22
|
+
- Hide winner address in jackpot result.
|
|
23
|
+
|
|
24
|
+
## 1.12.3
|
|
25
|
+
|
|
26
|
+
- Add `PlyGameRead(...).getJackpotResult(round:number): Promise<{amount: TokenAmount, winner: Address}>`: return jackpot winner of the given round
|
|
27
|
+
|
|
28
|
+
## 1.12.2
|
|
29
|
+
|
|
30
|
+
- Use DefiLlama API as an backup for Coingecko
|
|
31
|
+
|
|
32
|
+
## 1.12.0 + 1.12.1
|
|
33
|
+
|
|
34
|
+
- Use new referral contract
|
|
35
|
+
- Remove referral V1 data
|
|
36
|
+
|
|
37
|
+
- `ReferralRead(...).isNewUserAtReferralTime(address: Address): Promise<boolean>`: Return true if this is a new user of aurigami
|
|
38
|
+
when he got referred
|
|
39
|
+
- `...(...).depositedMoreThanMinimumAmount(address: Address): Promise<boolean>`: Return true if the user has deposited more than the minimum amount (100$)
|
|
40
|
+
|
|
41
|
+
- `ReferralRead(...).isWhitelistedAddress(address: Address): Promise<boolean>`: check whether a user is a whitelisted referrer or not
|
|
42
|
+
- `ReferralRead(...).isOnAuroraPlus(address: Address): Promise<boolean>`: Check whether a user on Aurora+ or not
|
|
43
|
+
|
|
44
|
+
- `ReferralRead(...).slotsInUse(referralCode: string): Promise<number>`
|
|
45
|
+
- `(...).totalReferralSlots(): number` -> return 500
|
|
46
|
+
- `(...).userReferralStatus(userAddr: Address): Promise<string>` -> return `notReferred`, `notQualified`, `Qualified`, or `Withdrawn` base on the user status
|
|
47
|
+
- Type changes: `ReferralReward` now will have `refereeAddress: string | null`
|
|
48
|
+
|
|
49
|
+
## 1.11.1
|
|
50
|
+
|
|
51
|
+
- PlyGame `getPlyGameResultsInTransaction` get result faster by using `getTransactionReceipt` instead of `waitForTransaction`
|
|
52
|
+
|
|
53
|
+
## 1.11.0
|
|
54
|
+
|
|
55
|
+
- Add support for Plygame with testing contract
|
|
56
|
+
- Type:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
export type PlyGameBetResult = {
|
|
60
|
+
player: string;
|
|
61
|
+
outcome: string;
|
|
62
|
+
lostAmount: TokenAmount;
|
|
63
|
+
unlockedPulpAmount: TokenAmount;
|
|
64
|
+
|
|
65
|
+
block: number;
|
|
66
|
+
timestamp: number;
|
|
67
|
+
transactionHash: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type PlyGameLeaderboardItem = {
|
|
71
|
+
player: string;
|
|
72
|
+
gamesPlayed: number;
|
|
73
|
+
unlockedPulpAmount: TokenAmount;
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- Read functions:
|
|
78
|
+
|
|
79
|
+
- `PlyGameRead(...).getUserPlyGameHistory(user) -> Promise<PlyGameBetResult[]>`: Get 100 most recent bets of the market users
|
|
80
|
+
- `(...).currentJackpotAmount(): Promise<TokenAmount>`
|
|
81
|
+
- `(...).earlyUnlockedPulpAmount(user): Promise<TokenAmount>`: get total unlocked pulp amount since launch.
|
|
82
|
+
- `(...).getPlyGameResultsInTransaction(txHash): Promise<PlyGameBetResult[]>`: Return list of bet made from the given transaction.
|
|
83
|
+
- `PlyGameRead(...).leaderboard(): Promise<PlyGameLeaderboardItem[]>`: ranking list of the top 100 users by amount of PULP unlocked
|
|
84
|
+
|
|
85
|
+
- Write functions:
|
|
86
|
+
|
|
87
|
+
- `PlyGameReadWrite(...).makeBetOnce(amount: TokenAmount)`
|
|
88
|
+
- `(...).approve(amount: TokenAmount)`: approve plygame contract spending user's PLY
|
|
89
|
+
|
|
90
|
+
## 1.10.0
|
|
91
|
+
|
|
92
|
+
- Public `PapermillRead(...).getWeek(timestamp: number): number`
|
|
93
|
+
|
|
94
|
+
## 1.9.7
|
|
95
|
+
|
|
96
|
+
- Change oracle address
|
|
97
|
+
|
|
98
|
+
## 1.9.6
|
|
99
|
+
|
|
100
|
+
- Add oracle to ENV
|
|
101
|
+
|
|
102
|
+
## 1.9.5
|
|
103
|
+
|
|
104
|
+
- Use compound formular to calculate market APY.
|
|
105
|
+
|
|
106
|
+
## 1.9.4
|
|
107
|
+
|
|
108
|
+
- Allow to set custom dust in sneak account
|
|
109
|
+
|
|
110
|
+
## 1.9.3
|
|
111
|
+
|
|
112
|
+
- Change ply circulating supply
|
|
113
|
+
|
|
114
|
+
## 1.9.2
|
|
115
|
+
|
|
116
|
+
- Use 10B for PLY total supply
|
|
117
|
+
|
|
118
|
+
## 1.9.1
|
|
119
|
+
|
|
120
|
+
- Handle error in fetching LP price
|
|
121
|
+
|
|
122
|
+
## 1.9.0
|
|
123
|
+
|
|
124
|
+
- Rename `contracts` folder to `interactors`.
|
|
125
|
+
- Catching fetch price error
|
|
126
|
+
|
|
127
|
+
## 1.8.6
|
|
128
|
+
|
|
129
|
+
- Fix bug in `formattedAmount` when using custom format.
|
|
130
|
+
|
|
131
|
+
## 1.8.5
|
|
132
|
+
|
|
133
|
+
- Able to customize format in TokenAmount.formattedAmount()
|
|
134
|
+
|
|
135
|
+
## 1.8.4
|
|
136
|
+
|
|
137
|
+
- Add campaign ids for referrals
|
|
138
|
+
|
|
139
|
+
## 1.8.3
|
|
140
|
+
|
|
141
|
+
- Markets rewards + staking rewards can be claim in one txn by `SdkReadWrite(...).claim()`
|
|
142
|
+
- Remove `SdkReadWrite(...).claimLpRewards()`
|
|
143
|
+
|
|
144
|
+
## 1.8.2
|
|
145
|
+
|
|
146
|
+
Bug fix on missing txnHash in referralReward type
|
|
147
|
+
|
|
148
|
+
## 1.8.1
|
|
149
|
+
|
|
150
|
+
- Change campaign id
|
|
151
|
+
|
|
152
|
+
## 1.8.0
|
|
153
|
+
|
|
154
|
+
- Return actual data for referral rewards.
|
|
155
|
+
- Change `ReferralRead(...).leaderboard()` to `ReferralRead(...).leaderboard(campaign: string)`: now can get the leaderboard of a given campaign.
|
|
156
|
+
|
|
157
|
+
## 1.7.9-dummy
|
|
158
|
+
|
|
159
|
+
- Add `userAddr` in ReferralReward type
|
|
160
|
+
|
|
161
|
+
## 1.7.8-dummy
|
|
162
|
+
|
|
163
|
+
- Update Meta rewards for stNEAR to `1,250,000` META.
|
|
164
|
+
|
|
165
|
+
## 1.7.7-dummy
|
|
166
|
+
|
|
167
|
+
- [Dummy data] Add `ReferralRead(...).referralRewards(userAddr: Address): Promise<ReferralReward[]>`: Array of rewards, sorted by time of the referral period (from latest to oldest)
|
|
168
|
+
- [Dummy data] Add `ReferralRead(...).leaderboard(): Promise<ReferralReward[]>`: Top 50 reward earners from the last round, sorted by token amount.
|
|
169
|
+
|
|
170
|
+
- Add `ReferralReadWrite(...).claimReferralRewards()`: Claim all unclaimed rewards for a given user
|
|
171
|
+
|
|
172
|
+
New type:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
export type ReferralReward = {
|
|
176
|
+
campaign: string;
|
|
177
|
+
/**
|
|
178
|
+
* start timetamp of the referral round
|
|
179
|
+
*/
|
|
180
|
+
startTime: number;
|
|
181
|
+
/**
|
|
182
|
+
* end timetamp of the referral round
|
|
183
|
+
*/
|
|
184
|
+
endTime: number;
|
|
185
|
+
/**
|
|
186
|
+
* referrer's rewards
|
|
187
|
+
*/
|
|
188
|
+
isReferrer: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* reward amount
|
|
191
|
+
*/
|
|
192
|
+
rewardTokenAmount: TokenAmount;
|
|
193
|
+
/**
|
|
194
|
+
* hash of the transaction on aurorascan (if no, return null)
|
|
195
|
+
*/
|
|
196
|
+
transactionHash: string | null;
|
|
197
|
+
};
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## 1.7.3
|
|
201
|
+
|
|
202
|
+
- Add helper functions for Auri monitoring system
|
|
203
|
+
|
|
204
|
+
## 1.7.1 & 1.7.2
|
|
205
|
+
|
|
206
|
+
- Return correct timestamp in referrals list
|
|
207
|
+
|
|
208
|
+
## 1.7.0
|
|
209
|
+
|
|
210
|
+
- Add `ReferralRead(...).getReferralsList(userAddr: Address): Promise<{ user: string; timestamp: number }[]>`: Get 50 latest referrals of the given address, sorted descending by timestamp. Currently the timestamp is dummy data.
|
|
211
|
+
|
|
212
|
+
## 1.6.9
|
|
213
|
+
|
|
214
|
+
Support internal aurilens
|
|
215
|
+
|
|
216
|
+
## 1.6.6
|
|
217
|
+
|
|
218
|
+
Use `public readonly` modifier instead of `private/protected` in SDK.
|
|
219
|
+
|
|
220
|
+
## 1.6.5
|
|
221
|
+
|
|
222
|
+
SDK refactor #2, remove support for loterry campaign. Package size reduced from 3MB -> 200KB
|
|
223
|
+
|
|
224
|
+
## 1.6.4
|
|
225
|
+
|
|
226
|
+
Return meaningful result instead of INF in `calcLMRewardApr`
|
|
227
|
+
|
|
228
|
+
## 1.6.3
|
|
229
|
+
|
|
230
|
+
Add USN supports. Hardcoded USN price to $1.
|
|
231
|
+
|
|
232
|
+
## 1.6.2
|
|
233
|
+
|
|
234
|
+
- Add `ReferralRead(...).getUserReferralCode(userAddr: Address): Promise<string>`: Get the referral code for a given address, returns empty string if not found. Called to check if a user has a referral code.
|
|
235
|
+
- Add `ReferralRead(...).getReferralCodeOwner(code: string): Promise<Address>`: Get owner of a referral code, returns zero address if not found.
|
|
236
|
+
- Add `ReferralRead(...).getReferralCodeUsed(userAddr: Address): Promise<string>`: Get referral code that a user was referred by, returns empty string if not found.
|
|
237
|
+
- Add `ReferralReadWrite(...).registerNewReferralCode(): Promise<TransactionResponse>`: Generate a referral code for a given address. Called when an user want to creates his own referral code
|
|
238
|
+
- Add `ReferralReadWrite(...).useReferralCode(code: string): Promise<TransactionResponse>`: Called when an user confirms he is referred by a specified code
|
|
239
|
+
|
|
240
|
+
## 1.6.1
|
|
241
|
+
|
|
242
|
+
Add `PapermillRead(...).getNextWeekTimestamp(): number`: get the start timestamp of next week of the papermill contract.
|
|
243
|
+
|
|
244
|
+
Add `SdkRead(...).getPlyCirculatingSupply(): Promise<TokenAmount>`: get the ply's circulating supply
|
|
245
|
+
|
|
246
|
+
## 1.6.0
|
|
247
|
+
|
|
248
|
+
SDK refactor - Why?:
|
|
249
|
+
|
|
250
|
+
- more modular and less coupled.
|
|
251
|
+
- more testable.
|
|
252
|
+
- more maintainable.
|
|
253
|
+
|
|
254
|
+
Things to do:
|
|
255
|
+
|
|
256
|
+
- [x] Restructure the folder structure.
|
|
257
|
+
- Refactor the code - Use composition pattern to SDK class
|
|
258
|
+
- [x] Use address from contract package instead of hardcoded address.
|
|
259
|
+
|
|
260
|
+
## 1.5.8 + 1.5.9
|
|
261
|
+
|
|
262
|
+
Fix gas error on claim rewards: Instead of claim all the rewards in all market in 1 txns, we will claim rewards in 2 txns.
|
|
263
|
+
|
|
264
|
+
## 1.5.7
|
|
265
|
+
|
|
266
|
+
- Change return type of `SdkRead(...).LpBalanceOf` and `stakeBalanceOf` from `TokenValuation` to `TokenAmount` to match other functions in the SDK.
|
|
267
|
+
- `totalStakedLiquidity` field in `PLYWNEARPoolDetails` is now `TokenAmount` instead of `TokenValuation`.
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
export type PLYWNEARPoolDetails = {
|
|
271
|
+
totalStakedLiquidity: TokenAmount;
|
|
272
|
+
APYs: TokenAPY[];
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## 1.5.6
|
|
277
|
+
|
|
278
|
+
Add PLYWNEAR pool to ALL_STAKING_POOLS
|
|
279
|
+
|
|
280
|
+
## 1.5.5
|
|
281
|
+
|
|
282
|
+
Add auPLY market, integrate new fair launch contract
|
|
283
|
+
|
|
284
|
+
Hard code PULP price to 0
|
|
285
|
+
|
|
286
|
+
## 1.5.4
|
|
287
|
+
|
|
288
|
+
Use browser-friendly assert
|
|
289
|
+
|
|
290
|
+
## 1.5.2
|
|
291
|
+
|
|
292
|
+
Added `SdkRead(...).unclaimedRewardsOf(userAddress: Address): Promise<TokenAmount[]>` to get unclaimed rewards of a user in LP staking.
|
|
293
|
+
|
|
294
|
+
## 1.5.1
|
|
295
|
+
|
|
296
|
+
Added `PapermillRead(...).getUnlockPortionAt(userAddress: Address, timestamp: number)`
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
export type TokenAPY = {
|
|
300
|
+
address: string;
|
|
301
|
+
apy: string;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export type PLYWNEARPoolDetails = {
|
|
305
|
+
totalStakedLiquidity: TokenValuation;
|
|
306
|
+
APYs: TokenAPY[];
|
|
307
|
+
//apy: string; removed
|
|
308
|
+
};
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## 1.5.0 For staking PLYWNEAR
|
|
312
|
+
|
|
313
|
+
### Unchanged:
|
|
314
|
+
|
|
315
|
+
- Stake/unstake: Use `SdkReadWrite(...).stake(amount: TokenAmount)` (or `unstake`)
|
|
316
|
+
|
|
317
|
+
### Rename:
|
|
318
|
+
|
|
319
|
+
- `SdkRead(...).getPlyAuroraPoolDetails` -> `SdkRead(...).getPLYWNEARPoolDetails`
|
|
320
|
+
|
|
321
|
+
### Add
|
|
322
|
+
|
|
323
|
+
- Read:
|
|
324
|
+
- `SdkRead(...).LpBalanceOf(user: Address):TokenValuation` => amount and $ value of LP token in wallet. To get amount staked, use the old `stakeBalanceOf()` above
|
|
325
|
+
- Type:
|
|
326
|
+
- `TokenValuation` is a type that contains amount and $ value of token.
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
export type TokenValuation = {
|
|
330
|
+
tokenAmount: TokenAmount;
|
|
331
|
+
currencyAmount: CurrencyAmount;
|
|
332
|
+
};
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
export type PLYWNEARPoolDetails = {
|
|
337
|
+
totalStakedLiquidity: TokenValuation;
|
|
338
|
+
apy: string;
|
|
339
|
+
};
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Return type changed:
|
|
343
|
+
|
|
344
|
+
- `SdkRead(...).stakeBalanceOf()` will return `TokenValuation` instead of `TokenAmount`
|
|
345
|
+
|
|
346
|
+
### Remove:
|
|
347
|
+
|
|
348
|
+
- Type `PlyAuroraPoolDetails` removed.
|
|
349
|
+
|
|
350
|
+
## 1.5.0 For Papermill
|
|
351
|
+
|
|
352
|
+
### Add
|
|
353
|
+
|
|
354
|
+
- Read functions:
|
|
355
|
+
|
|
356
|
+
- `new PapermillRead(...).getPlyBalance(address: Address): TokenAmount` => PLY balance in user wallet
|
|
357
|
+
- `new PapermillRead(...).getPulpBalance(address: Address): TokenAmount` => PULP balance in user wallet
|
|
358
|
+
- `new PapermillRead(...).getLockingDetails(address: Address): UserLockingDetails`: Get locking details. This function is for convenience only, because the locking details are already available in the `UserLockingDetails` result (which you can get by calling the old `SdkRead(...).getUserDetails()`)
|
|
359
|
+
|
|
360
|
+
- Write functions:
|
|
361
|
+
|
|
362
|
+
- `new PapermillReadWrite(...).redeem(recipient: Address, amount: TokenAmount)` => Redeem Ply from PULP. Set `amount` to `ethers.constants.MaxUint256` for max redeem.
|
|
363
|
+
- `new PapermillReadWrite(...).selfRedeem(amount: TokenAmount)` => Redeem Ply from PULP to msg.sender. This is just a shortcut for the redeem function above.
|
|
364
|
+
- Collect all PLY reward from all markets + staking pool: No added functions, using the old `SdkReadWrite(...).claim()`
|
|
365
|
+
|
|
366
|
+
- Type:
|
|
367
|
+
- `UserLockingDetails` to store all user locking details
|
|
368
|
+
|
|
369
|
+
### Update
|
|
370
|
+
|
|
371
|
+
- `SdkRead(...).getUserDetails()`: this will include the result from `getLockingDetails`.
|
|
372
|
+
|
|
373
|
+
### Remove
|
|
374
|
+
|
|
375
|
+
- `SdkRead(...).getLockingDetails()`: Use the `getLockingDetails` in papermill instead if needed.
|
|
376
|
+
- Remove `LockingDetails` type
|
|
@@ -38,4 +38,3 @@ export declare function devLog(message?: any, ...optionalParams: any[]): void;
|
|
|
38
38
|
* This method mutates the array and returns a reference to the same array.
|
|
39
39
|
**/
|
|
40
40
|
export declare function sortEvents<T extends Result>(events: TypedEvent<T>[]): TypedEvent<T>[];
|
|
41
|
-
export declare function Cache(cacheTimeout: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -28,6 +28,7 @@ var aurora_testnet_json = _interopDefault(require('@aurigami/contracts/deploymen
|
|
|
28
28
|
var axios = _interopDefault(require('axios'));
|
|
29
29
|
var abstractSigner = require('@ethersproject/abstract-signer');
|
|
30
30
|
var tslib = require('tslib');
|
|
31
|
+
var cacheDecorator = require('cache-decorator');
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
@@ -136,7 +137,7 @@ var networkAddresses = {
|
|
|
136
137
|
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase()
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
|
-
var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.
|
|
140
|
+
var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase()]; // All token that we can calculate the price via oracle + coingecko
|
|
140
141
|
|
|
141
142
|
var PRICE_WHITELISTED = /*#__PURE__*/new Set( /*#__PURE__*/[].concat( /*#__PURE__*/networkAddresses.auTokens.map(function (t) {
|
|
142
143
|
return t.underlying;
|
|
@@ -1539,37 +1540,25 @@ function sortEvents(events) {
|
|
|
1539
1540
|
|
|
1540
1541
|
return a.blockNumber - b.blockNumber;
|
|
1541
1542
|
});
|
|
1542
|
-
}
|
|
1543
|
-
function
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
return value;
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
var result = originalMethod.apply(this, args);
|
|
1566
|
-
cache.set(key, [Date.now(), result]);
|
|
1567
|
-
return result;
|
|
1568
|
-
};
|
|
1569
|
-
|
|
1570
|
-
return descriptor;
|
|
1571
|
-
};
|
|
1572
|
-
}
|
|
1543
|
+
} // export function Cache(cacheTimeout: number) {
|
|
1544
|
+
// return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
1545
|
+
// const originalMethod = descriptor.value;
|
|
1546
|
+
// let cache = new Map<string, any>();
|
|
1547
|
+
// descriptor.value = function (...args: any[]) {
|
|
1548
|
+
// let key = JSON.stringify(args);
|
|
1549
|
+
// if (cache.has(key)) {
|
|
1550
|
+
// let [timestamp, value] = cache.get(key);
|
|
1551
|
+
// if (Date.now() - timestamp < cacheTimeout) {
|
|
1552
|
+
// return value;
|
|
1553
|
+
// }
|
|
1554
|
+
// }
|
|
1555
|
+
// let result = originalMethod.apply(this, args);
|
|
1556
|
+
// cache.set(key, [Date.now(), result]);
|
|
1557
|
+
// return result;
|
|
1558
|
+
// };
|
|
1559
|
+
// return descriptor;
|
|
1560
|
+
// };
|
|
1561
|
+
// }
|
|
1573
1562
|
|
|
1574
1563
|
var BlockchainEntityRead = function BlockchainEntityRead(networkConnection) {
|
|
1575
1564
|
this._networkConnection = networkConnection;
|
|
@@ -1956,6 +1945,7 @@ function _fetchPriceFromDefiLlamaAPI() {
|
|
|
1956
1945
|
return res.data.coins[id].price;
|
|
1957
1946
|
})["catch"](function (err) {
|
|
1958
1947
|
console.log("unable to fetch price from DefiLlama API: " + err);
|
|
1948
|
+
console.error(err);
|
|
1959
1949
|
return 0;
|
|
1960
1950
|
});
|
|
1961
1951
|
|
|
@@ -1989,6 +1979,7 @@ function _fetchPriceFromCoingeckoAPI() {
|
|
|
1989
1979
|
return res.data[id];
|
|
1990
1980
|
})["catch"](function (err) {
|
|
1991
1981
|
console.log("Unable to fetch price from Coingecko API for " + id);
|
|
1982
|
+
console.error(err);
|
|
1992
1983
|
return {
|
|
1993
1984
|
usd: 0
|
|
1994
1985
|
};
|
|
@@ -3103,7 +3094,6 @@ var helpers = {
|
|
|
3103
3094
|
getBlockBeforeTimestamp: getBlockBeforeTimestamp,
|
|
3104
3095
|
devLog: devLog,
|
|
3105
3096
|
sortEvents: sortEvents,
|
|
3106
|
-
Cache: Cache,
|
|
3107
3097
|
fetchPriceFromDefiLlamaAPI: fetchPriceFromDefiLlamaAPI,
|
|
3108
3098
|
fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
|
|
3109
3099
|
fetchPriceFromDefiLlama: fetchPriceFromDefiLlama,
|
|
@@ -4043,31 +4033,70 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4043
4033
|
return MoneyMarketRead;
|
|
4044
4034
|
}(BlockchainEntityRead);
|
|
4045
4035
|
|
|
4046
|
-
tslib.__decorate([
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
tslib.__decorate([
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
tslib.__decorate([
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4036
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4037
|
+
ttl: CACHE_TIMEOUT,
|
|
4038
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4039
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getUnderlyingPrice", null);
|
|
4040
|
+
|
|
4041
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4042
|
+
ttl: CACHE_TIMEOUT,
|
|
4043
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4044
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getPlyPrice", null);
|
|
4045
|
+
|
|
4046
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4047
|
+
ttl: CACHE_TIMEOUT,
|
|
4048
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4049
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getRewardSpeeds", null);
|
|
4050
|
+
|
|
4051
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4052
|
+
ttl: CACHE_TIMEOUT,
|
|
4053
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4054
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getTotalTokenBorrowed", null);
|
|
4055
|
+
|
|
4056
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4057
|
+
ttl: CACHE_TIMEOUT,
|
|
4058
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4059
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getTotalTokenDeposited", null);
|
|
4060
|
+
|
|
4061
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4062
|
+
ttl: CACHE_TIMEOUT,
|
|
4063
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4064
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositAPY", null);
|
|
4065
|
+
|
|
4066
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4067
|
+
ttl: CACHE_TIMEOUT,
|
|
4068
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4069
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getBorrowAPY", null);
|
|
4070
|
+
|
|
4071
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4072
|
+
ttl: CACHE_TIMEOUT,
|
|
4073
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4074
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getCollateralRatio", null);
|
|
4075
|
+
|
|
4076
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4077
|
+
ttl: CACHE_TIMEOUT,
|
|
4078
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4079
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getBorrowPlyAPY", null);
|
|
4080
|
+
|
|
4081
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4082
|
+
ttl: CACHE_TIMEOUT,
|
|
4083
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4084
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositPlyAPY", null);
|
|
4085
|
+
|
|
4086
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4087
|
+
ttl: CACHE_TIMEOUT,
|
|
4088
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4089
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositNearAPY", null);
|
|
4090
|
+
|
|
4091
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4092
|
+
ttl: CACHE_TIMEOUT,
|
|
4093
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4094
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getBorrowNearAPY", null);
|
|
4095
|
+
|
|
4096
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4097
|
+
ttl: CACHE_TIMEOUT,
|
|
4098
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4099
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositMetaAPY", null);
|
|
4071
4100
|
|
|
4072
4101
|
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
4073
4102
|
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
@@ -7122,7 +7151,6 @@ exports.BlockchainEntity = BlockchainEntity;
|
|
|
7122
7151
|
exports.BlockchainEntityRead = BlockchainEntityRead;
|
|
7123
7152
|
exports.BlockchainEntityReadWrite = BlockchainEntityReadWrite;
|
|
7124
7153
|
exports.CACHE_TIMEOUT = CACHE_TIMEOUT;
|
|
7125
|
-
exports.Cache = Cache;
|
|
7126
7154
|
exports.DECIMAL_PRECISION = DECIMAL_PRECISION;
|
|
7127
7155
|
exports.DEPOSIT_NEAR_REWARDS_PER_WEEK = DEPOSIT_NEAR_REWARDS_PER_WEEK;
|
|
7128
7156
|
exports.DEPOSIT_ONLY_TOKENS = DEPOSIT_ONLY_TOKENS;
|