@aurigami/sdk 1.4.7 → 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 {
@@ -976,30 +977,35 @@ var networkAddresses = {
976
977
  }],
977
978
  misc: {
978
979
  COMPTROLLER: /*#__PURE__*/"0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb".toLowerCase(),
979
- FAKE_COMPTROLLER: /*#__PURE__*/"0x8072b287b6a95e1Db6C8404BBd78642387dFA16C".toLowerCase(),
980
980
  oracle: /*#__PURE__*/"0xC6e5185438e1730959c1eF3551059A3feC744E90".toLowerCase(),
981
- AURIFAIRLAUNCH: /*#__PURE__*/"0x9F9ceE911509abC6Af899c12ED625B0A6580D6e6".toLowerCase(),
982
- AURILENS: /*#__PURE__*/'0xC41a5C1625d492436600789469c1CE2eA20CEA6B'.toLowerCase(),
981
+ AURIFAIRLAUNCH: /*#__PURE__*/"0x6f068608573c840bB27b39458d7d87eB865e19Cc".toLowerCase(),
982
+ AURILENS: /*#__PURE__*/'0xFfdFfBDB966Cb84B50e62d70105f2Dbf2e0A1e70'.toLowerCase(),
983
983
  TOKENLOCK: /*#__PURE__*/'0xDACC02a4Ff16Ea3c1515AdbfdCeb7B1F448B79c8'.toLowerCase(),
984
984
  ETHREPAYHELPER: /*#__PURE__*/"0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6".toLowerCase(),
985
985
  AURI_AIRDROP: /*#__PURE__*/"0x6C42aA5b128B62D6CCf357726D7d13F3888335EC".toLowerCase()
986
986
  },
987
987
  tokens: {
988
988
  AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
989
- PLY: /*#__PURE__*/"0x981bD5832EAB9C8F607940E0e9faCBf8C09ee20a".toLowerCase(),
989
+ PLY: /*#__PURE__*/"0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f".toLowerCase(),
990
990
  stNEAR: /*#__PURE__*/"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),
991
991
  USDC: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
992
992
  WNEAR: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
993
993
  TRI: /*#__PURE__*/'0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
994
994
  META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
995
- AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
995
+ PULP: /*#__PURE__*/'0x04Ac48711BCdc45b4d223fb021E09DA73c71095e'.toLowerCase(),
996
+ PLYUSDC: /*#__PURE__*/'0x37cae2b29c18e05ece60111fa01d3ca217046016'.toLowerCase()
996
997
  }
997
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;
998
1003
  var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(1);
999
- var REWARDCLAIMSTART = 1640995200;
1000
1004
  var ONE_DAY = 86400;
1001
1005
  var ONE_YEAR = ONE_DAY * 365;
1002
- var AurPlyPid = 0;
1006
+ var PlyUsdcPid = 0;
1007
+ var PLYUSDCRewardTokens = ['0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'];
1008
+ var ALL_STAKING_POOLS = [];
1003
1009
  var INF = /*#__PURE__*/BigNumber$1.from(2).pow(256).sub(1);
1004
1010
  var AIRDROP_START_TIMESTAMP = 1649858400;
1005
1011
  var AIRDROP_END_TIMESTAMP = 1651068000;
