@aurigami/sdk 1.4.8 → 1.5.0-dummy

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.
@@ -9,17 +9,18 @@ var ethers = require('ethers');
9
9
  var utils = require('ethers/lib/utils');
10
10
  var abstractSigner = require('@ethersproject/abstract-signer');
11
11
  var axios = _interopDefault(require('axios'));
12
+ var assert = _interopDefault(require('assert'));
12
13
  var AuErc20ABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json'));
13
14
  var AuETHABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json'));
14
15
  var ComptrollerABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json'));
15
16
  var AuriLensABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json'));
16
17
  var EthRepayHelperABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json'));
17
- var TokenLockABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/TokenLock.sol/TokenLock.json'));
18
18
  var AuriFairLaunchABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json'));
19
19
  var FaucetABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json'));
20
+ var EIP20InterfaceABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json'));
21
+ var PulpABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json'));
20
22
  var AuTokenABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json'));
21
23
  var AuriAirdropABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json'));
22
- var assert = _interopDefault(require('assert'));
23
24
 
24
25
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
25
26
  try {
@@ -988,20 +989,26 @@ var networkAddresses = {
988
989
  },
989
990
  tokens: {
990
991
  AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
991
- PLY: /*#__PURE__*/"0x981bD5832EAB9C8F607940E0e9faCBf8C09ee20a".toLowerCase(),
992
+ PLY: /*#__PURE__*/"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f".toLowerCase(),
992
993
  stNEAR: /*#__PURE__*/"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),
993
994
  USDC: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
994
995
  WNEAR: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
995
996
  TRI: /*#__PURE__*/'0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
996
997
  META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
997
- AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
998
+ PULP: /*#__PURE__*/'0x04Ac48711BCdc45b4d223fb021E09DA73c71095e'.toLowerCase(),
999
+ PLYUSDC: /*#__PURE__*/'0x37cae2b29c18e05ece60111fa01d3ca217046016'.toLowerCase()
998
1000
  }
999
1001
  };
1002
+ var PRICE_WHITELISTED = /*#__PURE__*/new Set( /*#__PURE__*/[].concat( /*#__PURE__*/networkAddresses.auTokens.map(function (t) {
1003
+ return t.underlying;
1004
+ }), [networkAddresses.tokens.AURORA, networkAddresses.tokens.TRI, networkAddresses.tokens.META, networkAddresses.tokens.stNEAR]));
1005
+ var REWARD_CLAIM_START = 1651762800;
1000
1006
  var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(1);
1001
- var REWARDCLAIMSTART = 1640995200;
1002
1007
  var ONE_DAY = 86400;
1003
1008
  var ONE_YEAR = ONE_DAY * 365;
1004
- var AurPlyPid = 0;
1009
+ var PlyUsdcPid = 0;
1010
+ var PLYUSDCRewardTokens = ['0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'];
1011
+ var ALL_STAKING_POOLS = [];
1005
1012
  var INF = /*#__PURE__*/ethers.BigNumber.from(2).pow(256).sub(1);
1006
1013
  var AIRDROP_START_TIMESTAMP = 1649858400;
1007
1014
  var AIRDROP_END_TIMESTAMP = 1651068000;
