@aurigami/sdk 1.5.10 → 1.6.0-no-src

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 (55) hide show
  1. package/dist/SDK.d.ts +23 -16
  2. package/dist/consts/deployments.d.ts +3 -0
  3. package/dist/{dummy.d.ts → consts/dummy.d.ts} +3 -3
  4. package/dist/consts/index.d.ts +4 -0
  5. package/dist/{MoneyMarket.d.ts → contracts/MoneyMarket.d.ts} +3 -5
  6. package/dist/{Papermill.d.ts → contracts/Papermill.d.ts} +25 -4
  7. package/dist/{Staking.d.ts → contracts/Staking.d.ts} +8 -3
  8. package/dist/{airdrop-lottery.d.ts → contracts/airdrop-lottery.d.ts} +12 -4
  9. package/dist/contracts/index.d.ts +4 -0
  10. package/dist/{BlockchainEntity.d.ts → entities/BlockchainEntity.d.ts} +1 -1
  11. package/dist/entities/index.d.ts +3 -0
  12. package/dist/{tokenAmount.d.ts → entities/tokenAmount.d.ts} +1 -1
  13. package/dist/{helpers.d.ts → helpers/helpers.d.ts} +10 -1
  14. package/dist/helpers/index.d.ts +4 -0
  15. package/dist/{priceFetcher.d.ts → helpers/priceFetcher.d.ts} +2 -2
  16. package/dist/{transfer-event-query.d.ts → helpers/transfer-event-query.d.ts} +11 -2
  17. package/dist/index.d.ts +4 -11
  18. package/dist/sdk.cjs.development.js +1994 -104381
  19. package/dist/sdk.cjs.development.js.map +1 -1
  20. package/dist/sdk.cjs.production.min.js +1 -1
  21. package/dist/sdk.cjs.production.min.js.map +1 -1
  22. package/dist/sdk.esm.js +1990 -104384
  23. package/dist/sdk.esm.js.map +1 -1
  24. package/dist/{types.d.ts → types/index.d.ts} +15 -1
  25. package/package.json +12 -13
  26. package/src/BlockchainEntity.ts +0 -33
  27. package/src/MoneyMarket.ts +0 -510
  28. package/src/Papermill.ts +0 -262
  29. package/src/SDK.ts +0 -366
  30. package/src/Staking.ts +0 -183
  31. package/src/abis/Faucet.json +0 -157
  32. package/src/abis/IUniswapV2Pair.json +0 -663
  33. package/src/abis/Oracle.json +0 -247
  34. package/src/abis/dummy.json +0 -3
  35. package/src/airdrop-lottery.ts +0 -327
  36. package/src/airdrop_misc/auTokensInfo.json +0 -34
  37. package/src/airdrop_misc/whitelist.example.txt +0 -4
  38. package/src/airdrop_misc/whitelist.json +0 -102629
  39. package/src/aurora-api-helpers.ts +0 -20
  40. package/src/constants.ts +0 -143
  41. package/src/decimals.ts +0 -24
  42. package/src/deployments/aurora_mainnet.json +0 -31
  43. package/src/deployments/aurora_testnet.json +0 -31
  44. package/src/dummy.ts +0 -38
  45. package/src/helpers.ts +0 -91
  46. package/src/index.ts +0 -20
  47. package/src/priceFetcher.ts +0 -309
  48. package/src/token.ts +0 -21
  49. package/src/tokenAmount.ts +0 -42
  50. package/src/transfer-event-query.ts +0 -70
  51. package/src/types.ts +0 -106
  52. /package/dist/{constants.d.ts → consts/constants.d.ts} +0 -0
  53. /package/dist/{decimals.d.ts → consts/decimals.d.ts} +0 -0
  54. /package/dist/{token.d.ts → entities/token.d.ts} +0 -0
  55. /package/dist/{aurora-api-helpers.d.ts → helpers/aurora-api-helpers.d.ts} +0 -0