@@ -1060,7 +1066,7 @@ function _getQuery() {
1060
1066
 
1061
1067
  var decimalRecords = {
1062
1068
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
1063
- '0x981bd5832eab9c8f607940e0e9facbf8c09ee20a': 18,
1069
+ '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f': 18,
1064
1070
  '0x3195949f267702723bc614cae037cdc8d1e94786': 8,
1065
1071
  '0xfa94348467f64d5a457f75f8bc40495d33c65abb': 18,
1066
1072
  '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30': 24,
@@ -1078,7 +1084,9 @@ var decimalRecords = {
1078
1084
  '0xae4fac24dcdae0132c6d04f564dcf059616e9423': 8,
1079
1085
  '0xce4166363e3a584dac84a47bcd3414b43efcdd1c': 8,
1080
1086
  '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
1081
- '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24
1087
+ '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
1088
+ '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18,
1089
+ '0x37cae2b29c18e05ece60111fa01d3ca217046016': 18
1082
1090
  };
1083
1091
 
1084
1092
  function formatObject(object) {
@@ -1101,7 +1109,9 @@ function validateAndParseAddress(address) {
1101
1109
  }
1102
1110
  }
1103
1111
  function getDecimal(address) {
1104
- return decimalRecords[address.toLowerCase()];
1112
+ var addressLowercase = address.toLowerCase();
1113
+ assert(decimalRecords[addressLowercase] != undefined, "Decimal not found for " + address);
1114
+ return decimalRecords[addressLowercase];
1105
1115
  }
1106
1116
  function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1107
1117
  if (totalStakeValue.lte(0)) {
@@ -1188,7 +1198,7 @@ var Token = function Token(address, decimals) {
1188
1198
  this.decimals = decimals;
1189
1199
  };
1190
1200
  var PLYToken = /*#__PURE__*/new Token(networkAddresses.tokens.PLY, /*#__PURE__*/getDecimal(networkAddresses.tokens.PLY));
1191
- 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));
1192
1202
 
1193
1203
  var TokenAmount = /*#__PURE__*/function () {
1194
1204
  function TokenAmount(token, amount, isRaw) {
@@ -2239,15 +2249,15 @@ function fetchLPPositions(_x3, _x4) {
2239
2249
 
2240
2250
  function _fetchLPPositions() {
2241
2251
  _fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(LPAddress, provider) {
2242
- var promises, LPContract, values;
2252
+ var LPContract, promises, values;
2243
2253
  return runtime_1.wrap(function _callee3$(_context3) {
2244
2254
  while (1) {
2245
2255
  switch (_context3.prev = _context3.next) {
2246
2256
  case 0:
2247
- promises = [];
2248
2257
  LPContract = new Contract(LPAddress, IUniswapV2PairABI.abi, provider);
2258
+ promises = [];
2249
2259
  promises.push(LPContract.token0());
2250
- promises.push(LPContract.toekn1());
2260
+ promises.push(LPContract.token1());
2251
2261
  promises.push(LPContract.getReserves());
2252
2262
  promises.push(LPContract.totalSupply());
2253
2263
  _context3.next = 8;
@@ -2278,50 +2288,91 @@ function fetchLPPrice(_x5, _x6) {
2278
2288
  }
2279
2289
 
2280
2290
  function _fetchLPPrice() {
2281
- _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(address, provider) {
2282
- var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
2291
+ _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider) {
2292
+ var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy;
2283
2293
 
2284
- return runtime_1.wrap(function _callee4$(_context4) {
2294
+ return runtime_1.wrap(function _callee5$(_context5) {
2285
2295
  while (1) {
2286
- switch (_context4.prev = _context4.next) {
2296
+ switch (_context5.prev = _context5.next) {
2287
2297
  case 0:
2288
- _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;
2289
2337
  return fetchLPPositions(address, provider);
2290
2338
 
2291
- case 2:
2292
- LPInfo = _context4.sent;
2293
- _context4.prev = 3;
2294
- _context4.next = 6;
2295
- 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
+ });
2296
2348
 
2297
- case 6:
2298
- token0Price = _context4.sent;
2299
- reserveUSD = token0Price.multipliedBy(LPInfo.reserve0.toString()).multipliedBy(2);
2300
- 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
+ });
2301
2361
 
2302
- case 11:
2303
- _context4.prev = 11;
2304
- _context4.t0 = _context4["catch"](3);
2305
- _context4.prev = 13;
2306
- _context4.next = 16;
2307
- return fetchPrice(LPInfo.token1, provider);
2308
-
2309
- case 16:
2310
- token1Price = _context4.sent;
2311
- _reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
2312
- return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
2313
-
2314
- case 21:
2315
- _context4.prev = 21;
2316
- _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);
2317
2368
  throw Error("Unable to fetch price for both tokens of LP " + address);
2318
2369
 
2319
- case 24:
2370
+ case 23:
2320
2371
  case "end":
2321
- return _context4.stop();
2372
+ return _context5.stop();
2322
2373
  }
2323
2374
  }
2324
- }, _callee4, null, [[3, 11], [13, 21]]);
2375
+ }, _callee5, null, [[6, 12], [14, 20]]);
2325
2376
  }));
2326
2377
  return _fetchLPPrice.apply(this, arguments);
2327
2378
  }
@@ -2335,26 +2386,26 @@ function fetchPriceFromOracle(_x7, _x8, _x9) {
2335
2386
  }
2336
2387
 
2337
2388
  function _fetchPriceFromOracle() {
2338
- _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
2389
+ _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(auTokenAddress, underlyingDecimal, provider) {
2339
2390
  var oracleContract, rawPrice;
2340
- return runtime_1.wrap(function _callee5$(_context5) {
2391
+ return runtime_1.wrap(function _callee6$(_context6) {
2341
2392
  while (1) {
2342
- switch (_context5.prev = _context5.next) {
2393
+ switch (_context6.prev = _context6.next) {
2343
2394
  case 0:
2344
2395
  oracleContract = new Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
2345
- _context5.next = 3;
2396
+ _context6.next = 3;
2346
2397
  return oracleContract.getUnderlyingPrice(auTokenAddress);
2347
2398
 
2348
2399
  case 3:
2349
- rawPrice = _context5.sent;
2350
- return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2400
+ rawPrice = _context6.sent;
2401
+ return _context6.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2351
2402
 
2352
2403
  case 5:
2353
2404
  case "end":
2354
- return _context5.stop();
2405
+ return _context6.stop();
2355
2406
  }
2356
2407
  }
2357
- }, _callee5);
2408
+ }, _callee6);
2358
2409
  }));
2359
2410
  return _fetchPriceFromOracle.apply(this, arguments);
2360
2411
  }
@@ -2364,11 +2415,11 @@ function fetchUnderlyingTokensPrices(_x10) {
2364
2415
  }
2365
2416
 
2366
2417
  function _fetchUnderlyingTokensPrices() {
2367
- _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
2418
+ _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(provider) {
2368
2419
  var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
2369
- return runtime_1.wrap(function _callee6$(_context6) {
2420
+ return runtime_1.wrap(function _callee7$(_context7) {
2370
2421
  while (1) {
2371
- switch (_context6.prev = _context6.next) {
2422
+ switch (_context7.prev = _context7.next) {
2372
2423
  case 0:
2373
2424
  auriLens = new Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, provider);
2374
2425
  auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
@@ -2377,12 +2428,12 @@ function _fetchUnderlyingTokensPrices() {
2377
2428
  underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
2378
2429
  return getDecimal(auToken.underlying);
2379
2430
  });
2380
- _context6.next = 5;
2431
+ _context7.next = 5;
2381
2432
  return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
2382
2433
 
2383
2434
  case 5:
2384
- rawPrices = _context6.sent;
2385
- return _context6.abrupt("return", rawPrices.map(function (res, ind) {
2435
+ rawPrices = _context7.sent;
2436
+ return _context7.abrupt("return", rawPrices.map(function (res, ind) {
2386
2437
  return {
2387
2438
  auToken: res.auToken,
2388
2439
  underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
@@ -2391,10 +2442,10 @@ function _fetchUnderlyingTokensPrices() {
2391
2442
 
2392
2443
  case 7:
2393
2444
  case "end":
2394
- return _context6.stop();
2445
+ return _context7.stop();
2395
2446
  }
2396
2447
  }
2397
- }, _callee6);
2448
+ }, _callee7);
2398
2449
  }));
2399
2450
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2400
2451
  }
@@ -2404,33 +2455,33 @@ function fetchStNEARPrice() {
2404
2455
  }
2405
2456
 
2406
2457
  function _fetchStNEARPrice() {
2407
- _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
2458
+ _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
2408
2459
  var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
2409
2460
 
2410
- return runtime_1.wrap(function _callee7$(_context7) {
2461
+ return runtime_1.wrap(function _callee8$(_context8) {
2411
2462
  while (1) {
2412
- switch (_context7.prev = _context7.next) {
2463
+ switch (_context8.prev = _context8.next) {
2413
2464
  case 0:
2414
2465
  ratioPromise = axios.get("https://validators.narwallets.com/metrics_json").then(function (res) {
2415
2466
  return res.data;
2416
2467
  });
2417
2468
  nearPricePromise = fetchPriceFromCoingeckoAPI('near');
2418
- _context7.next = 4;
2469
+ _context8.next = 4;
2419
2470
  return Promise.all([ratioPromise, nearPricePromise]);
2420
2471
 
2421
2472
  case 4:
2422
- _yield$Promise$all = _context7.sent;
2473
+ _yield$Promise$all = _context8.sent;
2423
2474
  ratioRes = _yield$Promise$all[0];
2424
2475
  nearPrice = _yield$Promise$all[1];
2425
2476
  ratio = new BigNumber(ratioRes.st_near_price);
2426
- return _context7.abrupt("return", ratio.multipliedBy(nearPrice));
2477
+ return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
2427
2478
 
2428
2479
  case 9:
2429
2480
  case "end":
2430
- return _context7.stop();
2481
+ return _context8.stop();
2431
2482
  }
2432
2483
  }
2433
- }, _callee7);
2484
+ }, _callee8);
2434
2485
  }));
2435
2486
  return _fetchStNEARPrice.apply(this, arguments);
2436
2487
  }
@@ -2440,105 +2491,176 @@ function shouldFetchFromCoingecko(address) {
2440
2491
  return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
2441
2492
  }
2442
2493
 
2443
- function fetchPrice(_x11, _x12) {
2444
- return _fetchPrice.apply(this, arguments);
2494
+ function _fetchPrice(_x11, _x12) {
2495
+ return _fetchPrice2.apply(this, arguments);
2445
2496
  }
2446
2497
 
2447
- function _fetchPrice() {
2448
- _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
2498
+ function _fetchPrice2() {
2499
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
2449
2500
  var matchingAuToken;
2450
- return runtime_1.wrap(function _callee8$(_context8) {
2501
+ return runtime_1.wrap(function _callee9$(_context9) {
2451
2502
  while (1) {
2452
- switch (_context8.prev = _context8.next) {
2503
+ switch (_context9.prev = _context9.next) {
2453
2504
  case 0:
2454
- if (!( isSameAddress(address, networkAddresses.tokens.PLY))) {
2455
- _context8.next = 2;
2456
- break;
2457
- }
2458
-
2459
- return _context8.abrupt("return", new BigNumber(0));
2505
+ assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()));
2460
2506
 
2461
- case 2:
2462
2507
  if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
2463
- _context8.next = 4;
2508
+ _context9.next = 3;
2464
2509
  break;
2465
2510
  }
2466
2511
 
2467
- return _context8.abrupt("return", fetchStNEARPrice());
2512
+ return _context9.abrupt("return", fetchStNEARPrice());
2468
2513
 
2469
- case 4:
2514
+ case 3:
2470
2515
  if (!shouldFetchFromCoingecko(address)) {
2471
- _context8.next = 6;
2516
+ _context9.next = 5;
2472
2517
  break;
2473
2518
  }
2474
2519
 
2475
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2520
+ return _context9.abrupt("return", fetchPriceFromCoingecko(address));
2476
2521
 
2477
- case 6:
2522
+ case 5:
2478
2523
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2479
2524
  return isSameAddress(auToken.underlying, address);
2480
2525
  });
2481
2526
 
2482
2527
  if (!(matchingAuToken !== undefined)) {
2483
- _context8.next = 11;
2528
+ _context9.next = 10;
2484
2529
  break;
2485
2530
  }
2486
2531
 
2487
- 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);
2488
2536
 
2489
2537
  case 11:
2490
- if (!isSameAddress(address, networkAddresses.tokens.AURPLY)) {
2491
- _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;
2492
2567
  break;
2493
2568
  }
2494
2569
 
2495
- return _context8.abrupt("return", fetchLPPrice(address, provider));
2570
+ return _context10.abrupt("return", fetchPLYPrice(provider));
2496
2571
 
2497
- case 15:
2498
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2572
+ case 6:
2573
+ return _context10.abrupt("return", _fetchPrice(address, provider));
2499
2574
 
2500
- case 16:
2575
+ case 7:
2501
2576
  case "end":
2502
- return _context8.stop();
2577
+ return _context10.stop();
2503
2578
  }
2504
2579
  }
2505
- }, _callee8);
2580
+ }, _callee10);
2506
2581
  }));
2507
- return _fetchPrice.apply(this, arguments);
2582
+ return _fetchPrice3.apply(this, arguments);
2583
+ }
2584
+
2585
+ function fetchPLYPrice(_x15) {
2586
+ return _fetchPLYPrice.apply(this, arguments);
2508
2587
  }
