@aurigami/sdk 1.23.0 → 1.24.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.
Files changed (101) hide show
  1. package/dist/SDK.d.ts +48 -65
  2. package/dist/SDK.js +165 -0
  3. package/dist/abis/index.d.ts +18 -18
  4. package/dist/abis/index.js +39 -0
  5. package/dist/consts/constants.d.ts +139 -139
  6. package/dist/consts/constants.js +185 -0
  7. package/dist/consts/decimals.d.ts +1 -1
  8. package/dist/consts/decimals.js +35 -0
  9. package/dist/consts/deployments.d.ts +3 -3
  10. package/dist/consts/deployments.js +9 -0
  11. package/dist/consts/dummy.d.ts +13 -13
  12. package/dist/consts/dummy.js +43 -0
  13. package/dist/consts/index.d.ts +5 -5
  14. package/dist/consts/index.js +9 -0
  15. package/dist/consts/symbols.d.ts +1 -1
  16. package/dist/consts/symbols.js +10 -0
  17. package/dist/entities/BlockchainEntity.d.ts +13 -13
  18. package/dist/entities/BlockchainEntity.js +36 -0
  19. package/dist/entities/auriEnv.d.ts +34 -40
  20. package/dist/entities/auriEnv.js +166 -0
  21. package/dist/entities/index.d.ts +4 -4
  22. package/dist/entities/index.js +8 -0
  23. package/dist/entities/token.d.ts +7 -7
  24. package/dist/entities/token.js +27 -0
  25. package/dist/entities/tokenAmount.d.ts +13 -13
  26. package/dist/entities/tokenAmount.js +52 -0
  27. package/dist/helpers/aurigami-api.d.ts +13 -13
  28. package/dist/helpers/aurigami-api.js +26 -0
  29. package/dist/helpers/aurora-api-helpers.d.ts +1 -1
  30. package/dist/helpers/aurora-api-helpers.js +15 -0
  31. package/dist/helpers/graphql-helpers.d.ts +1 -1
  32. package/dist/helpers/graphql-helpers.js +13 -0
  33. package/dist/helpers/helpers.d.ts +23 -40
  34. package/dist/helpers/helpers.js +148 -0
  35. package/dist/helpers/historicalPriceFetcher.d.ts +15 -15
  36. package/dist/helpers/historicalPriceFetcher.js +142 -0
  37. package/dist/helpers/index.d.ts +7 -7
  38. package/dist/helpers/index.js +11 -0
  39. package/dist/helpers/kyber-aggregator-api.d.ts +5 -5
  40. package/dist/helpers/kyber-aggregator-api.js +27 -0
  41. package/dist/helpers/multicall.d.ts +40 -0
  42. package/dist/helpers/multicall.js +203 -0
  43. package/dist/helpers/notification-api.d.ts +2 -2
  44. package/dist/helpers/notification-api.js +21 -0
  45. package/dist/helpers/one-inch-aggregator-api.d.ts +21 -21
  46. package/dist/helpers/one-inch-aggregator-api.js +19 -0
  47. package/dist/helpers/priceFetcher.d.ts +36 -36
  48. package/dist/helpers/priceFetcher.js +296 -0
  49. package/dist/helpers/subgraphQuery.d.ts +1 -1
  50. package/dist/helpers/subgraphQuery.js +22 -0
  51. package/dist/helpers/transfer-event-query.d.ts +17 -26
  52. package/dist/helpers/transfer-event-query.js +41 -0
  53. package/dist/index.d.ts +7 -7
  54. package/dist/index.js +17 -8
  55. package/dist/interactors/Airdrop.d.ts +17 -26
  56. package/dist/interactors/Airdrop.js +48 -0
  57. package/dist/interactors/MoneyMarket.d.ts +63 -63
  58. package/dist/interactors/MoneyMarket.js +392 -0
  59. package/dist/interactors/Multicall.d.ts +15 -18
  60. package/dist/interactors/Multicall.js +36 -0
  61. package/dist/interactors/Papermill.d.ts +27 -57
  62. package/dist/interactors/Papermill.js +125 -0
  63. package/dist/interactors/PlyGame.d.ts +30 -42
  64. package/dist/interactors/PlyGame.js +146 -0
  65. package/dist/interactors/PlyTokenLock.d.ts +16 -16
  66. package/dist/interactors/PlyTokenLock.js +44 -0
  67. package/dist/interactors/Pulp.d.ts +17 -17
  68. package/dist/interactors/Pulp.js +43 -0
  69. package/dist/interactors/Referral.d.ts +35 -78
  70. package/dist/interactors/Referral.js +158 -0
  71. package/dist/interactors/Staking.d.ts +20 -26
  72. package/dist/interactors/Staking.js +106 -0
  73. package/dist/interactors/index.d.ts +9 -9
  74. package/dist/interactors/index.js +13 -0
  75. package/dist/interactors/misc.d.ts +31 -39
  76. package/dist/interactors/misc.js +318 -0
  77. package/dist/types/index.d.ts +175 -197
  78. package/dist/types/index.js +18 -0
  79. package/package.json +3 -3
  80. package/src/SDK.ts +1 -1
  81. package/src/entities/auriEnv.ts +29 -27
  82. package/src/helpers/historicalPriceFetcher.ts +9 -12
  83. package/src/helpers/multicall.ts +251 -0
  84. package/src/helpers/priceFetcher.ts +19 -21
  85. package/src/interactors/Airdrop.ts +2 -2
  86. package/src/interactors/MoneyMarket.ts +31 -27
  87. package/src/interactors/Multicall.ts +3 -3
  88. package/src/interactors/Papermill.ts +9 -9
  89. package/src/interactors/PlyGame.ts +10 -10
  90. package/src/interactors/PlyTokenLock.ts +2 -3
  91. package/src/interactors/Pulp.ts +4 -2
  92. package/src/interactors/Referral.ts +6 -6
  93. package/src/interactors/Staking.ts +13 -9
  94. package/src/interactors/misc.ts +7 -5
  95. package/src/types/index.ts +32 -2
  96. package/dist/sdk.cjs.development.js +0 -6325
  97. package/dist/sdk.cjs.development.js.map +0 -1
  98. package/dist/sdk.cjs.production.min.js +0 -2
  99. package/dist/sdk.cjs.production.min.js.map +0 -1
  100. package/dist/sdk.esm.js +0 -6193
  101. package/dist/sdk.esm.js.map +0 -1