@@ -1062,7 +1069,7 @@ function _getQuery() {
1062
1069
 
1063
1070
  var decimalRecords = {
1064
1071
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
1065
- '0x981bd5832eab9c8f607940e0e9facbf8c09ee20a': 18,
1072
+ '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f': 18,
1066
1073
  '0x3195949f267702723bc614cae037cdc8d1e94786': 8,
1067
1074
  '0xfa94348467f64d5a457f75f8bc40495d33c65abb': 18,
1068
1075
  '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30': 24,
@@ -1080,7 +1087,9 @@ var decimalRecords = {
1080
1087
  '0xae4fac24dcdae0132c6d04f564dcf059616e9423': 8,
1081
1088
  '0xce4166363e3a584dac84a47bcd3414b43efcdd1c': 8,
1082
1089
  '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
1083
- '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24
1090
+ '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
1091
+ '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18,
1092
+ '0x37cae2b29c18e05ece60111fa01d3ca217046016': 18
1084
1093
  };
1085
1094
 
1086
1095
  function formatObject(object) {
@@ -1103,7 +1112,9 @@ function validateAndParseAddress(address) {
1103
1112
  }
1104
1113
  }
1105
1114
  function getDecimal(address) {
1106
- return decimalRecords[address.toLowerCase()];
1115
+ var addressLowercase = address.toLowerCase();
1116
+ assert(decimalRecords[addressLowercase] != undefined, "Decimal not found for " + address);
1117
+ return decimalRecords[addressLowercase];
1107
1118
  }
1108
1119
  function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1109
1120
  if (totalStakeValue.lte(0)) {
@@ -1190,7 +1201,7 @@ var Token = function Token(address, decimals) {
1190
1201
  this.decimals = decimals;
1191
1202
  };
1192
1203
  var PLYToken = /*#__PURE__*/new Token(networkAddresses.tokens.PLY, /*#__PURE__*/getDecimal(networkAddresses.tokens.PLY));
1193
- var AURPLYToken = /*#__PURE__*/new Token(networkAddresses.tokens.AURPLY, /*#__PURE__*/getDecimal(networkAddresses.tokens.AURPLY));
1204
+ var PLYUSDCToken = /*#__PURE__*/new Token(networkAddresses.tokens.PLYUSDC, /*#__PURE__*/getDecimal(networkAddresses.tokens.PLYUSDC));
1194
1205
 
1195
1206
  var TokenAmount = /*#__PURE__*/function () {
1196
1207
  function TokenAmount(token, amount, isRaw) {
@@ -2241,15 +2252,15 @@ function fetchLPPositions(_x3, _x4) {
2241
2252
 
2242
2253
  function _fetchLPPositions() {
2243
2254
  _fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(LPAddress, provider) {
2244
- var promises, LPContract, values;
2255
+ var LPContract, promises, values;
2245
2256
  return runtime_1.wrap(function _callee3$(_context3) {
2246
2257
  while (1) {
2247
2258
  switch (_context3.prev = _context3.next) {
2248
2259
  case 0:
2249
- promises = [];
2250
2260
  LPContract = new ethers.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
2261
+ promises = [];
2251
2262
  promises.push(LPContract.token0());
2252
- promises.push(LPContract.toekn1());
2263
+ promises.push(LPContract.token1());
2253
2264
  promises.push(LPContract.getReserves());
2254
2265
  promises.push(LPContract.totalSupply());
2255
2266
  _context3.next = 8;
@@ -2280,50 +2291,91 @@ function fetchLPPrice(_x5, _x6) {
2280
2291
  }
2281
2292
 
2282
2293
  function _fetchLPPrice() {
2283
- _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(address, provider) {
2284
- var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
2294
+ _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider) {
2295
+ var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy;
2285
2296
 
2286
- return runtime_1.wrap(function _callee4$(_context4) {
2297
+ return runtime_1.wrap(function _callee5$(_context5) {
2287
2298
  while (1) {
2288
- switch (_context4.prev = _context4.next) {
2299
+ switch (_context5.prev = _context5.next) {
2289
2300
  case 0:
2290
- _context4.next = 2;
2301
+ _fetchLPPriceBy = function _fetchLPPriceBy3() {
2302
+ _fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(tokenReverse) {
2303
+ var tokenPrice, tokenDecimal, reserveUSD;
2304
+ return runtime_1.wrap(function _callee4$(_context4) {
2305
+ while (1) {
2306
+ switch (_context4.prev = _context4.next) {
2307
+ case 0:
2308
+ if (!tokenReverse.reserve.isZero()) {
2309
+ _context4.next = 2;
2310
+ break;
2311
+ }
2312
+
2313
+ return _context4.abrupt("return", new BigNumber(0));
2314
+
2315
+ case 2:
2316
+ _context4.next = 4;
2317
+ return _fetchPrice(tokenReverse.address, provider);
2318
+
2319
+ case 4:
2320
+ tokenPrice = _context4.sent;
2321
+ tokenDecimal = getDecimal(tokenReverse.address);
2322
+ reserveUSD = tokenPrice.multipliedBy(tokenReverse.reserve.toString()).multipliedBy(2);
2323
+ return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
2324
+
2325
+ case 8:
2326
+ case "end":
2327
+ return _context4.stop();
2328
+ }
2329
+ }
2330
+ }, _callee4);
2331
+ }));
2332
+ return _fetchLPPriceBy.apply(this, arguments);
2333
+ };
2334
+
2335
+ fetchLPPriceBy = function _fetchLPPriceBy2(_x20) {
2336
+ return _fetchLPPriceBy.apply(this, arguments);
2337
+ };
2338
+
2339
+ _context5.next = 4;
2291
2340
  return fetchLPPositions(address, provider);
2292
2341
 
2293
- case 2:
2294
- LPInfo = _context4.sent;
2295
- _context4.prev = 3;
2296
- _context4.next = 6;
2297
- return fetchPrice(LPInfo.token0, provider);
2342
+ case 4:
2343
+ LPInfo = _context5.sent;
2344
+ LPDecimal = getDecimal(address);
2345
+ _context5.prev = 6;
2346
+ _context5.next = 9;
2347
+ return fetchLPPriceBy({
2348
+ address: LPInfo.token0,
2349
+ reserve: LPInfo.reserve0
2350
+ });
2298
2351
 
2299
- case 6:
2300
- token0Price = _context4.sent;
2301
- reserveUSD = token0Price.multipliedBy(LPInfo.reserve0.toString()).multipliedBy(2);
2302
- return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
2352
+ case 9:
2353
+ return _context5.abrupt("return", _context5.sent);
2354
+
2355
+ case 12:
2356
+ _context5.prev = 12;
2357
+ _context5.t0 = _context5["catch"](6);
2358
+ _context5.prev = 14;
2359
+ _context5.next = 17;
2360
+ return fetchLPPriceBy({
2361
+ address: LPInfo.token1,
2362
+ reserve: LPInfo.reserve1
2363
+ });
2303
2364
 
2304
- case 11:
2305
- _context4.prev = 11;
2306
- _context4.t0 = _context4["catch"](3);
2307
- _context4.prev = 13;
2308
- _context4.next = 16;
2309
- return fetchPrice(LPInfo.token1, provider);
2310
-
2311
- case 16:
2312
- token1Price = _context4.sent;
2313
- _reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
2314
- return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
2315
-
2316
- case 21:
2317
- _context4.prev = 21;
2318
- _context4.t1 = _context4["catch"](13);
2365
+ case 17:
2366
+ return _context5.abrupt("return", _context5.sent);
2367
+
2368
+ case 20:
2369
+ _context5.prev = 20;
2370
+ _context5.t1 = _context5["catch"](14);
2319
2371
  throw Error("Unable to fetch price for both tokens of LP " + address);
2320
2372
 
2321
- case 24:
2373
+ case 23:
2322
2374
  case "end":
2323
- return _context4.stop();
2375
+ return _context5.stop();
2324
2376
  }
2325
2377
  }
2326
- }, _callee4, null, [[3, 11], [13, 21]]);
2378
+ }, _callee5, null, [[6, 12], [14, 20]]);
2327
2379
  }));
2328
2380
  return _fetchLPPrice.apply(this, arguments);
2329
2381
  }
@@ -2337,26 +2389,26 @@ function fetchPriceFromOracle(_x7, _x8, _x9) {
2337
2389
  }
2338
2390
 
2339
2391
  function _fetchPriceFromOracle() {
2340
- _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
2392
+ _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(auTokenAddress, underlyingDecimal, provider) {
2341
2393
  var oracleContract, rawPrice;
2342
- return runtime_1.wrap(function _callee5$(_context5) {
2394
+ return runtime_1.wrap(function _callee6$(_context6) {
2343
2395
  while (1) {
2344
- switch (_context5.prev = _context5.next) {
2396
+ switch (_context6.prev = _context6.next) {
2345
2397
  case 0:
2346
2398
  oracleContract = new ethers.Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
2347
- _context5.next = 3;
2399
+ _context6.next = 3;
2348
2400
  return oracleContract.getUnderlyingPrice(auTokenAddress);
2349
2401
 
2350
2402
  case 3:
2351
- rawPrice = _context5.sent;
2352
- return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2403
+ rawPrice = _context6.sent;
2404
+ return _context6.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2353
2405
 
2354
2406
  case 5:
2355
2407
  case "end":
2356
- return _context5.stop();
2408
+ return _context6.stop();
2357
2409
  }
2358
2410
  }
2359
- }, _callee5);
2411
+ }, _callee6);
2360
2412
  }));
2361
2413
  return _fetchPriceFromOracle.apply(this, arguments);
2362
2414
  }
@@ -2366,11 +2418,11 @@ function fetchUnderlyingTokensPrices(_x10) {
2366
2418
  }
2367
2419
 
2368
2420
  function _fetchUnderlyingTokensPrices() {
2369
- _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
2421
+ _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(provider) {
2370
2422
  var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
2371
- return runtime_1.wrap(function _callee6$(_context6) {
2423
+ return runtime_1.wrap(function _callee7$(_context7) {
2372
2424
  while (1) {
2373
- switch (_context6.prev = _context6.next) {
2425
+ switch (_context7.prev = _context7.next) {
2374
2426
  case 0:
2375
2427
  auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, provider);
2376
2428
  auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
@@ -2379,12 +2431,12 @@ function _fetchUnderlyingTokensPrices() {
2379
2431
  underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
2380
2432
  return getDecimal(auToken.underlying);
2381
2433
  });
2382
- _context6.next = 5;
2434
+ _context7.next = 5;
2383
2435
  return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
2384
2436
 
2385
2437
  case 5:
2386
- rawPrices = _context6.sent;
2387
- return _context6.abrupt("return", rawPrices.map(function (res, ind) {
2438
+ rawPrices = _context7.sent;
2439
+ return _context7.abrupt("return", rawPrices.map(function (res, ind) {
2388
2440
  return {
2389
2441
  auToken: res.auToken,
2390
2442
  underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
@@ -2393,10 +2445,10 @@ function _fetchUnderlyingTokensPrices() {
2393
2445
 
2394
2446
  case 7:
2395
2447
  case "end":
2396
- return _context6.stop();
2448
+ return _context7.stop();
2397
2449
  }
2398
2450
  }
2399
- }, _callee6);
2451
+ }, _callee7);
2400
2452
  }));
2401
2453
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2402
2454
  }
@@ -2406,33 +2458,33 @@ function fetchStNEARPrice() {
2406
2458
  }
2407
2459
 
2408
2460
  function _fetchStNEARPrice() {
2409
- _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
2461
+ _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
2410
2462
  var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
2411
2463
 
2412
- return runtime_1.wrap(function _callee7$(_context7) {
2464
+ return runtime_1.wrap(function _callee8$(_context8) {
2413
2465
  while (1) {
2414
- switch (_context7.prev = _context7.next) {
2466
+ switch (_context8.prev = _context8.next) {
2415
2467
  case 0:
2416
2468
  ratioPromise = axios.get("https://validators.narwallets.com/metrics_json").then(function (res) {
2417
2469
  return res.data;
2418
2470
  });
2419
2471
  nearPricePromise = fetchPriceFromCoingeckoAPI('near');
2420
- _context7.next = 4;
2472
+ _context8.next = 4;
2421
2473
  return Promise.all([ratioPromise, nearPricePromise]);
2422
2474
 
2423
2475
  case 4:
2424
- _yield$Promise$all = _context7.sent;
2476
+ _yield$Promise$all = _context8.sent;
2425
2477
  ratioRes = _yield$Promise$all[0];
2426
2478
  nearPrice = _yield$Promise$all[1];
2427
2479
  ratio = new BigNumber(ratioRes.st_near_price);
2428
- return _context7.abrupt("return", ratio.multipliedBy(nearPrice));
2480
+ return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
2429
2481
 
2430
2482
  case 9:
2431
2483
  case "end":
2432
- return _context7.stop();
2484
+ return _context8.stop();
2433
2485
  }
2434
2486
  }
2435
- }, _callee7);
2487
+ }, _callee8);
2436
2488
  }));
2437
2489
  return _fetchStNEARPrice.apply(this, arguments);
2438
2490
  }
@@ -2442,105 +2494,176 @@ function shouldFetchFromCoingecko(address) {
2442
2494
  return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
2443
2495
  }
2444
2496
 
2445
- function fetchPrice(_x11, _x12) {
2446
- return _fetchPrice.apply(this, arguments);
2497
+ function _fetchPrice(_x11, _x12) {
2498
+ return _fetchPrice2.apply(this, arguments);
2447
2499
  }
2448
2500
 
2449
- function _fetchPrice() {
2450
- _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
2501
+ function _fetchPrice2() {
2502
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
2451
2503
  var matchingAuToken;
2452
- return runtime_1.wrap(function _callee8$(_context8) {
2504
+ return runtime_1.wrap(function _callee9$(_context9) {
2453
2505
  while (1) {
2454
- switch (_context8.prev = _context8.next) {
2506
+ switch (_context9.prev = _context9.next) {
2455
2507
  case 0:
2456
- if (!( isSameAddress(address, networkAddresses.tokens.PLY))) {
2457
- _context8.next = 2;
2458
- break;
2459
- }
2460
-
2461
- return _context8.abrupt("return", new BigNumber(0));
2508
+ assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()));
2462
2509
 
2463
- case 2:
2464
2510
  if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
2465
- _context8.next = 4;
2511
+ _context9.next = 3;
2466
2512
  break;
2467
2513
  }
2468
2514
 
2469
- return _context8.abrupt("return", fetchStNEARPrice());
2515
+ return _context9.abrupt("return", fetchStNEARPrice());
2470
2516
 
2471
- case 4:
2517
+ case 3:
2472
2518
  if (!shouldFetchFromCoingecko(address)) {
2473
- _context8.next = 6;
2519
+ _context9.next = 5;
2474
2520
  break;
2475
2521
  }
2476
2522
 
2477
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2523
+ return _context9.abrupt("return", fetchPriceFromCoingecko(address));
2478
2524
 
2479
- case 6:
2525
+ case 5:
2480
2526
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2481
2527
  return isSameAddress(auToken.underlying, address);
2482
2528
  });
2483
2529
 
2484
2530
  if (!(matchingAuToken !== undefined)) {
2485
- _context8.next = 11;
2531
+ _context9.next = 10;
2486
2532
  break;
2487
2533
  }
2488
2534
 
2489
- return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2535
+ return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2536
+
2537
+ case 10:
2538
+ throw Error("Unable to fetch price for " + address);
2490
2539
 
2491
2540
  case 11:
2492
- if (!isSameAddress(address, networkAddresses.tokens.AURPLY)) {
2493
- _context8.next = 15;
2541
+ case "end":
2542
+ return _context9.stop();
2543
+ }
2544
+ }
2545
+ }, _callee9);
2546
+ }));
2547
+ return _fetchPrice2.apply(this, arguments);
2548
+ }
2549
+
2550
+ function fetchPrice(_x13, _x14) {
2551
+ return _fetchPrice3.apply(this, arguments);
2552
+ }
2553
+
2554
+ function _fetchPrice3() {
2555
+ _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
2556
+ return runtime_1.wrap(function _callee10$(_context10) {
2557
+ while (1) {
2558
+ switch (_context10.prev = _context10.next) {
2559
+ case 0:
2560
+ if (!isSameAddress(address, networkAddresses.tokens.PLYUSDC)) {
2561
+ _context10.next = 4;
2562
+ break;
2563
+ }
2564
+
2565
+ return _context10.abrupt("return", fetchLPPrice(address, provider));
2566
+
2567
+ case 4:
2568
+ if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2569
+ _context10.next = 6;
2494
2570
  break;
2495
2571
  }
2496
2572
 
2497
- return _context8.abrupt("return", fetchLPPrice(address, provider));
2573
+ return _context10.abrupt("return", fetchPLYPrice(provider));
2498
2574
 
2499
- case 15:
2500
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2575
+ case 6:
2576
+ return _context10.abrupt("return", _fetchPrice(address, provider));
2501
2577
 
2502
- case 16:
2578
+ case 7:
2503
2579
  case "end":
2504
- return _context8.stop();
2580
+ return _context10.stop();
2505
2581
  }
2506
2582
  }
2507
- }, _callee8);
2583
+ }, _callee10);
2508
2584
  }));
2509
- return _fetchPrice.apply(this, arguments);
2585
+ return _fetchPrice3.apply(this, arguments);
2586
+ }
2587
+
2588
+ function fetchPLYPrice(_x15) {
2589
+ return _fetchPLYPrice.apply(this, arguments);
2510
2590
  }
2511
2591
 
2512
- function fetchValuation(_x13, _x14) {
2592
+ function _fetchPLYPrice() {
2593
+ _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2594
+ var LPInfo, plyAddress, plyDecimal, usdcAddress, usdcDecimal;
2595
+ return runtime_1.wrap(function _callee11$(_context11) {
2596
+ while (1) {
2597
+ switch (_context11.prev = _context11.next) {
2598
+ case 0:
2599
+ _context11.next = 2;
2600
+ return fetchLPPositions(networkAddresses.tokens.PLYUSDC, provider);
2601
+
2602
+ case 2:
2603
+ LPInfo = _context11.sent;
2604
+
2605
+ if (!LPInfo.reserve1.isZero()) {
2606
+ _context11.next = 5;
2607
+ break;
2608
+ }
2609
+
2610
+ return _context11.abrupt("return", new BigNumber(0));
2611
+
2612
+ case 5:
2613
+ plyAddress = LPInfo.token0;
2614
+ assert(isSameAddress(plyAddress, networkAddresses.tokens.PLY));
2615
+ plyDecimal = getDecimal(plyAddress);
2616
+ usdcAddress = LPInfo.token1;
2617
+ assert(isSameAddress(usdcAddress, networkAddresses.tokens.USDC));
2618
+ usdcDecimal = getDecimal(usdcAddress);
2619
+ _context11.next = 13;
2620
+ return fetchPrice(usdcAddress, provider);
2621
+
2622
+ case 13:
2623
+ return _context11.abrupt("return", _context11.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(plyDecimal)).dividedBy(decimalFactor(usdcDecimal)).dividedBy(LPInfo.reserve0.toString()));
2624
+
2625
+ case 14:
2626
+ case "end":
2627
+ return _context11.stop();
2628
+ }
2629
+ }
2630
+ }, _callee11);
2631
+ }));
2632
+ return _fetchPLYPrice.apply(this, arguments);
2633
+ }
2634
+
2635
+ function fetchValuation(_x16, _x17) {
2513
2636
  return _fetchValuation.apply(this, arguments);
2514
2637
  }
