@aurigami/sdk 1.5.10 → 1.6.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 (56) 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 +2511 -2271
  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 +2508 -2275
  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 +11 -11
  26. package/src/SDK.ts +63 -65
  27. package/src/{constants.ts → consts/constants.ts} +19 -19
  28. package/src/consts/deployments.ts +4 -0
  29. package/src/{dummy.ts → consts/dummy.ts} +3 -3
  30. package/src/consts/index.ts +4 -0
  31. package/src/{MoneyMarket.ts → contracts/MoneyMarket.ts} +66 -66
  32. package/src/{Papermill.ts → contracts/Papermill.ts} +26 -30
  33. package/src/{Staking.ts → contracts/Staking.ts} +29 -29
  34. package/src/{airdrop-lottery.ts → contracts/airdrop-lottery.ts} +30 -37
  35. package/src/contracts/index.ts +4 -0
  36. package/src/{BlockchainEntity.ts → entities/BlockchainEntity.ts} +1 -1
  37. package/src/entities/index.ts +3 -0
  38. package/src/{token.ts → entities/token.ts} +2 -2
  39. package/src/{tokenAmount.ts → entities/tokenAmount.ts} +2 -2
  40. package/src/{helpers.ts → helpers/helpers.ts} +8 -2
  41. package/src/helpers/index.ts +4 -0
  42. package/src/{priceFetcher.ts → helpers/priceFetcher.ts} +16 -8
  43. package/src/{transfer-event-query.ts → helpers/transfer-event-query.ts} +2 -2
  44. package/src/index.ts +4 -11
  45. package/src/{types.ts → types/index.ts} +1 -1
  46. package/src/airdrop_misc/whitelist.example.txt +0 -4
  47. package/src/deployments/aurora_mainnet.json +0 -31
  48. package/src/deployments/aurora_testnet.json +0 -31
  49. /package/dist/{constants.d.ts → consts/constants.d.ts} +0 -0
  50. /package/dist/{decimals.d.ts → consts/decimals.d.ts} +0 -0
  51. /package/dist/{token.d.ts → entities/token.d.ts} +0 -0
  52. /package/dist/{aurora-api-helpers.d.ts → helpers/aurora-api-helpers.d.ts} +0 -0
  53. /package/src/{decimals.ts → consts/decimals.ts} +0 -0
  54. /package/src/{aurora-api-helpers.ts → helpers/aurora-api-helpers.ts} +0 -0
  55. /package/src/{airdrop_misc → misc/airdrop_misc}/auTokensInfo.json +0 -0
  56. /package/src/{airdrop_misc → misc/airdrop_misc}/whitelist.json +0 -0
@@ -1,28 +1,21 @@
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
1
  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
2
  import { AuriAirdrop } from '@aurigami/contracts/typechain';
24
- import { TokenAmount } from './tokenAmount';
25
- import { Token } from './token';
3
+ import {
4
+ Provider,
5
+ TransactionResponse,
6
+ } from '@ethersproject/abstract-provider';
7
+ import { BigNumber as BN, Contract, utils } from 'ethers';
8
+ import * as consts from '../consts';
9
+ import {
10
+ BlockchainEntity,
11
+ BlockchainEntityRead,
12
+ Token,
13
+ TokenAmount,
14
+ } from '../entities';
15
+ import * as helpers from '../helpers';
16
+ import AIRDROP_AUTOKEN_INFO from '../misc/airdrop_misc/auTokensInfo.json';
17
+ import AIRDROP_WHITELIST_ADDRESSES from '../misc/airdrop_misc/whitelist.json';
18
+ import { Address, NetworkConnection } from '../types';
26
19
 
