@aurigami/sdk 1.19.0 → 1.19.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.
@@ -210,6 +210,8 @@ var CACHE_TIMEOUT = 10 * 1000; // 10 seconds
210
210
  var SD_INCENTIVE_IN_SD = 83.35;
211
211
  var STADER_ETH = /*#__PURE__*/'0x30D20208d987713f46DFD34EF128Bb16C404D10f'.toLowerCase();
212
212
  var USDT_ETH = /*#__PURE__*/'0xdAC17F958D2ee523a2206206994597C13D831ec7'.toLowerCase();
213
+ var AURIGAMI_SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name/takao-aurigami/aurigami-feb-27';
214
+ var GRAPHQL_URL = 'https://explorer.mainnet.aurora.dev/graphiql';
213
215
 
214
216
  var decimalRecords = {
215
217
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
@@ -709,18 +711,17 @@ function _getQuery() {
709
711
  return _getQuery.apply(this, arguments);
710
712
  }
711
713
 
712
- var GRAPHQL_URL = 'https://explorer.mainnet.aurora.dev/graphiql';
713
- function queryGraphQL(_x) {
714
+ function queryGraphQL(_x, _x2) {
714
715
  return _queryGraphQL.apply(this, arguments);
715
716
  }
716
717
  function _queryGraphQL() {
717
- _queryGraphQL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(query) {
718
+ _queryGraphQL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(query, graphqlUrl) {
718
719
  var resp;
719
720
  return _regeneratorRuntime().wrap(function _callee$(_context) {
720
721
  while (1) switch (_context.prev = _context.next) {
721
722
  case 0:
722
723
  _context.next = 2;
723
- return axios.post(GRAPHQL_URL, {
724
+ return axios.post(graphqlUrl, {
724
725
  query: query
725
726
  });
726
727
  case 2:
@@ -927,7 +928,7 @@ function _getBlocksTimestamp() {
927
928
  });
928
929
  for (i = 0; i < lines.length; i += CHUNK_SIZE) {
929
930
  query = "{ " + lines.slice(i, i + CHUNK_SIZE).join('\n') + " }";
930
- promises.push(queryGraphQL(query));
931
+ promises.push(queryGraphQL(query, GRAPHQL_URL));
931
932
  }
932
933
  // merge all the json objects
933
934
  _context5.next = 8;
@@ -3172,48 +3173,44 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3172
3173
  }
3173
3174
  return borrowCap;
3174
3175
  }();
3175
- _proto.getApyWithoutIncentive = /*#__PURE__*/function () {
3176
- var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(userAddress) {
3177
- var _yield$Promise$all10, price, depositApy, borrowApy, depositBalance, borrowBalance, suppliedValue, borrowedValue, sum;
3176
+ _proto.getDepositBorrowValue = /*#__PURE__*/function () {
3177
+ var _getDepositBorrowValue = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(userAddress) {
3178
+ var _yield$Promise$all10, price, depositBalance, borrowBalance, suppliedValue, borrowedValue;
3178
3179
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
3179
3180
  while (1) switch (_context20.prev = _context20.next) {
3180
3181
  case 0:
3181
3182
  _context20.next = 2;
3182
- return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
3183
+ return Promise.all([this.getUnderlyingPrice(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
3183
3184
  case 2:
3184
3185
  _yield$Promise$all10 = _context20.sent;
3185
3186
  price = _yield$Promise$all10[0];
3186
- depositApy = _yield$Promise$all10[1];
3187
- borrowApy = _yield$Promise$all10[2];
3188
- depositBalance = _yield$Promise$all10[3];
3189
- borrowBalance = _yield$Promise$all10[4];
3187
+ depositBalance = _yield$Promise$all10[1];
3188
+ borrowBalance = _yield$Promise$all10[2];
3190
3189
  suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3191
3190
  borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3192
- sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
3193
3191
  return _context20.abrupt("return", {
3194
- sum: sum,
3195
3192
  suppliedValue: suppliedValue,
3196
3193
  borrowedValue: borrowedValue
3197
3194
  });
3198
- case 12:
3195
+ case 9:
3199
3196
  case "end":
3200
3197
  return _context20.stop();
3201
3198
  }
3202
3199
  }, _callee20, this);
3203
3200
  }));
3204
- function getApyWithoutIncentive(_x3) {
3205
- return _getApyWithoutIncentive.apply(this, arguments);
3201
+ function getDepositBorrowValue(_x3) {
3202
+ return _getDepositBorrowValue.apply(this, arguments);
3206
3203
  }
3207
- return getApyWithoutIncentive;
3204
+ return getDepositBorrowValue;
3208
3205
  }();
3209
- _proto.getApyWithIncentive = /*#__PURE__*/function () {
3210
- var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(userAddress) {
3211
- var _yield$Promise$all11, price, depositApy, borrowApy, depositBalance, borrowBalance, nearDepositApy, plyDepositApy, metaDepositApy, nearBorrowApy, plyBorrowApy, staderDepositApy, suppliedValue, borrowedValue, totalDepositApy, totalBorrowApy, sum;
3206
+ _proto.getApyWithoutIncentive = /*#__PURE__*/function () {
3207
+ var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(userAddress) {
3208
+ var _yield$Promise$all11, price, depositApy, borrowApy, depositBalance, borrowBalance, suppliedValue, borrowedValue, sum;
3212
3209
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
3213
3210
  while (1) switch (_context21.prev = _context21.next) {
3214
3211
  case 0:
3215
3212
  _context21.next = 2;
3216
- 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()]);
3213
+ return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
3217
3214
  case 2:
3218
3215
  _yield$Promise$all11 = _context21.sent;
3219
3216
  price = _yield$Promise$all11[0];
@@ -3221,32 +3218,66 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3221
3218
  borrowApy = _yield$Promise$all11[2];
3222
3219
  depositBalance = _yield$Promise$all11[3];
3223
3220
  borrowBalance = _yield$Promise$all11[4];
3224
- nearDepositApy = _yield$Promise$all11[5];
3225
- plyDepositApy = _yield$Promise$all11[6];
3226
- metaDepositApy = _yield$Promise$all11[7];
3227
- nearBorrowApy = _yield$Promise$all11[8];
3228
- plyBorrowApy = _yield$Promise$all11[9];
3229
- _context21.next = 15;
3221
+ suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3222
+ borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3223
+ sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
3224
+ return _context21.abrupt("return", {
3225
+ sum: sum,
3226
+ suppliedValue: suppliedValue,
3227
+ borrowedValue: borrowedValue
3228
+ });
3229
+ case 12:
3230
+ case "end":
3231
+ return _context21.stop();
3232
+ }
3233
+ }, _callee21, this);
3234
+ }));
3235
+ function getApyWithoutIncentive(_x4) {
3236
+ return _getApyWithoutIncentive.apply(this, arguments);
3237
+ }
3238
+ return getApyWithoutIncentive;
3239
+ }();
3240
+ _proto.getApyWithIncentive = /*#__PURE__*/function () {
3241
+ var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(userAddress) {
3242
+ var _yield$Promise$all12, price, depositApy, borrowApy, depositBalance, borrowBalance, nearDepositApy, plyDepositApy, metaDepositApy, nearBorrowApy, plyBorrowApy, staderDepositApy, suppliedValue, borrowedValue, totalDepositApy, totalBorrowApy, sum;
3243
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
3244
+ while (1) switch (_context22.prev = _context22.next) {
3245
+ case 0:
3246
+ _context22.next = 2;
3247
+ 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()]);
3248
+ case 2:
3249
+ _yield$Promise$all12 = _context22.sent;
3250
+ price = _yield$Promise$all12[0];
3251
+ depositApy = _yield$Promise$all12[1];
3252
+ borrowApy = _yield$Promise$all12[2];
3253
+ depositBalance = _yield$Promise$all12[3];
3254
+ borrowBalance = _yield$Promise$all12[4];
3255
+ nearDepositApy = _yield$Promise$all12[5];
3256
+ plyDepositApy = _yield$Promise$all12[6];
3257
+ metaDepositApy = _yield$Promise$all12[7];
3258
+ nearBorrowApy = _yield$Promise$all12[8];
3259
+ plyBorrowApy = _yield$Promise$all12[9];
3260
+ _context22.next = 15;
3230
3261
  return this.getDepositStaderAPY();
3231
3262
  case 15:
3232
- staderDepositApy = _context21.sent;
3263
+ staderDepositApy = _context22.sent;
3233
3264
  suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3234
3265
  borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3235
3266
  totalDepositApy = depositApy.plus(nearDepositApy).plus(plyDepositApy).plus(metaDepositApy).plus(staderDepositApy);
3236
3267
  totalBorrowApy = borrowApy.plus(nearBorrowApy).plus(plyBorrowApy);
3237
3268
  sum = calcNetApy(suppliedValue, totalDepositApy, borrowedValue, totalBorrowApy);
3238
- return _context21.abrupt("return", {
3269
+ return _context22.abrupt("return", {
3239
3270
  sum: sum,
3240
3271
  suppliedValue: suppliedValue,
3241
3272
  borrowedValue: borrowedValue
3242
3273
  });
3243
3274
  case 22:
3244
3275
  case "end":
3245
- return _context21.stop();
3276
+ return _context22.stop();
3246
3277
  }
3247
- }, _callee21, this);
3278
+ }, _callee22, this);
3248
3279
  }));