2515
2638
 
2516
2639
  function _fetchValuation() {
2517
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(tokenAmount, provider) {
2640
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(tokenAmount, provider) {
2518
2641
  var price;
2519
- return runtime_1.wrap(function _callee9$(_context9) {
2642
+ return runtime_1.wrap(function _callee12$(_context12) {
2520
2643
  while (1) {
2521
- switch (_context9.prev = _context9.next) {
2644
+ switch (_context12.prev = _context12.next) {
2522
2645
  case 0:
2523
2646
  if (!(tokenAmount.rawAmount() == "0")) {
2524
- _context9.next = 2;
2647
+ _context12.next = 2;
2525
2648
  break;
2526
2649
  }
2527
2650
 
2528
- return _context9.abrupt("return", new BigNumber(0));
2651
+ return _context12.abrupt("return", new BigNumber(0));
2529
2652
 
2530
2653
  case 2:
2531
- _context9.next = 4;
2654
+ _context12.next = 4;
2532
2655
  return fetchPrice(tokenAmount.token.address, provider);
2533
2656
 
2534
2657
  case 4:
2535
- price = _context9.sent;
2536
- return _context9.abrupt("return", calcValuation(tokenAmount, price));
2658
+ price = _context12.sent;
2659
+ return _context12.abrupt("return", calcValuation(tokenAmount, price));
2537
2660
 
2538
2661
  case 6:
2539
2662
  case "end":
2540
- return _context9.stop();
2663
+ return _context12.stop();
2541
2664
  }
2542
2665
  }
2543
- }, _callee9);
2666
+ }, _callee12);
2544
2667
  }));
2545
2668
  return _fetchValuation.apply(this, arguments);
2546
2669
  }