@@ -1,197 +1,175 @@
1
- import { AuToken } from '@aurigami/contracts/typechain';
2
- import { TypedEvent } from '@aurigami/contracts/typechain/common';
3
- import BigNumber from 'bignumber.js';
4
- import type { providers, Signer } from 'ethers';
5
- import { BigNumber as BN } from 'ethers';
6
- import { TokenAmount } from '../entities/tokenAmount';
7
- export declare enum ComptrollerRewardType {
8
- PLY = 0,
9
- AURORA = 1
10
- }
11
- export declare type NetworkConnection = {
12
- provider: providers.Provider;
13
- signer?: Signer;
14
- };
15
- export declare type Address = string;
16
- export declare type CurrencyAmount = {
17
- currency: string;
18
- amount: string;
19
- };
20
- export declare type TokenValuation = {
21
- tokenAmount: TokenAmount;
22
- currencyAmount: CurrencyAmount;
23
- };
24
- export declare type MoneyMarketDetails = {
25
- auTokenAddress: string;
26
- totalTokenDeposited: TokenAmount;
27
- totalTokenBorrowed: TokenAmount;
28
- depositApy: number;
29
- depositPlyApy: number;
30
- borrowApy: number;
31
- borrowPlyApy: number;
32
- collateralRatio: number;
33
- depositPlyPerWeek: TokenAmount;
34
- borrowPlyPerWeek: TokenAmount;
35
- depositMETAApy: number;
36
- depositNEARApy: number;
37
- borrowNEARApy: number;
38
- staderDepositApy: number;
39
- };
40
- export declare type UserDetails = {
41
- markets: UserMarketDetails[];
42
- borrowLimit: CurrencyAmount;
43
- borrowableAmount: CurrencyAmount;
44
- };
45
- export declare type UserLockingDetails = {
46
- vestingStart: number;
47
- /** % of reward they will receive in PLY, if they claim this week */
48
- currentUnlockPortion: number;
49
- accruedPly: TokenAmount;
50
- /** Amount of PLY they will receive, if they claim this week */
51
- currentPly: TokenAmount;
52
- /** Amount of PULP they will receive, if they claim this week */
53
- currentPulp: TokenAmount;
54
- /** % of reward they will receive in PLY, if they claim next week */
55
- nextUnlockPortion: number;
56
- /**
57
- * Amount of PLY they will receive, if they claim next week.
58
- * This doesn't include the additional reward that they will earn
59
- * in the next week.
60
- */
61
- nextPly: TokenAmount;
62
- /**
63
- * Amount of PULP they will receive, if they claim next week.
64
- * This doesn't include the additional reward that they will earn
65
- * in the next week.
66
- */
67
- nextPulp: TokenAmount;
68
- };
69
- export declare type UserMarketDetails = {
70
- market: string;
71
- depositBalance: TokenAmount;
72
- borrowBalance: TokenAmount;
73
- isCollateral: boolean;
74
- maxWithdrawableAmount: TokenAmount;
75
- collateralRatio: number;
76
- underlyingPrice: string;
77
- };
78
- export declare type TokenAPY = {
79
- address: string;
80
- apy: string;
81
- };
82
- export declare type PLYWNEARPoolDetails = {
83
- totalStakedLiquidity: TokenAmount;
84
- APYs: TokenAPY[];
85
- };
86
- export declare enum MarketAction {
87
- Deposit = 0,
88
- Borrow = 1,
89
- Withdraw = 2,
90
- Repay = 3,
91
- EnableCollateral = 4,
92
- DisableCollateral = 5
93
- }
94
- export declare type HypotheticalStats = {
95
- newBorrowLimit: CurrencyAmount;
96
- newBorrowUtilization: number;
97
- };
98
- export declare type AccountAuTokenInfo = {
99
- token: string;
100
- deposit: BigNumber;
101
- borrow: BigNumber;
102
- };
103
- export declare type AccountAuTokensInfo = {
104
- address: string;
105
- tokens: AccountAuTokenInfo[];
106
- };
107
- export declare type AuTokenWithUnderlying = AuToken & {
108
- underlying: string;
109
- };
110
- export declare type ReferralReward = {
111
- campaign: string;
112
- /**
113
- * Truncated user address.
114
- */
115
- userAddr: string;
116
- /**
117
- * start timetamp of the referral round
118
- */
119
- startTime: number;
120
- /**
121
- * end timetamp of the referral round
122
- */
123
- endTime: number;
124
- /**
125
- * referrer's rewards
126
- */
127
- isReferrer: boolean;
128
- /**
129
- * reward amount
130
- */
131
- rewardTokenAmount: TokenAmount;
132
- /**
133
- * hash of the transaction on aurorascan (if no, return null)
134
- */
135
- transactionHash: string | null;
136
- refereeAddress: string | null;
137
- };
138
- export declare type PlyGameBetResult = {
139
- player: string;
140
- /**
141
- * Bet outcome result
142
- */
143
- outcome: string;
144
- /**
145
- * ply lost amount
146
- */
147
- lostAmount: TokenAmount;
148
- unlockedPulpAmount: TokenAmount;
149
- block: number;
150
- timestamp: number;
151
- /**
152
- * hash of the transaction on aurorascan (if no, return null)
153
- */
154
- transactionHash: string;
155
- };
156
- export declare type PlyGameLeaderboardItem = {
157
- player: string;
158
- gamesPlayed: number;
159
- unlockedPulpAmount: TokenAmount;
160
- };
161
- export declare type PlyBetMadeEvent = TypedEvent<[string, BN, number] & {
162
- player: string;
163
- amount: BN;
164
- outcome: number;
165
- }>;
166
- export declare type Apy = {
167
- sum: BigNumber;
168
- suppliedValue: BigNumber;
169
- borrowedValue: BigNumber;
170
- };
171
- export declare type UserNotification = {
172
- message: string;
173
- userSetting: {
174
- address: Address;
175
- mail: string;
176
- utilisation: number;
177
- liquidation: boolean;
178
- }[];
179
- };
180
- export declare type LiquidationEventEntity = {
181
- liquidator: string;
182
- borrower: string;
183
- /** bigint string */
184
- repayAmount: string;
185
- marketRepayToken: string;
186
- /** bigint string */
187
- seizeTokens: string;
188
- auTokenCollateral: string;
189
- txnHash: string;
190
- blockNumber: number;
191
- };
192
- export declare type LiquidationDetail = {
193
- liquidationTime: Timestamp;
194
- tokenAmount: TokenAmount;
195
- transactionId: string;
196
- };
197
- export declare type Timestamp = number;
1
+ import { AuToken } from '@aurigami/contracts/typechain';
2
+ import { TypedEvent } from '@aurigami/contracts/typechain/common';
3
+ import type { BlockTag } from '@ethersproject/abstract-provider';
4
+ import BigNumber from 'bignumber.js';
5
+ import type { Contract, providers, Signer } from 'ethers';
6
+ import { BigNumber as BN } from 'ethers';
7
+ import { TokenAmount } from '../entities/tokenAmount';
8
+ export declare enum ComptrollerRewardType {
9
+ PLY = 0,
10
+ AURORA = 1
11
+ }
12
+ export type NetworkConnection = {
13
+ provider: providers.Provider;
14
+ signer?: Signer;
15
+ };
16
+ export type Address = string;
17
+ export type CurrencyAmount = {
18
+ currency: string;
19
+ amount: string;
20
+ };
21
+ export type TokenValuation = {
22
+ tokenAmount: TokenAmount;
23
+ currencyAmount: CurrencyAmount;
24
+ };
25
+ export type MoneyMarketDetails = {
26
+ auTokenAddress: string;
27
+ totalTokenDeposited: TokenAmount;
28
+ totalTokenBorrowed: TokenAmount;
29
+ depositApy: number;
30
+ depositPlyApy: number;
31
+ borrowApy: number;
32
+ borrowPlyApy: number;
33
+ collateralRatio: number;
34
+ depositPlyPerWeek: TokenAmount;
35
+ borrowPlyPerWeek: TokenAmount;
36
+ depositMETAApy: number;
37
+ depositNEARApy: number;
38
+ borrowNEARApy: number;
39
+ staderDepositApy: number;
40
+ };
41
+ export type UserDetails = {
42
+ markets: UserMarketDetails[];
43
+ borrowLimit: CurrencyAmount;
44
+ borrowableAmount: CurrencyAmount;
45
+ };
46
+ export type UserLockingDetails = {
47
+ vestingStart: number;
48
+ currentUnlockPortion: number;
49
+ accruedPly: TokenAmount;
50
+ currentPly: TokenAmount;
51
+ currentPulp: TokenAmount;
52
+ nextUnlockPortion: number;
53
+ nextPly: TokenAmount;
54
+ nextPulp: TokenAmount;
55
+ };
56
+ export type UserMarketDetails = {
57
+ market: string;
58
+ depositBalance: TokenAmount;
59
+ borrowBalance: TokenAmount;
60
+ isCollateral: boolean;
61
+ maxWithdrawableAmount: TokenAmount;
62
+ collateralRatio: number;
63
+ underlyingPrice: string;
64
+ };
65
+ export type TokenAPY = {
66
+ address: string;
67
+ apy: string;
68
+ };
69
+ export type PLYWNEARPoolDetails = {
70
+ totalStakedLiquidity: TokenAmount;
71
+ APYs: TokenAPY[];
72
+ };
73
+ export type MulticallOverrides = {
74
+ blockTag?: BlockTag | Promise<BlockTag>;
75
+ };
76
+ type ConcatTuple<A extends any[], B extends any[]> = [...A, ...B];
77
+ type RemoveLastOptionalParam<Fn extends (...params: any[]) => any> = Fn extends (...params: [...infer Head, any?]) => infer R ? (...params: Head) => R : Fn;
78
+ type AddParams<Fn extends (...params: any[]) => any, P extends any[]> = Fn extends (...params: infer Params) => infer R ? (...params: ConcatTuple<Params, P>) => R : Fn;
79
+ export type MulticallStatic<T extends Contract> = {
80
+ callStatic: {
81
+ [P in keyof T['callStatic']]: AddParams<RemoveLastOptionalParam<T['callStatic'][P]>, [
82
+ multicallOverrides?: MulticallOverrides
83
+ ]>;
84
+ };
85
+ address: string;
86
+ raw: T;
87
+ };
88
+ export declare enum MarketAction {
89
+ Deposit = 0,
90
+ Borrow = 1,
91
+ Withdraw = 2,
92
+ Repay = 3,
93
+ EnableCollateral = 4,
94
+ DisableCollateral = 5
95
+ }
96
+ export type HypotheticalStats = {
97
+ newBorrowLimit: CurrencyAmount;
98
+ newBorrowUtilization: number;
99
+ };
100
+ export type AccountAuTokenInfo = {
101
+ token: string;
102
+ deposit: BigNumber;
103
+ borrow: BigNumber;
104
+ };
105
+ export type AccountAuTokensInfo = {
106
+ address: string;
107
+ tokens: AccountAuTokenInfo[];
108
+ };
109
+ export type AuTokenWithUnderlying = MulticallStatic<AuToken> & {
110
+ underlying: string;
111
+ };
112
+ export type ReferralReward = {
113
+ campaign: string;
114
+ userAddr: string;
115
+ startTime: number;
116
+ endTime: number;
117
+ isReferrer: boolean;
118
+ rewardTokenAmount: TokenAmount;
119
+ transactionHash: string | null;
120
+ refereeAddress: string | null;
121
+ };
122
+ export type PlyGameBetResult = {
123
+ player: string;
124
+ outcome: string;
125
+ lostAmount: TokenAmount;
126
+ unlockedPulpAmount: TokenAmount;
127
+ block: number;
128
+ timestamp: number;
129
+ transactionHash: string;
130
+ };
131
+ export type PlyGameLeaderboardItem = {
132
+ player: string;
133
+ gamesPlayed: number;
134
+ unlockedPulpAmount: TokenAmount;
135
+ };
136
+ export type PlyBetMadeEvent = TypedEvent<[
137
+ string,
138
+ BN,
139
+ number
140
+ ] & {
141
+ player: string;
142
+ amount: BN;
143
+ outcome: number;
144
+ }>;
145
+ export type Apy = {
146
+ sum: BigNumber;
147
+ suppliedValue: BigNumber;
148
+ borrowedValue: BigNumber;
149
+ };
150
+ export type UserNotification = {
151
+ message: string;
152
+ userSetting: {
153
+ address: Address;
154
+ mail: string;
155
+ utilisation: number;
156
+ liquidation: boolean;
157
+ }[];
158
+ };
159
+ export type LiquidationEventEntity = {
160
+ liquidator: string;
161
+ borrower: string;
162
+ repayAmount: string;
163
+ marketRepayToken: string;
164
+ seizeTokens: string;
165
+ auTokenCollateral: string;
166
+ txnHash: string;
167
+ blockNumber: number;
168
+ };
169
+ export type LiquidationDetail = {
170
+ liquidationTime: Timestamp;
171
+ tokenAmount: TokenAmount;
172
+ transactionId: string;
173
+ };
174
+ export type Timestamp = number;
175
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MarketAction = exports.ComptrollerRewardType = void 0;
4
+ var ComptrollerRewardType;
5
+ (function (ComptrollerRewardType) {
6
+ ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
7
+ ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
8
+ })(ComptrollerRewardType || (exports.ComptrollerRewardType = ComptrollerRewardType = {}));
9
+ var MarketAction;
10
+ (function (MarketAction) {
11
+ MarketAction[MarketAction["Deposit"] = 0] = "Deposit";
12
+ MarketAction[MarketAction["Borrow"] = 1] = "Borrow";
13
+ MarketAction[MarketAction["Withdraw"] = 2] = "Withdraw";
14
+ MarketAction[MarketAction["Repay"] = 3] = "Repay";
15
+ MarketAction[MarketAction["EnableCollateral"] = 4] = "EnableCollateral";
16
+ MarketAction[MarketAction["DisableCollateral"] = 5] = "DisableCollateral";
17
+ })(MarketAction || (exports.MarketAction = MarketAction = {}));
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBUUEsSUFBWSxxQkFHWDtBQUhELFdBQVkscUJBQXFCO0lBQy9CLCtEQUFPLENBQUE7SUFDUCxxRUFBTSxDQUFBO0FBQ1IsQ0FBQyxFQUhXLHFCQUFxQixxQ0FBckIscUJBQXFCLFFBR2hDO0FBb0hELElBQVksWUFPWDtBQVBELFdBQVksWUFBWTtJQUN0QixxREFBVyxDQUFBO0lBQ1gsbURBQU0sQ0FBQTtJQUNOLHVEQUFRLENBQUE7SUFDUixpREFBSyxDQUFBO0lBQ0wsdUVBQWdCLENBQUE7SUFDaEIseUVBQWlCLENBQUE7QUFDbkIsQ0FBQyxFQVBXLFlBQVksNEJBQVosWUFBWSxRQU92QiJ9
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.23.0",
2
+ "version": "1.24.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "scripts": {
14
14
  "start": "tsdx watch",
