@aurigami/sdk 1.19.1 → 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.
@@ -3173,48 +3173,44 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3173
3173
  }
3174
3174
  return borrowCap;
3175
3175
  }();
3176
- _proto.getApyWithoutIncentive = /*#__PURE__*/function () {
3177
- var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(userAddress) {
3178
- 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;
3179
3179
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
3180
3180
  while (1) switch (_context20.prev = _context20.next) {
3181
3181
  case 0:
3182
3182
  _context20.next = 2;
3183
- 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)]);
3184
3184
  case 2:
3185
3185
  _yield$Promise$all10 = _context20.sent;
3186
3186
  price = _yield$Promise$all10[0];
3187
- depositApy = _yield$Promise$all10[1];
3188
- borrowApy = _yield$Promise$all10[2];
3189
- depositBalance = _yield$Promise$all10[3];
3190
- borrowBalance = _yield$Promise$all10[4];
3187
+ depositBalance = _yield$Promise$all10[1];
3188
+ borrowBalance = _yield$Promise$all10[2];
3191
3189
  suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3192
3190
  borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3193
- sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
3194
3191
  return _context20.abrupt("return", {
3195
- sum: sum,
3196
3192
  suppliedValue: suppliedValue,
3197
3193
  borrowedValue: borrowedValue
3198
3194
  });
3199
- case 12:
3195
+ case 9:
3200
3196
  case "end":
3201
3197
  return _context20.stop();
3202
3198
  }
3203
3199
  }, _callee20, this);
3204
3200
  }));
3205
- function getApyWithoutIncentive(_x3) {
3206
- return _getApyWithoutIncentive.apply(this, arguments);
3201
+ function getDepositBorrowValue(_x3) {
3202
+ return _getDepositBorrowValue.apply(this, arguments);
3207
3203
  }
3208
- return getApyWithoutIncentive;
3204
+ return getDepositBorrowValue;
3209
3205
  }();
3210
- _proto.getApyWithIncentive = /*#__PURE__*/function () {
3211
- var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(userAddress) {
3212
- 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;
3213
3209
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
3214
3210
  while (1) switch (_context21.prev = _context21.next) {
3215
3211
  case 0:
3216
3212
  _context21.next = 2;
3217
- 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)]);
3218
3214
  case 2:
3219
3215
  _yield$Promise$all11 = _context21.sent;
3220
3216
  price = _yield$Promise$all11[0];
@@ -3222,32 +3218,66 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3222
3218
  borrowApy = _yield$Promise$all11[2];
3223
3219
  depositBalance = _yield$Promise$all11[3];
3224
3220
  borrowBalance = _yield$Promise$all11[4];
3225
- nearDepositApy = _yield$Promise$all11[5];
3226
- plyDepositApy = _yield$Promise$all11[6];
3227
- metaDepositApy = _yield$Promise$all11[7];
3228
- nearBorrowApy = _yield$Promise$all11[8];
3229
- plyBorrowApy = _yield$Promise$all11[9];
3230
- _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;
3231
3261
  return this.getDepositStaderAPY();
3232
3262
  case 15:
3233
- staderDepositApy = _context21.sent;
3263
+ staderDepositApy = _context22.sent;
3234
3264
  suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
3235
3265
  borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
3236
3266
  totalDepositApy = depositApy.plus(nearDepositApy).plus(plyDepositApy).plus(metaDepositApy).plus(staderDepositApy);
3237
3267
  totalBorrowApy = borrowApy.plus(nearBorrowApy).plus(plyBorrowApy);
3238
3268
  sum = calcNetApy(suppliedValue, totalDepositApy, borrowedValue, totalBorrowApy);
3239
- return _context21.abrupt("return", {
3269
+ return _context22.abrupt("return", {
3240
3270
  sum: sum,
3241
3271
  suppliedValue: suppliedValue,
3242
3272
  borrowedValue: borrowedValue
3243
3273
  });
3244
3274
  case 22:
3245
3275
  case "end":
3246
- return _context21.stop();
3276
+ return _context22.stop();
3247
3277
  }
3248
- }, _callee21, this);
3278
+ }, _callee22, this);
3249
3279
  }));