@@ -2548,6 +2671,39 @@ function _fetchValuation() {
2548
2671
  function calcValuation(tokenAmount, price) {
2549
2672
  return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price);
2550
2673
  }
2674
+ function valuateToken(_x18, _x19) {
2675
+ return _valuateToken.apply(this, arguments);
2676
+ }
2677
+
2678
+ function _valuateToken() {
2679
+ _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(tokenAmount, provider) {
2680
+ var tokenValuation;
2681
+ return runtime_1.wrap(function _callee13$(_context13) {
2682
+ while (1) {
2683
+ switch (_context13.prev = _context13.next) {
2684
+ case 0:
2685
+ _context13.next = 2;
2686
+ return fetchValuation(tokenAmount, provider);
2687
+
2688
+ case 2:
2689
+ tokenValuation = _context13.sent;
2690
+ return _context13.abrupt("return", {
2691
+ tokenAmount: tokenAmount,
2692
+ currencyAmount: {
2693
+ currency: "USD",
2694
+ amount: tokenValuation.toFixed(DECIMAL_PRECISION)
2695
+ }
2696
+ });
2697
+
2698
+ case 4:
2699
+ case "end":
2700
+ return _context13.stop();
2701
+ }
2702
+ }
2703
+ }, _callee13);
2704
+ }));
2705
+ return _valuateToken.apply(this, arguments);
2706
+ }
2551
2707
 
2552
2708
  var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2553
2709
  _inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
@@ -3230,76 +3386,285 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
3230
3386
  return MoneyMarket;
3231
3387
  }(BlockchainEntity);
3232
3388
 
3233
- var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3234
- _inheritsLoose(SdkRead, _BlockchainEntityRead);
3389
+ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3390
+ _inheritsLoose(PapermillRead, _BlockchainEntityRead);
3235
3391
 