2509
2588
 
2510
- 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) {
2511
2633
  return _fetchValuation.apply(this, arguments);
2512
2634
  }
2513
2635
 
2514
2636
  function _fetchValuation() {
2515
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(tokenAmount, provider) {
2637
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(tokenAmount, provider) {
2516
2638
  var price;
2517
- return runtime_1.wrap(function _callee9$(_context9) {
2639
+ return runtime_1.wrap(function _callee12$(_context12) {
2518
2640
  while (1) {
2519
- switch (_context9.prev = _context9.next) {
2641
+ switch (_context12.prev = _context12.next) {
2520
2642
  case 0:
2521
2643
  if (!(tokenAmount.rawAmount() == "0")) {
2522
- _context9.next = 2;
2644
+ _context12.next = 2;
2523
2645
  break;
2524
2646
  }
2525
2647
 
2526
- return _context9.abrupt("return", new BigNumber(0));
2648
+ return _context12.abrupt("return", new BigNumber(0));
2527
2649
 
2528
2650
  case 2:
2529
- _context9.next = 4;
2651
+ _context12.next = 4;
2530
2652
  return fetchPrice(tokenAmount.token.address, provider);
2531
2653
 
2532
2654
  case 4:
2533
- price = _context9.sent;
2534
- return _context9.abrupt("return", calcValuation(tokenAmount, price));
2655
+ price = _context12.sent;
2656
+ return _context12.abrupt("return", calcValuation(tokenAmount, price));
2535
2657
 
2536
2658
  case 6:
2537
2659
  case "end":
2538
- return _context9.stop();
2660
+ return _context12.stop();
2539
2661
  }
2540
2662
  }
2541
- }, _callee9);
2663
+ }, _callee12);
2542
2664
  }));
2543
2665
  return _fetchValuation.apply(this, arguments);
2544
2666
  }