3250
- function getApyWithIncentive(_x4) {
3280
+ function getApyWithIncentive(_x5) {
3251
3281
  return _getApyWithIncentive.apply(this, arguments);
3252
3282
  }
3253
3283
  return getApyWithIncentive;
@@ -3320,112 +3350,112 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3320
3350
  }
3321
3351
  var _proto2 = MoneyMarketReadWrite.prototype;
3322
3352
  _proto2.deposit = /*#__PURE__*/function () {
3323
- var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(amount) {
3324
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
3325
- 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) {
3326
3356
  case 0:
3327
3357
  if (!isSameAddress(amount.token.address, ETHAddress)) {
3328
- _context22.next = 4;
3358
+ _context23.next = 4;
3329
3359
  break;
3330
3360
  }
3331
- return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
3361
+ return _context23.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
3332
3362
  value: amount.rawAmount()
3333
3363
  }));
3334
3364
  case 4:
3335
- 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()));
3336
3366
  case 5:
3337
3367
  case "end":
3338
- return _context22.stop();
3368
+ return _context23.stop();
3339
3369
  }
3340
- }, _callee22, this);
3370
+ }, _callee23, this);
3341
3371
  }));
3342
- function deposit(_x5) {
3372
+ function deposit(_x6) {
3343
3373
  return _deposit.apply(this, arguments);
3344
3374
  }
3345
3375
  return deposit;
3346
3376
  }();
3347
3377
  _proto2.borrow = /*#__PURE__*/function () {
3348
- var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(amount) {
3349
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3350
- 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) {
3351
3381
  case 0:
3352
- 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()));
3353
3383
  case 1:
3354
3384
  case "end":
3355
- return _context23.stop();
3385
+ return _context24.stop();
3356
3386
  }
3357
- }, _callee23, this);
3387
+ }, _callee24, this);
3358
3388
  }));
3359
- function borrow(_x6) {
3389
+ function borrow(_x7) {
3360
3390
  return _borrow.apply(this, arguments);
3361
3391
  }
3362
3392
  return borrow;
3363
3393
  }();
3364
3394
  _proto2.withdraw = /*#__PURE__*/function () {
3365
- var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(amount) {
3366
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3367
- 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) {
3368
3398
  case 0:
3369
3399
  if (!new BigNumber(amount.rawAmount()).lt(0)) {
3370
- _context24.next = 2;
3400
+ _context25.next = 2;
3371
3401
  break;
3372
3402
  }
3373
- 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));
3374
3404
  case 2:
3375
- 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()));
3376
3406
  case 3:
3377
3407
  case "end":
3378
- return _context24.stop();
3408
+ return _context25.stop();
3379
3409
  }
3380
- }, _callee24, this);
3410
+ }, _callee25, this);
3381
3411
  }));
3382
- function withdraw(_x7) {
3412
+ function withdraw(_x8) {
3383
3413
  return _withdraw.apply(this, arguments);
3384
3414
  }
3385
3415
  return withdraw;
3386
3416
  }();
3387
3417
  _proto2.repay = /*#__PURE__*/function () {
3388
- var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(amount) {
3389
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3390
- 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) {
3391
3421
  case 0:
3392
3422
  if (!isSameAddress(amount.token.address, ETHAddress)) {
3393
- _context25.next = 4;
3423
+ _context26.next = 4;
3394
3424
  break;
3395
3425
  }
3396
- return _context25.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
3426
+ return _context26.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
3397
3427
  value: amount.rawAmount()
3398
3428
  }));
3399
3429
  case 4:
3400
3430
  if (!new BigNumber(amount.rawAmount()).lt(0)) {
3401
- _context25.next = 8;
3431
+ _context26.next = 8;
3402
3432
  break;
3403
3433
  }
3404
- 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));
3405
3435
  case 8:
3406
- 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()));
3407
3437
  case 9:
3408
3438
  case "end":
3409
- return _context25.stop();
3439
+ return _context26.stop();
3410
3440
  }
3411
- }, _callee25, this);
3441
+ }, _callee26, this);
3412
3442
  }));
3413
- function repay(_x8) {
3443
+ function repay(_x9) {
3414
3444
  return _repay.apply(this, arguments);
3415
3445
  }
3416
3446
  return repay;
3417
3447
  }();
3418
3448
  _proto2.enableCollateral = /*#__PURE__*/function () {
3419
- var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
3420
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3421
- 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) {
3422
3452
  case 0:
3423
- 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]));
3424
3454
  case 1:
3425
3455
  case "end":
3426
- return _context26.stop();
3456
+ return _context27.stop();
3427
3457
  }
3428
- }, _callee26, this);
3458
+ }, _callee27, this);
3429
3459
  }));
3430
3460
  function enableCollateral() {
3431
3461
  return _enableCollateral.apply(this, arguments);
@@ -3433,16 +3463,16 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3433
3463
  return enableCollateral;
3434
3464
  }();
3435
3465
  _proto2.disableCollateral = /*#__PURE__*/function () {
3436
- var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
3437
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3438
- 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) {
3439
3469
  case 0:
3440
- 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));
3441
3471
  case 1:
3442
3472
  case "end":
3443
- return _context27.stop();
3473
+ return _context28.stop();
3444
3474
  }
3445
- }, _callee27, this);
3475
+ }, _callee28, this);
3446
3476
  }));
3447
3477
  function disableCollateral() {
3448
3478
  return _disableCollateral.apply(this, arguments);
@@ -5422,25 +5452,123 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5422
5452
  }
5423
5453
  return sneakAccounts;
5424
5454
  }();
5425
- _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5426
- var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(userAddress) {
5455
+ _proto.getLTVAndLiquidationThreshold = /*#__PURE__*/function () {
5456
+ var _getLTVAndLiquidationThreshold = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(userAddr) {
5427
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;
5428
5556
  var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator3, _step3, apy;
5429
- return _regeneratorRuntime().wrap(function _callee7$(_context8) {
5430
- while (1) switch (_context8.prev = _context8.next) {
5557
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
5558
+ while (1) switch (_context12.prev = _context12.next) {
5431
5559
  case 0:
5432
5560
  sum = new BigNumber(0);
5433
5561
  totalSuppliedValue = new BigNumber(0);
5434
5562
  totalBorrowedValue = new BigNumber(0);
5435
5563
  netApy = new BigNumber(0);
5436
- _context8.next = 6;
5564
+ _context12.next = 6;
5437
5565
  return Promise.all(networkAddresses.auTokens.map(function (auToken) {
5438
- var moneyMarket = new MoneyMarketRead(_this3._networkConnection, auToken.address, auToken.underlying);
5566
+ var moneyMarket = new MoneyMarketRead(_this4._networkConnection, auToken.address, auToken.underlying);
5439
5567
  var apyWithoutIncentive = moneyMarket.getApyWithoutIncentive(userAddress);
5440
5568
  return apyWithoutIncentive;
5441
5569
  }));
5442
5570
  case 6:
5443
- apys = _context8.sent;
5571
+ apys = _context12.sent;
5444
5572
  for (_iterator3 = _createForOfIteratorHelperLoose(apys); !(_step3 = _iterator3()).done;) {
5445
5573
  apy = _step3.value;
5446
5574
  sum = sum.plus(apy.sum);
@@ -5452,37 +5580,37 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5452
5580
  } else if (sum.lt(0)) {
5453
5581
  netApy = sum.div(totalBorrowedValue);
5454
5582
  }
5455
- return _context8.abrupt("return", netApy);
5583
+ return _context12.abrupt("return", netApy);
5456
5584
  case 10:
5457
5585
  case "end":
5458
- return _context8.stop();
5586
+ return _context12.stop();
5459
5587
  }
5460
- }, _callee7);
5588
+ }, _callee10);
5461
5589
  }));
5462
- function getNetApyWithoutIncentive(_x8) {
5590
+ function getNetApyWithoutIncentive(_x12) {
5463
5591
  return _getNetApyWithoutIncentive.apply(this, arguments);
5464
5592
  }
5465
5593
  return getNetApyWithoutIncentive;
5466
5594
  }();
