@aurigami/sdk 1.6.0-no-src → 1.6.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.
Files changed (39) hide show
  1. package/dist/SDK.d.ts +9 -0
  2. package/dist/contracts/Multicall.d.ts +18 -0
  3. package/dist/contracts/Papermill.d.ts +8 -0
  4. package/dist/sdk.cjs.development.js +102841 -40
  5. package/dist/sdk.cjs.development.js.map +1 -1
  6. package/dist/sdk.cjs.production.min.js +1 -1
  7. package/dist/sdk.cjs.production.min.js.map +1 -1
  8. package/dist/sdk.esm.js +102841 -40
  9. package/dist/sdk.esm.js.map +1 -1
  10. package/package.json +4 -3
  11. package/src/SDK.ts +430 -0
  12. package/src/abis/Faucet.json +157 -0
  13. package/src/abis/IUniswapV2Pair.json +663 -0
  14. package/src/abis/Oracle.json +247 -0
  15. package/src/abis/dummy.json +3 -0
  16. package/src/consts/constants.ts +146 -0
  17. package/src/consts/decimals.ts +24 -0
  18. package/src/consts/deployments.ts +4 -0
  19. package/src/consts/dummy.ts +38 -0
  20. package/src/consts/index.ts +4 -0
  21. package/src/contracts/MoneyMarket.ts +510 -0
  22. package/src/contracts/Multicall.ts +55 -0
  23. package/src/contracts/Papermill.ts +271 -0
  24. package/src/contracts/Staking.ts +183 -0
  25. package/src/contracts/airdrop-lottery.ts +320 -0
  26. package/src/contracts/index.ts +4 -0
  27. package/src/entities/BlockchainEntity.ts +33 -0
  28. package/src/entities/index.ts +3 -0
  29. package/src/entities/token.ts +21 -0
  30. package/src/entities/tokenAmount.ts +42 -0
  31. package/src/helpers/aurora-api-helpers.ts +20 -0
  32. package/src/helpers/helpers.ts +97 -0
  33. package/src/helpers/index.ts +4 -0
  34. package/src/helpers/priceFetcher.ts +317 -0
  35. package/src/helpers/transfer-event-query.ts +70 -0
  36. package/src/index.ts +13 -0
  37. package/src/misc/airdrop_misc/auTokensInfo.json +34 -0
  38. package/src/misc/airdrop_misc/whitelist.json +102629 -0
  39. package/src/types/index.ts +106 -0