3236
- function SdkRead(networkConnection) {
3392
+ function PapermillRead(networkConnection) {
3237
3393
  var _this;
3238
3394
 
3239
3395
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
3396
+ var plyAddress = networkAddresses.tokens.PLY;
3397
+ var pulpAddress = networkAddresses.tokens.PULP;
3398
+ _this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
3399
+ _this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
3240
3400
  _this._comptroller = new ethers.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
3241
- _this._tokenLock = new ethers.Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
3242
3401
  _this._auriFairLaunch = new ethers.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
3243
3402
  _this._auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
3403
+ _this._ply = new ethers.Contract(plyAddress, EIP20InterfaceABI.abi, networkConnection.provider);
3404
+ _this._pulp = new ethers.Contract(pulpAddress, PulpABI.abi, networkConnection.provider);
3244
3405
  return _this;
3245
3406
  }
3246
3407
 
3247
- var _proto = SdkRead.prototype;
3408
+ var _proto = PapermillRead.prototype;
3248
3409
 
3249
- _proto.getLockingDetails = /*#__PURE__*/function () {
3250
- var _getLockingDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3251
- var currentTime, currentWeek, denominator, promises, values;
3410
+ _proto.getPlyBalance = /*#__PURE__*/function () {
3411
+ var _getPlyBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
3412
+ var plyBalance;
3252
3413
  return runtime_1.wrap(function _callee$(_context) {
3253
3414
  while (1) {
3254
3415
  switch (_context.prev = _context.next) {
3416
+ case 0:
3417
+ _context.next = 2;
3418
+ return this._ply.balanceOf(userAddress);
3419
+
3420
+ case 2:
3421
+ plyBalance = _context.sent;
3422
+ return _context.abrupt("return", new TokenAmount(this.plyToken, plyBalance.toString()));
3423
+
3424
+ case 4:
3425
+ case "end":
3426
+ return _context.stop();
3427
+ }
3428
+ }
3429
+ }, _callee, this);
3430
+ }));
3431
+
3432
+ function getPlyBalance(_x) {
3433
+ return _getPlyBalance.apply(this, arguments);
3434
+ }
3435
+
3436
+ return getPlyBalance;
3437
+ }();
3438
+
3439
+ _proto.getPulpBalance = /*#__PURE__*/function () {
3440
+ var _getPulpBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
3441
+ var pulpBalance;
3442
+ return runtime_1.wrap(function _callee2$(_context2) {
3443
+ while (1) {
3444
+ switch (_context2.prev = _context2.next) {
3445
+ case 0:
3446
+ _context2.next = 2;
3447
+ return this._pulp.balanceOf(userAddress);
3448
+
3449
+ case 2:
3450
+ pulpBalance = _context2.sent;
3451
+ return _context2.abrupt("return", new TokenAmount(this.pulpToken, pulpBalance.toString()));
3452
+
3453
+ case 4:
3454
+ case "end":
3455
+ return _context2.stop();
3456
+ }
3457
+ }
3458
+ }, _callee2, this);
3459
+ }));
3460
+
3461
+ function getPulpBalance(_x2) {
3462
+ return _getPulpBalance.apply(this, arguments);
3463
+ }
3464
+
3465
+ return getPulpBalance;
3466
+ }();
3467
+
3468
+ _proto.getUnclaimedPlyReward = /*#__PURE__*/function () {
3469
+ var _getUnclaimedPlyReward = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(userAddress) {
3470
+ var rewardBalancesMetadata;
3471
+ return runtime_1.wrap(function _callee3$(_context3) {
3472
+ while (1) {
3473
+ switch (_context3.prev = _context3.next) {
3474
+ case 0:
3475
+ _context3.next = 2;
3476
+ return this._auriLens.callStatic.claimRewards(this._comptroller.address, this._auriFairLaunch.address, ALL_STAKING_POOLS, {
3477
+ from: userAddress
3478
+ });
3479
+
3480
+ case 2:
3481
+ rewardBalancesMetadata = _context3.sent;
3482
+ return _context3.abrupt("return", new TokenAmount(this.plyToken, rewardBalancesMetadata.plyAccrured.toString()));
3483
+
3484
+ case 4:
3485
+ case "end":
3486
+ return _context3.stop();
3487
+ }
3488
+ }
3489
+ }, _callee3, this);
3490
+ }));
3491
+
3492
+ function getUnclaimedPlyReward(_x3) {
3493
+ return _getUnclaimedPlyReward.apply(this, arguments);
3494
+ }
3495
+
3496
+ return getUnclaimedPlyReward;
3497
+ }();
3498
+
3499
+ _proto.getLockingDetails = /*#__PURE__*/function () {
3500
+ var _getLockingDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(userAddress) {
3501
+ var currentTime, currentWeek, denominator, promises, values, percentLockCurrentWeek, percentLockNextWeek, totalRewards, _yield$this$_pulp$cal, pulpAmountCurrentWeek, plyAmountCurrentWeek, plyAmountNextWeek, pulpAmountNextWeek, currentUnlockPortion, nextUnlockPortion;
3502
+
3503
+ return runtime_1.wrap(function _callee4$(_context4) {
3504
+ while (1) {
3505
+ switch (_context4.prev = _context4.next) {
3255
3506
  case 0:
3256
3507
  currentTime = getCurrentTimestamp();
3257
- currentWeek = ethers.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
3258
- denominator = 10000;
3508
+ currentWeek = ethers.BigNumber.from(currentTime - REWARD_CLAIM_START).div(7 * ONE_DAY).toNumber();
3509
+ denominator = ethers.BigNumber.from(10000);
3259
3510
  promises = [];
3260
- promises.push(this._tokenLock.percentageLock(currentWeek));
3261
- promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
3262
- return denominator;
3263
- }));
3264
- _context.next = 8;
3265
- return Promise.all(promises).then(function (res) {
3266
- return res.map(function (v) {
3267
- return v.toString();
3268
- });
3269
- });
3511
+ promises.push(this._auriLens.getPercentLock(this._pulp.address, userAddress, currentWeek));
3512
+ promises.push(this._auriLens.getPercentLock(this._pulp.address, userAddress, currentWeek + 1));
3513
+ promises.push(this.getUnclaimedPlyReward(userAddress));
3514
+ _context4.next = 9;
3515
+ return Promise.all(promises);
3270
3516
 
3271
- case 8:
3272
- values = _context.sent;
3273
- return _context.abrupt("return", {
3274
- vestingStart: REWARDCLAIMSTART,
3275
- currentUnlockPortion: new BigNumber(denominator).minus(values[0]).div(denominator).toNumber(),
3276
- nextUnlockPortion: new BigNumber(denominator).minus(values[1]).div(denominator).toNumber()
3517
+ case 9:
3518
+ values = _context4.sent;
3519
+ percentLockCurrentWeek = ethers.BigNumber.from(values[0]);
3520
+ percentLockNextWeek = ethers.BigNumber.from(values[1]);
3521
+ totalRewards = values[2];
3522
+ _context4.next = 15;
3523
+ return this._pulp.calcLockAmount(userAddress, totalRewards.rawAmount());
3524
+
3525
+ case 15:
3526
+ _yield$this$_pulp$cal = _context4.sent;
3527
+ pulpAmountCurrentWeek = _yield$this$_pulp$cal[0];
3528
+ plyAmountCurrentWeek = _yield$this$_pulp$cal[1];
3529
+ plyAmountNextWeek = percentLockNextWeek.mul(totalRewards.rawAmount()).div(denominator);
3530
+ pulpAmountNextWeek = ethers.BigNumber.from(totalRewards.rawAmount()).sub(plyAmountNextWeek);
3531
+ currentUnlockPortion = denominator.sub(percentLockCurrentWeek).toString();
3532
+ nextUnlockPortion = denominator.sub(percentLockNextWeek).toString();
3533
+ return _context4.abrupt("return", {
3534
+ vestingStart: REWARD_CLAIM_START,
3535
+ currentUnlockPortion: new BigNumber(currentUnlockPortion).dividedBy(100).toNumber(),
3536
+ accruedPly: totalRewards,
3537
+ currentPly: new TokenAmount(this.plyToken, plyAmountCurrentWeek.toString()),
3538
+ currentPulp: new TokenAmount(this.pulpToken, pulpAmountCurrentWeek.toString()),
3539
+ nextUnlockPortion: new BigNumber(nextUnlockPortion).dividedBy(100).toNumber(),
3540
+ nextPly: new TokenAmount(this.plyToken, plyAmountNextWeek.toString()),
3541
+ nextPulp: new TokenAmount(this.pulpToken, pulpAmountNextWeek.toString())
3277
3542
  });
3278
3543
 
3279
- case 10:
3544
+ case 23:
3280
3545
  case "end":
3281
- return _context.stop();
3546
+ return _context4.stop();
3282
3547
  }
3283
3548
  }
3284
- }, _callee, this);
3549
+ }, _callee4, this);
3285
3550
  }));
3286
3551
 
3287
- function getLockingDetails() {
3552
+ function getLockingDetails(_x4) {
3288
3553
  return _getLockingDetails.apply(this, arguments);
3289
3554
  }
3290
3555
 
3291
3556
  return getLockingDetails;
3292
3557
  }();
3293
3558
 
