@aurigami/sdk 1.24.0 → 1.24.2

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 (46) hide show
  1. package/dist/consts/constants.d.ts +3 -1
  2. package/dist/consts/constants.js +4 -2
  3. package/dist/entities/auriEnv.d.ts +2 -1
  4. package/dist/entities/auriEnv.js +3 -3
  5. package/dist/helpers/priceFetcher.js +9 -13
  6. package/dist/interactors/misc.js +2 -2
  7. package/package.json +2 -14
  8. package/src/SDK.ts +0 -223
  9. package/src/abis/index.ts +0 -38
  10. package/src/consts/constants.ts +0 -210
  11. package/src/consts/decimals.ts +0 -31
  12. package/src/consts/deployments.ts +0 -4
  13. package/src/consts/dummy.ts +0 -51
  14. package/src/consts/index.ts +0 -5
  15. package/src/consts/symbols.ts +0 -9
  16. package/src/entities/BlockchainEntity.ts +0 -29
  17. package/src/entities/auriEnv.ts +0 -180
  18. package/src/entities/index.ts +0 -4
  19. package/src/entities/token.ts +0 -21
  20. package/src/entities/tokenAmount.ts +0 -48
  21. package/src/helpers/aurigami-api.ts +0 -42
  22. package/src/helpers/aurora-api-helpers.ts +0 -17
  23. package/src/helpers/graphql-helpers.ts +0 -8
  24. package/src/helpers/helpers.ts +0 -212
  25. package/src/helpers/historicalPriceFetcher.ts +0 -200
  26. package/src/helpers/index.ts +0 -7
  27. package/src/helpers/kyber-aggregator-api.ts +0 -37
  28. package/src/helpers/multicall.ts +0 -251
  29. package/src/helpers/notification-api.ts +0 -22
  30. package/src/helpers/one-inch-aggregator-api.ts +0 -45
  31. package/src/helpers/priceFetcher.ts +0 -388
  32. package/src/helpers/subgraphQuery.ts +0 -17
  33. package/src/helpers/transfer-event-query.ts +0 -68
  34. package/src/index.ts +0 -14
  35. package/src/interactors/Airdrop.ts +0 -72
  36. package/src/interactors/MoneyMarket.ts +0 -486
  37. package/src/interactors/Multicall.ts +0 -50
  38. package/src/interactors/Papermill.ts +0 -185
  39. package/src/interactors/PlyGame.ts +0 -172
  40. package/src/interactors/PlyTokenLock.ts +0 -46
  41. package/src/interactors/Pulp.ts +0 -41
  42. package/src/interactors/Referral.ts +0 -214
  43. package/src/interactors/Staking.ts +0 -156
  44. package/src/interactors/index.ts +0 -9
  45. package/src/interactors/misc.ts +0 -433
  46. package/src/types/index.ts +0 -252
