@aurigami/sdk 1.20.7 → 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/sdk.esm.js CHANGED
@@ -106,7 +106,8 @@ var networkAddresses = {
106
106
  }],
107
107
  misc: {
108
108
  COMPTROLLER: /*#__PURE__*/MAINNET_ADDRESSES.comptroller.toLowerCase(),
109
- oracle: /*#__PURE__*/MAINNET_ADDRESSES.oracle.toLowerCase(),
109
+ DEPRECATED_OLD_ORACLE: /*#__PURE__*/MAINNET_ADDRESSES.oracle.toLowerCase(),
110
+ PYTH_ORACLE: /*#__PURE__*/MAINNET_ADDRESSES.pythOracle.toLowerCase(),
110
111
  AURIFAIRLAUNCH: /*#__PURE__*/MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
111
112
  AURILENS: /*#__PURE__*/MAINNET_ADDRESSES.auriLens.toLowerCase(),
112
113
  ETHREPAYHELPER: /*#__PURE__*/MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
@@ -1176,7 +1177,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1176
1177
  key: "oracle",
1177
1178
  get: function get() {
1178
1179
  if (!this._oracle) {
1179
- this._oracle = this.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
1180
+ this._oracle = this.getContract(networkAddresses.misc.PYTH_ORACLE, AuriOracleABI.abi);
1180
1181
  }
1181
1182
  return this._oracle;
1182
1183
  }
@@ -1809,7 +1810,7 @@ function _fetchPriceFromOracle() {
1809
1810
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1810
1811
  while (1) switch (_context12.prev = _context12.next) {
1811
1812
  case 0:
1812
- oracleContract = new Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
1813
+ oracleContract = new Contract(networkAddresses.misc.PYTH_ORACLE, AuriOracleABI.abi, provider);
1813
1814
  _context12.next = 3;
1814
1815
  return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
1815
1816
  console.log("Unable to fetch price from oracle for " + auTokenAddress);
@@ -2303,22 +2304,25 @@ function fetchHistoricalPriceFromOracle(_x7, _x8, _x9, _x10) {
2303
2304
  }
2304
2305
  function _fetchHistoricalPriceFromOracle() {
2305
2306
  _fetchHistoricalPriceFromOracle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(auTokenAddress, underlyingDecimal, provider, block) {
2306
- var oracleContract, rawPrice;
2307
+ var oracleAddress, oracleContract, rawPrice;
2307
2308
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
2308
2309
  while (1) switch (_context4.prev = _context4.next) {
2309
2310
  case 0:
2310
- oracleContract = new Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
2311
- _context4.next = 3;
2311
+ // from this block, we switch to use pyth
2312
+ // TODO: add to consts
2313
+ oracleAddress = block < 102438637 ? networkAddresses.misc.DEPRECATED_OLD_ORACLE : networkAddresses.misc.PYTH_ORACLE;
2314
+ oracleContract = new Contract(oracleAddress, AuriOracleABI.abi, provider);
2315
+ _context4.next = 4;
2312
2316
  return oracleContract.getUnderlyingPrice(auTokenAddress, {
2313
2317
  blockTag: block
2314
2318
  })["catch"](function (e) {
2315
2319
  console.log("Unable to fetch price from oracle for " + auTokenAddress);
2316
2320
  return BigNumber$1.from(0);
2317
2321
  });
2318
- case 3:
2322
+ case 4:
2319
2323
  rawPrice = _context4.sent;
2320
2324
  return _context4.abrupt("return", processPriceFromOracle$1(rawPrice, underlyingDecimal));
2321
- case 5:
2325
+ case 6:
2322
2326
  case "end":
2323
2327
  return _context4.stop();
2324
2328
  }
@@ -2917,38 +2921,15 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2917
2921
  }();
2918
2922
  _proto.getDepositMetaAPY = /*#__PURE__*/function () {
2919
2923
  var _getDepositMetaAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2920
- var _yield$Promise$all6, totalDeposited, underlyingPrice, depositMETAApy;
2921
2924
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2922
2925
  while (1) switch (_context13.prev = _context13.next) {
2923
2926
  case 0:
2924
- _context13.next = 2;
2925
- return Promise.all([this.getTotalTokenDeposited(), fetchPrice(this.underlying.address, this._networkConnection.provider)]);
2926
- case 2:
2927
- _yield$Promise$all6 = _context13.sent;
2928
- totalDeposited = _yield$Promise$all6[0];
2929
- underlyingPrice = _yield$Promise$all6[1];
2930
- if (!isSameAddress(this.underlying.address, networkAddresses.tokens.stNEAR)) {
2931
- _context13.next = 14;
2932
- break;
2933
- }
2934
- _context13.t0 = helpers;
2935
- _context13.next = 9;
2936
- return fetchValuation(TokenAmount.fromAddressAndAmount(networkAddresses.tokens.META, '250000', false), this._networkConnection.provider);
2937
- case 9:
2938
- _context13.t1 = _context13.sent;
2939
- _context13.t2 = underlyingPrice.multipliedBy(totalDeposited.formattedAmount());
2940
- depositMETAApy = _context13.t0.calcLMRewardApr.call(_context13.t0, _context13.t1, _context13.t2, 12);
2941
- _context13.next = 15;
2942
- break;
2943
- case 14:
2944
- depositMETAApy = new BigNumber(0);
2945
- case 15:
2946
- return _context13.abrupt("return", depositMETAApy);
2947
- case 16:
2927
+ return _context13.abrupt("return", new BigNumber(0));
2928
+ case 1:
2948
2929
  case "end":
2949
2930
  return _context13.stop();
2950
2931
  }
2951
- }, _callee13, this);
2932
+ }, _callee13);
2952
2933
  }));