3559
+ return PapermillRead;
3560
+ }(BlockchainEntityRead);
3561
+ var PapermillReadWrite = /*#__PURE__*/function (_PapermillRead) {
3562
+ _inheritsLoose(PapermillReadWrite, _PapermillRead);
3563
+
3564
+ function PapermillReadWrite(networkConnection) {
3565
+ return _PapermillRead.call(this, networkConnection) || this;
3566
+ }
3567
+
3568
+ var _proto2 = PapermillReadWrite.prototype;
3569
+
3570
+ _proto2.redeem = /*#__PURE__*/function () {
3571
+ var _redeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(recipient, amount) {
3572
+ return runtime_1.wrap(function _callee5$(_context5) {
3573
+ while (1) {
3574
+ switch (_context5.prev = _context5.next) {
3575
+ case 0:
3576
+ return _context5.abrupt("return", this._pulp.redeem(recipient, amount.rawAmount()));
3577
+
3578
+ case 1:
3579
+ case "end":
3580
+ return _context5.stop();
3581
+ }
3582
+ }
3583
+ }, _callee5, this);
3584
+ }));
3585
+
3586
+ function redeem(_x5, _x6) {
3587
+ return _redeem.apply(this, arguments);
3588
+ }
3589
+
3590
+ return redeem;
3591
+ }();
3592
+
3593
+ _proto2.selfRedeem = /*#__PURE__*/function () {
3594
+ var _selfRedeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(amount) {
3595
+ var msgSender;
3596
+ return runtime_1.wrap(function _callee6$(_context6) {
3597
+ while (1) {
3598
+ switch (_context6.prev = _context6.next) {
3599
+ case 0:
3600
+ _context6.next = 2;
3601
+ return this._networkConnection.signer.getAddress();
3602
+
3603
+ case 2:
3604
+ msgSender = _context6.sent;
3605
+ return _context6.abrupt("return", this.redeem(msgSender, amount));
3606
+
3607
+ case 4:
3608
+ case "end":
3609
+ return _context6.stop();
3610
+ }
3611
+ }
3612
+ }, _callee6, this);
3613
+ }));
3614
+
3615
+ function selfRedeem(_x7) {
3616
+ return _selfRedeem.apply(this, arguments);
3617
+ }
3618
+
3619
+ return selfRedeem;
3620
+ }();
3621
+
3622
+ return PapermillReadWrite;
3623
+ }(PapermillRead);
3624
+ var Papermill = /*#__PURE__*/function (_BlockchainEntity) {
3625
+ _inheritsLoose(Papermill, _BlockchainEntity);
3626
+
3627
+ function Papermill() {
3628
+ return _BlockchainEntity.call(this) || this;
3629
+ }
3630
+
3631
+ var _proto3 = Papermill.prototype;
3632
+
3633
+ _proto3.read = function read(networkConnection) {
3634
+ return new PapermillRead(networkConnection);
3635
+ };
3636
+
3637
+ _proto3.readWrite = function readWrite(networkConnection) {
3638
+ return new PapermillReadWrite(networkConnection);
3639
+ };
3640
+
3641
+ return Papermill;
3642
+ }(BlockchainEntity);
3643
+
3644
+ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3645
+ _inheritsLoose(SdkRead, _BlockchainEntityRead);
3646
+
3647
+ function SdkRead(networkConnection) {
3648
+ var _this;
3649
+
3650
+ _this = _BlockchainEntityRead.call(this, networkConnection) || this;
3651
+ _this._comptroller = new ethers.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
3652
+ _this._auriFairLaunch = new ethers.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
3653
+ _this._auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
3654
+ return _this;
3655
+ }
3656
+
3657
+ var _proto = SdkRead.prototype;
3658
+
3294
3659
  _proto.getUserDetails = /*#__PURE__*/function () {
3295
- var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
3660
+ var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
3296
3661
  var _this2 = this;
3297
3662
 
3298
- var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, rewardBalancesMetadata, lockedAmount, _yield$Promise$all, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
3663
+ var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
3299
3664
 
3300
- return runtime_1.wrap(function _callee2$(_context2) {
3665
+ return runtime_1.wrap(function _callee$(_context) {
3301
3666
  while (1) {
3302
- switch (_context2.prev = _context2.next) {
3667
+ switch (_context.prev = _context.next) {
3303
3668
  case 0:
3304
3669
  marketCount = networkAddresses.auTokens.length;
3305
3670
  userMarketDetails = [];
@@ -3335,15 +3700,15 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3335
3700
  promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
3336
3701
  assetsIn = res;
3337
3702
  }));
3338
- _context2.next = 10;
3703
+ _context.next = 10;
3339
3704
  return Promise.all(promises);
3340
3705
 
3341
3706
  case 10:
3342
- _context2.next = 12;
3707
+ _context.next = 12;
3343
3708
  return Promise.all(pricePromises);
3344
3709
 
3345
3710
  case 12:
3346
- underlyingPrices = _context2.sent;
3711
+ underlyingPrices = _context.sent;
3347
3712
  depositValues = [];
3348
3713
 
3349
3714
  _loop = function _loop() {
@@ -3368,20 +3733,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3368
3733
  if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
3369
3734
  return p;
3370
3735
  }, new BigNumber(0));
3371
- promises = new Array(3);
3372
- promises[0] = this._comptroller.getAccountLiquidity(userAddress);
3373
- promises[1] = this._auriLens.callStatic.claimRewards(this._comptroller.address, this._auriFairLaunch.address, [], {
3374
- from: userAddress
3375
- });
3376
- promises[2] = this._tokenLock.lockedAmounts(userAddress);
3377
- _context2.next = 23;
3378
- return Promise.all(promises);
3736
+ _context.next = 19;
3737
+ return this._comptroller.getAccountLiquidity(userAddress);
3379
3738
 
3380
- case 23:
3381
- _yield$Promise$all = _context2.sent;
3382
- accountLiquidity = _yield$Promise$all[0];
3383
- rewardBalancesMetadata = _yield$Promise$all[1];
3384
- lockedAmount = _yield$Promise$all[2];
3739
+ case 19:
3740
+ accountLiquidity = _context.sent;
3385
3741
  borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
3386
3742
 
3387
3743
  if (borrowedvaluation.lt("0.00001")) {
@@ -3405,26 +3761,33 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3405
3761
  userMarketDetails[i].maxWithdrawableAmount = userMarketDetails[i].isCollateral && maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount()) ? new TokenAmount(moneyMarket.underlying, maxWithdrawCap.toFixed(24), false) : new TokenAmount(moneyMarket.underlying, userMarketDetails[i].depositBalance.rawAmount());
3406
3762
  }
3407
3763
 
3408
- return _context2.abrupt("return", {
3409
- markets: userMarketDetails,
3410
- borrowLimit: {
3411
- currency: "USD",
3412
- amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
3413
- },
3414
- accruedPly: new TokenAmount(PLYToken, rewardBalancesMetadata.plyAccrured.toString()),
3415
- lockedPly: new TokenAmount(PLYToken, lockedAmount.toString()),
3416
- borrowableAmount: {
3417
- currency: "USD",
3418
- amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
3419
- }
3764
+ _context.t0 = userMarketDetails;
3765
+ _context.t1 = {
3766
+ currency: "USD",
3767
+ amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
3768
+ };
3769
+ _context.next = 30;
3770
+ return new PapermillRead(this._networkConnection).getLockingDetails(userAddress);
3771
+
3772
+ case 30:
3773
+ _context.t2 = _context.sent;
3774
+ _context.t3 = {
3775
+ currency: "USD",
3776
+ amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
3777
+ };
3778
+ return _context.abrupt("return", {
3779
+ markets: _context.t0,
3780
+ borrowLimit: _context.t1,
3781
+ userLockingDetails: _context.t2,
3782
+ borrowableAmount: _context.t3
3420
3783
  });
3421
3784
 
3422
- case 34:
3785
+ case 33:
3423
3786
  case "end":
3424
- return _context2.stop();
3787
+ return _context.stop();
3425
3788
  }
3426
3789
  }
3427
- }, _callee2, this);
3790
+ }, _callee, this);
3428
3791
  }));