3249
- function getApyWithIncentive(_x4) {
3280
+ function getApyWithIncentive(_x5) {
3250
3281
  return _getApyWithIncentive.apply(this, arguments);
3251
3282
  }
3252
3283
  return getApyWithIncentive;
@@ -3319,112 +3350,112 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3319
3350
  }
3320
3351
  var _proto2 = MoneyMarketReadWrite.prototype;
3321
3352
  _proto2.deposit = /*#__PURE__*/function () {
3322
- var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(amount) {
3323
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
3324
- while (1) switch (_context22.prev = _context22.next) {
3353
+ var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(amount) {
3354
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3355
+ while (1) switch (_context23.prev = _context23.next) {
3325
3356
  case 0:
3326
3357
  if (!isSameAddress(amount.token.address, ETHAddress)) {
3327
- _context22.next = 4;
3358
+ _context23.next = 4;
3328
3359
  break;
3329
3360
  }
3330
- return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
3361
+ return _context23.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
3331
3362
  value: amount.rawAmount()
3332
3363
  }));
3333
3364
  case 4:
3334
- return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
3365
+ return _context23.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
3335
3366
  case 5:
3336
3367
  case "end":
3337
- return _context22.stop();
3368
+ return _context23.stop();
3338
3369
  }
3339
- }, _callee22, this);
3370
+ }, _callee23, this);
3340
3371
  }));
3341
- function deposit(_x5) {
3372
+ function deposit(_x6) {
3342
3373
  return _deposit.apply(this, arguments);
3343
3374
  }
3344
3375
  return deposit;
3345
3376
  }();
3346
3377
  _proto2.borrow = /*#__PURE__*/function () {
3347
- var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(amount) {
3348
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3349
- while (1) switch (_context23.prev = _context23.next) {
3378
+ var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(amount) {
3379
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3380
+ while (1) switch (_context24.prev = _context24.next) {
3350
3381
  case 0:
3351
- return _context23.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
3382
+ return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
3352
3383
  case 1:
3353
3384
  case "end":
3354
- return _context23.stop();
3385
+ return _context24.stop();
3355
3386
  }
3356
- }, _callee23, this);
3387
+ }, _callee24, this);
3357
3388
  }));
3358
- function borrow(_x6) {
3389
+ function borrow(_x7) {
3359
3390
  return _borrow.apply(this, arguments);
3360
3391
  }
3361
3392
  return borrow;
3362
3393
  }();
3363
3394
  _proto2.withdraw = /*#__PURE__*/function () {
3364
- var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(amount) {
3365
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3366
- while (1) switch (_context24.prev = _context24.next) {
3395
+ var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(amount) {
3396
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3397
+ while (1) switch (_context25.prev = _context25.next) {
3367
3398
  case 0:
3368
3399
  if (!new BigNumber(amount.rawAmount()).lt(0)) {
3369
- _context24.next = 2;
3400
+ _context25.next = 2;
3370
3401
  break;
3371
3402
  }
3372
- return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
3403
+ return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
3373
3404
  case 2:
3374
- return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
3405
+ return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
3375
3406
  case 3:
3376
3407
  case "end":
3377
- return _context24.stop();
3408
+ return _context25.stop();
3378
3409
  }
3379
- }, _callee24, this);
3410
+ }, _callee25, this);
3380
3411
  }));
