@aurigami/sdk 1.4.8 → 1.5.0-dummy-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.
- package/dist/MoneyMarket.d.ts +2 -2
- package/dist/Papermill.d.ts +31 -0
- package/dist/SDK.d.ts +6 -7
- package/dist/airdrop-lottery.d.ts +4 -4
- package/dist/constants.d.ts +6 -2
- package/dist/helpers.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/priceFetcher.d.ts +6 -4
- package/dist/sdk.cjs.development.js +700 -270
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +690 -268
- package/dist/sdk.esm.js.map +1 -1
- package/dist/token.d.ts +1 -1
- package/dist/tokenAmount.d.ts +1 -1
- package/dist/transfer-event-query.d.ts +4 -4
- package/dist/types.d.ts +13 -9
- package/package.json +5 -11
- package/src/BlockchainEntity.ts +6 -2
- package/src/MoneyMarket.ts +317 -105
- package/src/Papermill.ts +243 -0
- package/src/SDK.ts +307 -147
- package/src/airdrop-lottery.ts +293 -248
- package/src/aurora-api-helpers.ts +11 -6
- package/src/constants.ts +82 -60
- package/src/decimals.ts +5 -3
- package/src/dummy.ts +17 -23
- package/src/helpers.ts +45 -26
- package/src/index.ts +2 -1
- package/src/priceFetcher.ts +256 -103
- package/src/token.ts +16 -16
- package/src/tokenAmount.ts +21 -21
- package/src/transfer-event-query.ts +64 -54
- package/src/types.ts +39 -19
package/src/constants.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { ethers, Signer, BigNumber as BN} from 'ethers';
|
|
3
|
-
export const dummyAddress: string =
|
|
4
|
-
|
|
2
|
+
import { ethers, Signer, BigNumber as BN } from 'ethers';
|
|
3
|
+
export const dummyAddress: string =
|
|
4
|
+
'0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
|
|
5
|
+
export const ETHAddress: string = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
5
6
|
|
|
6
7
|
export const AURORA_CHAINID = 1313161554;
|
|
7
8
|
|
|
@@ -9,108 +10,129 @@ export const DECIMAL_PRECISION = 10;
|
|
|
9
10
|
|
|
10
11
|
export type NetworkAddresses = {
|
|
11
12
|
auTokens: {
|
|
12
|
-
name: string
|
|
13
|
-
address: string
|
|
14
|
-
underlying: string
|
|
15
|
-
}[]
|
|
16
|
-
misc: Record<string, string
|
|
17
|
-
tokens: Record<string, string
|
|
18
|
-
}
|
|
13
|
+
name: string;
|
|
14
|
+
address: string;
|
|
15
|
+
underlying: string;
|
|
16
|
+
}[];
|
|
17
|
+
misc: Record<string, string>;
|
|
18
|
+
tokens: Record<string, string>;
|
|
19
|
+
};
|
|
19
20
|
export const networkAddresses: NetworkAddresses = {
|
|
20
21
|
auTokens: [
|
|
21
22
|
{
|
|
22
|
-
name:
|
|
23
|
+
name: 'auUSDC',
|
|
23
24
|
address: '0x4f0d864b1ABf4B701799a0b30b57A22dFEB5917b'.toLowerCase(),
|
|
24
|
-
underlying: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
|
|
25
|
+
underlying: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
|
|
25
26
|
},
|
|
26
27
|
{
|
|
27
|
-
name:
|
|
28
|
+
name: 'auETH',
|
|
28
29
|
address: '0xca9511B610bA5fc7E311FDeF9cE16050eE4449E9'.toLowerCase(),
|
|
29
|
-
underlying: ETHAddress.toLowerCase()
|
|
30
|
+
underlying: ETHAddress.toLowerCase(),
|
|
30
31
|
},
|
|
31
32
|
{
|
|
32
|
-
name:
|
|
33
|
+
name: 'auWBTC',
|
|
33
34
|
address: '0xCFb6b0498cb7555e7e21502E0F449bf28760Adbb'.toLowerCase(),
|
|
34
|
-
underlying: '0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
|
|
35
|
+
underlying: '0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase(),
|
|
35
36
|
},
|
|
36
37
|
{
|
|
37
|
-
name:
|
|
38
|
+
name: 'auUSDT',
|
|
38
39
|
address: '0xaD5A2437Ff55ed7A8Cad3b797b3eC7c5a19B1c54'.toLowerCase(),
|
|
39
|
-
underlying: '0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
|
|
40
|
+
underlying: '0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase(),
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
|
-
name:
|
|
43
|
+
name: 'auDAI',
|
|
43
44
|
address: '0xCE4166363E3a584DAc84A47bCD3414B43EfCDd1c'.toLowerCase(),
|
|
44
|
-
underlying: '0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
|
|
45
|
+
underlying: '0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase(),
|
|
45
46
|
},
|
|
46
47
|
{
|
|
47
|
-
name:
|
|
48
|
+
name: 'auWNEAR',
|
|
48
49
|
address: '0xaE4fac24dCdAE0132C6d04f564dCf059616E9423'.toLowerCase(),
|
|
49
|
-
underlying: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
|
|
50
|
+
underlying: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
|
|
50
51
|
},
|
|
51
52
|
{
|
|
52
|
-
name:
|
|
53
|
-
address:
|
|
54
|
-
underlying: '0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30'.toLowerCase()
|
|
53
|
+
name: 'auSTNEAR',
|
|
54
|
+
address: '0x3195949f267702723bc614cAE037cdc8D1E94786'.toLowerCase(),
|
|
55
|
+
underlying: '0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30'.toLowerCase(),
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
|
-
name:
|
|
58
|
-
address:
|
|
59
|
-
underlying:
|
|
58
|
+
name: 'auAURORA',
|
|
59
|
+
address: '0x8888682E24dd4Df7B7Ff2B91fccB575737E433bf'.toLowerCase(),
|
|
60
|
+
underlying: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
|
-
name:
|
|
63
|
-
address:
|
|
64
|
-
underlying:
|
|
65
|
-
}
|
|
63
|
+
name: 'auTRI',
|
|
64
|
+
address: '0x6Ea6C03061bDdCE23d4Ec60B6E6e880c33d24dca'.toLowerCase(),
|
|
65
|
+
underlying: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
|
|
66
|
+
},
|
|
66
67
|
],
|
|
67
68
|
misc: {
|
|
68
|
-
COMPTROLLER:
|
|
69
|
-
oracle:
|
|
70
|
-
AURIFAIRLAUNCH:
|
|
69
|
+
COMPTROLLER: '0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb'.toLowerCase(),
|
|
70
|
+
oracle: '0xC6e5185438e1730959c1eF3551059A3feC744E90'.toLowerCase(),
|
|
71
|
+
AURIFAIRLAUNCH: '0x6f068608573c840bB27b39458d7d87eB865e19Cc'.toLowerCase(),
|
|
71
72
|
AURILENS: '0xFfdFfBDB966Cb84B50e62d70105f2Dbf2e0A1e70'.toLowerCase(),
|
|
72
73
|
TOKENLOCK: '0xDACC02a4Ff16Ea3c1515AdbfdCeb7B1F448B79c8'.toLowerCase(),
|
|
73
|
-
ETHREPAYHELPER:
|
|
74
|
-
AURI_AIRDROP:
|
|
74
|
+
ETHREPAYHELPER: '0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6'.toLowerCase(),
|
|
75
|
+
AURI_AIRDROP: '0x6C42aA5b128B62D6CCf357726D7d13F3888335EC'.toLowerCase(),
|
|
75
76
|
},
|
|
76
77
|
tokens: {
|
|
77
|
-
AURORA:
|
|
78
|
-
PLY:
|
|
79
|
-
stNEAR:
|
|
78
|
+
AURORA: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
|
|
79
|
+
PLY: '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
|
|
80
|
+
stNEAR: '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30'.toLowerCase(),
|
|
80
81
|
USDC: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
|
|
81
82
|
WNEAR: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
|
|
82
83
|
TRI: '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
|
|
83
84
|
META: '0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
85
|
+
PULP: '0x04Ac48711BCdc45b4d223fb021E09DA73c71095e'.toLowerCase(),
|
|
86
|
+
PLYUSDC: '0x37cae2b29c18e05ece60111fa01d3ca217046016'.toLowerCase(),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
// All token that we can calculate the price via oracle + coingecko
|
|
91
|
+
export const PRICE_WHITELISTED = new Set([
|
|
92
|
+
...networkAddresses.auTokens.map((t) => t.underlying),
|
|
93
|
+
networkAddresses.tokens.AURORA,
|
|
94
|
+
networkAddresses.tokens.TRI,
|
|
95
|
+
networkAddresses.tokens.META,
|
|
96
|
+
networkAddresses.tokens.stNEAR,
|
|
97
|
+
]);
|
|
89
98
|
|
|
90
|
-
export const
|
|
99
|
+
export const REWARD_CLAIM_START = 1651762800; // 5 May 2022 15:00:00 UTC
|
|
100
|
+
|
|
101
|
+
export const BORROW_LIMIT_BUFFER = new BigNumber(1);
|
|
91
102
|
|
|
92
103
|
export const ONE_DAY = 86400;
|
|
104
|
+
export const ONE_WEEK = ONE_DAY * 7;
|
|
93
105
|
export const ONE_YEAR = ONE_DAY * 365;
|
|
94
106
|
|
|
95
|
-
export const
|
|
96
|
-
export const
|
|
97
|
-
|
|
107
|
+
export const PlyUsdcPid = 0;
|
|
108
|
+
export const PLYUSDCRewardTokens = [
|
|
109
|
+
'0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', // PLY
|
|
110
|
+
'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', // WNEAR
|
|
111
|
+
'0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', // AURORA
|
|
112
|
+
'0xFa94348467f64D5A457F75F8bc40495D33c65aBB', // TRI
|
|
113
|
+
];
|
|
114
|
+
// could call RPC to get all the staking pools but it's not necessary for now
|
|
115
|
+
// export const ALL_STAKING_POOLS = [PlyUsdcPid];
|
|
116
|
+
// TODO: fix this
|
|
117
|
+
export const ALL_STAKING_POOLS = [];
|
|
118
|
+
export const INF = BN.from(2).pow(256).sub(1);
|
|
98
119
|
|
|
99
120
|
export const AIRDROP_START_TIMESTAMP = 1649858400;
|
|
100
121
|
export const AIRDROP_END_TIMESTAMP = 1651068000;
|
|
101
122
|
export const AIRDROP_KEEP_THRESHOLD = 7 * 86400;
|
|
102
123
|
|
|
103
|
-
export const DEPOSIT_NEAR_REWARDS_PER_WEEK: {[k
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
124
|
+
export const DEPOSIT_NEAR_REWARDS_PER_WEEK: { [k: string]: string } =
|
|
125
|
+
Object.fromEntries(
|
|
126
|
+
// lower case all addresses
|
|
127
|
+
Object.entries({
|
|
128
|
+
'0xb12bfca5a55806aaf64e99521918a4bf0fc40802': '36375', // USDC
|
|
129
|
+
'0x4988a896b1227218e4a686fde5eabdcabd91571f': '14550', // USDT
|
|
130
|
+
'0xf4eb217ba2454613b15dbdea6e5f22276410e89e': '3638', // WBTC
|
|
131
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE': '14550', // ETH
|
|
132
|
+
'0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': '3638', // WNEAR
|
|
133
|
+
}).map(([k, v]) => [k.toLowerCase(), v])
|
|
134
|
+
);
|
|
113
135
|
|
|
114
|
-
export const BORROW_NEAR_REWARDS_PER_WEEK: {[k
|
|
136
|
+
export const BORROW_NEAR_REWARDS_PER_WEEK: { [k: string]: string } = {
|
|
115
137
|
// currently 0 for all markets
|
|
116
|
-
}
|
|
138
|
+
};
|
package/src/decimals.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const decimalRecords: Record<string, number> = {
|
|
2
2
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
3
|
-
'
|
|
3
|
+
'0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f': 18,
|
|
4
4
|
'0x3195949f267702723bc614cae037cdc8d1e94786': 8,
|
|
5
5
|
'0xfa94348467f64d5a457f75f8bc40495d33c65abb': 18,
|
|
6
6
|
'0x07f9f7f963c5cd2bbffd30ccfb964be114332e30': 24,
|
|
@@ -18,5 +18,7 @@ export const decimalRecords: Record<string, number> = {
|
|
|
18
18
|
'0xae4fac24dcdae0132c6d04f564dcf059616e9423': 8,
|
|
19
19
|
'0xce4166363e3a584dac84a47bcd3414b43efcdd1c': 8,
|
|
20
20
|
'0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
|
|
21
|
-
'0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24
|
|
22
|
-
|
|
21
|
+
'0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
|
|
22
|
+
'0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18, // PULP
|
|
23
|
+
'0x37cae2b29c18e05ece60111fa01d3ca217046016': 18, // PLYUSDC
|
|
24
|
+
};
|
package/src/dummy.ts
CHANGED
|
@@ -2,34 +2,28 @@ import { Token } from './token';
|
|
|
2
2
|
import { TokenAmount } from './tokenAmount';
|
|
3
3
|
import { UserMarketDetails } from './types';
|
|
4
4
|
|
|
5
|
-
export const dummyToken = new Token(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export const dummyPlyAurora = new Token('0xE530dC2095Ef5653205CF5ea79F8979a7028065c', 18);
|
|
10
|
-
|
|
11
|
-
export const dummyTokenAmount = new TokenAmount(
|
|
12
|
-
dummyToken,
|
|
13
|
-
'123.456',
|
|
14
|
-
false,
|
|
5
|
+
export const dummyToken = new Token(
|
|
6
|
+
'0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
7
|
+
6
|
|
15
8
|
);
|
|
16
9
|
|
|
17
|
-
export const
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
export const dummyPly = new Token(
|
|
11
|
+
'0x8729438eb15e2c8b576fcc6aecda6a148776c0f5',
|
|
12
|
+
18
|
|
20
13
|
);
|
|
21
14
|
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
false,
|
|
15
|
+
export const dummyPlyAurora = new Token(
|
|
16
|
+
'0xE530dC2095Ef5653205CF5ea79F8979a7028065c',
|
|
17
|
+
18
|
|
26
18
|
);
|
|
27
19
|
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
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);
|
|
33
27
|
|
|
34
28
|
export const dummyMarketAddress = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f'; // qiUSDC
|
|
35
29
|
|
|
@@ -40,5 +34,5 @@ export const dummyUserMarketDetails: UserMarketDetails = {
|
|
|
40
34
|
isCollateral: true,
|
|
41
35
|
maxWithdrawableAmount: dummyTokenAmount,
|
|
42
36
|
collateralRatio: 0.5,
|
|
43
|
-
underlyingPrice:
|
|
37
|
+
underlyingPrice: '1',
|
|
44
38
|
};
|
package/src/helpers.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import EIP20InterfaceABI from
|
|
2
|
-
import { EIP20Interface, IERC20 } from
|
|
3
|
-
import { Provider } from
|
|
4
|
-
import BigNumber from
|
|
5
|
-
import { BigNumber as BN, Contract, providers, utils } from
|
|
6
|
-
import { getQuery as getAuroraAPIQuery } from
|
|
7
|
-
import { decimalRecords } from
|
|
8
|
-
import { Address, NetworkConnection } from
|
|
1
|
+
import EIP20InterfaceABI from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
|
|
2
|
+
import { EIP20Interface, IERC20 } from '@aurigami/contracts/typechain';
|
|
3
|
+
import { Provider } from '@ethersproject/abstract-provider';
|
|
4
|
+
import BigNumber from 'bignumber.js';
|
|
5
|
+
import { BigNumber as BN, Contract, providers, utils } from 'ethers';
|
|
6
|
+
import { getQuery as getAuroraAPIQuery } from './aurora-api-helpers';
|
|
7
|
+
import { decimalRecords } from './decimals';
|
|
8
|
+
import { Address, NetworkConnection } from './types';
|
|
9
|
+
import assert from 'assert';
|
|
9
10
|
|
|
10
11
|
export function formatObject(object: Object) {
|
|
11
12
|
return JSON.stringify(object, null, ' ');
|
|
@@ -15,34 +16,50 @@ export function decimalFactor(decimal: number) {
|
|
|
15
16
|
return BN.from(10).pow(decimal).toString();
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export const isSameAddress = (
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export const isSameAddress = (
|
|
20
|
+
address1: Address,
|
|
21
|
+
address2: Address
|
|
22
|
+
): boolean => {
|
|
23
|
+
return address1.toLowerCase() == address2.toLowerCase();
|
|
24
|
+
};
|
|
21
25
|
|
|
22
26
|
export const getCurrentTimestamp = (): number => {
|
|
23
|
-
return Math.trunc(Date.now() / 1000)
|
|
24
|
-
}
|
|
27
|
+
return Math.trunc(Date.now() / 1000);
|
|
28
|
+
};
|
|
25
29
|
|
|
26
30
|
export function validateAndParseAddress(address: Address): Address {
|
|
27
31
|
try {
|
|
28
32
|
return utils.getAddress(address);
|
|
29
33
|
} catch (error) {
|
|
30
|
-
throw new Error(
|
|
34
|
+
throw new Error('Invalid address: ' + address);
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
export function getDecimal(address: Address): number {
|
|
35
|
-
|
|
39
|
+
let addressLowercase = address.toLowerCase();
|
|
40
|
+
assert(
|
|
41
|
+
decimalRecords[addressLowercase] != undefined,
|
|
42
|
+
'Decimal not found for ' + address
|
|
43
|
+
);
|
|
44
|
+
return decimalRecords[addressLowercase];
|
|
36
45
|
}
|
|
37
46
|
|
|
38
|
-
export function calcLMRewardApr(
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
export function calcLMRewardApr(
|
|
48
|
+
rewardsValue: BigNumber,
|
|
49
|
+
totalStakeValue: BigNumber,
|
|
50
|
+
frequencyPerYear: number
|
|
51
|
+
): BigNumber {
|
|
52
|
+
if (totalStakeValue.lte(0)) {
|
|
53
|
+
// avoid division by zero when there is no stake
|
|
54
|
+
return new BigNumber('999999999');
|
|
41
55
|
}
|
|
42
56
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
export async function getBlockTimestamp(
|
|
59
|
+
export async function getBlockTimestamp(
|
|
60
|
+
provider: Provider,
|
|
61
|
+
blockNumber: number
|
|
62
|
+
): Promise<number> {
|
|
46
63
|
const block = await provider.getBlock(blockNumber);
|
|
47
64
|
return block.timestamp;
|
|
48
65
|
}
|
|
@@ -55,14 +72,16 @@ export async function getBlockTimestamp(provider: Provider, blockNumber: number)
|
|
|
55
72
|
*
|
|
56
73
|
* This function is much faster than using binary search.
|
|
57
74
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
export async function getBlockBeforeTimestamp(
|
|
76
|
+
provider: Provider,
|
|
77
|
+
timestamp: number
|
|
78
|
+
) {
|
|
79
|
+
let result = await getAuroraAPIQuery('block', 'getblocknobytime', {
|
|
80
|
+
timestamp: timestamp,
|
|
81
|
+
closest: 'before',
|
|
82
|
+
});
|
|
64
83
|
|
|
65
84
|
// In case the API return `Block timestamp too far in the future`
|
|
66
85
|
// use the last block number
|
|
67
|
-
return parseInt(result) || await provider.getBlockNumber();
|
|
86
|
+
return parseInt(result) || (await provider.getBlockNumber());
|
|
68
87
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
import { Logger } from 'ethers/lib/utils';
|
|
4
4
|
|
|
5
5
|
ethers.utils.Logger.setLogLevel(Logger.levels.ERROR);
|
|
6
|
-
BigNumber.config({DECIMAL_PLACES: 50})
|
|
6
|
+
BigNumber.config({ DECIMAL_PLACES: 50 });
|
|
7
7
|
|
|
8
8
|
export * from './SDK';
|
|
9
9
|
export * from './MoneyMarket';
|
|
@@ -17,3 +17,4 @@ export * from './tokenAmount';
|
|
|
17
17
|
export * from './types';
|
|
18
18
|
export * from './airdrop-lottery';
|
|
19
19
|
export * from './transfer-event-query';
|
|
20
|
+
export * from './Papermill';
|