@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.
@@ -57,7 +57,8 @@ export declare const networkAddresses: {
57
57
  }];
58
58
  readonly misc: {
59
59
  readonly COMPTROLLER: string;
60
- readonly oracle: string;
60
+ readonly DEPRECATED_OLD_ORACLE: string;
61
+ readonly PYTH_ORACLE: string;
61
62
  readonly AURIFAIRLAUNCH: string;
62
63
  readonly AURILENS: string;
63
64
  readonly ETHREPAYHELPER: string;
@@ -1,4 +1,4 @@
1
- import { AuErc20, AuriAirdrop, AuriFairLaunch, AuriInternalLens, AuriLens, AuriOracle, Comptroller, IERC20, PlyGame, PULP, ReferralDirectoryV2, PlyTokenLock } from '@aurigami/contracts/typechain';
1
+ import { AuErc20, AuriAirdrop, AuriFairLaunch, AuriInternalLens, AuriLens, AuriOracle, Comptroller, IERC20, PULP, PlyGame, PlyTokenLock, ReferralDirectoryV2 } from '@aurigami/contracts/typechain';
2
2
  import { Contract } from 'ethers';
3
3
  import { AuTokenWithUnderlying } from '../types';
4
4
  import { BlockchainEntityRead } from './BlockchainEntity';
@@ -111,7 +111,8 @@ var networkAddresses = {
111
111
  }],
112
112
  misc: {
113
113
  COMPTROLLER: /*#__PURE__*/MAINNET_ADDRESSES.comptroller.toLowerCase(),
114
- oracle: /*#__PURE__*/MAINNET_ADDRESSES.oracle.toLowerCase(),
114
+ DEPRECATED_OLD_ORACLE: /*#__PURE__*/MAINNET_ADDRESSES.oracle.toLowerCase(),
115
+ PYTH_ORACLE: /*#__PURE__*/MAINNET_ADDRESSES.pythOracle.toLowerCase(),
115
116
  AURIFAIRLAUNCH: /*#__PURE__*/MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
116
117
  AURILENS: /*#__PURE__*/MAINNET_ADDRESSES.auriLens.toLowerCase(),
117
118
  ETHREPAYHELPER: /*#__PURE__*/MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
@@ -1181,7 +1182,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1181
1182
  key: "oracle",
1182
1183
  get: function get() {
1183
1184
  if (!this._oracle) {
1184
- this._oracle = this.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
1185
+ this._oracle = this.getContract(networkAddresses.misc.PYTH_ORACLE, AuriOracleABI.abi);
1185
1186
  }
1186
1187
  return this._oracle;
1187
1188
  }
@@ -1814,7 +1815,7 @@ function _fetchPriceFromOracle() {
1814
1815
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1815
1816
  while (1) switch (_context12.prev = _context12.next) {
1816
1817
  case 0:
1817
- oracleContract = new ethers.Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
1818
+ oracleContract = new ethers.Contract(networkAddresses.misc.PYTH_ORACLE, AuriOracleABI.abi, provider);
1818
1819
  _context12.next = 3;
1819
1820
  return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
1820
1821
  console.log("Unable to fetch price from oracle for " + auTokenAddress);
@@ -2308,22 +2309,25 @@ function fetchHistoricalPriceFromOracle(_x7, _x8, _x9, _x10) {
2308
2309
  }
2309
2310
  function _fetchHistoricalPriceFromOracle() {
2310
2311
  _fetchHistoricalPriceFromOracle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(auTokenAddress, underlyingDecimal, provider, block) {
2311
- var oracleContract, rawPrice;
2312
+ var oracleAddress, oracleContract, rawPrice;
2312
2313
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2313
2314
  while (1) switch (_context4.prev = _context4.next) {
2314
2315
  case 0:
2315
- oracleContract = new ethers.Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
2316
- _context4.next = 3;
2316
+ // from this block, we switch to use pyth
2317
+ // TODO: add to consts
2318
+ oracleAddress = block < 102438637 ? networkAddresses.misc.DEPRECATED_OLD_ORACLE : networkAddresses.misc.PYTH_ORACLE;
2319
+ oracleContract = new ethers.Contract(oracleAddress, AuriOracleABI.abi, provider);
2320
+ _context4.next = 4;
2317
2321
  return oracleContract.getUnderlyingPrice(auTokenAddress, {
2318
2322
  blockTag: block
2319
2323
  })["catch"](function (e) {
2320
2324
  console.log("Unable to fetch price from oracle for " + auTokenAddress);
2321
2325
  return ethers.BigNumber.from(0);
2322
2326
  });
2323
- case 3:
2327
+ case 4:
2324
2328
  rawPrice = _context4.sent;
2325
2329
  return _context4.abrupt("return", processPriceFromOracle$1(rawPrice, underlyingDecimal));
2326
- case 5:
2330
+ case 6:
2327
2331
  case "end":
2328
2332
  return _context4.stop();
2329
2333
  }
@@ -5340,7 +5344,7 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5340
5344
  dust = /*#__PURE__*/new BigNumber(0.1);
5341
5345
  }
5342
5346
  _1E18 = ethers.BigNumber.from(10).pow(18);
5343
- oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
5347
+ oracle = this.env.oracle;
5344
5348
  tokens = tokenAddresses.map(function (addr) {
5345
5349
  return _this2.env.getContract(addr, abis$5.abi);
5346
5350
  });