3381
- function withdraw(_x7) {
3412
+ function withdraw(_x8) {
3382
3413
  return _withdraw.apply(this, arguments);
3383
3414
  }
3384
3415
  return withdraw;
3385
3416
  }();
3386
3417
  _proto2.repay = /*#__PURE__*/function () {
3387
- var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(amount) {
3388
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3389
- while (1) switch (_context25.prev = _context25.next) {
3418
+ var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(amount) {
3419
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3420
+ while (1) switch (_context26.prev = _context26.next) {
3390
3421
  case 0:
3391
3422
  if (!isSameAddress(amount.token.address, ETHAddress)) {
3392
- _context25.next = 4;
3423
+ _context26.next = 4;
3393
3424
  break;
3394
3425
  }
3395
- return _context25.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
3426
+ return _context26.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
3396
3427
  value: amount.rawAmount()
3397
3428
  }));
3398
3429
  case 4:
3399
3430
  if (!new BigNumber(amount.rawAmount()).lt(0)) {
3400
- _context25.next = 8;
3431
+ _context26.next = 8;
3401
3432
  break;
3402
3433
  }
3403
- return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
3434
+ return _context26.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
3404
3435
  case 8:
3405
- return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
3436
+ return _context26.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
3406
3437
  case 9:
3407
3438
  case "end":
3408
- return _context25.stop();
3439
+ return _context26.stop();
3409
3440
  }
3410
- }, _callee25, this);
3441
+ }, _callee26, this);
3411
3442
  }));
3412
- function repay(_x8) {
3443
+ function repay(_x9) {
3413
3444
  return _repay.apply(this, arguments);
3414
3445
  }
3415
3446
  return repay;
3416
3447
  }();
3417
3448
  _proto2.enableCollateral = /*#__PURE__*/function () {
3418
- var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
3419
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3420
- while (1) switch (_context26.prev = _context26.next) {
3449
+ var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
3450
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3451
+ while (1) switch (_context27.prev = _context27.next) {
3421
3452
  case 0:
3422
- return _context26.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
3453
+ return _context27.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
3423
3454
  case 1:
3424
3455
  case "end":
3425
- return _context26.stop();
3456
+ return _context27.stop();
3426
3457
  }
3427
- }, _callee26, this);
3458
+ }, _callee27, this);
3428
3459
  }));
3429
3460
  function enableCollateral() {
3430
3461
  return _enableCollateral.apply(this, arguments);
@@ -3432,16 +3463,16 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3432
3463
  return enableCollateral;
3433
3464
  }();
3434
3465
  _proto2.disableCollateral = /*#__PURE__*/function () {
3435
- var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
3436
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3437
- while (1) switch (_context27.prev = _context27.next) {
3466
+ var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3467
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3468
+ while (1) switch (_context28.prev = _context28.next) {
3438
3469
  case 0:
3439
- return _context27.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
3470
+ return _context28.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
3440
3471
  case 1:
3441
3472
  case "end":
3442
- return _context27.stop();
3473
+ return _context28.stop();
3443
3474
  }
3444
- }, _callee27, this);
3475
+ }, _callee28, this);
3445
3476
  }));
3446
3477
  function disableCollateral() {
3447
3478
  return _disableCollateral.apply(this, arguments);
@@ -5200,6 +5231,40 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5200
5231
  }
5201
5232
  return getTokenPrice;
5202
5233
  }();
5234
+ _proto.calcBorrowPower = /*#__PURE__*/function () {
5235
+ var _calcBorrowPower = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tokenAmount) {
5236
+ var autoken, moneyMarket, collateralRatio, underlyingPrice, borrowPower;
5237
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
5238
+ while (1) switch (_context4.prev = _context4.next) {
5239
+ case 0:
5240
+ autoken = networkAddresses.auTokens.find(function (auToken) {
5241
+ return isSameAddress(auToken.underlying, tokenAmount.token.address);
5242
+ });
5243
+ moneyMarket = new MoneyMarketRead(this._networkConnection, autoken.address, autoken.underlying);
5244
+ _context4.next = 4;
5245
+ return moneyMarket.getCollateralRatio();
5246
+ case 4:
5247
+ collateralRatio = _context4.sent;
5248
+ _context4.next = 7;
5249
+ return fetchPrice(tokenAmount.token.address, this._networkConnection.provider);
5250
+ case 7:
5251
+ underlyingPrice = _context4.sent;
5252
+ borrowPower = calcValuation(tokenAmount, new BigNumber(underlyingPrice)).multipliedBy(collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
5253
+ return _context4.abrupt("return", {
5254
+ currency: 'USD',
5255
+ amount: borrowPower.toFixed(DECIMAL_PRECISION)
5256
+ });
5257
+ case 10:
5258
+ case "end":
5259
+ return _context4.stop();
5260
+ }
5261
+ }, _callee3, this);
5262
+ }));
5263
+ function calcBorrowPower(_x3) {
5264
+ return _calcBorrowPower.apply(this, arguments);
5265
+ }
5266
+ return calcBorrowPower;
5267
+ }();
5203
5268
  _proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
5204
5269
  var userMarketDetail = _ref.userMarketDetail,
5205
5270
  currentBorrowLimit = _ref.currentBorrowLimit,
@@ -5244,10 +5309,10 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5244
5309
  _proto.getPlyCirculatingSupply =
5245
5310
  /*#__PURE__*/
5246
5311
  function () {
5247
- var _getPlyCirculatingSupply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
5312
+ var _getPlyCirculatingSupply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
5248
5313
  var multicallRead, baseBalanceOfCall, listAddrs, calls, callResults, circulatingSupply;
5249
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
5250
- while (1) switch (_context4.prev = _context4.next) {
5314
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
5315
+ while (1) switch (_context5.prev = _context5.next) {
5251
5316
  case 0:
5252
5317
  multicallRead = new MulticallRead(this._networkConnection);
5253
5318
  baseBalanceOfCall = {
@@ -5261,20 +5326,20 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5261
5326
  args: [addr]
5262
5327
  });
5263
5328
  });
5264
- _context4.next = 6;
5329
+ _context5.next = 6;
5265
5330
  return multicallRead.aggregate(calls);
5266
5331
  case 6:
5267
- callResults = _context4.sent;
5332
+ callResults = _context5.sent;
5268
5333
  circulatingSupply = ethers.BigNumber.from('1' + '0'.repeat(10) + '0'.repeat(getDecimal(this.env.ply.address)));