@@ -2546,6 +2668,39 @@ function _fetchValuation() {
2546
2668
  function calcValuation(tokenAmount, price) {
2547
2669
  return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price);
2548
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
+ }
2549
2704
 
2550
2705
  var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2551
2706
  _inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
@@ -3228,77 +3383,285 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
3228
3383
  return MoneyMarket;
3229
3384
  }(BlockchainEntity);
3230
3385
 
3231
- var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3232
- _inheritsLoose(SdkRead, _BlockchainEntityRead);
3386
+ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3387
+ _inheritsLoose(PapermillRead, _BlockchainEntityRead);
3233
3388
 
3234
- function SdkRead(networkConnection) {
3389
+ function PapermillRead(networkConnection) {
3235
3390
  var _this;
3236
3391
 
3237
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));
3238
3397
  _this._comptroller = new Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
3239
- _this._tokenLock = new Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
3240
3398
  _this._auriFairLaunch = new Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
3241
3399
  _this._auriLens = new Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
3242
- _this._fakeComptroller = new Contract(networkAddresses.misc.FAKE_COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
3400
+ _this._ply = new Contract(plyAddress, EIP20InterfaceABI.abi, networkConnection.provider);
3401
+ _this._pulp = new Contract(pulpAddress, PulpABI.abi, networkConnection.provider);
3243
3402
  return _this;
3244
3403
  }