5467
5595
  _proto.getNetApyWithIncentive = /*#__PURE__*/function () {
5468
- var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(userAddress) {
5469
- var _this4 = this;
5596
+ var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userAddress) {
5597
+ var _this5 = this;
5470
5598
  var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator4, _step4, apy;
5471
- return _regeneratorRuntime().wrap(function _callee8$(_context9) {
5472
- while (1) switch (_context9.prev = _context9.next) {
5599
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
5600
+ while (1) switch (_context13.prev = _context13.next) {
5473
5601
  case 0:
5474
5602
  sum = new BigNumber(0);
5475
5603
  totalSuppliedValue = new BigNumber(0);
5476
5604
  totalBorrowedValue = new BigNumber(0);
5477
5605
  netApy = new BigNumber(0);
5478
- _context9.next = 6;
5606
+ _context13.next = 6;
5479
5607
  return Promise.all(networkAddresses.auTokens.map(function (auToken) {
5480
- var moneyMarket = new MoneyMarketRead(_this4._networkConnection, auToken.address, auToken.underlying);
5608
+ var moneyMarket = new MoneyMarketRead(_this5._networkConnection, auToken.address, auToken.underlying);
5481
5609
  var apyWithIncentive = moneyMarket.getApyWithIncentive(userAddress);
5482
5610
  return apyWithIncentive;
5483
5611
  }));
5484
5612
  case 6:
5485
- apys = _context9.sent;
5613
+ apys = _context13.sent;
5486
5614
  for (_iterator4 = _createForOfIteratorHelperLoose(apys); !(_step4 = _iterator4()).done;) {
5487
5615
  apy = _step4.value;
5488
5616
  sum = sum.plus(apy.sum);
@@ -5494,14 +5622,14 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5494
5622
  } else if (sum.lt(0)) {
5495
5623
  netApy = sum.div(totalBorrowedValue);
5496
5624
  }
5497
- return _context9.abrupt("return", netApy);
5625
+ return _context13.abrupt("return", netApy);
5498
5626
  case 10:
5499
5627
  case "end":
5500
- return _context9.stop();
5628
+ return _context13.stop();
5501
5629
  }
5502
- }, _callee8);
5630
+ }, _callee11);
5503
5631
  }));
5504
- function getNetApyWithIncentive(_x9) {
5632
+ function getNetApyWithIncentive(_x13) {
5505
5633
  return _getNetApyWithIncentive.apply(this, arguments);
5506
5634
  }
5507
5635
  return getNetApyWithIncentive;
@@ -5822,49 +5950,62 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5822
5950
  }
5823
5951
  return sneakAccounts;
5824
5952
  }();
5825
- _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5826
- var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(userAddress) {
5827
- var miscRead;
5953
+ _proto.getLTVAndLiquidationThreshold = /*#__PURE__*/function () {
5954
+ var _getLTVAndLiquidationThreshold = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(userAddr) {
5828
5955
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
5829
5956
  while (1) switch (_context10.prev = _context10.next) {
5830
5957
  case 0:
5831
- miscRead = new MiscRead(this._networkConnection);
5832
- return _context10.abrupt("return", miscRead.getNetApyWithoutIncentive(userAddress));
5833
- case 2:
5958
+ return _context10.abrupt("return", this._misc.getLTVAndLiquidationThreshold(userAddr));
5959
+ case 1:
5834
5960
  case "end":
5835
5961
  return _context10.stop();
5836
5962
  }
5837
5963
  }, _callee10, this);
5838
5964
  }));
5839
- function getNetApyWithoutIncentive(_x10) {
5840
- return _getNetApyWithoutIncentive.apply(this, arguments);
5965
+ function getLTVAndLiquidationThreshold(_x10) {
5966
+ return _getLTVAndLiquidationThreshold.apply(this, arguments);
5841
5967
  }
5842
- return getNetApyWithoutIncentive;
5968
+ return getLTVAndLiquidationThreshold;
5843
5969
  }();
5844
- _proto.getNetApyWithIncentive = /*#__PURE__*/function () {
5845
- var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userAddress) {
5846
- var miscRead;
5970
+ _proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
5971
+ var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(userAddress) {
5847
5972
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
5848
5973
  while (1) switch (_context11.prev = _context11.next) {
5849
5974
  case 0:
5850
- miscRead = new MiscRead(this._networkConnection);
5851
- return _context11.abrupt("return", miscRead.getNetApyWithIncentive(userAddress));
5852
- case 2:
5975
+ return _context11.abrupt("return", this._misc.getNetApyWithoutIncentive(userAddress));
5976
+ case 1:
5853
5977
  case "end":
5854
5978
  return _context11.stop();
5855
5979
  }
5856
5980
  }, _callee11, this);
5857
5981
  }));