@@ -1,210 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { BigNumber as BN } from 'ethers';
3
- import { MAINNET_ADDRESSES } from './deployments';
4
- export const dummyAddress: string = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
5
- export const ETHAddress: string = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
6
-
7
- export const AURORA_CHAINID = 1313161554;
8
-
9
- export const DECIMAL_PRECISION = 10;
10
-
11
- export const AURORA_PLUS_API_PREFIX = 'https://aurora.plus/api/wallet/';
12
-
13
- export const networkAddresses = {
14
- auTokens: [
15
- {
16
- name: 'auUSDC',
17
- address: MAINNET_ADDRESSES.auTokens.USDC.toLowerCase(),
18
- underlying: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
19
- },
20
- {
21
- name: 'auETH',
22
- address: MAINNET_ADDRESSES.auTokens.ETH.toLowerCase(),
23
- underlying: ETHAddress.toLowerCase(),
24
- },
25
- {
26
- name: 'auWBTC',
27
- address: MAINNET_ADDRESSES.auTokens.WBTC.toLowerCase(),
28
- underlying: '0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase(),
29
- },
30
- {
31
- name: 'auUSDT',
32
- address: MAINNET_ADDRESSES.auTokens.USDT.toLowerCase(),
33
- underlying: '0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase(),
34
- },
35
- {
36
- name: 'auDAI',
37
- address: MAINNET_ADDRESSES.auTokens.DAI.toLowerCase(),
38
- underlying: '0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase(),
39
- },
40
- {
41
- name: 'auWNEAR',
42
- address: MAINNET_ADDRESSES.auTokens.WNEAR.toLowerCase(),
43
- underlying: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
44
- },
45
- {
46
- name: 'auSTNEAR',
47
- address: MAINNET_ADDRESSES.auTokens.STNEAR.toLowerCase(),
48
- underlying: '0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30'.toLowerCase(),
49
- },
50
- {
51
- name: 'auAURORA',
52
- address: MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(),
53
- underlying: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
54
- },
55
- {
56
- name: 'auTRI',
57
- address: MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(),
58
- underlying: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
59
- },
60
- {
61
- name: 'auPLY',
62
- address: MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(),
63
- underlying: '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
64
- },
65
- {
66
- name: 'auUSN',
67
- address: MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
68
- underlying: '0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
69
- },
70
- {
71
- name: 'auNEARX',
72
- address: MAINNET_ADDRESSES.auTokens.NEARX.toLowerCase(),
73
- underlying: '0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase(),
74
- },
75
- {
76
- name: 'auUSDCNative',
77
- address: MAINNET_ADDRESSES.auTokens.USDC_NATIVE.toLowerCase(),
78
- underlying: '0x368ebb46aca6b8d0787c96b2b20bd3cc3f2c45f7'.toLowerCase(),
79
- },
80
- {
81
- name: 'auUSDTNative',
82
- address: MAINNET_ADDRESSES.auTokens.USDT_NATIVE.toLowerCase(),
83
- underlying: '0x80da25da4d783e57d2fcda0436873a193a4beccf'.toLowerCase(),
84
- },
85
- ],
86
- misc: {
87
- COMPTROLLER: MAINNET_ADDRESSES.comptroller.toLowerCase(),
88
- DEPRECATED_OLD_ORACLE: MAINNET_ADDRESSES.oracle.toLowerCase(),
89
- PYTH_ORACLE: MAINNET_ADDRESSES.pythOracle.toLowerCase(),
90
- AURIFAIRLAUNCH: MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
91
- AURILENS: MAINNET_ADDRESSES.auriLens.toLowerCase(),
92
- ETHREPAYHELPER: MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
93
- AURI_AIRDROP: MAINNET_ADDRESSES.auriAirdropMultipleRedeem.toLowerCase(),
94
- MULTICALL: MAINNET_ADDRESSES.multicall.toLowerCase(),
95
- TEAM_MULTISIG: '0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE'.toLowerCase(),
96
- TEAM_MULTISIG_AURORA_PLUS: '0x31f501589c7a090bf68f2fe2687744bf9130e1ab'.toLowerCase(),
97
- AURORA_PLUS: '0xf075c896cbbb625e7911e284cd23ee19bdccf299'.toLowerCase(),
98
- PULP_CONTRACT: '0x04ac48711bcdc45b4d223fb021e09da73c71095e'.toLowerCase(),
99
- PLY_TOKEN_LOCK: MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
100
- REFERRAL: MAINNET_ADDRESSES.referralDirectory.toLowerCase(),
101
- REFERRAL_V2: '0xCECd147409B2d64A9A2E5418e3E471E8af19E0bd'.toLowerCase(),
102
- AURI_INTERNAL_LENS: MAINNET_ADDRESSES.auriInternalLens.toLowerCase(),
103
- PLYGAME: MAINNET_ADDRESSES.plyGame.toLowerCase(),
104
- },
105
- tokens: {
106
- AURORA: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
107
- PLY: '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
108
- stNEAR: '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30'.toLowerCase(),
109
- USDC: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
110
- WNEAR: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
111
- TRI: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
112
- META: '0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLowerCase(),
113
- PULP: MAINNET_ADDRESSES.PULP.toLowerCase(),
114
- PLYWNEAR: MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
115
- USN: '0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
116
- PLY_WNEAR: '0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
117
- WNEAR_TRI: '0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
118
- AURORA_WNEAR: '0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase(),
119
- NEARX: '0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase(),
120
- STADER: '0x078e103d5f9629ac48b8563fa2bfcd2f6d5fde84'.toLowerCase(),
121
- USDC_NATIVE: '0x368ebb46aca6b8d0787c96b2b20bd3cc3f2c45f7'.toLowerCase(),
122
- USDT_NATIVE: '0x80da25da4d783e57d2fcda0436873a193a4beccf'.toLowerCase(),
123
- },
124
- } as const;
125
-
126
- export const DEPOSIT_ONLY_TOKENS = [
127
- MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(),
128
- MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(),
129
- MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(),
130
- MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
131
- ];
132
-
133
- // All token that we can calculate the price via oracle + coingecko
134
- export const PRICE_WHITELISTED = new Set([
135
- ...networkAddresses.auTokens.map((t) => t.underlying),
136
- networkAddresses.tokens.AURORA,
137
- networkAddresses.tokens.TRI,
138
- networkAddresses.tokens.META,
139
- networkAddresses.tokens.stNEAR,
140
- networkAddresses.tokens.STADER,
141
- ]);
142
-
143
- export const REWARD_CLAIM_START = 1651759200; // Thursday, 5 May 2022 14:00:00 UTC
144
-
145
- export const BORROW_LIMIT_BUFFER = new BigNumber(1);
146
-
147
- export const ONE_DAY = 86400;
148
- export const ONE_WEEK = ONE_DAY * 7;
149
- export const ONE_YEAR = ONE_DAY * 365;
150
-
151
- export const PLYWNEAR_POOL_ID = 0;
152
- export const PLYWNEAR_REWARD_TOKENS = [
153
- '0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', // PLY
154
- '0x04Ac48711BCdc45b4d223fb021E09DA73c71095e', // PULP
155
- '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', // WNEAR
156
- '0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30', // STNEAR
157
- '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', // AURORA
158
- '0xFa94348467f64D5A457F75F8bc40495D33c65aBB', // TRI
159
- ];
160
- // could call RPC to get all the staking pools but it's not necessary for now
161
- export const ALL_STAKING_POOLS: number[] = [PLYWNEAR_POOL_ID];
162
- export const INF = BN.from(2).pow(256).sub(1);
163
-
164
- export const AIRDROP_START_TIMESTAMP = 1649858400;
165
- export const AIRDROP_END_TIMESTAMP = 1651068000;
166
- export const AIRDROP_KEEP_THRESHOLD = 7 * 86400;
167
-
168
- export const DEPOSIT_NEAR_REWARDS_PER_WEEK: { [k: string]: string } = Object.fromEntries(
169
- // lower case all addresses
170
- Object.entries({
171
- '0xb12bfca5a55806aaf64e99521918a4bf0fc40802': '36375', // USDC
172
- '0x4988a896b1227218e4a686fde5eabdcabd91571f': '14550', // USDT
173
- '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': '3638', // WBTC
174
- '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE': '14550', // ETH
175
- '0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': '3638', // WNEAR
176
- }).map(([k, v]) => [k.toLowerCase(), v])
177
- );
178
-
179
- export const BORROW_NEAR_REWARDS_PER_WEEK: { [k: string]: string } = {
180
- // currently 0 for all markets
181
- };
182
-
183
- export const HARDCODE_PRICE_TOKENS: { [k: string]: string } = Object.fromEntries([
184
- [networkAddresses.tokens.USN.toLowerCase(), '1'],
185
- ]);
186
-
187
- export const REFERRAL_CAMPAIGNS: { [k: string]: { start: number; end: number } } =
188
- Object.fromEntries([
189
- ['referral-2505', { start: 1652882400, end: 1653487199 }],
190
- ['referrer-2505', { start: 1652882400, end: 1653487199 }],
191
- ['referral-0106', { start: 1653487200, end: 1654091999 }],
192
- ['referrer-0106', { start: 1653487200, end: 1654091999 }],
193
- ['referral-0806', { start: 1654092000, end: 1654696799 }],
194
- ['referrer-0806', { start: 1654092000, end: 1654696799 }],
195
- ['referral-1506', { start: 1654696800, end: 1655301599 }],
196
- ['referrer-1506', { start: 1654696800, end: 1655301599 }],
197
- ]);
198
-
199
- export const CACHE_TIMEOUT = 10 * 1000; // 10 seconds
200
-
201
- export const SD_INCENTIVE_IN_SD = 83.35;
202
-
203
- export const STADER_ETH = '0x30D20208d987713f46DFD34EF128Bb16C404D10f'.toLowerCase();
204
-
205
- export const USDT_ETH = '0xdAC17F958D2ee523a2206206994597C13D831ec7'.toLowerCase();
206
-
207
- export const AURIGAMI_SUBGRAPH_URL =
208
- 'https://api.thegraph.com/subgraphs/name/takao-aurigami/aurigami-feb-27';
209
-
210
- export const GRAPHQL_URL = 'https://old.explorer.aurora.dev/api/v1/graphql';
@@ -1,31 +0,0 @@
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
- '0x5183e1b1091804bc2602586919e6880ac1cf2896': 18, // USN
25
- '0x84b123875f0f36b966d0b6ca14b31121bd9676ad': 18, // WNEAR_TRI,
26
- '0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18, // AURORA_WNEAR
27
- '0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375': 24, // NEARX
28
- '0x078e103d5f9629ac48b8563fa2bfcd2f6d5fde84': 18, // STADER
29
- '0x80da25da4d783e57d2fcda0436873a193a4beccf': 6, // decimals for USDT_NATIVE
30
- '0x368ebb46aca6b8d0787c96b2b20bd3cc3f2c45f7': 6, // decimals for USDC_NATIVE
31
- };
@@ -1,4 +0,0 @@
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 };
@@ -1,51 +0,0 @@
1
- import { Token, TokenAmount } from '../entities';
2
- import { ReferralReward, UserMarketDetails } from '../types';
3
- import { networkAddresses } from './constants';
4
-
5
- export const dummyToken = new Token(networkAddresses.tokens.WNEAR, 24);
6
-
7
- export const dummyPly = new Token('0x8729438eb15e2c8b576fcc6aecda6a148776c0f5', 18);
8
-
9
- export const dummyPlyAurora = new Token('0xE530dC2095Ef5653205CF5ea79F8979a7028065c', 18);
10
-
11
- export const dummyTokenAmount = new TokenAmount(dummyToken, '123.456', false);
12
-
13
- export const dummyZeroTokenAmount = new TokenAmount(dummyToken, '0');
14
-
15
- export const dummyTokenAmount2 = new TokenAmount(dummyToken, '456.123', false);
16
-
17
- export const dummyTokenAmount3 = new TokenAmount(dummyToken, '1000.123', false);
18
-
19
- export const dummyMarketAddress = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f'; // qiUSDC
20
-
21
- export const dummyUserMarketDetails: UserMarketDetails = {
22
- market: dummyMarketAddress,
23
- depositBalance: dummyTokenAmount2,
24
- borrowBalance: dummyZeroTokenAmount,
25
- isCollateral: true,
26
- maxWithdrawableAmount: dummyTokenAmount,
27
- collateralRatio: 0.5,
28
- underlyingPrice: '1',
29
- };
30
-
31
- export const referralRewardDummy1: ReferralReward = {
32
- campaign: 'testa',
33
- startTime: Math.trunc(new Date(2022, 8, 1).getTime() / 1000),
34
- endTime: Math.trunc(new Date(2022, 9, 30).getTime() / 1000),
35
- isReferrer: false,
36
- rewardTokenAmount: dummyTokenAmount,
37
- transactionHash: null,
38
- userAddr: '0x...123',
39
- refereeAddress: '0x123..123',
40
- };
41
-
42
- export const referralRewardDummy2: ReferralReward = {
43
- campaign: 'testb',
44
- startTime: Math.trunc(new Date(2022, 8, 1).getTime() / 1000),
45
- endTime: Math.trunc(new Date(2022, 8, 31).getTime() / 1000),
46
- isReferrer: true,
47
- rewardTokenAmount: dummyTokenAmount2,
48
- transactionHash: '0x4da9657663b46ef18d150b897b28c7b717f16421978b52e3a06d91b54ca3548b',
49
- userAddr: '0x...456',
50
- refereeAddress: '0x123..123',
51
- };
@@ -1,5 +0,0 @@
1
- export * from './constants';
2
- export * from './decimals';
3
- export * from './deployments';
4
- export * from './dummy';
5
- export * from './symbols';
@@ -1,9 +0,0 @@
1
- import { networkAddresses } from './constants';
2
-
3
- export const symbolRecords: Record<string, string> = Object.fromEntries(
4
- networkAddresses.auTokens
5
- .map((e) => [e.address, e.name]) // AuToken
6
- .concat(networkAddresses.auTokens.map((e) => [e.underlying, e.name.slice(2)])) // underlying token
7
- .concat([['0x04ac48711bcdc45b4d223fb021e09da73c71095e', 'PULP']]) // others
8
- .map(([address, name]) => [address.toLowerCase(), name])
9
- );
@@ -1,29 +0,0 @@
1
- import { Signer } from '@ethersproject/abstract-signer';
2
- import { NetworkConnection } from '../types';
3
-
4
- export class BlockchainEntityRead {
5
- protected _networkConnection: NetworkConnection;
6
- public constructor(networkConnection: NetworkConnection) {
7
- this._networkConnection = networkConnection;
8
- }
9
- }
10
-
11
- export class BlockchainEntityReadWrite extends BlockchainEntityRead {
12
- public constructor(networkConnection: NetworkConnection) {
13
- if (!(networkConnection.signer instanceof Signer)) {
14
- throw Error('Signer is not provided when constructing BlockchainEntityReadWrite');
15
- }
16
- super(networkConnection);
17
- }
18
- }
19
-
20
- export class BlockchainEntity {
21
- constructor() {}
22
- public read(networkConnection: NetworkConnection): BlockchainEntityRead {
23
- return new BlockchainEntityRead(networkConnection);
24
- }
25
-
26
- public readWrite(networkConnection: NetworkConnection): BlockchainEntityReadWrite {
27
- return new BlockchainEntityReadWrite(networkConnection);
28
- }
29
- }
@@ -1,180 +0,0 @@
1
- import {
2
- AuErc20,
3
- AuToken,
4
- AuriAirdrop,
5
- AuriFairLaunch,
6
- AuriInternalLens,
7
- AuriLens,
8
- AuriOracle,
9
- Comptroller,
10
- IERC20,
11
- PULP,
12
- PlyGame,
13
- PlyTokenLock,
14
- ReferralDirectoryV2,
15
- } from '@aurigami/contracts/typechain';
16
- import { Contract } from 'ethers';
17
- import * as abis from '../abis';
18
- import { networkAddresses } from '../consts/constants';
19
- import { assert } from '../helpers/helpers';
20
- import { createContract } from '../helpers/multicall';
21
- import { AuTokenWithUnderlying, MulticallStatic } from '../types';
22
- import { BlockchainEntityRead } from './BlockchainEntity';
23
-
24
- export class AuriEnv extends BlockchainEntityRead {
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;
36
-
37
- public getContract<CType extends Contract>(address: string, abi: any) {
38
- return createContract<CType>(address, abi, this._networkConnection.provider);
39
- }
40
-
41
- public getAuTokenContracts(): AuTokenWithUnderlying[] {
42
- return networkAddresses.auTokens.map((auToken) => {
43
- const contract = this.getContract<AuToken>(
44
- auToken.address,
45
- abis.AuTokenABI.abi
46
- ) as AuTokenWithUnderlying;
47
- contract.underlying = auToken.underlying;
48
- return contract;
49
- });
50
- }
51
-
52
- /**
53
- * Get AuErc20 contract by its address or underlying name.
54
- *
55
- * Either address or underlyingName must be provided
56
- *
57
- */
58
- public getAuErc20Contract({
59
- address,
60
- underlyingName,
61
- }: {
62
- address?: string;
63
- underlyingName?: string;
64
- }) {
65
- assert(
66
- address !== undefined || underlyingName !== undefined,
67
- 'Either address or underlyingName must be provided'
68
- );
69
-
70
- if (underlyingName) {
71
- address = networkAddresses.auTokens.find(
72
- (auToken) => auToken.name == 'au' + underlyingName
73
- )?.address;
74
- assert(address !== undefined, `AuToken with underlying ${underlyingName} not found`);
75
- }
76
-
77
- return this.getContract<AuErc20>(address!, abis.AuErc20ABI.abi);
78
- }
79
-
80
- get comptroller() {
81
- if (!this._comptroller) {
82
- this._comptroller = this.getContract<Comptroller>(
83
- networkAddresses.misc.COMPTROLLER,
84
- abis.ComptrollerABI.abi
85
- );
86
- }
87
- return this._comptroller;
88
- }
89
-
90
- get auriFairLaunch() {
91
- if (!this._auriFairLaunch) {
92
- this._auriFairLaunch = this.getContract<AuriFairLaunch>(
93
- networkAddresses.misc.AURIFAIRLAUNCH,
94
- abis.AuriFairLaunchABI.abi
95
- );
96
- }
97
- return this._auriFairLaunch;
98
- }
99
-
100
- get auriLens() {
101
- if (!this._auriLens) {
102
- this._auriLens = this.getContract<AuriLens>(
103
- networkAddresses.misc.AURILENS,
104
- abis.AuriLensABI.abi
105
- );
106
- }
107
- return this._auriLens;
108
- }
109
-
110
- get ply() {
111
- if (!this._ply) {
112
- this._ply = this.getContract<IERC20>(networkAddresses.tokens.PLY, abis.EIP20InterfaceABI.abi);
113
- }
114
- return this._ply;
115
- }
116
-
117
- get pulp() {
118
- if (!this._pulp) {
119
- this._pulp = this.getContract<PULP>(networkAddresses.tokens.PULP, abis.PulpABI.abi);
120
- }
121
- return this._pulp;
122
- }
123
-
124
- get auriInternalLens() {
125
- if (!this._auriInternalLens) {
126
- this._auriInternalLens = this.getContract<AuriInternalLens>(
127
- networkAddresses.misc.AURI_INTERNAL_LENS,
128
- abis.AuriInternalLensABI.abi
129
- );
130
- }
131
- return this._auriInternalLens;
132
- }
133
-
134
- get auriAirdrop() {
135
- if (!this._auriAirdrop) {
136
- this._auriAirdrop = this.getContract<AuriAirdrop>(
137
- networkAddresses.misc.AURI_AIRDROP,
138
- abis.AuriAirdropABI.abi
139
- );
140
- }
141
- return this._auriAirdrop;
142
- }
143
-
144
- get referralDirectoryV2() {
145
- if (!this._referralDirectoryV2) {
146
- this._referralDirectoryV2 = this.getContract<ReferralDirectoryV2>(
147
- networkAddresses.misc.REFERRAL_V2,
148
- abis.ReferralDirectoryV2ABI.abi
149
- );
150
- }
151
- return this._referralDirectoryV2;
152
- }
153
-
154
- get oracle() {
155
- if (!this._oracle) {
156
- this._oracle = this.getContract<AuriOracle>(
157
- networkAddresses.misc.PYTH_ORACLE,
158
- abis.AuriOracleABI.abi
159
- );
160
- }
161
- return this._oracle;
162
- }
163
-
164
- get plygame() {
165
- if (!this._plygame) {
166
- this._plygame = this.getContract<PlyGame>(networkAddresses.misc.PLYGAME, abis.PlyGameABI.abi);
167
- }
168
- return this._plygame;
169
- }
170
-
171
- get plyTokenLock() {
172
- if (!this._plyTokenLock) {
173
- this._plyTokenLock = this.getContract<PlyTokenLock>(
174
- networkAddresses.misc.PLY_TOKEN_LOCK,
175
- abis.PlyTokenLockABI.abi
176
- );
177
- }
178
- return this._plyTokenLock;
179
- }
180
- }
@@ -1,4 +0,0 @@
1
- export * from './auriEnv';
2
- export * from './BlockchainEntity';
3
- export * from './token';
4
- export * from './tokenAmount';
@@ -1,21 +0,0 @@
1
- import { networkAddresses } from '../consts/constants';
2
- import { getDecimal } from '../helpers/helpers';
3
-
4
- export class Token {
5
- public readonly address: string;
6
- public readonly decimals: number;
7
- public constructor(address: string, decimals: number) {
8
- this.address = address.toLowerCase();
9
- this.decimals = decimals;
10
- }
11
- }
12
-
13
- export const PLYToken = new Token(
14
- networkAddresses.tokens.PLY,
15
- getDecimal(networkAddresses.tokens.PLY)
16
- );
17
-
18
- export const PLYWNEARToken = new Token(
19
- networkAddresses.tokens.PLYWNEAR,
20
- getDecimal(networkAddresses.tokens.PLYWNEAR)
21
- );
@@ -1,48 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- import { decimalFactor, getDecimal, getSymbol } from '../helpers/helpers';
3
- import { Address } from '../types';
4
- import { Token } from './token';
5
-
6
- export class TokenAmount {
7
- public readonly token: Token;
8
- private rawAmnt: string;
9
-
10
- public constructor(token: Token, amount: string, isRaw: boolean = true) {
11
- if (isRaw) {
12
- this.rawAmnt = amount;
13
- } else {
14
- this.rawAmnt = new BigNumber(amount).times(decimalFactor(token.decimals)).toFixed(0);
15
- }
16
- this.token = token;
17
- }
18
-
19
- public formattedAmount(decimal?: number, fmt?: BigNumber.Format): string {
20
- if (decimal !== undefined && fmt !== undefined) {
21
- return new BigNumber(this.rawAmnt)
22
- .div(decimalFactor(this.token.decimals))
23
- .toFormat(decimal, fmt);
24
- }
25
-
26
- return new BigNumber(this.rawAmnt).div(decimalFactor(this.token.decimals)).toString();
27
- }
28
-
29
- public formattedAmountWithSymbol(decimal?: number, fmt?: BigNumber.Format): string {
30
- return `${this.formattedAmount(decimal, fmt)} ${getSymbol(this.token.address)}`;
31
- }
32
-
33
- public rawAmount(): string {
34
- return this.rawAmnt;
35
- }
36
-
37
- public compare(other: TokenAmount): number {
38
- return new BigNumber(this.rawAmnt).comparedTo(new BigNumber(other.rawAmnt));
39
- }
40
-
41
- public static fromAddressAndAmount(
42
- tokenAddress: Address,
43
- amount: string,
44
- isRaw: boolean = true
45
- ): TokenAmount {
46
- return new TokenAmount(new Token(tokenAddress, getDecimal(tokenAddress)), amount, isRaw);
47
- }
48
- }
@@ -1,42 +0,0 @@
1
- import axios from 'axios';
2
-
3
- const AURIGAMI_API_END_POINT = 'https://api.aurigami.finance/app/';
4
-
5
- export async function getApi(url: string, params: Record<string, any> = {}): Promise<any> {
6
- const resp = await axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
7
- headers: { 'Content-Type': 'application/json' },
8
- });
9
-
10
- return resp.data;
11
- }
12
-
13
- export type MetaApiResponse = {
14
- totalItems: number;
15
- itemCount: number;
16
- itemsPerPage: number;
17
- totalPages: number;
18
- currentPage: number;
19
- };
20
-
21
- export type PaginagedApiResponse<T> = {
22
- items: T[];
23
- meta: MetaApiResponse;
24
- };
25
-
26
- export async function getPaginatedApi<T = any>(
27
- url: string,
28
- params: Record<string, any> = {},
29
- page: number = 1,
30
- pageSize: number = 50
31
- ): Promise<PaginagedApiResponse<T>> {
32
- params = {
33
- ...params,
34
- page,
35
- limit: pageSize,
36
- };
37
- const resp = await axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
38
- headers: { 'Content-Type': 'application/json' },
39
- });
40
-
41
- return resp.data;
42
- }
@@ -1,17 +0,0 @@
1
- import axios from 'axios';
2
-
3
- const AURORA_API_BASE_URL = 'https://explorer.mainnet.aurora.dev/api';
4
-
5
- export async function getQuery(
6
- module: string,
7
- action: string,
8
- params: Record<string, any> = {}
9
- ): Promise<any> {
10
- params = { ...params, module: module, action: action };
11
-
12
- let resp = await axios.get(AURORA_API_BASE_URL + '?' + new URLSearchParams(params), {
13
- headers: { 'Content-Type': 'application/json' },
14
- });
15
-
16
- return resp.data.result!;
17
- }
@@ -1,8 +0,0 @@
1
- import axios from 'axios';
2
-
3
- export async function queryGraphQL(query: string, graphqlUrl: string): Promise<any> {
4
- let resp = await axios.post(graphqlUrl, {
5
- query: query,
6
- });
7
- return resp.data.data!;
8
- }