3245
3404
 
3246
- var _proto = SdkRead.prototype;
3405
+ var _proto = PapermillRead.prototype;
3247
3406
 
3248
- _proto.getLockingDetails = /*#__PURE__*/function () {
3249
- var _getLockingDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3250
- 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;
3251
3410
  return runtime_1.wrap(function _callee$(_context) {
3252
3411
  while (1) {
3253
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) {
3254
3503
  case 0:
3255
3504
  currentTime = getCurrentTimestamp();
3256
- currentWeek = BigNumber$1.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
3257
- denominator = 10000;
3505
+ currentWeek = BigNumber$1.from(currentTime - REWARD_CLAIM_START).div(7 * ONE_DAY).toNumber();
3506
+ denominator = BigNumber$1.from(10000);
3258
3507
  promises = [];
3259
- promises.push(this._tokenLock.percentageLock(currentWeek));
3260
- promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
3261
- return denominator;
3262
- }));
3263
- _context.next = 8;
3264
- return Promise.all(promises).then(function (res) {
3265
- return res.map(function (v) {
3266
- return v.toString();
3267
- });
3268
- });
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);
3269
3513
 
3270
- case 8:
3271
- values = _context.sent;
3272
- return _context.abrupt("return", {
3273
- vestingStart: REWARDCLAIMSTART,
3274
- currentUnlockPortion: new BigNumber(denominator).minus(values[0]).div(denominator).toNumber(),
3275
- 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())
3276
3539
  });