5269
5334
  callResults.forEach(function (result, i) {
5270
5335
  circulatingSupply = circulatingSupply.sub(result[0]);
5271
5336
  });
5272
- return _context4.abrupt("return", new TokenAmount(PLYToken, circulatingSupply.toString()));
5337
+ return _context5.abrupt("return", new TokenAmount(PLYToken, circulatingSupply.toString()));
5273
5338
  case 10:
5274
5339
  case "end":
5275
- return _context4.stop();
5340
+ return _context5.stop();
5276
5341
  }
5277
- }, _callee3, this);
5342
+ }, _callee4, this);
5278
5343
  }));
5279
5344
  function getPlyCirculatingSupply() {
5280
5345
  return _getPlyCirculatingSupply.apply(this, arguments);
@@ -5282,35 +5347,35 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5282
5347
  return getPlyCirculatingSupply;
5283
5348
  }();
5284
5349
  _proto.getUtilisation = /*#__PURE__*/function () {
5285
- var _getUtilisation = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(userAddr) {
5350
+ var _getUtilisation = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(userAddr) {
5286
5351
  var accountDetail, sumBorrow, sumCol;
5287
- return _regeneratorRuntime().wrap(function _callee4$(_context5) {
5288
- while (1) switch (_context5.prev = _context5.next) {
5352
+ return _regeneratorRuntime().wrap(function _callee5$(_context6) {
5353
+ while (1) switch (_context6.prev = _context6.next) {
5289
5354
  case 0:
5290
- _context5.next = 2;
5355
+ _context6.next = 2;
5291
5356
  return this.env.auriInternalLens.callStatic.getAccountLiquidityAccrueInterest(userAddr);
5292
5357
  case 2:
5293
- accountDetail = _context5.sent;
5358
+ accountDetail = _context6.sent;
5294
5359
  sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
5295
5360
  sumCol = new BigNumber(accountDetail.sumCollateral.toString());
5296
- return _context5.abrupt("return", sumBorrow.dividedBy(sumCol));
5361
+ return _context6.abrupt("return", sumBorrow.dividedBy(sumCol));
5297
5362
  case 6:
5298
5363
  case "end":
5299
- return _context5.stop();
5364
+ return _context6.stop();
5300
5365
  }
5301
- }, _callee4, this);
5366
+ }, _callee5, this);
5302
5367
  }));
5303
- function getUtilisation(_x3) {
5368
+ function getUtilisation(_x4) {
5304
5369
  return _getUtilisation.apply(this, arguments);
5305
5370
  }
5306
5371
  return getUtilisation;
5307
5372
  }();
5308
5373
  _proto.sneakAccounts = /*#__PURE__*/function () {
5309
- var _sneakAccounts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(accounts, tokenAddresses, dust) {
5374
+ var _sneakAccounts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(accounts, tokenAddresses, dust) {
5310
5375
  var _this2 = this;
5311
5376
  var _1E18, oracle, tokens, prices, exrate, res, _iterator2, _step2, addr, infos, i, snapshot, bal, bor, balR, borR;
5312
- return _regeneratorRuntime().wrap(function _callee5$(_context6) {
5313
- while (1) switch (_context6.prev = _context6.next) {
5377
+ return _regeneratorRuntime().wrap(function _callee6$(_context7) {
5378
+ while (1) switch (_context7.prev = _context7.next) {
5314
5379
  case 0:
5315
5380
  if (dust === void 0) {
5316
5381
  dust = /*#__PURE__*/new BigNumber(0.1);
@@ -5320,19 +5385,19 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5320
5385
  tokens = tokenAddresses.map(function (addr) {
5321
5386
  return _this2.env.getContract(addr, abis$5.abi);
5322
5387
  });
5323
- _context6.next = 6;
5388
+ _context7.next = 6;
5324
5389
  return oracle.getUnderlyingPrices(tokenAddresses);
5325
5390
  case 6:
5326
- prices = _context6.sent;
5327
- _context6.next = 9;
5391
+ prices = _context7.sent;
5392
+ _context7.next = 9;
5328
5393
  return this.env.auriInternalLens.callStatic.getExchangeRates(tokenAddresses);
5329
5394
  case 9:
5330
- exrate = _context6.sent;
5395
+ exrate = _context7.sent;
5331
5396
  res = [];
5332
5397
  _iterator2 = _createForOfIteratorHelperLoose(accounts);
5333
5398
  case 12:
5334
5399
  if ((_step2 = _iterator2()).done) {
5335
- _context6.next = 33;
5400
+ _context7.next = 33;
5336
5401
  break;
5337
5402
  }
5338
5403
  addr = _step2.value;
@@ -5340,22 +5405,22 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5340
5405
  i = 0;
5341
5406
  case 16:
5342
5407
  if (!(i < tokens.length)) {
5343
- _context6.next = 30;
5408
+ _context7.next = 30;
5344
5409
  break;
5345
5410
  }
5346
- _context6.next = 19;
5411
+ _context7.next = 19;
5347
5412
  return tokens[i].getAccountSnapshot(addr);
5348
5413
  case 19:
5349
- snapshot = _context6.sent;
5414
+ snapshot = _context7.sent;
5350
5415
  bal = snapshot[0].mul(exrate[i]).div(_1E18).mul(prices[i]).div(_1E18);
5351
5416
  bor = snapshot[1].mul(prices[i]).div(_1E18);
5352
5417
  balR = new BigNumber(bal.toString()).dividedBy(_1E18.toString());
5353
5418
  borR = new BigNumber(bor.toString()).dividedBy(_1E18.toString());
5354
5419
  if (!(balR.lte(dust) && borR.lte(dust))) {
5355
- _context6.next = 26;
5420
+ _context7.next = 26;
5356
5421
  break;
5357
5422
  }
5358
- return _context6.abrupt("continue", 27);
5423
+ return _context7.abrupt("continue", 27);
5359
5424
  case 26:
5360
5425
  infos.push({
5361
5426
  token: getSymbol(tokenAddresses[i]),
@@ -5364,7 +5429,7 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5364
5429
  });
5365
5430
  case 27:
5366
5431
  ++i;
5367
- _context6.next = 16;
5432
+ _context7.next = 16;
5368
5433
  break;
5369
5434
  case 30:
5370
5435
  res.push({
@@ -5372,40 +5437,138 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5372
5437
  tokens: infos
5373
5438
  });
5374
5439
  case 31:
5375
- _context6.next = 12;
5440
+ _context7.next = 12;
5376
5441
  break;
5377
5442
  case 33:
5378
- return _context6.abrupt("return", res);
5443
+ return _context7.abrupt("return", res);
5379
5444
  case 34:
5380
5445
  case "end":
5381
- return _context6.stop();
5446
+ return _context7.stop();
5382
5447
  }
5383
- }, _callee5, this);
5448
+ }, _callee6, this);
5384
5449
  }));
5385
- function sneakAccounts(_x4, _x5, _x6) {
5450
+ function sneakAccounts(_x5, _x6, _x7) {
5386
5451
  return _sneakAccounts.apply(this, arguments);
5387
5452
  }
5388
5453
  return sneakAccounts;
5389
5454
  }();
5390
- _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5391
- var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userAddress) {
5455
+ _proto.getLTVAndLiquidationThreshold = /*#__PURE__*/function () {
5456
+ var _getLTVAndLiquidationThreshold = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(userAddr) {
5392
5457
  var _this3 = this;
5458
+ var totalSuppliedValue, totalBorrowedValue, collateralValue, assetsIn, marketValues, _loop2, i, ltv, liquidationThreshold;
5459
+ return _regeneratorRuntime().wrap(function _callee9$(_context11) {
5460
+ while (1) switch (_context11.prev = _context11.next) {
5461
+ case 0:
5462
+ totalSuppliedValue = new BigNumber(0);
5463
+ totalBorrowedValue = new BigNumber(0);
5464
+ collateralValue = new BigNumber(0);
5465
+ _context11.next = 5;
5466
+ return this.env.comptroller.getAssetsIn(userAddr);
5467
+ case 5:
5468
+ assetsIn = _context11.sent;
5469
+ _context11.next = 8;
5470
+ return Promise.all(networkAddresses.auTokens.map( /*#__PURE__*/function () {
5471
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(auToken) {
5472
+ var moneyMarket;
5473
+ return _regeneratorRuntime().wrap(function _callee7$(_context8) {
5474
+ while (1) switch (_context8.prev = _context8.next) {
5475
+ case 0:
5476
+ moneyMarket = new MoneyMarketRead(_this3._networkConnection, auToken.address, auToken.underlying);
5477
+ return _context8.abrupt("return", Promise.all([moneyMarket.getCollateralRatio(), moneyMarket.getDepositBorrowValue(userAddr)]));
5478
+ case 2:
5479
+ case "end":
5480
+ return _context8.stop();
5481
+ }
5482
+ }, _callee7);
5483
+ }));
5484
+ return function (_x9) {
5485
+ return _ref2.apply(this, arguments);
5486
+ };
5487
+ }()));
5488
+ case 8:
5489
+ marketValues = _context11.sent;
5490
+ networkAddresses.auTokens.forEach( /*#__PURE__*/function () {
5491
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(auToken, i) {
5492
+ return _regeneratorRuntime().wrap(function _callee8$(_context9) {
5493
+ while (1) switch (_context9.prev = _context9.next) {
5494
+ case 0:
5495
+ case "end":
5496
+ return _context9.stop();
5497
+ }
5498
+ }, _callee8);
5499
+ }));
5500
+ return function (_x10, _x11) {
5501
+ return _ref3.apply(this, arguments);
5502
+ };
5503
+ }());
5504
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
5505
+ var auToken, _marketValues$i, collateralRatio, depositBorrowValue;
5506
+ return _regeneratorRuntime().wrap(function _loop2$(_context10) {
5507
+ while (1) switch (_context10.prev = _context10.next) {
5508
+ case 0:
5509
+ auToken = networkAddresses.auTokens[i];
5510
+ _marketValues$i = marketValues[i], collateralRatio = _marketValues$i[0], depositBorrowValue = _marketValues$i[1];
5511
+ if (assetsIn.find(function (auAddress) {
5512
+ return isSameAddress(auToken.address, auAddress);
5513
+ }) !== undefined) {
5514
+ totalSuppliedValue = totalSuppliedValue.plus(depositBorrowValue.suppliedValue);
5515
+ collateralValue = collateralValue.plus(depositBorrowValue.suppliedValue.times(collateralRatio));
5516
+ }
5517
+ totalBorrowedValue = totalBorrowedValue.plus(depositBorrowValue.borrowedValue);
5518
+ case 4:
5519
+ case "end":
5520
+ return _context10.stop();
5521
+ }
5522
+ }, _loop2);
5523
+ });
5524
+ i = 0;
5525
+ case 12:
5526
+ if (!(i < marketValues.length)) {
5527
+ _context11.next = 17;
5528
+ break;
5529
+ }
5530
+ return _context11.delegateYield(_loop2(), "t0", 14);
5531
+ case 14:
5532
+ i++;
5533
+ _context11.next = 12;
5534
+ break;
5535
+ case 17:
5536
+ ltv = totalBorrowedValue.div(totalSuppliedValue);
5537
+ liquidationThreshold = collateralValue.div(totalSuppliedValue);
5538
+ return _context11.abrupt("return", {
5539
+ ltv: ltv,
5540
+ liquidationThreshold: liquidationThreshold
5541
+ });
5542
+ case 20:
5543
+ case "end":
5544
+ return _context11.stop();
5545
+ }
5546
+ }, _callee9, this);
5547
+ }));
5548
+ function getLTVAndLiquidationThreshold(_x8) {
5549
+ return _getLTVAndLiquidationThreshold.apply(this, arguments);
5550
+ }
5551
+ return getLTVAndLiquidationThreshold;
5552
+ }();
5553
+ _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5554
+ var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(userAddress) {
5555
+ var _this4 = this;
5393
5556
  var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator3, _step3, apy;
5394
- return _regeneratorRuntime().wrap(function _callee6$(_context7) {
5395
- while (1) switch (_context7.prev = _context7.next) {
5557
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
5558
+ while (1) switch (_context12.prev = _context12.next) {
5396
5559
  case 0:
5397
5560
  sum = new BigNumber(0);
5398
5561
  totalSuppliedValue = new BigNumber(0);
5399
5562
  totalBorrowedValue = new BigNumber(0);
5400
5563
  netApy = new BigNumber(0);
5401
- _context7.next = 6;
5564
+ _context12.next = 6;
5402
5565
  return Promise.all(networkAddresses.auTokens.map(function (auToken) {
5403
- var moneyMarket = new MoneyMarketRead(_this3._networkConnection, auToken.address, auToken.underlying);
5566
+ var moneyMarket = new MoneyMarketRead(_this4._networkConnection, auToken.address, auToken.underlying);
5404
5567
  var apyWithoutIncentive = moneyMarket.getApyWithoutIncentive(userAddress);
5405
5568
  return apyWithoutIncentive;
5406
5569
  }));
5407
5570
  case 6:
5408
- apys = _context7.sent;
5571
+ apys = _context12.sent;
5409
5572
  for (_iterator3 = _createForOfIteratorHelperLoose(apys); !(_step3 = _iterator3()).done;) {
5410
5573
  apy = _step3.value;
5411
5574
  sum = sum.plus(apy.sum);
@@ -5417,37 +5580,37 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5417
5580
  } else if (sum.lt(0)) {
5418
5581
  netApy = sum.div(totalBorrowedValue);
5419
5582
  }
5420
- return _context7.abrupt("return", netApy);
5583
+ return _context12.abrupt("return", netApy);
5421
5584
  case 10:
5422
5585
  case "end":
5423
- return _context7.stop();
5586
+ return _context12.stop();
5424
5587
  }
5425
- }, _callee6);
5588
+ }, _callee10);
5426
5589
  }));