3429
3792
 
3430
3793
  function getUserDetails(_x) {
@@ -3434,76 +3797,92 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3434
3797
  return getUserDetails;
3435
3798
  }();
3436
3799
 
3437
- _proto.getPlyAuroraPoolDetails = /*#__PURE__*/function () {
3438
- var _getPlyAuroraPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
3439
- var stakedLiquidity, rewardPerSecond, promises, rewardPerSecondValuation, totalStakeValuation;
3440
- return runtime_1.wrap(function _callee3$(_context3) {
3800
+ _proto.getPlyUsdcPoolDetails = /*#__PURE__*/function () {
3801
+ var _getPlyUsdcPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
3802
+ var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, promises, _i, rewardTokenAddress, rewardToken, rewardPerSecond, rewardPerSecondValuation, totalStakeValuation;
3803
+
3804
+ return runtime_1.wrap(function _callee2$(_context2) {
3441
3805
  while (1) {
3442
- switch (_context3.prev = _context3.next) {
3806
+ switch (_context2.prev = _context2.next) {
3443
3807
  case 0:
3444
- promises = [];
3445
- promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then(function (res) {
3808
+ _context2.next = 2;
3809
+ return this._auriFairLaunch.getPoolInfo(PlyUsdcPid).then(function (res) {
3446
3810
  stakedLiquidity = res.totalStake;
3447
- rewardPerSecond = res.rewardPerSeconds[0];
3448
- }));
3449
- _context3.next = 4;
3450
- return Promise.all(promises);
3811
+ rewardPerSeconds = res.rewardPerSeconds;
3812
+ });
3451
3813
 
3452
- case 4:
3814
+ case 2:
3815
+ stakedLiquidityAmount = new TokenAmount(PLYUSDCToken, stakedLiquidity.toString());
3453
3816
  promises = [];
3454
- promises.push(fetchValuation(new TokenAmount(PLYToken, rewardPerSecond.toString()), this._networkConnection.provider).then(function (res) {
3455
- return rewardPerSecondValuation = res;
3456
- }));
3457
- promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
3458
- return totalStakeValuation = res;
3459
- }));
3460
- _context3.next = 9;
3817
+
3818
+ for (_i = 0; _i < rewardPerSeconds.length; _i++) {
3819
+ rewardTokenAddress = PLYUSDCRewardTokens[_i];
3820
+ rewardToken = new Token(rewardTokenAddress, getDecimal(rewardTokenAddress));
3821
+ rewardPerSecond = rewardPerSeconds[_i];
3822
+ promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
3823
+ }
3824
+
3825
+ _context2.next = 7;
3461
3826
  return Promise.all(promises);
3462
3827
 
3463
- case 9:
3464
- return _context3.abrupt("return", {
3465
- totalStakedLiquidity: new TokenAmount(AURPLYToken, stakedLiquidity.toString()),
3828
+ case 7:
3829
+ rewardPerSecondValuation = _context2.sent.reduce(function (p, v) {
3830
+ return p.plus(v);
3831
+ }, new BigNumber(0));
3832
+ _context2.next = 10;
3833
+ return fetchValuation(stakedLiquidityAmount, this._networkConnection.provider);
3834
+
3835
+ case 10:
3836
+ totalStakeValuation = _context2.sent;
3837
+ return _context2.abrupt("return", {
3838
+ totalStakedLiquidity: {
3839
+ tokenAmount: stakedLiquidityAmount,
3840
+ currencyAmount: {
3841
+ currency: "USD",
3842
+ amount: totalStakeValuation.toFixed(DECIMAL_PRECISION)
3843
+ }
3844
+ },
3466
3845
  apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
3467
3846
  });
3468
3847
 
3469
- case 10:
3848
+ case 12:
3470
3849
  case "end":
3471
- return _context3.stop();
3850
+ return _context2.stop();
3472
3851
  }
3473
3852
  }
3474
- }, _callee3, this);
3853
+ }, _callee2, this);
3475
3854
  }));
3476
3855
 
3477
- function getPlyAuroraPoolDetails() {
3478
- return _getPlyAuroraPoolDetails.apply(this, arguments);
3856
+ function getPlyUsdcPoolDetails() {
3857
+ return _getPlyUsdcPoolDetails.apply(this, arguments);
3479
3858
  }
3480
3859
 
3481
- return getPlyAuroraPoolDetails;
3860
+ return getPlyUsdcPoolDetails;
3482
3861
  }();
3483
3862
 