3277
3540
 
3278
- case 10:
3541
+ case 23:
3279
3542
  case "end":
3280
- return _context.stop();
3543
+ return _context4.stop();
3281
3544
  }
3282
3545
  }
3283
- }, _callee, this);
3546
+ }, _callee4, this);
3284
3547
  }));
3285
3548
 
3286
- function getLockingDetails() {
3549
+ function getLockingDetails(_x4) {
3287
3550
  return _getLockingDetails.apply(this, arguments);
3288
3551
  }
3289
3552
 
3290
3553
  return getLockingDetails;
3291
3554
  }();
3292
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
+
3293
3656
  _proto.getUserDetails = /*#__PURE__*/function () {
3294
- var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
3657
+ var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
3295
3658
  var _this2 = this;
3296
3659
 
3297
- var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, rewardBalancesMetadata, lockedAmount, values, 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;
3298
3661
 
3299
- return runtime_1.wrap(function _callee2$(_context2) {
3662
+ return runtime_1.wrap(function _callee$(_context) {
3300
3663
  while (1) {
3301
- switch (_context2.prev = _context2.next) {
3664
+ switch (_context.prev = _context.next) {
3302
3665
  case 0:
3303
3666
  marketCount = networkAddresses.auTokens.length;
3304
3667
  userMarketDetails = [];
@@ -3334,15 +3697,15 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3334
3697
  promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
3335
3698
  assetsIn = res;
3336
3699
  }));
3337
- _context2.next = 10;
3700
+ _context.next = 10;
3338
3701
  return Promise.all(promises);
3339
3702
 
3340
3703
  case 10:
3341
- _context2.next = 12;
3704
+ _context.next = 12;
3342
3705
  return Promise.all(pricePromises);
3343
3706
 
3344
3707
  case 12:
3345
- underlyingPrices = _context2.sent;
3708
+ underlyingPrices = _context.sent;
3346
3709
  depositValues = [];
3347
3710
 
3348
3711
  _loop = function _loop() {
@@ -3367,20 +3730,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3367
3730
  if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
3368
3731
  return p;
3369
3732
  }, new BigNumber(0));
3370
- promises = new Array(3);
3371
- promises[0] = this._fakeComptroller.getAccountLiquidity(userAddress);
3372
- promises[1] = this._auriLens.callStatic.claimAndGetRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, [], {
3373
- from: userAddress
3374
- });
3375
- promises[2] = this._tokenLock.lockedAmounts(userAddress);
3376
- _context2.next = 23;
3377
- return Promise.all(promises);
3733
+ _context.next = 19;
3734
+ return this._comptroller.getAccountLiquidity(userAddress);
3378
3735
 
3379
- case 23:
3380
- values = _context2.sent;
3381
- accountLiquidity = values[0];
3382
- rewardBalancesMetadata = values[1];
3383
- lockedAmount = values[2];
3736
+ case 19:
3737
+ accountLiquidity = _context.sent;
3384
3738
  borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
3385
3739
 
3386
3740
  if (borrowedvaluation.lt("0.00001")) {
@@ -3404,26 +3758,33 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3404
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());
3405
3759
  }
3406
3760
 
3407
- return _context2.abrupt("return", {
3408
- markets: userMarketDetails,
3409
- borrowLimit: {
3410
- currency: "USD",
3411
- amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
3412
- },
3413
- accruedPly: new TokenAmount(PLYToken, rewardBalancesMetadata.plyAccrued.toString()),
3414
- lockedPly: new TokenAmount(PLYToken, lockedAmount.toString()),
3415
- borrowableAmount: {
3416
- currency: "USD",
3417
- amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
3418
- }
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
3419
3780
  });
3420
3781
 
3421
- case 34:
3782
+ case 33:
3422
3783
  case "end":
3423
- return _context2.stop();
3784
+ return _context.stop();
3424
3785
  }
3425
3786
  }