5427
- function getNetApyWithoutIncentive(_x7) {
5590
+ function getNetApyWithoutIncentive(_x12) {
5428
5591
  return _getNetApyWithoutIncentive.apply(this, arguments);
5429
5592
  }
5430
5593
  return getNetApyWithoutIncentive;
5431
5594
  }();
5432
5595
  _proto.getNetApyWithIncentive = /*#__PURE__*/function () {
5433
- var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(userAddress) {
5434
- var _this4 = this;
5596
+ var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userAddress) {
5597
+ var _this5 = this;
5435
5598
  var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator4, _step4, apy;
5436
- return _regeneratorRuntime().wrap(function _callee7$(_context8) {
5437
- while (1) switch (_context8.prev = _context8.next) {
5599
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
5600
+ while (1) switch (_context13.prev = _context13.next) {
5438
5601
  case 0:
5439
5602
  sum = new BigNumber(0);
5440
5603
  totalSuppliedValue = new BigNumber(0);
5441
5604
  totalBorrowedValue = new BigNumber(0);
5442
5605
  netApy = new BigNumber(0);
5443
- _context8.next = 6;
5606
+ _context13.next = 6;
5444
5607
  return Promise.all(networkAddresses.auTokens.map(function (auToken) {
5445
- var moneyMarket = new MoneyMarketRead(_this4._networkConnection, auToken.address, auToken.underlying);
5608
+ var moneyMarket = new MoneyMarketRead(_this5._networkConnection, auToken.address, auToken.underlying);
5446
5609
  var apyWithIncentive = moneyMarket.getApyWithIncentive(userAddress);
5447
5610
  return apyWithIncentive;
5448
5611
  }));
5449
5612
  case 6:
5450
- apys = _context8.sent;
5613
+ apys = _context13.sent;
5451
5614
  for (_iterator4 = _createForOfIteratorHelperLoose(apys); !(_step4 = _iterator4()).done;) {
5452
5615
  apy = _step4.value;
5453
5616
  sum = sum.plus(apy.sum);
@@ -5459,14 +5622,14 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5459
5622
  } else if (sum.lt(0)) {
5460
5623
  netApy = sum.div(totalBorrowedValue);
5461
5624
  }
5462
- return _context8.abrupt("return", netApy);
5625
+ return _context13.abrupt("return", netApy);
5463
5626
  case 10:
5464
5627
  case "end":
5465
- return _context8.stop();
5628
+ return _context13.stop();
5466
5629
  }
5467
- }, _callee7);
5630
+ }, _callee11);
5468
5631
  }));