3484
3863
  _proto.getTokenPrice = /*#__PURE__*/function () {
3485
- var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(token) {
3864
+ var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(token) {
3486
3865
  var price;
3487
- return runtime_1.wrap(function _callee4$(_context4) {
3866
+ return runtime_1.wrap(function _callee3$(_context3) {
3488
3867
  while (1) {
3489
- switch (_context4.prev = _context4.next) {
3868
+ switch (_context3.prev = _context3.next) {
3490
3869
  case 0:
3491
- _context4.next = 2;
3870
+ _context3.next = 2;
3492
3871
  return fetchPrice(token.address, this._networkConnection.provider);
3493
3872
 
3494
3873
  case 2:
3495
- price = _context4.sent;
3496
- return _context4.abrupt("return", {
3874
+ price = _context3.sent;
3875
+ return _context3.abrupt("return", {
3497
3876
  currency: "USD",
3498
3877
  amount: price.toFixed(DECIMAL_PRECISION)
3499
3878
  });
3500
3879
 
3501
3880
  case 4:
3502
3881
  case "end":
3503
- return _context4.stop();
3882
+ return _context3.stop();
3504
3883
  }
3505
3884
  }
3506
- }, _callee4, this);
3885
+ }, _callee3, this);
3507
3886
  }));
3508
3887
 
3509
3888
  function getTokenPrice(_x2) {
@@ -3514,25 +3893,26 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3514
3893
  }();
3515
3894
 
3516
3895
  _proto.stakeBalanceOf = /*#__PURE__*/function () {
3517
- var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(user) {
3518
- var userInfo;
3519
- return runtime_1.wrap(function _callee5$(_context5) {
3896
+ var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(user) {
3897
+ var userInfo, stakeAmount;
3898
+ return runtime_1.wrap(function _callee4$(_context4) {
3520
3899
  while (1) {
3521
- switch (_context5.prev = _context5.next) {
3900
+ switch (_context4.prev = _context4.next) {
3522
3901
  case 0:
3523
- _context5.next = 2;
3524
- return this._auriFairLaunch.getUserInfo(AurPlyPid, user);
3902
+ _context4.next = 2;
3903
+ return this._auriFairLaunch.getUserInfo(PlyUsdcPid, user);
3525
3904
 
3526
3905
  case 2:
3527
- userInfo = _context5.sent;
3528
- return _context5.abrupt("return", new TokenAmount(AURPLYToken, userInfo.amount.toString()));
3906
+ userInfo = _context4.sent;
3907
+ stakeAmount = new TokenAmount(PLYUSDCToken, userInfo.amount.toString());
3908
+ return _context4.abrupt("return", valuateToken(stakeAmount, this._networkConnection.provider));
3529
3909
 
3530
- case 4:
3910
+ case 5:
3531
3911
  case "end":
3532
- return _context5.stop();
3912
+ return _context4.stop();
3533
3913
  }
3534
3914
  }
3535
- }, _callee5, this);
3915
+ }, _callee4, this);
3536
3916
  }));
3537
3917
 
3538
3918
  function stakeBalanceOf(_x3) {
@@ -3542,6 +3922,36 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3542
3922
  return stakeBalanceOf;
3543
3923
  }();
3544
3924
 
3925
+ _proto.LpBalanceOf = /*#__PURE__*/function () {
3926
+ var _LpBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(user) {
3927
+ var lpERC20, balance;
3928
+ return runtime_1.wrap(function _callee5$(_context5) {
3929
+ while (1) {
3930
+ switch (_context5.prev = _context5.next) {
3931
+ case 0:
3932
+ lpERC20 = new ethers.Contract(networkAddresses.tokens.PLYUSDC, EIP20InterfaceABI.abi, this._networkConnection.provider);
3933
+ _context5.next = 3;
3934
+ return lpERC20.balanceOf(user);
3935
+
3936
+ case 3:
3937
+ balance = _context5.sent;
3938
+ return _context5.abrupt("return", valuateToken(new TokenAmount(PLYUSDCToken, balance.toString()), this._networkConnection.provider));
3939
+
3940
+ case 5:
3941
+ case "end":
3942
+ return _context5.stop();
3943
+ }
3944
+ }
3945
+ }, _callee5, this);
3946
+ }));
3947
+
3948
+ function LpBalanceOf(_x4) {
3949
+ return _LpBalanceOf.apply(this, arguments);
3950
+ }
3951
+
3952
+ return LpBalanceOf;
3953
+ }();
3954
+
3545
3955
  _proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
3546
3956
  var userMarketDetail = _ref.userMarketDetail,
3547
3957
  currentBorrowLimit = _ref.currentBorrowLimit,
@@ -3597,7 +4007,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3597
4007
  while (1) {
3598
4008
  switch (_context6.prev = _context6.next) {
3599
4009
  case 0:
3600
- return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid]));
4010
+ return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, ALL_STAKING_POOLS));
3601
4011
 
3602
4012
  case 1:
3603
4013
  case "end":
@@ -3620,7 +4030,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3620
4030
  while (1) {
3621
4031
  switch (_context7.prev = _context7.next) {
3622
4032
  case 0:
3623
- return _context7.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).deposit(AurPlyPid, amount.rawAmount()));
4033
+ return _context7.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).deposit(PlyUsdcPid, amount.rawAmount()));
3624
4034
 
3625
4035
  case 1:
3626
4036
  case "end":
@@ -3630,7 +4040,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3630
4040
  }, _callee7, this);
3631
4041
  }));
3632
4042
 
3633
- function stake(_x4) {
4043
+ function stake(_x5) {
3634
4044
  return _stake.apply(this, arguments);
3635
4045
  }
3636
4046
 
@@ -3643,7 +4053,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3643
4053
  while (1) {
3644
4054
  switch (_context8.prev = _context8.next) {
3645
4055
  case 0:
3646
- return _context8.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).withdraw(AurPlyPid, amount.rawAmount()));
4056
+ return _context8.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).withdraw(PlyUsdcPid, amount.rawAmount()));
3647
4057
 
3648
4058
  case 1:
3649
4059
  case "end":
@@ -3653,7 +4063,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3653
4063
  }, _callee8, this);
3654
4064
  }));
3655
4065
 
3656
- function unstake(_x5) {
4066
+ function unstake(_x6) {
3657
4067
  return _unstake.apply(this, arguments);
3658
4068
  }
3659
4069
 
@@ -106914,12 +107324,11 @@ BigNumber.config({
106914
107324
  exports.AIRDROP_END_TIMESTAMP = AIRDROP_END_TIMESTAMP;
106915
107325
  exports.AIRDROP_KEEP_THRESHOLD = AIRDROP_KEEP_THRESHOLD;
106916
107326
  exports.AIRDROP_START_TIMESTAMP = AIRDROP_START_TIMESTAMP;
107327
+ exports.ALL_STAKING_POOLS = ALL_STAKING_POOLS;
106917
107328
  exports.AURORA_CHAINID = AURORA_CHAINID;
106918
- exports.AURPLYToken = AURPLYToken;
106919
107329
  exports.Airdrop = Airdrop;
106920
107330
  exports.AirdropRead = AirdropRead;
106921
107331
  exports.AirdropReadWrite = AirdropReadWrite;
106922
- exports.AurPlyPid = AurPlyPid;
106923
107332
  exports.BORROW_LIMIT_BUFFER = BORROW_LIMIT_BUFFER;
106924
107333
  exports.BORROW_NEAR_REWARDS_PER_WEEK = BORROW_NEAR_REWARDS_PER_WEEK;
106925
107334
  exports.BlockchainEntity = BlockchainEntity;
@@ -106935,7 +107344,14 @@ exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
106935
107344
  exports.ONE_DAY = ONE_DAY;
106936
107345
  exports.ONE_YEAR = ONE_YEAR;
106937
107346
  exports.PLYToken = PLYToken;
106938
- exports.REWARDCLAIMSTART = REWARDCLAIMSTART;
107347
+ exports.PLYUSDCRewardTokens = PLYUSDCRewardTokens;
107348
+ exports.PLYUSDCToken = PLYUSDCToken;
107349
+ exports.PRICE_WHITELISTED = PRICE_WHITELISTED;
107350
+ exports.Papermill = Papermill;
107351
+ exports.PapermillRead = PapermillRead;
107352
+ exports.PapermillReadWrite = PapermillReadWrite;
107353
+ exports.PlyUsdcPid = PlyUsdcPid;
107354
+ exports.REWARD_CLAIM_START = REWARD_CLAIM_START;
106939
107355
  exports.SDK = SDK;
106940
107356
  exports.SdkRead = SdkRead;
106941
107357
  exports.SdkReadWrite = SdkReadWrite;
@@ -106957,6 +107373,7 @@ exports.dummyUserMarketDetails = dummyUserMarketDetails;
106957
107373
  exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
106958
107374
  exports.fetchLPPositions = fetchLPPositions;
106959
107375
  exports.fetchLPPrice = fetchLPPrice;
107376
+ exports.fetchPLYPrice = fetchPLYPrice;
106960
107377
  exports.fetchPrice = fetchPrice;
106961
107378
  exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
106962
107379
  exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
@@ -106972,4 +107389,5 @@ exports.getDecimal = getDecimal;
106972
107389
  exports.isSameAddress = isSameAddress;
106973
107390
  exports.networkAddresses = networkAddresses;
106974
107391
  exports.validateAndParseAddress = validateAndParseAddress;
107392
+ exports.valuateToken = valuateToken;
106975
107393
  //# sourceMappingURL=sdk.cjs.development.js.map