3426
- }, _callee2, this);
3787
+ }, _callee, this);
3427
3788
  }));
3428
3789
 
3429
3790
  function getUserDetails(_x) {
@@ -3433,76 +3794,92 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3433
3794
  return getUserDetails;
3434
3795
  }();
3435
3796
 
3436
- _proto.getPlyAuroraPoolDetails = /*#__PURE__*/function () {
3437
- var _getPlyAuroraPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
3438
- var stakedLiquidity, rewardPerSecond, promises, rewardPerSecondValuation, totalStakeValuation;
3439
- 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) {
3440
3802
  while (1) {
3441
- switch (_context3.prev = _context3.next) {
3803
+ switch (_context2.prev = _context2.next) {
3442
3804
  case 0:
3443
- promises = [];
3444
- promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then(function (res) {
3805
+ _context2.next = 2;
3806
+ return this._auriFairLaunch.getPoolInfo(PlyUsdcPid).then(function (res) {
3445
3807
  stakedLiquidity = res.totalStake;
3446
- rewardPerSecond = res.rewardPerSecond;
3447
- }));
3448
- _context3.next = 4;
3449
- return Promise.all(promises);
3808
+ rewardPerSeconds = res.rewardPerSeconds;
3809
+ });
3450
3810
 
3451
- case 4:
3811
+ case 2:
3812
+ stakedLiquidityAmount = new TokenAmount(PLYUSDCToken, stakedLiquidity.toString());
3452
3813
  promises = [];
3453
- promises.push(fetchValuation(new TokenAmount(PLYToken, rewardPerSecond.toString()), this._networkConnection.provider).then(function (res) {
3454
- return rewardPerSecondValuation = res;
3455
- }));
3456
- promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
3457
- return totalStakeValuation = res;
3458
- }));
3459
- _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;
3460
3823
  return Promise.all(promises);
3461
3824
 
3462
- case 9:
3463
- return _context3.abrupt("return", {
3464
- 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
+ },
3465
3842
  apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
3466
3843
  });
3467
3844
 
3468
- case 10:
3845
+ case 12:
3469
3846
  case "end":
3470
- return _context3.stop();
3847
+ return _context2.stop();
3471
3848
  }
3472
3849
  }
3473
- }, _callee3, this);
3850
+ }, _callee2, this);
3474
3851
  }));
3475
3852
 
3476
- function getPlyAuroraPoolDetails() {
3477
- return _getPlyAuroraPoolDetails.apply(this, arguments);
3853
+ function getPlyUsdcPoolDetails() {
3854
+ return _getPlyUsdcPoolDetails.apply(this, arguments);
3478
3855
  }
3479
3856
 
3480
- return getPlyAuroraPoolDetails;
3857
+ return getPlyUsdcPoolDetails;
3481
3858
  }();
3482
3859
 
