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