5469
- function getNetApyWithIncentive(_x8) {
5632
+ function getNetApyWithIncentive(_x13) {
5470
5633
  return _getNetApyWithIncentive.apply(this, arguments);
5471
5634
  }
5472
5635
  return getNetApyWithIncentive;
@@ -5580,6 +5743,10 @@ function _postApi() {
5580
5743
  return _postApi.apply(this, arguments);
5581
5744
  }
5582
5745
 
5746
+ function getLiquidationEventsQuery(address, limit) {
5747
+ return "{\n liquidationEvents(\n first: " + limit + ",\n where: {from: \"" + address.toLowerCase() + "\"}\n ) {\n amount\n auTokenSymbol\n blockTime\n from\n id\n underlyingRepayAmountUSD\n underlyingSymbol\n underlyingRepayAmount\n }\n }";
5748
+ }
5749
+
5583
5750
  var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5584
5751
  _inheritsLoose(SdkRead, _BlockchainEntityRead);
5585
5752
  function SdkRead(networkConnection) {
@@ -5783,49 +5950,62 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5783
5950
  }
5784
5951
  return sneakAccounts;
5785
5952
  }();
5786
- _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5787
- var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(userAddress) {
5788
- var miscRead;
5953
+ _proto.getLTVAndLiquidationThreshold = /*#__PURE__*/function () {
5954
+ var _getLTVAndLiquidationThreshold = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(userAddr) {
5789
5955
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
5790
5956
  while (1) switch (_context10.prev = _context10.next) {
5791
5957
  case 0:
5792
- miscRead = new MiscRead(this._networkConnection);
5793
- return _context10.abrupt("return", miscRead.getNetApyWithoutIncentive(userAddress));
5794
- case 2:
5958
+ return _context10.abrupt("return", this._misc.getLTVAndLiquidationThreshold(userAddr));
5959
+ case 1:
5795
5960
  case "end":
5796
5961
  return _context10.stop();
5797
5962
  }
5798
5963
  }, _callee10, this);
5799
5964
  }));
5800
- function getNetApyWithoutIncentive(_x10) {
5801
- return _getNetApyWithoutIncentive.apply(this, arguments);
5965
+ function getLTVAndLiquidationThreshold(_x10) {
5966
+ return _getLTVAndLiquidationThreshold.apply(this, arguments);
5802
5967
  }
5803
- return getNetApyWithoutIncentive;
5968
+ return getLTVAndLiquidationThreshold;
5804
5969
  }();