3483
3860
  _proto.getTokenPrice = /*#__PURE__*/function () {
3484
- var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(token) {
3861
+ var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(token) {
3485
3862
  var price;
3486
- return runtime_1.wrap(function _callee4$(_context4) {
3863
+ return runtime_1.wrap(function _callee3$(_context3) {
3487
3864
  while (1) {
3488
- switch (_context4.prev = _context4.next) {
3865
+ switch (_context3.prev = _context3.next) {
3489
3866
  case 0:
3490
- _context4.next = 2;
3867
+ _context3.next = 2;
3491
3868
  return fetchPrice(token.address, this._networkConnection.provider);
3492
3869
 
3493
3870
  case 2:
3494
- price = _context4.sent;
3495
- return _context4.abrupt("return", {
3871
+ price = _context3.sent;
3872
+ return _context3.abrupt("return", {
3496
3873
  currency: "USD",
3497
3874
  amount: price.toFixed(DECIMAL_PRECISION)
3498
3875
  });
3499
3876
 
3500
3877
  case 4:
3501
3878
  case "end":
3502
- return _context4.stop();
3879
+ return _context3.stop();
3503
3880
  }
3504
3881
  }
3505
- }, _callee4, this);
3882
+ }, _callee3, this);
3506
3883
  }));
3507
3884
 
3508
3885
  function getTokenPrice(_x2) {
@@ -3513,25 +3890,26 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3513
3890
  }();
3514
3891
 
3515
3892
  _proto.stakeBalanceOf = /*#__PURE__*/function () {
3516
- var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(user) {
3517
- var userInfo;
3518
- 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) {
3519
3896
  while (1) {
3520
- switch (_context5.prev = _context5.next) {
3897
+ switch (_context4.prev = _context4.next) {
3521
3898
  case 0:
3522
- _context5.next = 2;
3523
- return this._auriFairLaunch.getUserInfo(AurPlyPid, user);
3899
+ _context4.next = 2;
3900
+ return this._auriFairLaunch.getUserInfo(PlyUsdcPid, user);
3524
3901
 
3525
3902
  case 2:
3526
- userInfo = _context5.sent;
3527
- 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));
3528
3906
 
3529
- case 4:
3907
+ case 5:
3530
3908
  case "end":
3531
- return _context5.stop();
3909
+ return _context4.stop();
3532
3910
  }
3533
3911
  }
3534
- }, _callee5, this);
3912
+ }, _callee4, this);
3535
3913
  }));
3536
3914
 
3537
3915
  function stakeBalanceOf(_x3) {
@@ -3541,6 +3919,36 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3541
3919
  return stakeBalanceOf;
3542
3920
  }();
3543
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
+
3544
3952
  _proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
3545
3953
  var userMarketDetail = _ref.userMarketDetail,
3546
3954
  currentBorrowLimit = _ref.currentBorrowLimit,
@@ -3596,7 +4004,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3596
4004
  while (1) {
3597
4005
  switch (_context6.prev = _context6.next) {
3598
4006
  case 0:
3599
- 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));
3600
4008
 
3601
4009
  case 1:
3602
4010
  case "end":
@@ -3619,7 +4027,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3619
4027
  while (1) {
3620
4028
  switch (_context7.prev = _context7.next) {
3621
4029
  case 0:
3622
- 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()));
3623
4031
 
3624
4032
  case 1:
3625
4033
  case "end":
@@ -3629,7 +4037,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3629
4037
  }, _callee7, this);
3630
4038
  }));
3631
4039
 
3632
- function stake(_x4) {
4040
+ function stake(_x5) {
3633
4041
  return _stake.apply(this, arguments);
3634
4042
  }
3635
4043
 
@@ -3642,7 +4050,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3642
4050
  while (1) {
3643
4051
  switch (_context8.prev = _context8.next) {
3644
4052
  case 0:
3645
- 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()));
3646
4054
 
3647
4055
  case 1:
3648
4056
  case "end":
@@ -3652,7 +4060,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3652
4060
  }, _callee8, this);
3653
4061
  }));
3654
4062
 
3655
- function unstake(_x5) {
4063
+ function unstake(_x6) {
3656
4064
  return _unstake.apply(this, arguments);
3657
4065
  }
3658
4066
 
@@ -106910,5 +107318,5 @@ BigNumber.config({
106910
107318
  DECIMAL_PLACES: 50
106911
107319
  });
106912
107320
 
106913
- 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 };
106914
107322
  //# sourceMappingURL=sdk.esm.js.map