@aurigami/sdk 1.20.8 → 1.21.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.
- package/dist/consts/constants.d.ts +2 -1
- package/dist/entities/auriEnv.d.ts +1 -1
- package/dist/sdk.cjs.development.js +13 -9
- 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 +13 -9
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/a.ts.log +29 -0
- package/src/consts/constants.ts +2 -1
- package/src/entities/auriEnv.ts +4 -4
- package/src/helpers/historicalPriceFetcher.ts +8 -1
- package/src/helpers/priceFetcher.ts +5 -5
- package/src/interactors/misc.ts +2 -5
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.21.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"typescript": "^4.5.4"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aurigami/contracts": "3.
|
|
64
|
+
"@aurigami/contracts": "3.20.0",
|
|
65
65
|
"axios": "^0.26.1",
|
|
66
66
|
"bignumber.js": "^9.0.2",
|
|
67
67
|
"cache-decorator": "^0.1.6",
|
package/src/a.ts.log
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuToken } from '@aurigami/contracts/typechain';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { AuriEnv, formatObject, getDecimal, MAINNET_ADDRESSES, networkAddresses, SDK, Token } from '../src';
|
|
4
|
+
import { ask } from 'stdio';
|
|
5
|
+
const AURORA_DEFAULT_PROVIDER_URL = `https://mainnet.aurora.dev/`;
|
|
6
|
+
|
|
7
|
+
const AURORA_DEFAULT_PROVIDER = new ethers.providers.JsonRpcProvider(
|
|
8
|
+
AURORA_DEFAULT_PROVIDER_URL
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
async function foo(contract: AuToken, block: number) {
|
|
12
|
+
let data = await contract.callStatic.borrowBalanceCurrent('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
|
|
13
|
+
console.log("c", data.toString());
|
|
14
|
+
data = await contract.callStatic.borrowBalanceStored('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
|
|
15
|
+
console.log("s", data.toString());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
let env = new AuriEnv({ provider: AURORA_DEFAULT_PROVIDER });
|
|
20
|
+
let contract = env.getAuErc20Contract({address: MAINNET_ADDRESSES.auTokens.USDC});
|
|
21
|
+
// let block = 60596417;
|
|
22
|
+
// while (true) {
|
|
23
|
+
// block = parseInt(eval(await ask('block')));
|
|
24
|
+
// if (block == 0) break;
|
|
25
|
+
// await foo(contract, block);
|
|
26
|
+
// }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main();
|
package/src/consts/constants.ts
CHANGED
|
@@ -75,7 +75,8 @@ export const networkAddresses = {
|
|
|
75
75
|
],
|
|
76
76
|
misc: {
|
|
77
77
|
COMPTROLLER: MAINNET_ADDRESSES.comptroller.toLowerCase(),
|
|
78
|
-
|
|
78
|
+
DEPRECATED_OLD_ORACLE: MAINNET_ADDRESSES.oracle.toLowerCase(),
|
|
79
|
+
PYTH_ORACLE: MAINNET_ADDRESSES.pythOracle.toLowerCase(),
|
|
79
80
|
AURIFAIRLAUNCH: MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
|
|
80
81
|
AURILENS: MAINNET_ADDRESSES.auriLens.toLowerCase(),
|
|
81
82
|
ETHREPAYHELPER: MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
|
package/src/entities/auriEnv.ts
CHANGED
|
@@ -7,15 +7,15 @@ import {
|
|
|
7
7
|
AuriOracle,
|
|
8
8
|
Comptroller,
|
|
9
9
|
IERC20,
|
|
10
|
-
PlyGame,
|
|
11
10
|
PULP,
|
|
12
|
-
|
|
11
|
+
PlyGame,
|
|
13
12
|
PlyTokenLock,
|
|
13
|
+
ReferralDirectoryV2,
|
|
14
14
|
} from '@aurigami/contracts/typechain';
|
|
15
15
|
import { Contract } from 'ethers';
|
|
16
|
-
import { assert } from '../helpers/helpers';
|
|
17
16
|
import * as abis from '../abis';
|
|
18
17
|
import { networkAddresses } from '../consts/constants';
|
|
18
|
+
import { assert } from '../helpers/helpers';
|
|
19
19
|
import { AuTokenWithUnderlying } from '../types';
|
|
20
20
|
import { BlockchainEntityRead } from './BlockchainEntity';
|
|
21
21
|
|
|
@@ -152,7 +152,7 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
152
152
|
get oracle(): AuriOracle {
|
|
153
153
|
if (!this._oracle) {
|
|
154
154
|
this._oracle = this.getContract<AuriOracle>(
|
|
155
|
-
networkAddresses.misc.
|
|
155
|
+
networkAddresses.misc.PYTH_ORACLE,
|
|
156
156
|
abis.AuriOracleABI.abi
|
|
157
157
|
);
|
|
158
158
|
}
|
|
@@ -104,8 +104,15 @@ export async function fetchHistoricalPriceFromOracle(
|
|
|
104
104
|
provider: providers.Provider,
|
|
105
105
|
block: number
|
|
106
106
|
): Promise<BigNumber> {
|
|
107
|
+
// from this block, we switch to use pyth
|
|
108
|
+
// TODO: add to consts
|
|
109
|
+
const oracleAddress =
|
|
110
|
+
block < 102438637
|
|
111
|
+
? networkAddresses.misc.DEPRECATED_OLD_ORACLE
|
|
112
|
+
: networkAddresses.misc.PYTH_ORACLE;
|
|
113
|
+
|
|
107
114
|
const oracleContract: PriceOracle = new Contract(
|
|
108
|
-
|
|
115
|
+
oracleAddress,
|
|
109
116
|
AuriOracleABI.abi,
|
|
110
117
|
provider
|
|
111
118
|
) as PriceOracle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
|
|
2
|
-
import { ERC20, IUniswapV2Pair
|
|
2
|
+
import { AuriPythOracle, ERC20, IUniswapV2Pair } from '@aurigami/contracts/typechain';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import BigNumber from 'bignumber.js';
|
|
5
5
|
import { BigNumber as BN, Contract, ethers, providers } from 'ethers';
|
|
@@ -7,10 +7,10 @@ import { AuriOracleABI, EIP20InterfaceABI, IUniswapV2PairABI } from '../abis';
|
|
|
7
7
|
import {
|
|
8
8
|
DECIMAL_PRECISION,
|
|
9
9
|
HARDCODE_PRICE_TOKENS,
|
|
10
|
-
networkAddresses,
|
|
11
10
|
PRICE_WHITELISTED,
|
|
12
11
|
STADER_ETH,
|
|
13
12
|
USDT_ETH,
|
|
13
|
+
networkAddresses,
|
|
14
14
|
} from '../consts/constants';
|
|
15
15
|
import { TokenAmount } from '../entities/tokenAmount';
|
|
16
16
|
import { Address, TokenValuation } from '../types';
|
|
@@ -229,11 +229,11 @@ export async function fetchPriceFromOracle(
|
|
|
229
229
|
underlyingDecimal: number,
|
|
230
230
|
provider: providers.Provider
|
|
231
231
|
): Promise<BigNumber> {
|
|
232
|
-
const oracleContract:
|
|
233
|
-
networkAddresses.misc.
|
|
232
|
+
const oracleContract: AuriPythOracle = new Contract(
|
|
233
|
+
networkAddresses.misc.PYTH_ORACLE,
|
|
234
234
|
AuriOracleABI.abi,
|
|
235
235
|
provider
|
|
236
|
-
) as
|
|
236
|
+
) as AuriPythOracle;
|
|
237
237
|
const rawPrice = await oracleContract.getUnderlyingPrice(auTokenAddress).catch((e: any) => {
|
|
238
238
|
console.log(`Unable to fetch price from oracle for ${auTokenAddress}`);
|
|
239
239
|
return BN.from(0);
|
package/src/interactors/misc.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuToken
|
|
1
|
+
import { AuToken } from '@aurigami/contracts/typechain';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { BigNumber as BN } from 'ethers';
|
|
4
4
|
import * as abis from '../abis';
|
|
@@ -290,10 +290,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
290
290
|
dust: BigNumber = new BigNumber(0.1)
|
|
291
291
|
): Promise<types.AccountAuTokensInfo[]> {
|
|
292
292
|
const _1E18 = BN.from(10).pow(18);
|
|
293
|
-
const oracle = this.env.
|
|
294
|
-
consts.networkAddresses.misc.oracle,
|
|
295
|
-
abis.AuriOracleABI.abi
|
|
296
|
-
);
|
|
293
|
+
const oracle = this.env.oracle;
|
|
297
294
|
const tokens = tokenAddresses.map((addr) =>
|
|
298
295
|
this.env.getContract<AuToken>(addr, abis.AuTokenABI.abi)
|
|
299
296
|
);
|