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