15
- "build": "tsdx build",
15
+ "build": "tsc -p ./tsconfig.build.json ",
16
16
  "test": "tsdx test --no-cache",
17
17
  "w-hardhat": "env TS_NODE_PROJECT=\"test-hardhat/tsconfig.json\" yarn hardhat",
18
18
  "lint": "prettier --check \"{src,test,test-hardhat}/**/*.{js,ts}\"",
@@ -58,7 +58,7 @@
58
58
  "ts-node": "^10.7.0",
59
59
  "tsdx": "^0.14.1",
60
60
  "tslib": "^2.3.1",
61
- "typescript": "^4.5.4"
61
+ "typescript": "^5.0.2"
62
62
  },
63
63
  "dependencies": {
64
64
  "@aurigami/contracts": "3.21.0",
package/src/SDK.ts CHANGED
@@ -187,7 +187,7 @@ export class SdkReadWrite extends SdkRead {
187
187
  * Claim rewards in all markets + staking pools
188
188
  */
189
189
  public async claim(): Promise<TransactionResponse> {
190
- return this.env.auriLens
190
+ return this.env.auriLens.raw
191
191
  .connect(this._networkConnection.signer!)
192
192
  .claimRewards(
193
193
  this.env.comptroller.address,
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AuErc20,
3
+ AuToken,
3
4
  AuriAirdrop,
4
5
  AuriFairLaunch,
5
6
  AuriInternalLens,
@@ -16,32 +17,33 @@ import { Contract } from 'ethers';
16
17
  import * as abis from '../abis';
17
18
  import { networkAddresses } from '../consts/constants';
18
19
  import { assert } from '../helpers/helpers';
19
- import { AuTokenWithUnderlying } from '../types';
20
+ import { createContract } from '../helpers/multicall';
21
+ import { AuTokenWithUnderlying, MulticallStatic } from '../types';
20
22
  import { BlockchainEntityRead } from './BlockchainEntity';
21
23
 
22
24
  export class AuriEnv extends BlockchainEntityRead {
23
- private _comptroller: Comptroller | null = null;
24
- private _auriFairLaunch: AuriFairLaunch | null = null;
25
- private _auriLens: AuriLens | null = null;
26
- private _ply: IERC20 | null = null;
27
- private _pulp: PULP | null = null;
28
- private _auriInternalLens: AuriInternalLens | null = null;
29
- private _auriAirdrop: AuriAirdrop | null = null;
30
- private _referralDirectoryV2: ReferralDirectoryV2 | null = null;
31
- private _oracle: AuriOracle | null = null;
32
- private _plygame: PlyGame | null = null;
33
- private _plyTokenLock: PlyTokenLock | null = null;
25
+ private _comptroller: MulticallStatic<Comptroller> | null = null;
26
+ private _auriFairLaunch: MulticallStatic<AuriFairLaunch> | null = null;
27
+ private _auriLens: MulticallStatic<AuriLens> | null = null;
28
+ private _ply: MulticallStatic<IERC20> | null = null;
29
+ private _pulp: MulticallStatic<PULP> | null = null;
30
+ private _auriInternalLens: MulticallStatic<AuriInternalLens> | null = null;
31
+ private _auriAirdrop: MulticallStatic<AuriAirdrop> | null = null;
32
+ private _referralDirectoryV2: MulticallStatic<ReferralDirectoryV2> | null = null;
33
+ private _oracle: MulticallStatic<AuriOracle> | null = null;
34
+ private _plygame: MulticallStatic<PlyGame> | null = null;
35
+ private _plyTokenLock: MulticallStatic<PlyTokenLock> | null = null;
34
36
 
35
37
  public getContract<CType extends Contract>(address: string, abi: any) {
36
- return new Contract(address, abi, this._networkConnection.provider) as CType;
38
+ return createContract<CType>(address, abi, this._networkConnection.provider);
37
39
  }
38
40
 
39
41
  public getAuTokenContracts(): AuTokenWithUnderlying[] {
40
42
  return networkAddresses.auTokens.map((auToken) => {
41
- const contract = this.getContract<AuTokenWithUnderlying>(
43
+ const contract = this.getContract<AuToken>(
42
44
  auToken.address,
43
45
  abis.AuTokenABI.abi
44
- );
46
+ ) as AuTokenWithUnderlying;
45
47
  contract.underlying = auToken.underlying;
46
48
  return contract;
47
49
  });
@@ -59,7 +61,7 @@ export class AuriEnv extends BlockchainEntityRead {
59
61
  }: {
60
62
  address?: string;
61
63
  underlyingName?: string;
62
- }): AuErc20 {
64
+ }) {
63
65
  assert(
64
66
  address !== undefined || underlyingName !== undefined,
65
67
  'Either address or underlyingName must be provided'
@@ -75,7 +77,7 @@ export class AuriEnv extends BlockchainEntityRead {
75
77
  return this.getContract<AuErc20>(address!, abis.AuErc20ABI.abi);
76
78
  }
77
79
 
78
- get comptroller(): Comptroller {
80
+ get comptroller() {
79
81
  if (!this._comptroller) {
80
82
  this._comptroller = this.getContract<Comptroller>(
81
83
  networkAddresses.misc.COMPTROLLER,
@@ -85,7 +87,7 @@ export class AuriEnv extends BlockchainEntityRead {
85
87
  return this._comptroller;
86
88
  }
87
89
 
88
- get auriFairLaunch(): AuriFairLaunch {
90
+ get auriFairLaunch() {
89
91
  if (!this._auriFairLaunch) {
90
92
  this._auriFairLaunch = this.getContract<AuriFairLaunch>(
91
93
  networkAddresses.misc.AURIFAIRLAUNCH,
@@ -95,7 +97,7 @@ export class AuriEnv extends BlockchainEntityRead {
95
97
  return this._auriFairLaunch;
96
98
  }
97
99
 
98
- get auriLens(): AuriLens {
100
+ get auriLens() {
99
101
  if (!this._auriLens) {
100
102
  this._auriLens = this.getContract<AuriLens>(
101
103
  networkAddresses.misc.AURILENS,
@@ -105,21 +107,21 @@ export class AuriEnv extends BlockchainEntityRead {
105
107
  return this._auriLens;
106
108
  }
107
109
 
108
- get ply(): IERC20 {
110
+ get ply() {
109
111
  if (!this._ply) {
110
112
  this._ply = this.getContract<IERC20>(networkAddresses.tokens.PLY, abis.EIP20InterfaceABI.abi);
111
113
  }
112
114
  return this._ply;
113
115
  }
114
116
 
115
- get pulp(): PULP {
117
+ get pulp() {
116
118
  if (!this._pulp) {
117
119
  this._pulp = this.getContract<PULP>(networkAddresses.tokens.PULP, abis.PulpABI.abi);
118
120
  }
119
121
  return this._pulp;
120
122
  }
121
123
 
122
- get auriInternalLens(): AuriInternalLens {
124
+ get auriInternalLens() {
123
125
  if (!this._auriInternalLens) {
124
126
  this._auriInternalLens = this.getContract<AuriInternalLens>(
125
127
  networkAddresses.misc.AURI_INTERNAL_LENS,
@@ -129,7 +131,7 @@ export class AuriEnv extends BlockchainEntityRead {
129
131
  return this._auriInternalLens;
130
132
  }
131
133
 
132
- get auriAirdrop(): AuriAirdrop {
134
+ get auriAirdrop() {
133
135
  if (!this._auriAirdrop) {
134
136
  this._auriAirdrop = this.getContract<AuriAirdrop>(
135
137
  networkAddresses.misc.AURI_AIRDROP,
@@ -139,7 +141,7 @@ export class AuriEnv extends BlockchainEntityRead {
139
141
  return this._auriAirdrop;
140
142
  }
141
143
 
142
- get referralDirectoryV2(): ReferralDirectoryV2 {
144
+ get referralDirectoryV2() {
143
145
  if (!this._referralDirectoryV2) {
144
146
  this._referralDirectoryV2 = this.getContract<ReferralDirectoryV2>(
145
147
  networkAddresses.misc.REFERRAL_V2,
@@ -149,7 +151,7 @@ export class AuriEnv extends BlockchainEntityRead {
149
151
  return this._referralDirectoryV2;
150
152
  }
151
153
 
152
- get oracle(): AuriOracle {
154
+ get oracle() {
153
155
  if (!this._oracle) {
154
156
  this._oracle = this.getContract<AuriOracle>(
155
157
  networkAddresses.misc.PYTH_ORACLE,
@@ -159,14 +161,14 @@ export class AuriEnv extends BlockchainEntityRead {
159
161
  return this._oracle;
160
162
  }
161
163
 
162
- get plygame(): PlyGame {
164
+ get plygame() {
163
165
  if (!this._plygame) {
164
166
  this._plygame = this.getContract<PlyGame>(networkAddresses.misc.PLYGAME, abis.PlyGameABI.abi);
165
167
  }
166
168
  return this._plygame;
167
169
  }
168
170
 
169
- get plyTokenLock(): PlyTokenLock {
171
+ get plyTokenLock() {
170
172
  if (!this._plyTokenLock) {
171
173
  this._plyTokenLock = this.getContract<PlyTokenLock>(
172
174
  networkAddresses.misc.PLY_TOKEN_LOCK,
@@ -1,10 +1,11 @@
1
1
  import { IUniswapV2Pair, PriceOracle } from '@aurigami/contracts/typechain';
2
2
  import BigNumber from 'bignumber.js';
3
- import { BigNumber as BN, Contract, providers } from 'ethers';
3
+ import { BigNumber as BN, providers } from 'ethers';
4
4
  import { AuriOracleABI, IUniswapV2PairABI } from '../abis';
5
5
  import { HARDCODE_PRICE_TOKENS, networkAddresses } from '../consts/constants';
6
6
  import { Address } from '../types';
7
7
  import { decimalFactor, devLog, getDecimal, isSameAddress } from './helpers';
8
+ import { createContract } from './multicall';
8
9
 
9
10
  export async function fetchHistoricalLPPositions(
10
11
  LPAddress: Address,
@@ -17,12 +18,12 @@ export async function fetchHistoricalLPPositions(
17
18
  reserve1: BN;
18
19
  totalSupply: BN;
19
20
  }> {
20
- const LPContract = new Contract(LPAddress, IUniswapV2PairABI.abi, provider) as IUniswapV2Pair;
21
+ const LPContract = createContract<IUniswapV2Pair>(LPAddress, IUniswapV2PairABI.abi, provider);
21
22
  var promises: any[] = [];
22
- promises.push(LPContract.token0());
23
- promises.push(LPContract.token1());
24
- promises.push(LPContract.getReserves({ blockTag: block }));
25
- promises.push(LPContract.totalSupply({ blockTag: block }));
23
+ promises.push(LPContract.callStatic.token0());
24
+ promises.push(LPContract.callStatic.token1());
25
+ promises.push(LPContract.callStatic.getReserves({ blockTag: block }));
26
+ promises.push(LPContract.callStatic.totalSupply({ blockTag: block }));
26
27
  const values: any[] = await Promise.all(promises);
27
28
 
28
29
  return {
@@ -111,12 +112,8 @@ export async function fetchHistoricalPriceFromOracle(
111
112
  ? networkAddresses.misc.DEPRECATED_OLD_ORACLE
112
113
  : networkAddresses.misc.PYTH_ORACLE;
113
114
 
114
- const oracleContract: PriceOracle = new Contract(
115
- oracleAddress,
116
- AuriOracleABI.abi,
117
- provider
118
- ) as PriceOracle;
119
- const rawPrice = await oracleContract
115
+ const oracleContract = createContract<PriceOracle>(oracleAddress, AuriOracleABI.abi, provider);
116
+ const rawPrice = await oracleContract.callStatic
120
117
  .getUnderlyingPrice(auTokenAddress, { blockTag: block })
121
118
  .catch((e: any) => {
122
119
  console.log(`Unable to fetch price from oracle for ${auTokenAddress}`);