27
20
  type AirdropUnderlyingInfo = {
28
21
  minDeposit: BN;
@@ -40,9 +33,9 @@ class AirdropSettings {
40
33
 
41
34
  airdropStartBlock: number = 0;
42
35
  airdropEndBlock: number = 0;
43
- airdropStartTimestamp: number = AIRDROP_START_TIMESTAMP;
44
- airdropEndTimestamp: number = AIRDROP_END_TIMESTAMP;
45
- airdropThreshold: number = AIRDROP_KEEP_THRESHOLD;
36
+ airdropStartTimestamp: number = consts.AIRDROP_START_TIMESTAMP;
37
+ airdropEndTimestamp: number = consts.AIRDROP_END_TIMESTAMP;
38
+ airdropThreshold: number = consts.AIRDROP_KEEP_THRESHOLD;
46
39
  private constructor() {}
47
40
 
48
41
  public static async getSettings(
@@ -52,12 +45,12 @@ class AirdropSettings {
52
45
 
53
46
  let settings: AirdropSettings = new AirdropSettings();
54
47
 
55
- settings.airdropStartBlock = await getBlockBeforeTimestamp(
48
+ settings.airdropStartBlock = await helpers.getBlockBeforeTimestamp(
56
49
  provider,
57
50
  settings.airdropStartTimestamp
58
51
  );
59
52
 
60
- settings.airdropEndBlock = await getBlockBeforeTimestamp(
53
+ settings.airdropEndBlock = await helpers.getBlockBeforeTimestamp(
61
54
  provider,
62
55
  settings.airdropEndTimestamp
63
56
  );
@@ -68,14 +61,14 @@ class AirdropSettings {
68
61
  }
69
62
 
70
63
  class AirdropAuTokenKeepTracker extends BlockchainEntityRead {
71
- private _transferQuery: TransferEventQuery;
64
+ private _transferQuery: helpers.TransferEventQuery;
72
65
  private _airdropAuTokenInfo: AirdropAuTokenInfo;
73
66
  public constructor(
74
67
  networkConnection: NetworkConnection,
75
68
  airdropAuTokenInfo: AirdropAuTokenInfo
76
69
  ) {
77
70
  super(networkConnection);
78
- this._transferQuery = new TransferEventQuery(
71
+ this._transferQuery = new helpers.TransferEventQuery(
79
72
  airdropAuTokenInfo.address,
80
73
  networkConnection
81
74
  );
@@ -147,10 +140,10 @@ class AirdropAuTokenKeepTracker extends BlockchainEntityRead {
147
140
  );
148
141
 
149
142
  for (let { from, to, amount, blockNumber } of events) {
150
- if (isSameAddress(from, address)) {
143
+ if (helpers.isSameAddress(from, address)) {
151
144
  balance = balance.sub(amount);
152
145
  }
153
- if (isSameAddress(to, address)) {
146
+ if (helpers.isSameAddress(to, address)) {
154
147
  balance = balance.add(amount);
155
148
  }
156
149
 
@@ -183,7 +176,7 @@ class AirdropAuTokenKeepTracker extends BlockchainEntityRead {
183
176
  if (flag == ABOVE) {
184
177
  const timestamp = Math.min(
185
178
  settings.airdropEndTimestamp,
186
- getCurrentTimestamp()
179
+ helpers.getCurrentTimestamp()
187
180
  );
188
181
  return (
189
182
  timestamp - lastEligibleBalanceTimestamp >= settings.airdropThreshold
@@ -201,7 +194,7 @@ export class AirdropRead extends BlockchainEntityRead {
201
194
  public constructor(networkConnection: NetworkConnection) {
202
195
  super(networkConnection);
203
196
  this._airDrop = new Contract(
204
- networkAddresses.misc.AURI_AIRDROP,
197
+ consts.networkAddresses.misc.AURI_AIRDROP,
205
198
  AuriAirdropABI.abi,
206
199
  networkConnection.provider
207
200
  ) as AuriAirdrop;
@@ -246,7 +239,7 @@ export class AirdropRead extends BlockchainEntityRead {
246
239
  this._networkConnection.provider
247
240
  );
248
241
 
249
- if (getCurrentTimestamp() < settings.airdropStartTimestamp) {
242
+ if (helpers.getCurrentTimestamp() < settings.airdropStartTimestamp) {
250
243
  return false;
251
244
  }
252
245
 
@@ -272,7 +265,7 @@ export class AirdropRead extends BlockchainEntityRead {
272
265
  token: Address,
273
266
  user: Address
274
267
  ): Promise<TokenAmount> {
275
- let tokenInstance: Token = new Token(token, getDecimal(token));
268
+ let tokenInstance: Token = new Token(token, helpers.getDecimal(token));
276
269
 
277
270
  let rewards: BN = await this._airDrop.getRedeemableReward(
278
271
  utils.formatBytes32String(campaign),
@@ -292,7 +285,7 @@ export class AirdropReadWrite extends AirdropRead {
292
285
  campaigns: string[],
293
286
  tokens: Address[]
294
287
  ): Promise<TransactionResponse> {
295
- assert(
288
+ helpers.assert(
296
289
  campaigns.length == tokens.length,
297
290
  'campaigns and tokens must have the same length'
298
291
  );
@@ -0,0 +1,4 @@
1
+ export * from './airdrop-lottery';
2
+ export * from './MoneyMarket';
3
+ export * from './Papermill';
4
+ export * from './Staking';
@@ -1,5 +1,5 @@
1
1
  import { Signer } from '@ethersproject/abstract-signer';
2
- import { NetworkConnection } from './types';
2
+ import { NetworkConnection } from '../types';
3
3
 
4
4
  export class BlockchainEntityRead {
5
5
  protected _networkConnection: NetworkConnection;
@@ -0,0 +1,3 @@
1
+ export * from './BlockchainEntity';
2
+ export * from './token';
3
+ export * from './tokenAmount';
@@ -1,5 +1,5 @@
1
- import { getDecimal } from './helpers';
2
- import { networkAddresses } from './constants';
1
+ import { getDecimal } from '../helpers/helpers';
2
+ import { networkAddresses } from '../consts/constants';
3
3
 
4
4
  export class Token {
5
5
  public readonly address: string;
@@ -1,7 +1,7 @@
1
1
  import { Token } from './token';
2
2
  import BigNumber from 'bignumber.js';
3
- import { decimalFactor, getDecimal } from './helpers';
4
- import { Address } from './types';
3
+ import { decimalFactor, getDecimal } from '../helpers/helpers';
4
+ import { Address } from '../types';
5
5
 
6
6
  export class TokenAmount {
7
7
  public readonly token: Token;
@@ -2,8 +2,8 @@ import { Provider } from '@ethersproject/abstract-provider';
2
2
  import BigNumber from 'bignumber.js';
3
3
  import { BigNumber as BN, utils } from 'ethers';
4
4
  import { getQuery as getAuroraAPIQuery } from './aurora-api-helpers';
5
- import { decimalRecords } from './decimals';
6
- import { Address } from './types';
5
+ import { decimalRecords } from '../consts/decimals';
6
+ import { Address } from '../types';
7
7
 
8
8
  export function assert(condition: boolean, message: string = ''): void {
9
9
  if (!condition) {
@@ -89,3 +89,9 @@ export async function getBlockBeforeTimestamp(
89
89
  // use the last block number
90
90
  return parseInt(result) || (await provider.getBlockNumber());
91
91
  }
92
+
93
+ export function devLog(message?: any, ...optionalParams: any[]): void {
94
+ if ('production' !== process.env.NODE_ENV) {
95
+ console.log(message, ...optionalParams);
96
+ }
97
+ }
@@ -0,0 +1,4 @@
1
+ export * from './aurora-api-helpers';
2
+ export * from './helpers';
3
+ export * from './priceFetcher';
4
+ export * from './transfer-event-query';
@@ -4,13 +4,19 @@ import {
4
4
  DECIMAL_PRECISION,
5
5
  networkAddresses,
6
6
  PRICE_WHITELISTED,
7
- } from './constants';
8
- import OracleABI from './abis/Oracle.json';
9
- import { isSameAddress, decimalFactor, getDecimal, assert } from './helpers';
7
+ } from '../consts/constants';
8
+ import OracleABI from '../abis/Oracle.json';
9
+ import {
10
+ isSameAddress,
11
+ decimalFactor,
12
+ getDecimal,
13
+ assert,
14
+ devLog,
15
+ } from './helpers';
10
16
  import { IUniswapV2Pair, PriceOracle } from '@aurigami/contracts/typechain';
11
- import { TokenAmount } from './tokenAmount';
12
- import { Address, TokenValuation } from './types';
13
- import IUniswapV2PairABI from './abis/IUniswapV2Pair.json';
17
+ import { TokenAmount } from '../entities/tokenAmount';
18
+ import { Address, TokenValuation } from '../types';
19
+ import IUniswapV2PairABI from '../abis/IUniswapV2Pair.json';
14
20
  import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
15
21
  import axios from 'axios';
16
22
 
@@ -114,14 +120,16 @@ export async function fetchLPPrice(
114
120
  address: LPInfo.token0,
115
121
  reserve: LPInfo.reserve0,
116
122
  });
117
- } catch {
123
+ } catch (e) {
124
+ devLog(`fetchLPPriceBy ${LPInfo.token0} failed`, e);
118
125
  try {
119
126
  // MUST await here
120
127
  return await fetchLPPriceBy({
121
128
  address: LPInfo.token1,
122
129
  reserve: LPInfo.reserve1,
123
130
  });
124
- } catch {
131
+ } catch (e) {
132
+ devLog(`fetchLPPriceBy ${LPInfo.token1} failed`, e);
125
133
  throw Error(`Unable to fetch price for both tokens of LP ${address}`);
126
134
  }
127
135
  }
@@ -1,5 +1,5 @@
1
- import { BlockchainEntityRead } from './BlockchainEntity';
2
- import { NetworkConnection } from './types';
1
+ import { BlockchainEntityRead } from '../entities/BlockchainEntity';
2
+ import { NetworkConnection } from '../types';
3
3
  import { AuToken } from '@aurigami/contracts/typechain';
4
4
  import AuTokenABI from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
5
5
  import { BigNumber as BN, Contract } from 'ethers';
package/src/index.ts CHANGED
@@ -5,16 +5,9 @@ import { Logger } from 'ethers/lib/utils';
5
5
  ethers.utils.Logger.setLogLevel(Logger.levels.ERROR);
6
6
  BigNumber.config({ DECIMAL_PLACES: 50 });
7
7
 
8
- export * from './SDK';
9
- export * from './MoneyMarket';
10
- export * from './BlockchainEntity';
8
+ export * from './consts';
9
+ export * from './contracts';
10
+ export * from './entities';
11
11
  export * from './helpers';
12
- export * from './constants';
13
- export * from './dummy';
14
- export * from './priceFetcher';
15
- export * from './token';
16
- export * from './tokenAmount';
17
12
  export * from './types';
18
- export * from './airdrop-lottery';
19
- export * from './transfer-event-query';
20
- export * from './Papermill';
13
+ export * from './SDK';
@@ -1,5 +1,5 @@
1
1
  import type { BigNumber, providers, Signer } from 'ethers';
2
- import { TokenAmount } from './tokenAmount';
2
+ import { TokenAmount } from '../entities/tokenAmount';
3
3
 
4
4
  export enum ComptrollerRewardType {
5
5
  PLY = 0,
@@ -1,4 +0,0 @@
1
- 0x2b285e1b49ba0cb6f71d8b0d9cafdfbf9868fda9
2
- 0xe8e9a0a2571299a0dabcaae98608352faf533e6a
3
- 0xb3539af6596d8e08f75e96452d92bc17e3cdffc0
4
- 0x0c5a5bd45078916ff5ff3acafeb19fe96fd747dc
@@ -1,31 +0,0 @@
1
- {
2
- "deployer": "0xb969526EBc8dd4b1d816Da846eE08180515fFBbC",
3
- "unitroller": "0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb",
4
- "comptrollerImpl": "0x559c68b1276d070CB9d6Da75ECeA90FFB6497b18",
5
- "comptroller": "0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb",
6
- "PLY": "0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f",
7
- "jumpRateModel": "0x0Bc03bd8d4aF1e8bab2194860268F5774C9d400a",
8
- "oracle": "0xC6e5185438e1730959c1eF3551059A3feC744E90",
9
- "auTokens": {
10
- "USDC": "0x4f0d864b1ABf4B701799a0b30b57A22dFEB5917b",
11
- "ETH": "0xca9511B610bA5fc7E311FDeF9cE16050eE4449E9",
12
- "WBTC": "0xCFb6b0498cb7555e7e21502E0F449bf28760Adbb",
13
- "USDT": "0xaD5A2437Ff55ed7A8Cad3b797b3eC7c5a19B1c54",
14
- "DAI": "0xCE4166363E3a584DAc84A47bCD3414B43EfCDd1c",
15
- "WNEAR": "0xaE4fac24dCdAE0132C6d04f564dCf059616E9423",
16
- "STNEAR": "0x3195949f267702723bc614cAE037cdc8D1E94786",
17
- "AURORA": "0x8888682E24dd4Df7B7Ff2B91fccB575737E433bf",
18
- "TRI": "0x6Ea6C03061bDdCE23d4Ec60B6E6e880c33d24dca",
19
- "PLY": "0xC9011e629c9d0b8B1e4A2091e123fBB87B3A792c"
20
- },
21
- "fairLaunch": "0xC9A848AC73e378516B16E4EeBBa5ef6aFbC0BBc2",
22
- "auriLens": "0xFfdFfBDB966Cb84B50e62d70105f2Dbf2e0A1e70",
23
- "ethRepayHelper": "0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6",
24
- "configReader": "0x347B321c466663D6A0fE9C0ccfCF8cEa86F8ecD3",
25
- "auriAirdropImpl": "0x94cdA0Da833b384B901d33D5c56FccDE21D5E6e7",
26
- "auriAirdrop": "0x6C42aA5b128B62D6CCf357726D7d13F3888335EC",
27
- "ply_wnear_lp": "0x044b6B0CD3Bb13D2b9057781Df4459C66781dCe7",
28
- "PULP": "0x04Ac48711BCdc45b4d223fb021E09DA73c71095e",
29
- "plyTokenLock": "0x5715C45D2C82292D8e5961Eb5e2C66fe0Fc5412B",
30
- "test": {}
31
- }
@@ -1,31 +0,0 @@
1
- {
2
- "networkId": 1313161555,
3
- "deployer": "0x42D2D78Cc14e1B7D5e317B42e5335D8816B4Fd3F",
4
- "unitroller": "0x1626d7941DF19781657a921014597c449F86941e",
5
- "comptroller": "0x06200C8331193241e6487235C1E8a1340fcc9C1A",
6
- "ply": "0x84B5C41DC786316c5aA319B5A22CA77472e1d31f",
7
- "tokenLock": "0xc77E562C41ec3Ce860b5424758B77ad0aDb1bB93",
8
- "lens": "0x680e15080Df9ff61131499D21aa5Ca9Bd05E60e0",
9
- "fairLaunch": "0x4e91CdfeA23f44D4269E66494fe532867a0fAe5E",
10
- "oracle": "0xe0E2Bb669a75Ae2384371cB4c4c95ff6fC1581b0",
11
- "interestRateModel": "0x7346c735bce0c4838A917AFa9879F7723f1bB963",
12
- "auTokens": {
13
- "USDC": "0x1c7EB2ADdC2df2F28E9631cce970D2E2DF22429A",
14
- "ETH": "0xdaE860b77c26498e7Bd8e16Fb80AD572FaB9688f",
15
- "WBTC": "0x5329f32A9dDaC3d274Cc670B284561b0086D2244",
16
- "USDT": "0x57E15Bf9Bc4c8a7AFd3C8DBE153ED29eC90B68Fa",
17
- "DAI": "0xdCdA4c7eF408961200193d7180357AEC404C267A",
18
- "PLY": "0xa8474c18f502551937367120a6D8453dA785f1DD",
19
- "WNEAR": "0x2Db190F0Db94E78B87D805e022D2a07803652211"
20
- },
21
- "supportedTokens": {
22
- "USDC": "0x3dcB6AdF46E4d854E94719b6ed9cfab6939cC1Cb",
23
- "WBTC": "0x6fF98E346Ba4C56fBc3Ebc3f92477ffCe09D96AB",
24
- "USDT": "0x05b8777B6c280DB4E61CF0F63d59b4Ac8ec70538",
25
- "DAI": "0xd94951E6B276fD4327FFBD3253b6307d112403e2",
26
- "PLY": "0x84B5C41DC786316c5aA319B5A22CA77472e1d31f",
27
- "WNEAR": "0xb2cBCe33a6fb7D2efFb1cF73A654a4c0c9255874"
28
- },
29
- "PLY_AUR_LP": "",
30
- "faucet": "0x8F791d611D71699B76C03857A51D7B7E5E66f01E"
31
- }
File without changes
File without changes
File without changes
File without changes