5805
- _proto.getNetApyWithIncentive = /*#__PURE__*/function () {
5806
- var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userAddress) {
5807
- var miscRead;
5970
+ _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5971
+ var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userAddress) {
5808
5972
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
5809
5973
  while (1) switch (_context11.prev = _context11.next) {
5810
5974
  case 0:
5811
- miscRead = new MiscRead(this._networkConnection);
5812
- return _context11.abrupt("return", miscRead.getNetApyWithIncentive(userAddress));
5813
- case 2:
5975
+ return _context11.abrupt("return", this._misc.getNetApyWithoutIncentive(userAddress));
5976
+ case 1:
5814
5977
  case "end":
5815
5978
  return _context11.stop();
5816
5979
  }
5817
5980
  }, _callee11, this);
5818
5981
  }));
5819
- function getNetApyWithIncentive(_x11) {
5982
+ function getNetApyWithoutIncentive(_x11) {
5983
+ return _getNetApyWithoutIncentive.apply(this, arguments);
5984
+ }
5985
+ return getNetApyWithoutIncentive;
5986
+ }();
5987
+ _proto.getNetApyWithIncentive = /*#__PURE__*/function () {
5988
+ var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(userAddress) {
5989
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
5990
+ while (1) switch (_context12.prev = _context12.next) {
5991
+ case 0:
5992
+ return _context12.abrupt("return", this._misc.getNetApyWithIncentive(userAddress));
5993
+ case 1:
5994
+ case "end":
5995
+ return _context12.stop();
5996
+ }
5997
+ }, _callee12, this);
5998
+ }));
5999
+ function getNetApyWithIncentive(_x12) {
5820
6000
  return _getNetApyWithIncentive.apply(this, arguments);
5821
6001
  }
5822
6002
  return getNetApyWithIncentive;
5823
6003
  }();
5824
6004
  _proto.setUserNotificationSettings = /*#__PURE__*/function () {
5825
- var _setUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address, mail, utilisation, liquidation, captchaResponse) {
6005
+ var _setUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, mail, utilisation, liquidation, captchaResponse) {
5826
6006
  var body, response;
5827
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
5828
- while (1) switch (_context12.prev = _context12.next) {
6007
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
6008
+ while (1) switch (_context13.prev = _context13.next) {
5829
6009
  case 0:
5830
6010
  body = {
5831
6011
  address: address,
@@ -5836,27 +6016,27 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5836
6016
  },
5837
6017
  captchaResponse: captchaResponse
5838
6018
  };
5839
- _context12.next = 3;
6019
+ _context13.next = 3;
5840
6020
  return postApi('alert-setting/set', body);
5841
6021
  case 3:
5842
- response = _context12.sent;
5843
- return _context12.abrupt("return", response);
6022
+ response = _context13.sent;
6023
+ return _context13.abrupt("return", response);
5844
6024
  case 5:
5845
6025
  case "end":
5846
- return _context12.stop();
6026
+ return _context13.stop();
5847
6027
  }
5848
- }, _callee12);
6028
+ }, _callee13);
5849
6029
  }));
5850
- function setUserNotificationSettings(_x12, _x13, _x14, _x15, _x16) {
6030
+ function setUserNotificationSettings(_x13, _x14, _x15, _x16, _x17) {
5851
6031
  return _setUserNotificationSettings.apply(this, arguments);
5852
6032
  }
5853
6033
  return setUserNotificationSettings;
5854
6034
  }();
5855
6035
  _proto.unsetUserNotificationSettings = /*#__PURE__*/function () {
5856
- var _unsetUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, captchaResponse) {
6036
+ var _unsetUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(address, captchaResponse) {
5857
6037
  var body, response;
5858
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
5859
- while (1) switch (_context13.prev = _context13.next) {
6038
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
6039
+ while (1) switch (_context14.prev = _context14.next) {
5860
6040
  case 0:
5861
6041
  body = {
5862
6042
  address: address,
@@ -5867,47 +6047,90 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5867
6047
  },
5868
6048
  captchaResponse: captchaResponse
5869
6049
  };
5870
- _context13.next = 3;
6050
+ _context14.next = 3;
5871
6051
  return postApi('alert-setting/set', body);
5872
6052
  case 3:
5873
- response = _context13.sent;
5874
- return _context13.abrupt("return", response);
6053
+ response = _context14.sent;
6054
+ return _context14.abrupt("return", response);
5875
6055
  case 5:
5876
6056
  case "end":
5877
- return _context13.stop();
6057
+ return _context14.stop();
5878
6058
  }
5879
- }, _callee13);
6059
+ }, _callee14);
5880
6060
  }));
5881
- function unsetUserNotificationSettings(_x17, _x18) {
6061
+ function unsetUserNotificationSettings(_x18, _x19) {
5882
6062
  return _unsetUserNotificationSettings.apply(this, arguments);
5883
6063
  }
5884
6064
  return unsetUserNotificationSettings;
5885
6065
  }();
5886
6066
  _proto.getUserNotificationSettings = /*#__PURE__*/function () {
5887
- var _getUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(addresses) {
6067
+ var _getUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(addresses) {
5888
6068
  var body, response;
5889
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
5890
- while (1) switch (_context14.prev = _context14.next) {
6069
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
6070
+ while (1) switch (_context15.prev = _context15.next) {
5891
6071
  case 0:
5892
6072
  body = {
5893
6073
  addresses: addresses
5894
6074
  };
5895
- _context14.next = 3;
6075
+ _context15.next = 3;
5896
6076
  return postApi('alert-setting/get-user-setting', body);
5897
6077
  case 3:
5898
- response = _context14.sent;
5899
- return _context14.abrupt("return", response);
6078
+ response = _context15.sent;
6079
+ return _context15.abrupt("return", response);
5900
6080
  case 5:
5901
6081
  case "end":
5902
- return _context14.stop();
6082
+ return _context15.stop();
5903
6083
  }
5904
- }, _callee14);
6084
+ }, _callee15);
5905
6085
  }));
5906
- function getUserNotificationSettings(_x19) {
6086
+ function getUserNotificationSettings(_x20) {
5907
6087
  return _getUserNotificationSettings.apply(this, arguments);
5908
6088
  }
5909
6089
  return getUserNotificationSettings;
5910
6090
  }();