5858
- 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) {
5859
6000
  return _getNetApyWithIncentive.apply(this, arguments);
5860
6001
  }
5861
6002
  return getNetApyWithIncentive;
5862
6003
  }();
5863
6004
  _proto.setUserNotificationSettings = /*#__PURE__*/function () {
5864
- 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) {
5865
6006
  var body, response;
5866
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
5867
- while (1) switch (_context12.prev = _context12.next) {
6007
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
6008
+ while (1) switch (_context13.prev = _context13.next) {
5868
6009
  case 0:
5869
6010
  body = {
5870
6011
  address: address,
@@ -5875,27 +6016,27 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5875
6016
  },
5876
6017
  captchaResponse: captchaResponse
5877
6018
  };
5878
- _context12.next = 3;
6019
+ _context13.next = 3;
5879
6020
  return postApi('alert-setting/set', body);
5880
6021
  case 3:
5881
- response = _context12.sent;
5882
- return _context12.abrupt("return", response);
6022
+ response = _context13.sent;
6023
+ return _context13.abrupt("return", response);
5883
6024
  case 5:
5884
6025
  case "end":
5885
- return _context12.stop();
6026
+ return _context13.stop();
5886
6027
  }
5887
- }, _callee12);
6028
+ }, _callee13);
5888
6029
  }));
5889
- function setUserNotificationSettings(_x12, _x13, _x14, _x15, _x16) {
6030
+ function setUserNotificationSettings(_x13, _x14, _x15, _x16, _x17) {
5890
6031
  return _setUserNotificationSettings.apply(this, arguments);
5891
6032
  }
5892
6033
  return setUserNotificationSettings;
5893
6034
  }();
5894
6035
  _proto.unsetUserNotificationSettings = /*#__PURE__*/function () {
5895
- var _unsetUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address, captchaResponse) {
6036
+ var _unsetUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(address, captchaResponse) {
5896
6037
  var body, response;
5897
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
5898
- while (1) switch (_context13.prev = _context13.next) {
6038
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
6039
+ while (1) switch (_context14.prev = _context14.next) {
5899
6040
  case 0:
5900
6041
  body = {
5901
6042
  address: address,
@@ -5906,57 +6047,57 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5906
6047
  },
5907
6048
  captchaResponse: captchaResponse
5908
6049
  };
5909
- _context13.next = 3;
6050
+ _context14.next = 3;
5910
6051
  return postApi('alert-setting/set', body);
5911
6052
  case 3:
5912
- response = _context13.sent;
5913
- return _context13.abrupt("return", response);
6053
+ response = _context14.sent;
6054
+ return _context14.abrupt("return", response);
5914
6055
  case 5:
5915
6056
  case "end":
5916
- return _context13.stop();
6057
+ return _context14.stop();
5917
6058
  }
5918
- }, _callee13);
6059
+ }, _callee14);
5919
6060
  }));
5920
- function unsetUserNotificationSettings(_x17, _x18) {
6061
+ function unsetUserNotificationSettings(_x18, _x19) {
5921
6062
  return _unsetUserNotificationSettings.apply(this, arguments);
5922
6063
  }
5923
6064
  return unsetUserNotificationSettings;
5924
6065
  }();
5925
6066
  _proto.getUserNotificationSettings = /*#__PURE__*/function () {
5926
- var _getUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(addresses) {
6067
+ var _getUserNotificationSettings = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(addresses) {
5927
6068
  var body, response;
5928
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
5929
- while (1) switch (_context14.prev = _context14.next) {
6069
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
6070
+ while (1) switch (_context15.prev = _context15.next) {
5930
6071
  case 0:
5931
6072
  body = {
5932
6073
  addresses: addresses
5933
6074
  };
5934
- _context14.next = 3;
6075
+ _context15.next = 3;
5935
6076
  return postApi('alert-setting/get-user-setting', body);
5936
6077
  case 3:
5937
- response = _context14.sent;
5938
- return _context14.abrupt("return", response);
6078
+ response = _context15.sent;
6079
+ return _context15.abrupt("return", response);
5939
6080
  case 5:
5940
6081
  case "end":
5941
- return _context14.stop();
6082
+ return _context15.stop();
5942
6083
  }
5943
- }, _callee14);
6084
+ }, _callee15);
5944
6085
  }));