@@ -0,0 +1,247 @@
1
+ {
2
+ "abi": [
3
+ {
4
+ "inputs": [],
5
+ "payable": false,
6
+ "stateMutability": "nonpayable",
7
+ "type": "constructor"
8
+ },
9
+ {
10
+ "anonymous": false,
11
+ "inputs": [
12
+ {
13
+ "indexed": false,
14
+ "internalType": "address",
15
+ "name": "feed",
16
+ "type": "address"
17
+ },
18
+ {
19
+ "indexed": false,
20
+ "internalType": "string",
21
+ "name": "symbol",
22
+ "type": "string"
23
+ }
24
+ ],
25
+ "name": "FeedSet",
26
+ "type": "event"
27
+ },
28
+ {
29
+ "anonymous": false,
30
+ "inputs": [
31
+ {
32
+ "indexed": false,
33
+ "internalType": "address",
34
+ "name": "oldAdmin",
35
+ "type": "address"
36
+ },
37
+ {
38
+ "indexed": false,
39
+ "internalType": "address",
40
+ "name": "newAdmin",
41
+ "type": "address"
42
+ }
43
+ ],
44
+ "name": "NewAdmin",
45
+ "type": "event"
46
+ },
47
+ {
48
+ "anonymous": false,
49
+ "inputs": [
50
+ {
51
+ "indexed": false,
52
+ "internalType": "address",
53
+ "name": "asset",
54
+ "type": "address"
55
+ },
56
+ {
57
+ "indexed": false,
58
+ "internalType": "uint256",
59
+ "name": "previousPriceMantissa",
60
+ "type": "uint256"
61
+ },
62
+ {
63
+ "indexed": false,
64
+ "internalType": "uint256",
65
+ "name": "requestedPriceMantissa",
66
+ "type": "uint256"
67
+ },
68
+ {
69
+ "indexed": false,
70
+ "internalType": "uint256",
71
+ "name": "newPriceMantissa",
72
+ "type": "uint256"
73
+ }
74
+ ],
75
+ "name": "PricePosted",
76
+ "type": "event"
77
+ },
78
+ {
79
+ "constant": true,
80
+ "inputs": [],
81
+ "name": "admin",
82
+ "outputs": [
83
+ {
84
+ "internalType": "address",
85
+ "name": "",
86
+ "type": "address"
87
+ }
88
+ ],
89
+ "payable": false,
90
+ "stateMutability": "view",
91
+ "type": "function"
92
+ },
93
+ {
94
+ "constant": true,
95
+ "inputs": [
96
+ {
97
+ "internalType": "address",
98
+ "name": "asset",
99
+ "type": "address"
100
+ }
101
+ ],
102
+ "name": "assetPrices",
103
+ "outputs": [
104
+ {
105
+ "internalType": "uint256",
106
+ "name": "",
107
+ "type": "uint256"
108
+ }
109
+ ],
110
+ "payable": false,
111
+ "stateMutability": "view",
112
+ "type": "function"
113
+ },
114
+ {
115
+ "constant": true,
116
+ "inputs": [
117
+ {
118
+ "internalType": "string",
119
+ "name": "symbol",
120
+ "type": "string"
121
+ }
122
+ ],
123
+ "name": "getFeed",
124
+ "outputs": [
125
+ {
126
+ "internalType": "contract AggregatorV2V3Interface",
127
+ "name": "",
128
+ "type": "address"
129
+ }
130
+ ],
131
+ "payable": false,
132
+ "stateMutability": "view",
133
+ "type": "function"
134
+ },
135
+ {
136
+ "constant": true,
137
+ "inputs": [
138
+ {
139
+ "internalType": "contract QiToken",
140
+ "name": "qiToken",
141
+ "type": "address"
142
+ }
143
+ ],
144
+ "name": "getUnderlyingPrice",
145
+ "outputs": [
146
+ {
147
+ "internalType": "uint256",
148
+ "name": "",
149
+ "type": "uint256"
150
+ }
151
+ ],
152
+ "payable": false,
153
+ "stateMutability": "view",
154
+ "type": "function"
155
+ },
156
+ {
157
+ "constant": true,
158
+ "inputs": [],
159
+ "name": "isPriceOracle",
160
+ "outputs": [
161
+ {
162
+ "internalType": "bool",
163
+ "name": "",
164
+ "type": "bool"
165
+ }
166
+ ],
167
+ "payable": false,
168
+ "stateMutability": "view",
169
+ "type": "function"
170
+ },
171
+ {
172
+ "constant": false,
173
+ "inputs": [
174
+ {
175
+ "internalType": "address",
176
+ "name": "newAdmin",
177
+ "type": "address"
178
+ }
179
+ ],
180
+ "name": "setAdmin",
181
+ "outputs": [],
182
+ "payable": false,
183
+ "stateMutability": "nonpayable",
184
+ "type": "function"
185
+ },
186
+ {
187
+ "constant": false,
188
+ "inputs": [
189
+ {
190
+ "internalType": "address",
191
+ "name": "asset",
192
+ "type": "address"
193
+ },
194
+ {
195
+ "internalType": "uint256",
196
+ "name": "price",
197
+ "type": "uint256"
198
+ }
199
+ ],
200
+ "name": "setDirectPrice",
201
+ "outputs": [],
202
+ "payable": false,
203
+ "stateMutability": "nonpayable",
204
+ "type": "function"
205
+ },
206
+ {
207
+ "constant": false,
208
+ "inputs": [
209
+ {
210
+ "internalType": "string",
211
+ "name": "symbol",
212
+ "type": "string"
213
+ },
214
+ {
215
+ "internalType": "address",
216
+ "name": "feed",
217
+ "type": "address"
218
+ }
219
+ ],
220
+ "name": "setFeed",
221
+ "outputs": [],
222
+ "payable": false,
223
+ "stateMutability": "nonpayable",
224
+ "type": "function"
225
+ },
226
+ {
227
+ "constant": false,
228
+ "inputs": [
229
+ {
230
+ "internalType": "contract QiToken",
231
+ "name": "qiToken",
232
+ "type": "address"
233
+ },
234
+ {
235
+ "internalType": "uint256",
236
+ "name": "underlyingPriceMantissa",
237
+ "type": "uint256"
238
+ }
239
+ ],
240
+ "name": "setUnderlyingPrice",
241
+ "outputs": [],
242
+ "payable": false,
243
+ "stateMutability": "nonpayable",
244
+ "type": "function"
245
+ }
246
+ ]
247
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "abi": []
3
+ }
@@ -0,0 +1,146 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { ethers, Signer, BigNumber as BN } from 'ethers';
3
+ import { MAINNET_ADDRESSES } from './deployments';
4
+ export const dummyAddress: string =
5
+ '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
6
+ export const ETHAddress: string = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
7
+
8
+ export const AURORA_CHAINID = 1313161554;
9
+
10
+ export const DECIMAL_PRECISION = 10;
11
+
12
+ export type NetworkAddresses = {
13
+ auTokens: {
14
+ name: string;
15
+ address: string;
16
+ underlying: string;
17
+ }[];
18
+ misc: Record<string, string>;
19
+ tokens: Record<string, string>;
20
+ };
21
+ export const networkAddresses: NetworkAddresses = {
22
+ auTokens: [
23
+ {
24
+ name: 'auUSDC',
25
+ address: MAINNET_ADDRESSES.auTokens.USDC.toLowerCase(),
26
+ underlying: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
27
+ },
28
+ {
29
+ name: 'auETH',
30
+ address: MAINNET_ADDRESSES.auTokens.ETH.toLowerCase(),
31
+ underlying: ETHAddress.toLowerCase(),
32
+ },
33
+ {
34
+ name: 'auWBTC',
35
+ address: MAINNET_ADDRESSES.auTokens.WBTC.toLowerCase(),
36
+ underlying: '0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase(),
37
+ },
38
+ {
39
+ name: 'auUSDT',
40
+ address: MAINNET_ADDRESSES.auTokens.USDT.toLowerCase(),
41
+ underlying: '0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase(),
42
+ },
43
+ {
44
+ name: 'auDAI',
45
+ address: MAINNET_ADDRESSES.auTokens.DAI.toLowerCase(),
46
+ underlying: '0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase(),
47
+ },
48
+ {
49
+ name: 'auWNEAR',
50
+ address: MAINNET_ADDRESSES.auTokens.WNEAR.toLowerCase(),
51
+ underlying: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
52
+ },
53
+ {
54
+ name: 'auSTNEAR',
55
+ address: MAINNET_ADDRESSES.auTokens.STNEAR.toLowerCase(),
56
+ underlying: '0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30'.toLowerCase(),
57
+ },
58
+ {
59
+ name: 'auAURORA',
60
+ address: MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(),
61
+ underlying: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
62
+ },
63
+ {
64
+ name: 'auTRI',
65
+ address: MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(),
66
+ underlying: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
67
+ },
68
+ {
69
+ name: 'auPLY',
70
+ address: MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(),
71
+ underlying: '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
72
+ },
73
+ ],
74
+ misc: {
75
+ COMPTROLLER: MAINNET_ADDRESSES.comptroller.toLowerCase(),
76
+ oracle: MAINNET_ADDRESSES.oracle.toLowerCase(),
77
+ AURIFAIRLAUNCH: MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
78
+ AURILENS: MAINNET_ADDRESSES.auriLens.toLowerCase(),
79
+ ETHREPAYHELPER: MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
80
+ AURI_AIRDROP: MAINNET_ADDRESSES.auriAirdrop.toLowerCase(),
81
+ MULTICALL: MAINNET_ADDRESSES.multicall.toLowerCase(),
82
+ TEAM_MULTISIG: '0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE'.toLowerCase(),
83
+ PLY_TOKEN_LOCK: MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
84
+ },
85
+ tokens: {
86
+ AURORA: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
87
+ PLY: '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
88
+ stNEAR: '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30'.toLowerCase(),
89
+ USDC: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
90
+ WNEAR: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
91
+ TRI: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
92
+ META: '0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
93
+ PULP: MAINNET_ADDRESSES.PULP.toLowerCase(),
94
+ PLYWNEAR: MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
95
+ },
96
+ };
97
+
98
+ // All token that we can calculate the price via oracle + coingecko
99
+ export const PRICE_WHITELISTED = new Set([
100
+ ...networkAddresses.auTokens.map((t) => t.underlying),
101
+ networkAddresses.tokens.AURORA,
102
+ networkAddresses.tokens.TRI,
103
+ networkAddresses.tokens.META,
104
+ networkAddresses.tokens.stNEAR,
105
+ ]);
106
+
107
+ export const REWARD_CLAIM_START = 1651759200; // Thursday, 5 May 2022 14:00:00 UTC
108
+
109
+ export const BORROW_LIMIT_BUFFER = new BigNumber(1);
110
+
111
+ export const ONE_DAY = 86400;
112
+ export const ONE_WEEK = ONE_DAY * 7;
113
+ export const ONE_YEAR = ONE_DAY * 365;
114
+
115
+ export const PLYWNEAR_POOL_ID = 0;
116
+ export const PLYWNEAR_REWARD_TOKENS = [
117
+ '0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', // PLY
118
+ '0x04Ac48711BCdc45b4d223fb021E09DA73c71095e', // PULP
119
+ '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', // WNEAR
120
+ '0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30', // STNEAR
121
+ '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', // AURORA
122
+ '0xFa94348467f64D5A457F75F8bc40495D33c65aBB', // TRI
123
+ ];
124
+ // could call RPC to get all the staking pools but it's not necessary for now
125
+ export const ALL_STAKING_POOLS: number[] = [PLYWNEAR_POOL_ID];
126
+ export const INF = BN.from(2).pow(256).sub(1);
127
+
128
+ export const AIRDROP_START_TIMESTAMP = 1649858400;
129
+ export const AIRDROP_END_TIMESTAMP = 1651068000;
130
+ export const AIRDROP_KEEP_THRESHOLD = 7 * 86400;
131
+
132
+ export const DEPOSIT_NEAR_REWARDS_PER_WEEK: { [k: string]: string } =
133
+ Object.fromEntries(
134
+ // lower case all addresses
135
+ Object.entries({
136
+ '0xb12bfca5a55806aaf64e99521918a4bf0fc40802': '36375', // USDC
137
+ '0x4988a896b1227218e4a686fde5eabdcabd91571f': '14550', // USDT
138
+ '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': '3638', // WBTC
139
+ '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE': '14550', // ETH
140
+ '0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': '3638', // WNEAR
141
+ }).map(([k, v]) => [k.toLowerCase(), v])
142
+ );
143
+
144
+ export const BORROW_NEAR_REWARDS_PER_WEEK: { [k: string]: string } = {
145
+ // currently 0 for all markets
146
+ };
@@ -0,0 +1,24 @@
1
+ export const decimalRecords: Record<string, number> = {
2
+ '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
3
+ '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f': 18,
4
+ '0x3195949f267702723bc614cae037cdc8d1e94786': 8,
5
+ '0xfa94348467f64d5a457f75f8bc40495d33c65abb': 18,
6
+ '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30': 24,
7
+ '0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24,
8
+ '0x6ea6c03061bddce23d4ec60b6e6e880c33d24dca': 8,
9
+ '0xca9511b610ba5fc7e311fdef9ce16050ee4449e9': 8,
10
+ '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
11
+ '0xcfb6b0498cb7555e7e21502e0f449bf28760adbb': 8,
12
+ '0x4f0d864b1abf4b701799a0b30b57a22dfeb5917b': 8,
13
+ '0xad5a2437ff55ed7a8cad3b797b3ec7c5a19b1c54': 8,
14
+ '0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
15
+ '0xb12bfca5a55806aaf64e99521918a4bf0fc40802': 6,
16
+ '0xe3520349f477a5f6eb06107066048508498a291b': 18,
17
+ '0x8888682e24dd4df7b7ff2b91fccb575737e433bf': 8,
18
+ '0xae4fac24dcdae0132c6d04f564dcf059616e9423': 8,
19
+ '0xce4166363e3a584dac84a47bcd3414b43efcdd1c': 8,
20
+ '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
21
+ '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
22
+ '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18, // PULP
23
+ '0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18, // PLYWNEAR
24
+ };
@@ -0,0 +1,4 @@
1
+ import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
2
+ import TESTNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_testnet.json';
3
+
4
+ export { MAINNET_ADDRESSES, TESTNET_ADDRESSES };
@@ -0,0 +1,38 @@
1
+ import { Token } from '../entities';
2
+ import { TokenAmount } from '../entities';
3
+ import { UserMarketDetails } from '../types';
4
+
5
+ export const dummyToken = new Token(
6
+ '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
7
+ 6
8
+ );
9
+
10
+ export const dummyPly = new Token(
11
+ '0x8729438eb15e2c8b576fcc6aecda6a148776c0f5',
12
+ 18
13
+ );
14
+
15
+ export const dummyPlyAurora = new Token(
16
+ '0xE530dC2095Ef5653205CF5ea79F8979a7028065c',
17
+ 18
18
+ );
19
+
20
+ export const dummyTokenAmount = new TokenAmount(dummyToken, '123.456', false);
21
+
22
+ export const dummyZeroTokenAmount = new TokenAmount(dummyToken, '0');
23
+
24
+ export const dummyTokenAmount2 = new TokenAmount(dummyToken, '456.123', false);
25
+
26
+ export const dummyTokenAmount3 = new TokenAmount(dummyToken, '1000.123', false);
27
+
28
+ export const dummyMarketAddress = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f'; // qiUSDC
29
+
30
+ export const dummyUserMarketDetails: UserMarketDetails = {
31
+ market: dummyMarketAddress,
32
+ depositBalance: dummyTokenAmount2,
33
+ borrowBalance: dummyZeroTokenAmount,
34
+ isCollateral: true,
35
+ maxWithdrawableAmount: dummyTokenAmount,
36
+ collateralRatio: 0.5,
37
+ underlyingPrice: '1',
38
+ };
@@ -0,0 +1,4 @@
1
+ export * from './constants';
2
+ export * from './decimals';
3
+ export * from './dummy';
4
+ export * from './deployments';