2953
2934
  function getDepositMetaAPY() {
2954
2935
  return _getDepositMetaAPY.apply(this, arguments);
@@ -2974,30 +2955,30 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2974
2955
  }();
2975
2956
  _proto.getDetails = /*#__PURE__*/function () {
2976
2957
  var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
2977
- var _yield$Promise$all7, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeeds, _yield$Promise$all8, depositPlyAPY, borrowPlyAPY, depositNearAPY, borrowNearAPY, depositMetaAPY, staderDepositApy;
2958
+ var _yield$Promise$all6, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeeds, _yield$Promise$all7, depositPlyAPY, borrowPlyAPY, depositNearAPY, borrowNearAPY, depositMetaAPY, staderDepositApy;
2978
2959
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2979
2960
  while (1) switch (_context15.prev = _context15.next) {
2980
2961
  case 0:
2981
2962
  _context15.next = 2;
2982
2963
  return Promise.all([this.getTotalTokenDeposited(), this.getTotalTokenBorrowed(), this.getDepositAPY(), this.getBorrowAPY(), this.getCollateralRatio(), this.getRewardSpeeds()]);
2983
2964
  case 2:
2984
- _yield$Promise$all7 = _context15.sent;
2985
- totalDeposited = _yield$Promise$all7[0];
2986
- totalBorrowed = _yield$Promise$all7[1];
2987
- depositAPY = _yield$Promise$all7[2];
2988
- borrowAPY = _yield$Promise$all7[3];
2989
- collateralRatio = _yield$Promise$all7[4];
2990
- rewardSpeeds = _yield$Promise$all7[5];
2965
+ _yield$Promise$all6 = _context15.sent;
2966
+ totalDeposited = _yield$Promise$all6[0];
2967
+ totalBorrowed = _yield$Promise$all6[1];
2968
+ depositAPY = _yield$Promise$all6[2];
2969
+ borrowAPY = _yield$Promise$all6[3];
2970
+ collateralRatio = _yield$Promise$all6[4];
2971
+ rewardSpeeds = _yield$Promise$all6[5];
2991
2972
  _context15.next = 11;
2992
2973
  return Promise.all([this.getDepositPlyAPY(), this.getBorrowPlyAPY(), this.getDepositNearAPY(), this.getBorrowNearAPY(), this.getDepositMetaAPY(), this.getDepositStaderAPY()]);
2993
2974
  case 11:
2994
- _yield$Promise$all8 = _context15.sent;
2995
- depositPlyAPY = _yield$Promise$all8[0];
2996
- borrowPlyAPY = _yield$Promise$all8[1];
2997
- depositNearAPY = _yield$Promise$all8[2];
2998
- borrowNearAPY = _yield$Promise$all8[3];
2999
- depositMetaAPY = _yield$Promise$all8[4];
3000
- staderDepositApy = _yield$Promise$all8[5];
2975
+ _yield$Promise$all7 = _context15.sent;
2976
+ depositPlyAPY = _yield$Promise$all7[0];
2977
+ borrowPlyAPY = _yield$Promise$all7[1];
2978
+ depositNearAPY = _yield$Promise$all7[2];
2979
+ borrowNearAPY = _yield$Promise$all7[3];
2980
+ depositMetaAPY = _yield$Promise$all7[4];
2981
+ staderDepositApy = _yield$Promise$all7[5];
3001
2982
  return _context15.abrupt("return", {
3002
2983
  auTokenAddress: this.auToken.address,
3003
2984
  totalTokenDeposited: totalDeposited,
@@ -3143,17 +3124,17 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3143
3124
  }();
3144
3125
  _proto.getDepositBorrowValue = /*#__PURE__*/function () {
3145
3126
  var _getDepositBorrowValue = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(userAddress) {
3146
- var _yield$Promise$all9, price, depositBalance, borrowBalance, suppliedValue, borrowedValue;
3127
+ var _yield$Promise$all8, price, depositBalance, borrowBalance, suppliedValue, borrowedValue;
3147
3128
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
3148
3129
  while (1) switch (_context20.prev = _context20.next) {
3149
3130
  case 0:
3150
3131
  _context20.next = 2;
3151
3132
  return Promise.all([this.getUnderlyingPrice(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
3152
3133
  case 2:
3153
- _yield$Promise$all9 = _context20.sent;
3154
- price = _yield$Promise$all9[0];
3155
- depositBalance = _yield$Promise$all9[1];
3156
- borrowBalance = _yield$Promise$all9[2];
3134
+ _yield$Promise$all8 = _context20.sent;
3135
+ price = _yield$Promise$all8[0];
3136
+ depositBalance = _yield$Promise$all8[1];
3137
+ borrowBalance = _yield$Promise$all8[2];
3157
3138
  suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3158
3139
  borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3159
3140
  return _context20.abrupt("return", {
@@ -3173,19 +3154,19 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3173
3154
  }();
3174
3155
  _proto.getApyWithoutIncentive = /*#__PURE__*/function () {
3175
3156
  var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(userAddress) {
3176
- var _yield$Promise$all10, price, depositApy, borrowApy, depositBalance, borrowBalance, suppliedValue, borrowedValue, sum;
3157
+ var _yield$Promise$all9, price, depositApy, borrowApy, depositBalance, borrowBalance, suppliedValue, borrowedValue, sum;
3177
3158
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
3178
3159
  while (1) switch (_context21.prev = _context21.next) {
3179
3160
  case 0:
3180
3161
  _context21.next = 2;
3181
3162
  return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
3182
3163
  case 2:
3183
- _yield$Promise$all10 = _context21.sent;
3184
- price = _yield$Promise$all10[0];
3185
- depositApy = _yield$Promise$all10[1];
3186
- borrowApy = _yield$Promise$all10[2];
3187
- depositBalance = _yield$Promise$all10[3];
3188
- borrowBalance = _yield$Promise$all10[4];
3164
+ _yield$Promise$all9 = _context21.sent;
3165
+ price = _yield$Promise$all9[0];
3166
+ depositApy = _yield$Promise$all9[1];
3167
+ borrowApy = _yield$Promise$all9[2];
3168
+ depositBalance = _yield$Promise$all9[3];
3169
+ borrowBalance = _yield$Promise$all9[4];
3189
3170
  suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3190
3171
  borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3191
3172
  sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
@@ -3207,24 +3188,24 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3207
3188
  }();
3208
3189
  _proto.getApyWithIncentive = /*#__PURE__*/function () {
3209
3190
  var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(userAddress) {
3210
- var _yield$Promise$all11, price, depositApy, borrowApy, depositBalance, borrowBalance, nearDepositApy, plyDepositApy, metaDepositApy, nearBorrowApy, plyBorrowApy, staderDepositApy, suppliedValue, borrowedValue, totalDepositApy, totalBorrowApy, sum;
3191
+ var _yield$Promise$all10, price, depositApy, borrowApy, depositBalance, borrowBalance, nearDepositApy, plyDepositApy, metaDepositApy, nearBorrowApy, plyBorrowApy, staderDepositApy, suppliedValue, borrowedValue, totalDepositApy, totalBorrowApy, sum;
3211
3192
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
3212
3193
  while (1) switch (_context22.prev = _context22.next) {
3213
3194
  case 0:
3214
3195
  _context22.next = 2;
3215
3196
  return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress), this.getDepositNearAPY(), this.getDepositPlyAPY(), this.getDepositMetaAPY(), this.getBorrowNearAPY(), this.getBorrowPlyAPY()]);
3216
3197
  case 2:
3217
- _yield$Promise$all11 = _context22.sent;
3218
- price = _yield$Promise$all11[0];
3219
- depositApy = _yield$Promise$all11[1];
3220
- borrowApy = _yield$Promise$all11[2];
3221
- depositBalance = _yield$Promise$all11[3];
3222
- borrowBalance = _yield$Promise$all11[4];
3223
- nearDepositApy = _yield$Promise$all11[5];
3224
- plyDepositApy = _yield$Promise$all11[6];
3225
- metaDepositApy = _yield$Promise$all11[7];
3226
- nearBorrowApy = _yield$Promise$all11[8];
3227
- plyBorrowApy = _yield$Promise$all11[9];
3198
+ _yield$Promise$all10 = _context22.sent;
3199
+ price = _yield$Promise$all10[0];
3200
+ depositApy = _yield$Promise$all10[1];
3201
+ borrowApy = _yield$Promise$all10[2];
3202
+ depositBalance = _yield$Promise$all10[3];
3203
+ borrowBalance = _yield$Promise$all10[4];
3204
+ nearDepositApy = _yield$Promise$all10[5];
3205
+ plyDepositApy = _yield$Promise$all10[6];
3206
+ metaDepositApy = _yield$Promise$all10[7];
3207
+ nearBorrowApy = _yield$Promise$all10[8];
3208
+ plyBorrowApy = _yield$Promise$all10[9];
3228
3209
  _context22.next = 15;
3229
3210
  return this.getDepositStaderAPY();
3230
3211
  case 15:
@@ -5360,7 +5341,7 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5360
5341
  dust = /*#__PURE__*/new BigNumber(0.1);
5361
5342
  }
5362
5343
  _1E18 = BigNumber$1.from(10).pow(18);
5363
- oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
5344
+ oracle = this.env.oracle;
5364
5345
  tokens = tokenAddresses.map(function (addr) {
5365
5346
  return _this2.env.getContract(addr, abis.abi);
5366
5347
  });