6091
+ _proto.getLiquidationHistory = /*#__PURE__*/function () {
6092
+ var _getLiquidationHistory = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(address) {
6093
+ var liquidationHistorySubgraph, liquidationEvents;
6094
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
6095
+ while (1) switch (_context16.prev = _context16.next) {
6096
+ case 0:
6097
+ _context16.next = 2;
6098
+ return queryGraphQL(getLiquidationEventsQuery(address, 100), AURIGAMI_SUBGRAPH_URL);
6099
+ case 2:
6100
+ liquidationHistorySubgraph = _context16.sent;
6101
+ liquidationEvents = liquidationHistorySubgraph.liquidationEvents.map(function (event) {
6102
+ var value = {
6103
+ amount: event.underlyingRepayAmountUSD.toString(),
6104
+ currency: 'USD'
6105
+ };
6106
+ var underlyingAddress = networkAddresses.auTokens.find(function (auToken) {
6107
+ return auToken.name.slice(2).toLowerCase() === event.underlyingSymbol.toLowerCase();
6108
+ }).underlying;
6109
+ var decimal = getDecimal(underlyingAddress);
6110
+ var token = new Token(underlyingAddress, decimal);
6111
+ var tokenAmount = new TokenAmount(token, event.underlyingRepayAmount.toString(), false);
6112
+ return {
6113
+ liquidationTime: event.blockTime,
6114
+ tokenAmount: tokenAmount,
6115
+ value: value,
6116
+ transactionId: event.id.split('-')[0]
6117
+ };
6118
+ });
6119
+ return _context16.abrupt("return", liquidationEvents);
6120
+ case 5:
6121
+ case "end":
6122
+ return _context16.stop();
6123
+ }
6124
+ }, _callee16);
6125
+ }));
6126
+ function getLiquidationHistory(_x21) {
6127
+ return _getLiquidationHistory.apply(this, arguments);
6128
+ }
6129
+ return getLiquidationHistory;
6130
+ }();
6131
+ _proto.calculateBorrowPower = function calculateBorrowPower(tokenAmount) {
6132
+ return this._misc.calcBorrowPower(tokenAmount);
6133
+ };
5911
6134
  return SdkRead;
5912
6135
  }(BlockchainEntityRead);
5913
6136
  var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
@@ -5922,16 +6145,16 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
5922
6145
  _proto2.claim =
5923
6146
  /*#__PURE__*/
5924
6147
  function () {
5925
- var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
5926
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
5927
- while (1) switch (_context15.prev = _context15.next) {
6148
+ var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
6149
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
6150
+ while (1) switch (_context17.prev = _context17.next) {
5928
6151
  case 0:
5929
- return _context15.abrupt("return", this.env.auriLens.connect(this._networkConnection.signer).claimRewards(this.env.comptroller.address, this.env.auriFairLaunch.address, ALL_STAKING_POOLS));
6152
+ return _context17.abrupt("return", this.env.auriLens.connect(this._networkConnection.signer).claimRewards(this.env.comptroller.address, this.env.auriFairLaunch.address, ALL_STAKING_POOLS));
5930
6153
  case 1:
5931
6154
  case "end":
5932
- return _context15.stop();
6155
+ return _context17.stop();
5933
6156
  }
5934
- }, _callee15, this);
6157
+ }, _callee17, this);
5935
6158
  }));
5936
6159
  function claim() {
5937
6160
  return _claim.apply(this, arguments);
@@ -5939,35 +6162,35 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
5939
6162
  return claim;
5940
6163
  }();
5941
6164
  _proto2.stake = /*#__PURE__*/function () {
5942
- var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(amount) {
5943
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
5944
- while (1) switch (_context16.prev = _context16.next) {
6165
+ var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(amount) {
6166
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
6167
+ while (1) switch (_context18.prev = _context18.next) {
5945
6168
  case 0:
5946
- return _context16.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
6169
+ return _context18.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
5947
6170
  case 1:
5948
6171
  case "end":
5949
- return _context16.stop();
6172
+ return _context18.stop();
5950
6173
  }
5951
- }, _callee16, this);
6174
+ }, _callee18, this);
5952
6175
  }));
5953
- function stake(_x20) {
6176
+ function stake(_x22) {
5954
6177
  return _stake.apply(this, arguments);
5955
6178
  }
5956
6179
  return stake;
5957
6180
  }();
5958
6181
  _proto2.unstake = /*#__PURE__*/function () {
5959
- var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(amount) {
5960
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
5961
- while (1) switch (_context17.prev = _context17.next) {
6182
+ var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(amount) {
6183
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
6184
+ while (1) switch (_context19.prev = _context19.next) {
5962
6185
  case 0:
5963
- return _context17.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
6186
+ return _context19.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
5964
6187
  case 1:
5965
6188
  case "end":
5966
- return _context17.stop();
6189
+ return _context19.stop();
5967
6190
  }
5968
- }, _callee17, this);
6191
+ }, _callee19, this);
5969
6192
  }));
5970
- function unstake(_x21) {
6193
+ function unstake(_x23) {
5971
6194
  return _unstake.apply(this, arguments);
5972
6195
  }
5973
6196
  return unstake;
@@ -6000,6 +6223,7 @@ exports.AIRDROP_END_TIMESTAMP = AIRDROP_END_TIMESTAMP;
6000
6223
  exports.AIRDROP_KEEP_THRESHOLD = AIRDROP_KEEP_THRESHOLD;
6001
6224
  exports.AIRDROP_START_TIMESTAMP = AIRDROP_START_TIMESTAMP;
6002
6225
  exports.ALL_STAKING_POOLS = ALL_STAKING_POOLS;
6226
+ exports.AURIGAMI_SUBGRAPH_URL = AURIGAMI_SUBGRAPH_URL;
6003
6227
  exports.AURORA_CHAINID = AURORA_CHAINID;
6004
6228
  exports.AURORA_PLUS_API_PREFIX = AURORA_PLUS_API_PREFIX;
6005
6229
  exports.Airdrop = Airdrop;
@@ -6016,6 +6240,7 @@ exports.DECIMAL_PRECISION = DECIMAL_PRECISION;
6016
6240
  exports.DEPOSIT_NEAR_REWARDS_PER_WEEK = DEPOSIT_NEAR_REWARDS_PER_WEEK;
6017
6241
  exports.DEPOSIT_ONLY_TOKENS = DEPOSIT_ONLY_TOKENS;
6018
6242
  exports.ETHAddress = ETHAddress;
6243
+ exports.GRAPHQL_URL = GRAPHQL_URL;
6019
6244
  exports.HARDCODE_PRICE_TOKENS = HARDCODE_PRICE_TOKENS;
6020
6245
  exports.INF = INF;
6021
6246
  exports.MiscRead = MiscRead;