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