@@ -1,247 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- {
2
- "abi": []
3
- }
@@ -1,327 +0,0 @@
1
- import { Provider } from '@ethersproject/abstract-provider';
2
- import { TransactionResponse } from '@ethersproject/abstract-provider';
3
- import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
4
- import { Address, NetworkConnection } from './types';
5
- import { BigNumber as BN, Contract, utils } from 'ethers';
6
- import { TransferEventQuery } from './transfer-event-query';
7
- import {
8
- AIRDROP_START_TIMESTAMP,
9
- AIRDROP_KEEP_THRESHOLD,
10
- AIRDROP_END_TIMESTAMP,
11
- networkAddresses,
12
- } from './constants';
13
- import AuriAirdropABI from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json';
14
- import {
15
- getBlockBeforeTimestamp,
16
- getCurrentTimestamp,
17
- getDecimal,
18
- isSameAddress,
19
- assert,
20
- } from './helpers';
21
- import AIRDROP_AUTOKEN_INFO from './airdrop_misc/auTokensInfo.json';
22
- import AIRDROP_WHITELIST_ADDRESSES from './airdrop_misc/whitelist.json';
23
- import { AuriAirdrop } from '@aurigami/contracts/typechain';
24
- import { TokenAmount } from './tokenAmount';
25
- import { Token } from './token';
26
-
27
- type AirdropUnderlyingInfo = {
28
- minDeposit: BN;
29
- };
30
-
31
- type AirdropAuTokenInfo = {
32
- address: string;
33
- exchangeRate: BN;
34
- deploymentBlock: number;
35
- underlying: AirdropUnderlyingInfo;
36
- };
37
-
38
- class AirdropSettings {
39
- private static _instance: AirdropSettings;
40
-
41
- airdropStartBlock: number = 0;
42
- airdropEndBlock: number = 0;
43
- airdropStartTimestamp: number = AIRDROP_START_TIMESTAMP;
44
- airdropEndTimestamp: number = AIRDROP_END_TIMESTAMP;
45
- airdropThreshold: number = AIRDROP_KEEP_THRESHOLD;
46
- private constructor() {}
47
-
48
- public static async getSettings(
49
- provider: Provider
50
- ): Promise<AirdropSettings> {
51
- if (this._instance) return this._instance;
52
-
53
- let settings: AirdropSettings = new AirdropSettings();
54
-
55
- settings.airdropStartBlock = await getBlockBeforeTimestamp(
56
- provider,
57
- settings.airdropStartTimestamp
58
- );
59
-
60
- settings.airdropEndBlock = await getBlockBeforeTimestamp(
61
- provider,
62
- settings.airdropEndTimestamp
63
- );
64
-
65
- this._instance = settings;
66
- return settings;
67
- }
68
- }
69
-
70
- class AirdropAuTokenKeepTracker extends BlockchainEntityRead {
71
- private _transferQuery: TransferEventQuery;
72
- private _airdropAuTokenInfo: AirdropAuTokenInfo;
73
- public constructor(
74
- networkConnection: NetworkConnection,
75
- airdropAuTokenInfo: AirdropAuTokenInfo
76
- ) {
77
- super(networkConnection);
78
- this._transferQuery = new TransferEventQuery(
79
- airdropAuTokenInfo.address,
80
- networkConnection
81
- );
82
- this._airdropAuTokenInfo = airdropAuTokenInfo;
83
-
84
- // exchangeRate = 102% * exchangeRate, see why in the comment of _toUnderlyingValue
85
- this._airdropAuTokenInfo.exchangeRate =
86
- this._airdropAuTokenInfo.exchangeRate.add(
87
- this._airdropAuTokenInfo.exchangeRate.div(50)
88
- );
89
- }
90
-
91
- /**
92
- * Convert the given amount of auToken to the underlying value with the stored exchange rate
93
- *
94
- * Why we need to do this?
95
- *
96
- * By transfer event, we cannot know the exact underlying, the only
97
- * info that we can keep track of via transfer is event is the auToken amount. So we need to
98
- * convert it to the underlying value with the stored exchange rate.
99
- *
100
- * However, we cannot just simply use auTokenAmount * exchangeRate, because the exchange rate
101
- * is changing over time. As advice of the contract team, use fixed exchangeRate * 102% is good enough.
102
- *
103
- */
104
- private _toUnderlyingValue(auTokenAmount: BN): BN {
105
- return auTokenAmount
106
- .mul(this._airdropAuTokenInfo.exchangeRate)
107
- .div(BN.from(10).pow(18));
108
- }
109
-
110
- /**
111
- * Check if the user has been deposit at least (minDeposit) and keep it for
112
- * more than AIRDROP_KEEP_THRESHOLD milliseconds
113
- *
114
- * How it works:
115
- * Whenever the user balance is exceed minDeposit, we will record the timestamp,
116
- * and when the balance is below minDeposit, we will compare with the saved timestamp to see
117
- * whether it has been keep for more than AIRDROP_KEEP_THRESHOLD milliseconds.
118
- *
119
- */
120
- public async isEligible(address: string): Promise<boolean> {
121
- const settings = await AirdropSettings.getSettings(
122
- this._networkConnection.provider
123
- );
124
- const minDeposit = this._airdropAuTokenInfo.underlying.minDeposit;
125
-
126
- // Get user balance at the time of Airdrop start
127
- let balance = await this._transferQuery.queryERC20BalanceAt(
128
- address,
129
- settings.airdropStartBlock - 1
130
- );
131
-
132
- const [BELOW, ABOVE] = [false, true];
133
- let flag = BELOW;
134
- // variable to store the last timestamp that, from it to "current" timestamp,
135
- // the balance is always above minDeposit
136
- let lastEligibleBalanceTimestamp = 0;
137
-
138
- if (this._toUnderlyingValue(balance).gte(minDeposit)) {
139
- lastEligibleBalanceTimestamp = settings.airdropStartTimestamp;
140
- flag = ABOVE;
141
- }
142
-
143
- let events = await this._transferQuery.queryERC20TransfersOf(
144
- address,
145
- settings.airdropStartBlock,
146
- settings.airdropEndBlock
147
- );
148
-
149
- for (let { from, to, amount, blockNumber } of events) {
150
- if (isSameAddress(from, address)) {
151
- balance = balance.sub(amount);
152
- }
153
- if (isSameAddress(to, address)) {
154
- balance = balance.add(amount);
155
- }
156
-
157
- // if it is different from the flag, that means the balance is changing
158
- if (this._toUnderlyingValue(balance).gte(minDeposit) != flag) {
159
- flag = !flag;
160
- const timestamp = (
161
- await this._networkConnection.provider.getBlock(blockNumber)
162
- ).timestamp;
163
-
164
- // if this txn make the balance below the minDeposit,
165
- // check whether it has been keep for more than AIRDROP_KEEP_THRESHOLD
166
- if (flag == BELOW) {
167
- if (
168
- timestamp - lastEligibleBalanceTimestamp >=
169
- settings.airdropThreshold
170
- ) {
171
- return true;
172
- }
173
- lastEligibleBalanceTimestamp = 0;
174
- } else {
175
- // record the timestamp when the balance is above minDeposit
176
- lastEligibleBalanceTimestamp = timestamp;
177
- }
178
- }
179
- }
180
-
181
- // if after the last txn, the balance is still above minDeposit,
182
- // we should check from the last timestamp to "now"
183
- if (flag == ABOVE) {
184
- const timestamp = Math.min(
185
- settings.airdropEndTimestamp,
186
- getCurrentTimestamp()
187
- );
188
- return (
189
- timestamp - lastEligibleBalanceTimestamp >= settings.airdropThreshold
190
- );
191
- }
192
-
193
- return false;
194
- }
195
- }
196
-
197
- export class AirdropRead extends BlockchainEntityRead {
198
- protected _airDrop: AuriAirdrop;
199
- private _whitelistedAddresses: Set<string>;
200
- private keepTrackers: AirdropAuTokenKeepTracker[] = [];
201
- public constructor(networkConnection: NetworkConnection) {
202
- super(networkConnection);
203
- this._airDrop = new Contract(
204
- networkAddresses.misc.AURI_AIRDROP,
205
- AuriAirdropABI.abi,
206
- networkConnection.provider
207
- ) as AuriAirdrop;
208
-
209
- this._whitelistedAddresses = new Set(
210
- (AIRDROP_WHITELIST_ADDRESSES as string[]).map((e) =>
211
- e.toLocaleLowerCase()
212
- )
213
- );
214
-
215
- let auTokens: any = AIRDROP_AUTOKEN_INFO;
216
-
217
- for (let auToken in auTokens) {
218
- let { address, exchangeRate, deploymentBlock, underlying } =
219
- auTokens[auToken];
220
-
221
- let airdropInfo: AirdropAuTokenInfo = {
222
- address: address,
223
- exchangeRate: BN.from(exchangeRate),
224
- deploymentBlock: parseInt(deploymentBlock),
225
- underlying: {
226
- minDeposit: BN.from(underlying.minDeposit),
227
- },
228
- };
229
-
230
- this.keepTrackers.push(
231
- new AirdropAuTokenKeepTracker(networkConnection, airdropInfo)
232
- );
233
- }
234
- }
235
-
236
- public countWhitelistedAddresses(): number {
237
- return this._whitelistedAddresses.size;
238
- }
239
-
240
- public isWhitelisted(user: string): boolean {
241
- return this._whitelistedAddresses.has(user.toLocaleLowerCase());
242
- }
243
-
244
- public async hasCompletedChallenge(user: string): Promise<boolean> {
245
- const settings = await AirdropSettings.getSettings(
246
- this._networkConnection.provider
247
- );
248
-
249
- if (getCurrentTimestamp() < settings.airdropStartTimestamp) {
250
- return false;
251
- }
252
-
253
- if (!this.isWhitelisted(user)) {
254
- return false;
255
- }
256
-
257
- // iterate for all the market and check if the user has completed the challenge
258
- return (
259
- await Promise.all(
260
- this.keepTrackers.map(async (keepTracker) => {
261
- return keepTracker.isEligible(user);
262
- })
263
- )
264
- ).includes(true);
265
- }
266
-
267
- /**
268
- * Get redeemable rewards amount of user
269
- */
270
- public async getRedeemableReward(
271
- campaign: string,
272
- token: Address,
273
- user: Address
274
- ): Promise<TokenAmount> {
275
- let tokenInstance: Token = new Token(token, getDecimal(token));
276
-
277
- let rewards: BN = await this._airDrop.getRedeemableReward(
278
- utils.formatBytes32String(campaign),
279
- token,
280
- user
281
- );
282
-
283
- return new TokenAmount(tokenInstance, rewards.toString());
284
- }
285
- }
286
-
287
- export class AirdropReadWrite extends AirdropRead {
288
- /**
289
- * Transfer rewards from multiple campaigns to msg.sender
290
- */
291
- public async redeemMultiple(
292
- campaigns: string[],
293
- tokens: Address[]
294
- ): Promise<TransactionResponse> {
295
- assert(
296
- campaigns.length == tokens.length,
297
- 'campaigns and tokens must have the same length'
298
- );
299
- return this._airDrop.connect(this._networkConnection.signer!).redeem(
300
- campaigns.map((e) => utils.formatBytes32String(e)),
301
- tokens,
302
- await this._networkConnection.signer!.getAddress()
303
- );
304
- }
305
-
306
- /**
307
- * Redeem reward from a single campaign
308
- */
309
- public async redeemSingle(
310
- campaign: string,
311
- token: Address
312
- ): Promise<TransactionResponse> {
313
- return this.redeemMultiple([campaign], [token]);
314
- }
315
- }
316
-
317
- export class Airdrop extends BlockchainEntity {
318
- constructor() {
319
- super();
320
- }
321
- public read(networkConnection: NetworkConnection): AirdropRead {
322
- return new AirdropRead(networkConnection);
323
- }
324
- public readWrite(networkConnection: NetworkConnection): AirdropReadWrite {
325
- return new AirdropReadWrite(networkConnection);
326
- }
327
- }
@@ -1,34 +0,0 @@
1
- {
2
- "auUSDC": {
3
- "address": "0x4f0d864b1ABf4B701799a0b30b57A22dFEB5917b",
4
- "exchangeRate": "200810680770707",
5
- "deploymentBlock": "60501576",
6
- "underlying": {
7
- "minDeposit": "1000000000"
8
- }
9
- },
10
- "auETH": {
11
- "address": "0xca9511B610bA5fc7E311FDeF9cE16050eE4449E9",
12
- "exchangeRate": "200390813218617347858934298",
13
- "deploymentBlock": "60501625",
14
- "underlying": {
15
- "minDeposit": "300000000000000000"
16
- }
17
- },
18
- "auWBTC": {
19
- "address": "0xCFb6b0498cb7555e7e21502E0F449bf28760Adbb",
20
- "exchangeRate": "20050472926613996",
21
- "deploymentBlock": "60501670",
22
- "underlying": {
23
- "minDeposit": "2000000"
24
- }
25
- },
26
- "auUSDT": {
27
- "address": "0xaD5A2437Ff55ed7A8Cad3b797b3eC7c5a19B1c54",
28
- "exchangeRate": "200868369820223",
29
- "deploymentBlock": "60501723",
30
- "underlying": {
31
- "minDeposit": "1000000000"
32
- }
33
- }
34
- }
@@ -1,4 +0,0 @@
1
- 0x2b285e1b49ba0cb6f71d8b0d9cafdfbf9868fda9
2
- 0xe8e9a0a2571299a0dabcaae98608352faf533e6a
3
- 0xb3539af6596d8e08f75e96452d92bc17e3cdffc0
4
- 0x0c5a5bd45078916ff5ff3acafeb19fe96fd747dc