5945
- function getUserNotificationSettings(_x19) {
6086
+ function getUserNotificationSettings(_x20) {
5946
6087
  return _getUserNotificationSettings.apply(this, arguments);
5947
6088
  }
5948
6089
  return getUserNotificationSettings;
5949
6090
  }();
5950
6091
  _proto.getLiquidationHistory = /*#__PURE__*/function () {
5951
- var _getLiquidationHistory = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(address) {
6092
+ var _getLiquidationHistory = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(address) {
5952
6093
  var liquidationHistorySubgraph, liquidationEvents;
5953
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
5954
- while (1) switch (_context15.prev = _context15.next) {
6094
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
6095
+ while (1) switch (_context16.prev = _context16.next) {
5955
6096
  case 0:
5956
- _context15.next = 2;
6097
+ _context16.next = 2;
5957
6098
  return queryGraphQL(getLiquidationEventsQuery(address, 100), AURIGAMI_SUBGRAPH_URL);
5958
6099
  case 2:
5959
- liquidationHistorySubgraph = _context15.sent;
6100
+ liquidationHistorySubgraph = _context16.sent;
5960
6101
  liquidationEvents = liquidationHistorySubgraph.liquidationEvents.map(function (event) {
5961
6102
  var value = {
5962
6103
  amount: event.underlyingRepayAmountUSD.toString(),
@@ -5975,14 +6116,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5975
6116
  transactionId: event.id.split('-')[0]
5976
6117
  };
5977
6118
  });
5978
- return _context15.abrupt("return", liquidationEvents);
6119
+ return _context16.abrupt("return", liquidationEvents);
5979
6120
  case 5:
5980
6121
  case "end":
5981
- return _context15.stop();
6122
+ return _context16.stop();
5982
6123
  }
5983
- }, _callee15);
6124
+ }, _callee16);
5984
6125
  }));
5985
- function getLiquidationHistory(_x20) {
6126
+ function getLiquidationHistory(_x21) {
5986
6127
  return _getLiquidationHistory.apply(this, arguments);
5987
6128
  }
5988
6129
  return getLiquidationHistory;
@@ -6004,16 +6145,16 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
6004
6145
  _proto2.claim =
6005
6146
  /*#__PURE__*/
6006
6147
  function () {
6007
- var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
6008
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
6009
- while (1) switch (_context16.prev = _context16.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) {
6010
6151
  case 0:
6011
- return _context16.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));
6012
6153
  case 1:
6013
6154
  case "end":
6014
- return _context16.stop();
6155
+ return _context17.stop();
6015
6156
  }
6016
- }, _callee16, this);
6157
+ }, _callee17, this);
6017
6158
  }));
6018
6159
  function claim() {
6019
6160
  return _claim.apply(this, arguments);
@@ -6021,35 +6162,35 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
6021
6162
  return claim;
6022
6163
  }();
6023
6164
  _proto2.stake = /*#__PURE__*/function () {
6024
- var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(amount) {
6025
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
6026
- while (1) switch (_context17.prev = _context17.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) {
6027
6168
  case 0:
6028
- return _context17.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
6169
+ return _context18.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
6029
6170
  case 1:
6030
6171
  case "end":
6031
- return _context17.stop();
6172
+ return _context18.stop();
6032
6173
  }
6033
- }, _callee17, this);
6174
+ }, _callee18, this);
6034
6175
  }));
6035
- function stake(_x21) {
6176
+ function stake(_x22) {
6036
6177
  return _stake.apply(this, arguments);
6037
6178
  }
6038
6179
  return stake;
6039
6180
  }();
6040
6181
  _proto2.unstake = /*#__PURE__*/function () {
6041
- var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(amount) {
6042
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
6043
- while (1) switch (_context18.prev = _context18.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) {
6044
6185
  case 0:
6045
- return _context18.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
6186
+ return _context19.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
6046
6187
  case 1:
6047
6188
  case "end":
6048
- return _context18.stop();
6189
+ return _context19.stop();
6049
6190
  }
6050
- }, _callee18, this);
6191
+ }, _callee19, this);
6051
6192
  }));
6052
- function unstake(_x22) {
6193
+ function unstake(_x23) {
6053
6194
  return _unstake.apply(this, arguments);
6054
6195
  }
6055
6196
  return unstake;