@aurigami/sdk 1.4.8 → 1.5.0-dummy-1

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 {
@@ -897,7 +898,7 @@ var BlockchainEntityReadWrite = /*#__PURE__*/function (_BlockchainEntityRead) {
897
898
 
898
899
  function BlockchainEntityReadWrite(networkConnection) {
899
900
  if (!(networkConnection.signer instanceof abstractSigner.Signer)) {
900
- throw Error("Signer is not provided when constructing BlockchainEntityReadWrite");
901
+ throw Error('Signer is not provided when constructing BlockchainEntityReadWrite');
901
902
  }
902
903
 
903
904
  return _BlockchainEntityRead.call(this, networkConnection) || this;
@@ -935,73 +936,80 @@ var BlockchainEntity = /*#__PURE__*/function () {
935
936
  MarketAction[MarketAction["DisableCollateral"] = 5] = "DisableCollateral";
936
937
  })(exports.MarketAction || (exports.MarketAction = {}));
937
938
 
938
- var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
939
- var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
939
+ var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
940
+ var ETHAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
940
941
  var AURORA_CHAINID = 1313161554;
941
942
  var DECIMAL_PRECISION = 10;
942
943
  var networkAddresses = {
943
944
  auTokens: [{
944
- name: "auUSDC",
945
+ name: 'auUSDC',
945
946
  address: /*#__PURE__*/'0x4f0d864b1ABf4B701799a0b30b57A22dFEB5917b'.toLowerCase(),
946
947
  underlying: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
947
948
  }, {
948
- name: "auETH",
949
+ name: 'auETH',
949
950
  address: /*#__PURE__*/'0xca9511B610bA5fc7E311FDeF9cE16050eE4449E9'.toLowerCase(),
950
951
  underlying: /*#__PURE__*/ETHAddress.toLowerCase()
951
952
  }, {
952
- name: "auWBTC",
953
+ name: 'auWBTC',
953
954
  address: /*#__PURE__*/'0xCFb6b0498cb7555e7e21502E0F449bf28760Adbb'.toLowerCase(),
954
955
  underlying: /*#__PURE__*/'0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
955
956
  }, {
956
- name: "auUSDT",
957
+ name: 'auUSDT',
957
958
  address: /*#__PURE__*/'0xaD5A2437Ff55ed7A8Cad3b797b3eC7c5a19B1c54'.toLowerCase(),
958
959
  underlying: /*#__PURE__*/'0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
959
960
  }, {
960
- name: "auDAI",
961
+ name: 'auDAI',
961
962
  address: /*#__PURE__*/'0xCE4166363E3a584DAc84A47bCD3414B43EfCDd1c'.toLowerCase(),
962
963
  underlying: /*#__PURE__*/'0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
963
964
  }, {
964
- name: "auWNEAR",
965
+ name: 'auWNEAR',
965
966
  address: /*#__PURE__*/'0xaE4fac24dCdAE0132C6d04f564dCf059616E9423'.toLowerCase(),
966
967
  underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
967
968
  }, {
968
- name: "auSTNEAR",
969
- address: /*#__PURE__*/"0x3195949f267702723bc614cAE037cdc8D1E94786".toLowerCase(),
969
+ name: 'auSTNEAR',
970
+ address: /*#__PURE__*/'0x3195949f267702723bc614cAE037cdc8D1E94786'.toLowerCase(),
970
971
  underlying: /*#__PURE__*/'0x07F9F7f963C5cD2BBFFd30CcfB964Be114332E30'.toLowerCase()
971
972
  }, {
972
- name: "auAURORA",
973
- address: /*#__PURE__*/"0x8888682E24dd4Df7B7Ff2B91fccB575737E433bf".toLowerCase(),
974
- underlying: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase()
973
+ name: 'auAURORA',
974
+ address: /*#__PURE__*/'0x8888682E24dd4Df7B7Ff2B91fccB575737E433bf'.toLowerCase(),
975
+ underlying: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase()
975
976
  }, {
976
- name: "auTRI",
977
- address: /*#__PURE__*/"0x6Ea6C03061bDdCE23d4Ec60B6E6e880c33d24dca".toLowerCase(),
978
- underlying: /*#__PURE__*/"0xFa94348467f64D5A457F75F8bc40495D33c65aBB".toLowerCase()
977
+ name: 'auTRI',
978
+ address: /*#__PURE__*/'0x6Ea6C03061bDdCE23d4Ec60B6E6e880c33d24dca'.toLowerCase(),
979
+ underlying: /*#__PURE__*/'0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase()
979
980
  }],
980
981
  misc: {
981
- COMPTROLLER: /*#__PURE__*/"0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb".toLowerCase(),
982
- oracle: /*#__PURE__*/"0xC6e5185438e1730959c1eF3551059A3feC744E90".toLowerCase(),
983
- AURIFAIRLAUNCH: /*#__PURE__*/"0x6f068608573c840bB27b39458d7d87eB865e19Cc".toLowerCase(),
982
+ COMPTROLLER: /*#__PURE__*/'0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb'.toLowerCase(),
983
+ oracle: /*#__PURE__*/'0xC6e5185438e1730959c1eF3551059A3feC744E90'.toLowerCase(),
984
+ AURIFAIRLAUNCH: /*#__PURE__*/'0x6f068608573c840bB27b39458d7d87eB865e19Cc'.toLowerCase(),
984
985
  AURILENS: /*#__PURE__*/'0xFfdFfBDB966Cb84B50e62d70105f2Dbf2e0A1e70'.toLowerCase(),
985
986
  TOKENLOCK: /*#__PURE__*/'0xDACC02a4Ff16Ea3c1515AdbfdCeb7B1F448B79c8'.toLowerCase(),
986
- ETHREPAYHELPER: /*#__PURE__*/"0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6".toLowerCase(),
987
- AURI_AIRDROP: /*#__PURE__*/"0x6C42aA5b128B62D6CCf357726D7d13F3888335EC".toLowerCase()
987
+ ETHREPAYHELPER: /*#__PURE__*/'0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6'.toLowerCase(),
988
+ AURI_AIRDROP: /*#__PURE__*/'0x6C42aA5b128B62D6CCf357726D7d13F3888335EC'.toLowerCase()
988
989
  },
989
990
  tokens: {
990
- AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
991
- PLY: /*#__PURE__*/"0x981bD5832EAB9C8F607940E0e9faCBf8C09ee20a".toLowerCase(),
992
- stNEAR: /*#__PURE__*/"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),
991
+ AURORA: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
992
+ PLY: /*#__PURE__*/'0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase(),
993
+ stNEAR: /*#__PURE__*/'0x07f9f7f963c5cd2bbffd30ccfb964be114332e30'.toLowerCase(),
993
994
  USDC: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
994
995
  WNEAR: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
995
996
  TRI: /*#__PURE__*/'0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
996
997
  META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
997
- AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
998
+ PULP: /*#__PURE__*/'0x04Ac48711BCdc45b4d223fb021E09DA73c71095e'.toLowerCase(),
999
+ PLYUSDC: /*#__PURE__*/'0x37cae2b29c18e05ece60111fa01d3ca217046016'.toLowerCase()
998
1000
  }
999
1001
  };
1002
+ var PRICE_WHITELISTED = /*#__PURE__*/new Set( /*#__PURE__*/[].concat( /*#__PURE__*/networkAddresses.auTokens.map(function (t) {
1003
+ return t.underlying;
1004
+ }), [networkAddresses.tokens.AURORA, networkAddresses.tokens.TRI, networkAddresses.tokens.META, networkAddresses.tokens.stNEAR]));
1005
+ var REWARD_CLAIM_START = 1651762800;
1000
1006
  var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(1);
1001
- var REWARDCLAIMSTART = 1640995200;
1002
1007
  var ONE_DAY = 86400;
1008
+ var ONE_WEEK = ONE_DAY * 7;
1003
1009
  var ONE_YEAR = ONE_DAY * 365;
1004
- var AurPlyPid = 0;
1010
+ var PlyUsdcPid = 0;
1011
+ var PLYUSDCRewardTokens = ['0x09C9D464b58d96837f8d8b6f4d9fE4aD408d3A4f', '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d', '0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79', '0xFa94348467f64D5A457F75F8bc40495D33c65aBB'];
1012
+ var ALL_STAKING_POOLS = [];
1005
1013
  var INF = /*#__PURE__*/ethers.BigNumber.from(2).pow(256).sub(1);
1006
1014
  var AIRDROP_START_TIMESTAMP = 1649858400;
1007
1015
  var AIRDROP_END_TIMESTAMP = 1651068000;
@@ -1036,8 +1044,8 @@ function _getQuery() {
1036
1044
  }
1037
1045
 
1038
1046
  params = _extends({}, params, {
1039
- 'module': module,
1040
- 'action': action
1047
+ module: module,
1048
+ action: action
1041
1049
  });
1042
1050
  _context.next = 4;
1043
1051
  return axios.get(AURORA_API_BASE_URL + '?' + new URLSearchParams(params), {
@@ -1062,7 +1070,7 @@ function _getQuery() {
1062
1070
 
1063
1071
  var decimalRecords = {
1064
1072
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
1065
- '0x981bd5832eab9c8f607940e0e9facbf8c09ee20a': 18,
1073
+ '0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f': 18,
1066
1074
  '0x3195949f267702723bc614cae037cdc8d1e94786': 8,
1067
1075
  '0xfa94348467f64d5a457f75f8bc40495d33c65abb': 18,
1068
1076
  '0x07f9f7f963c5cd2bbffd30ccfb964be114332e30': 24,
@@ -1080,7 +1088,9 @@ var decimalRecords = {
1080
1088
  '0xae4fac24dcdae0132c6d04f564dcf059616e9423': 8,
1081
1089
  '0xce4166363e3a584dac84a47bcd3414b43efcdd1c': 8,
1082
1090
  '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
1083
- '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24
1091
+ '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
1092
+ '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18,
1093
+ '0x37cae2b29c18e05ece60111fa01d3ca217046016': 18
1084
1094
  };
1085
1095
 
1086
1096
  function formatObject(object) {
@@ -1099,11 +1109,13 @@ function validateAndParseAddress(address) {
1099
1109
  try {
1100
1110
  return ethers.utils.getAddress(address);
1101
1111
  } catch (error) {
1102
- throw new Error("Invalid address: " + address);
1112
+ throw new Error('Invalid address: ' + address);
1103
1113
  }
1104
1114
  }
1105
1115
  function getDecimal(address) {
1106
- return decimalRecords[address.toLowerCase()];
1116
+ var addressLowercase = address.toLowerCase();
1117
+ assert(decimalRecords[addressLowercase] != undefined, 'Decimal not found for ' + address);
1118
+ return decimalRecords[addressLowercase];
1107
1119
  }
1108
1120
  function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1109
1121
  if (totalStakeValue.lte(0)) {
@@ -1153,8 +1165,8 @@ function _getBlockBeforeTimestamp() {
1153
1165
  case 0:
1154
1166
  _context2.next = 2;
1155
1167
  return getQuery('block', 'getblocknobytime', {
1156
- 'timestamp': timestamp,
1157
- 'closest': 'before'
1168
+ timestamp: timestamp,
1169
+ closest: 'before'
1158
1170
  });
1159
1171
 
1160
1172
  case 2:
@@ -1190,7 +1202,7 @@ var Token = function Token(address, decimals) {
1190
1202
  this.decimals = decimals;
1191
1203
  };
1192
1204
  var PLYToken = /*#__PURE__*/new Token(networkAddresses.tokens.PLY, /*#__PURE__*/getDecimal(networkAddresses.tokens.PLY));
1193
- var AURPLYToken = /*#__PURE__*/new Token(networkAddresses.tokens.AURPLY, /*#__PURE__*/getDecimal(networkAddresses.tokens.AURPLY));
1205
+ var PLYUSDCToken = /*#__PURE__*/new Token(networkAddresses.tokens.PLYUSDC, /*#__PURE__*/getDecimal(networkAddresses.tokens.PLYUSDC));
1194
1206
 
1195
1207
  var TokenAmount = /*#__PURE__*/function () {
1196
1208
  function TokenAmount(token, amount, isRaw) {
@@ -2241,15 +2253,15 @@ function fetchLPPositions(_x3, _x4) {
2241
2253
 
2242
2254
  function _fetchLPPositions() {
2243
2255
  _fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(LPAddress, provider) {
2244
- var promises, LPContract, values;
2256
+ var LPContract, promises, values;
2245
2257
  return runtime_1.wrap(function _callee3$(_context3) {
2246
2258
  while (1) {
2247
2259
  switch (_context3.prev = _context3.next) {
2248
2260
  case 0:
2249
- promises = [];
2250
2261
  LPContract = new ethers.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
2262
+ promises = [];
2251
2263
  promises.push(LPContract.token0());
2252
- promises.push(LPContract.toekn1());
2264
+ promises.push(LPContract.token1());
2253
2265
  promises.push(LPContract.getReserves());
2254
2266
  promises.push(LPContract.totalSupply());
2255
2267
  _context3.next = 8;
@@ -2280,50 +2292,91 @@ function fetchLPPrice(_x5, _x6) {
2280
2292
  }
2281
2293
 
2282
2294
  function _fetchLPPrice() {
2283
- _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(address, provider) {
2284
- var LPInfo, token0Price, reserveUSD, token1Price, _reserveUSD;
2295
+ _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider) {
2296
+ var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy;
2285
2297
 
2286
- return runtime_1.wrap(function _callee4$(_context4) {
2298
+ return runtime_1.wrap(function _callee5$(_context5) {
2287
2299
  while (1) {
2288
- switch (_context4.prev = _context4.next) {
2300
+ switch (_context5.prev = _context5.next) {
2289
2301
  case 0:
2290
- _context4.next = 2;
2302
+ _fetchLPPriceBy = function _fetchLPPriceBy3() {
2303
+ _fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(tokenReverse) {
2304
+ var tokenPrice, tokenDecimal, reserveUSD;
2305
+ return runtime_1.wrap(function _callee4$(_context4) {
2306
+ while (1) {
2307
+ switch (_context4.prev = _context4.next) {
2308
+ case 0:
2309
+ if (!tokenReverse.reserve.isZero()) {
2310
+ _context4.next = 2;
2311
+ break;
2312
+ }
2313
+
2314
+ return _context4.abrupt("return", new BigNumber(0));
2315
+
2316
+ case 2:
2317
+ _context4.next = 4;
2318
+ return _fetchPrice(tokenReverse.address, provider);
2319
+
2320
+ case 4:
2321
+ tokenPrice = _context4.sent;
2322
+ tokenDecimal = getDecimal(tokenReverse.address);
2323
+ reserveUSD = tokenPrice.multipliedBy(tokenReverse.reserve.toString()).multipliedBy(2);
2324
+ return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
2325
+
2326
+ case 8:
2327
+ case "end":
2328
+ return _context4.stop();
2329
+ }
2330
+ }
2331
+ }, _callee4);
2332
+ }));
2333
+ return _fetchLPPriceBy.apply(this, arguments);
2334
+ };
2335
+
2336
+ fetchLPPriceBy = function _fetchLPPriceBy2(_x20) {
2337
+ return _fetchLPPriceBy.apply(this, arguments);
2338
+ };
2339
+
2340
+ _context5.next = 4;
2291
2341
  return fetchLPPositions(address, provider);
2292
2342
 
2293
- case 2:
2294
- LPInfo = _context4.sent;
2295
- _context4.prev = 3;
2296
- _context4.next = 6;
2297
- return fetchPrice(LPInfo.token0, provider);
2343
+ case 4:
2344
+ LPInfo = _context5.sent;
2345
+ LPDecimal = getDecimal(address);
2346
+ _context5.prev = 6;
2347
+ _context5.next = 9;
2348
+ return fetchLPPriceBy({
2349
+ address: LPInfo.token0,
2350
+ reserve: LPInfo.reserve0
2351
+ });
2298
2352
 
2299
- case 6:
2300
- token0Price = _context4.sent;
2301
- reserveUSD = token0Price.multipliedBy(LPInfo.reserve0.toString()).multipliedBy(2);
2302
- return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
2353
+ case 9:
2354
+ return _context5.abrupt("return", _context5.sent);
2355
+
2356
+ case 12:
2357
+ _context5.prev = 12;
2358
+ _context5.t0 = _context5["catch"](6);
2359
+ _context5.prev = 14;
2360
+ _context5.next = 17;
2361
+ return fetchLPPriceBy({
2362
+ address: LPInfo.token1,
2363
+ reserve: LPInfo.reserve1
2364
+ });
2303
2365
 
2304
- case 11:
2305
- _context4.prev = 11;
2306
- _context4.t0 = _context4["catch"](3);
2307
- _context4.prev = 13;
2308
- _context4.next = 16;
2309
- return fetchPrice(LPInfo.token1, provider);
2310
-
2311
- case 16:
2312
- token1Price = _context4.sent;
2313
- _reserveUSD = token1Price.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(2);
2314
- return _context4.abrupt("return", _reserveUSD.multipliedBy(decimalFactor(18)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())));
2315
-
2316
- case 21:
2317
- _context4.prev = 21;
2318
- _context4.t1 = _context4["catch"](13);
2366
+ case 17:
2367
+ return _context5.abrupt("return", _context5.sent);
2368
+
2369
+ case 20:
2370
+ _context5.prev = 20;
2371
+ _context5.t1 = _context5["catch"](14);
2319
2372
  throw Error("Unable to fetch price for both tokens of LP " + address);
2320
2373
 
2321
- case 24:
2374
+ case 23:
2322
2375
  case "end":
2323
- return _context4.stop();
2376
+ return _context5.stop();
2324
2377
  }
2325
2378
  }
2326
- }, _callee4, null, [[3, 11], [13, 21]]);
2379
+ }, _callee5, null, [[6, 12], [14, 20]]);
2327
2380
  }));
2328
2381
  return _fetchLPPrice.apply(this, arguments);
2329
2382
  }
@@ -2337,26 +2390,26 @@ function fetchPriceFromOracle(_x7, _x8, _x9) {
2337
2390
  }
2338
2391
 
2339
2392
  function _fetchPriceFromOracle() {
2340
- _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
2393
+ _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(auTokenAddress, underlyingDecimal, provider) {
2341
2394
  var oracleContract, rawPrice;
2342
- return runtime_1.wrap(function _callee5$(_context5) {
2395
+ return runtime_1.wrap(function _callee6$(_context6) {
2343
2396
  while (1) {
2344
- switch (_context5.prev = _context5.next) {
2397
+ switch (_context6.prev = _context6.next) {
2345
2398
  case 0:
2346
2399
  oracleContract = new ethers.Contract(networkAddresses.misc.oracle, OracleABI.abi, provider);
2347
- _context5.next = 3;
2400
+ _context6.next = 3;
2348
2401
  return oracleContract.getUnderlyingPrice(auTokenAddress);
2349
2402
 
2350
2403
  case 3:
2351
- rawPrice = _context5.sent;
2352
- return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2404
+ rawPrice = _context6.sent;
2405
+ return _context6.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2353
2406
 
2354
2407
  case 5:
2355
2408
  case "end":
2356
- return _context5.stop();
2409
+ return _context6.stop();
2357
2410
  }
2358
2411
  }
2359
- }, _callee5);
2412
+ }, _callee6);
2360
2413
  }));
2361
2414
  return _fetchPriceFromOracle.apply(this, arguments);
2362
2415
  }
@@ -2366,11 +2419,11 @@ function fetchUnderlyingTokensPrices(_x10) {
2366
2419
  }
2367
2420
 
2368
2421
  function _fetchUnderlyingTokensPrices() {
2369
- _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
2422
+ _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(provider) {
2370
2423
  var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
2371
- return runtime_1.wrap(function _callee6$(_context6) {
2424
+ return runtime_1.wrap(function _callee7$(_context7) {
2372
2425
  while (1) {
2373
- switch (_context6.prev = _context6.next) {
2426
+ switch (_context7.prev = _context7.next) {
2374
2427
  case 0:
2375
2428
  auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, provider);
2376
2429
  auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
@@ -2379,12 +2432,12 @@ function _fetchUnderlyingTokensPrices() {
2379
2432
  underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
2380
2433
  return getDecimal(auToken.underlying);
2381
2434
  });
2382
- _context6.next = 5;
2435
+ _context7.next = 5;
2383
2436
  return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
2384
2437
 
2385
2438
  case 5:
2386
- rawPrices = _context6.sent;
2387
- return _context6.abrupt("return", rawPrices.map(function (res, ind) {
2439
+ rawPrices = _context7.sent;
2440
+ return _context7.abrupt("return", rawPrices.map(function (res, ind) {
2388
2441
  return {
2389
2442
  auToken: res.auToken,
2390
2443
  underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
@@ -2393,10 +2446,10 @@ function _fetchUnderlyingTokensPrices() {
2393
2446
 
2394
2447
  case 7:
2395
2448
  case "end":
2396
- return _context6.stop();
2449
+ return _context7.stop();
2397
2450
  }
2398
2451
  }
2399
- }, _callee6);
2452
+ }, _callee7);
2400
2453
  }));
2401
2454
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2402
2455
  }
@@ -2406,33 +2459,33 @@ function fetchStNEARPrice() {
2406
2459
  }
2407
2460
 
2408
2461
  function _fetchStNEARPrice() {
2409
- _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
2462
+ _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
2410
2463
  var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
2411
2464
 
2412
- return runtime_1.wrap(function _callee7$(_context7) {
2465
+ return runtime_1.wrap(function _callee8$(_context8) {
2413
2466
  while (1) {
2414
- switch (_context7.prev = _context7.next) {
2467
+ switch (_context8.prev = _context8.next) {
2415
2468
  case 0:
2416
- ratioPromise = axios.get("https://validators.narwallets.com/metrics_json").then(function (res) {
2469
+ ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
2417
2470
  return res.data;
2418
2471
  });
2419
2472
  nearPricePromise = fetchPriceFromCoingeckoAPI('near');
2420
- _context7.next = 4;
2473
+ _context8.next = 4;
2421
2474
  return Promise.all([ratioPromise, nearPricePromise]);
2422
2475
 
2423
2476
  case 4:
2424
- _yield$Promise$all = _context7.sent;
2477
+ _yield$Promise$all = _context8.sent;
2425
2478
  ratioRes = _yield$Promise$all[0];
2426
2479
  nearPrice = _yield$Promise$all[1];
2427
2480
  ratio = new BigNumber(ratioRes.st_near_price);
2428
- return _context7.abrupt("return", ratio.multipliedBy(nearPrice));
2481
+ return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
2429
2482
 
2430
2483
  case 9:
2431
2484
  case "end":
2432
- return _context7.stop();
2485
+ return _context8.stop();
2433
2486
  }
2434
2487
  }
2435
- }, _callee7);
2488
+ }, _callee8);
2436
2489
  }));
2437
2490
  return _fetchStNEARPrice.apply(this, arguments);
2438
2491
  }
@@ -2442,105 +2495,176 @@ function shouldFetchFromCoingecko(address) {
2442
2495
  return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
2443
2496
  }
2444
2497
 
2445
- function fetchPrice(_x11, _x12) {
2446
- return _fetchPrice.apply(this, arguments);
2498
+ function _fetchPrice(_x11, _x12) {
2499
+ return _fetchPrice2.apply(this, arguments);
2447
2500
  }
2448
2501
 
2449
- function _fetchPrice() {
2450
- _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
2502
+ function _fetchPrice2() {
2503
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
2451
2504
  var matchingAuToken;
2452
- return runtime_1.wrap(function _callee8$(_context8) {
2505
+ return runtime_1.wrap(function _callee9$(_context9) {
2453
2506
  while (1) {
2454
- switch (_context8.prev = _context8.next) {
2507
+ switch (_context9.prev = _context9.next) {
2455
2508
  case 0:
2456
- if (!( isSameAddress(address, networkAddresses.tokens.PLY))) {
2457
- _context8.next = 2;
2458
- break;
2459
- }
2460
-
2461
- return _context8.abrupt("return", new BigNumber(0));
2509
+ assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()));
2462
2510
 
2463
- case 2:
2464
2511
  if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
2465
- _context8.next = 4;
2512
+ _context9.next = 3;
2466
2513
  break;
2467
2514
  }
2468
2515
 
2469
- return _context8.abrupt("return", fetchStNEARPrice());
2516
+ return _context9.abrupt("return", fetchStNEARPrice());
2470
2517
 
2471
- case 4:
2518
+ case 3:
2472
2519
  if (!shouldFetchFromCoingecko(address)) {
2473
- _context8.next = 6;
2520
+ _context9.next = 5;
2474
2521
  break;
2475
2522
  }
2476
2523
 
2477
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2524
+ return _context9.abrupt("return", fetchPriceFromCoingecko(address));
2478
2525
 
2479
- case 6:
2526
+ case 5:
2480
2527
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2481
2528
  return isSameAddress(auToken.underlying, address);
2482
2529
  });
2483
2530
 
2484
2531
  if (!(matchingAuToken !== undefined)) {
2485
- _context8.next = 11;
2532
+ _context9.next = 10;
2486
2533
  break;
2487
2534
  }
2488
2535
 
2489
- return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2536
+ return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2537
+
2538
+ case 10:
2539
+ throw Error("Unable to fetch price for " + address);
2490
2540
 
2491
2541
  case 11:
2492
- if (!isSameAddress(address, networkAddresses.tokens.AURPLY)) {
2493
- _context8.next = 15;
2542
+ case "end":
2543
+ return _context9.stop();
2544
+ }
2545
+ }
2546
+ }, _callee9);
2547
+ }));
2548
+ return _fetchPrice2.apply(this, arguments);
2549
+ }
2550
+
2551
+ function fetchPrice(_x13, _x14) {
2552
+ return _fetchPrice3.apply(this, arguments);
2553
+ }
2554
+
2555
+ function _fetchPrice3() {
2556
+ _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
2557
+ return runtime_1.wrap(function _callee10$(_context10) {
2558
+ while (1) {
2559
+ switch (_context10.prev = _context10.next) {
2560
+ case 0:
2561
+ if (!isSameAddress(address, networkAddresses.tokens.PLYUSDC)) {
2562
+ _context10.next = 4;
2563
+ break;
2564
+ }
2565
+
2566
+ return _context10.abrupt("return", fetchLPPrice(address, provider));
2567
+
2568
+ case 4:
2569
+ if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2570
+ _context10.next = 6;
2494
2571
  break;
2495
2572
  }
2496
2573
 
2497
- return _context8.abrupt("return", fetchLPPrice(address, provider));
2574
+ return _context10.abrupt("return", fetchPLYPrice(provider));
2498
2575
 
2499
- case 15:
2500
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2576
+ case 6:
2577
+ return _context10.abrupt("return", _fetchPrice(address, provider));
2501
2578
 
2502
- case 16:
2579
+ case 7:
2503
2580
  case "end":
2504
- return _context8.stop();
2581
+ return _context10.stop();
2505
2582
  }
2506
2583
  }
2507
- }, _callee8);
2584
+ }, _callee10);
2585
+ }));
2586
+ return _fetchPrice3.apply(this, arguments);
2587
+ }
2588
+
2589
+ function fetchPLYPrice(_x15) {
2590
+ return _fetchPLYPrice.apply(this, arguments);
2591
+ }
2592
+
2593
+ function _fetchPLYPrice() {
2594
+ _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2595
+ var LPInfo, plyAddress, plyDecimal, usdcAddress, usdcDecimal;
2596
+ return runtime_1.wrap(function _callee11$(_context11) {
2597
+ while (1) {
2598
+ switch (_context11.prev = _context11.next) {
2599
+ case 0:
2600
+ _context11.next = 2;
2601
+ return fetchLPPositions(networkAddresses.tokens.PLYUSDC, provider);
2602
+
2603
+ case 2:
2604
+ LPInfo = _context11.sent;
2605
+
2606
+ if (!LPInfo.reserve1.isZero()) {
2607
+ _context11.next = 5;
2608
+ break;
2609
+ }
2610
+
2611
+ return _context11.abrupt("return", new BigNumber(0));
2612
+
2613
+ case 5:
2614
+ plyAddress = LPInfo.token0;
2615
+ assert(isSameAddress(plyAddress, networkAddresses.tokens.PLY));
2616
+ plyDecimal = getDecimal(plyAddress);
2617
+ usdcAddress = LPInfo.token1;
2618
+ assert(isSameAddress(usdcAddress, networkAddresses.tokens.USDC));
2619
+ usdcDecimal = getDecimal(usdcAddress);
2620
+ _context11.next = 13;
2621
+ return fetchPrice(usdcAddress, provider);
2622
+
2623
+ case 13:
2624
+ return _context11.abrupt("return", _context11.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(plyDecimal)).dividedBy(decimalFactor(usdcDecimal)).dividedBy(LPInfo.reserve0.toString()));
2625
+
2626
+ case 14:
2627
+ case "end":
2628
+ return _context11.stop();
2629
+ }
2630
+ }
2631
+ }, _callee11);
2508
2632
  }));
2509
- return _fetchPrice.apply(this, arguments);
2633
+ return _fetchPLYPrice.apply(this, arguments);
2510
2634
  }
2511
2635
 
2512
- function fetchValuation(_x13, _x14) {
2636
+ function fetchValuation(_x16, _x17) {
2513
2637
  return _fetchValuation.apply(this, arguments);
2514
2638
  }
2515
2639
 
2516
2640
  function _fetchValuation() {
2517
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(tokenAmount, provider) {
2641
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(tokenAmount, provider) {
2518
2642
  var price;
2519
- return runtime_1.wrap(function _callee9$(_context9) {
2643
+ return runtime_1.wrap(function _callee12$(_context12) {
2520
2644
  while (1) {
2521
- switch (_context9.prev = _context9.next) {
2645
+ switch (_context12.prev = _context12.next) {
2522
2646
  case 0:
2523
- if (!(tokenAmount.rawAmount() == "0")) {
2524
- _context9.next = 2;
2647
+ if (!(tokenAmount.rawAmount() == '0')) {
2648
+ _context12.next = 2;
2525
2649
  break;
2526
2650
  }
2527
2651
 
2528
- return _context9.abrupt("return", new BigNumber(0));
2652
+ return _context12.abrupt("return", new BigNumber(0));
2529
2653
 
2530
2654
  case 2:
2531
- _context9.next = 4;
2655
+ _context12.next = 4;
2532
2656
  return fetchPrice(tokenAmount.token.address, provider);
2533
2657
 
2534
2658
  case 4:
2535
- price = _context9.sent;
2536
- return _context9.abrupt("return", calcValuation(tokenAmount, price));
2659
+ price = _context12.sent;
2660
+ return _context12.abrupt("return", calcValuation(tokenAmount, price));
2537
2661
 
2538
2662
  case 6:
2539
2663
  case "end":
2540
- return _context9.stop();
2664
+ return _context12.stop();
2541
2665
  }
2542
2666
  }
2543
- }, _callee9);
2667
+ }, _callee12);
2544
2668
  }));
2545
2669
  return _fetchValuation.apply(this, arguments);
2546
2670
  }
@@ -2548,6 +2672,39 @@ function _fetchValuation() {
2548
2672
  function calcValuation(tokenAmount, price) {
2549
2673
  return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price);
2550
2674
  }
2675
+ function valuateToken(_x18, _x19) {
2676
+ return _valuateToken.apply(this, arguments);
2677
+ }
2678
+
2679
+ function _valuateToken() {
2680
+ _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(tokenAmount, provider) {
2681
+ var tokenValuation;
2682
+ return runtime_1.wrap(function _callee13$(_context13) {
2683
+ while (1) {
2684
+ switch (_context13.prev = _context13.next) {
2685
+ case 0:
2686
+ _context13.next = 2;
2687
+ return fetchValuation(tokenAmount, provider);
2688
+
2689
+ case 2:
2690
+ tokenValuation = _context13.sent;
2691
+ return _context13.abrupt("return", {
2692
+ tokenAmount: tokenAmount,
2693
+ currencyAmount: {
2694
+ currency: 'USD',
2695
+ amount: tokenValuation.toFixed(DECIMAL_PRECISION)
2696
+ }
2697
+ });
2698
+
2699
+ case 4:
2700
+ case "end":
2701
+ return _context13.stop();
2702
+ }
2703
+ }
2704
+ }, _callee13);
2705
+ }));
2706
+ return _valuateToken.apply(this, arguments);
2707
+ }
2551
2708
 
2552
2709
  var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2553
2710
  _inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
@@ -2991,10 +3148,10 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2991
3148
  if (currentTime <= rewardStopTime && currentTime > rewardStartTime) {
2992
3149
  var _DEPOSIT_NEAR_REWARDS;
2993
3150
 
2994
- var reward = (_DEPOSIT_NEAR_REWARDS = DEPOSIT_NEAR_REWARDS_PER_WEEK[this.underlying.address.toLocaleLowerCase()]) != null ? _DEPOSIT_NEAR_REWARDS : "0";
3151
+ var reward = (_DEPOSIT_NEAR_REWARDS = DEPOSIT_NEAR_REWARDS_PER_WEEK[this.underlying.address.toLocaleLowerCase()]) != null ? _DEPOSIT_NEAR_REWARDS : '0';
2995
3152
  return new TokenAmount(NEARToken, reward, false);
2996
3153
  } else {
2997
- return new TokenAmount(NEARToken, "0");
3154
+ return new TokenAmount(NEARToken, '0');
2998
3155
  }
2999
3156
  };
3000
3157
 
@@ -3007,10 +3164,10 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3007
3164
  if (currentTime <= rewardStopTime && currentTime > rewardStartTime) {
3008
3165
  var _BORROW_NEAR_REWARDS_;
3009
3166
 
3010
- var reward = (_BORROW_NEAR_REWARDS_ = BORROW_NEAR_REWARDS_PER_WEEK[this.underlying.address.toLocaleLowerCase()]) != null ? _BORROW_NEAR_REWARDS_ : "0";
3167
+ var reward = (_BORROW_NEAR_REWARDS_ = BORROW_NEAR_REWARDS_PER_WEEK[this.underlying.address.toLocaleLowerCase()]) != null ? _BORROW_NEAR_REWARDS_ : '0';
3011
3168
  return new TokenAmount(NEARToken, reward, false);
3012
3169
  } else {
3013
- return new TokenAmount(NEARToken, "0");
3170
+ return new TokenAmount(NEARToken, '0');
3014
3171
  }
3015
3172
  };
3016
3173
 
@@ -3230,76 +3387,295 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
3230
3387
  return MoneyMarket;
3231
3388
  }(BlockchainEntity);
3232
3389
 
3233
- var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3234
- _inheritsLoose(SdkRead, _BlockchainEntityRead);
3390
+ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3391
+ _inheritsLoose(PapermillRead, _BlockchainEntityRead);
3235
3392
 
3236
- function SdkRead(networkConnection) {
3393
+ function PapermillRead(networkConnection) {
3237
3394
  var _this;
3238
3395
 
3239
3396
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
3397
+ var plyAddress = networkAddresses.tokens.PLY;
3398
+ var pulpAddress = networkAddresses.tokens.PULP;
3399
+ _this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
3400
+ _this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
3240
3401
  _this._comptroller = new ethers.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
3241
- _this._tokenLock = new ethers.Contract(networkAddresses.misc.TOKENLOCK, TokenLockABI.abi, networkConnection.provider);
3242
3402
  _this._auriFairLaunch = new ethers.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
3243
3403
  _this._auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
3404
+ _this._ply = new ethers.Contract(plyAddress, EIP20InterfaceABI.abi, networkConnection.provider);
3405
+ _this._pulp = new ethers.Contract(pulpAddress, PulpABI.abi, networkConnection.provider);
3244
3406
  return _this;
3245
3407
  }
3246
3408
 
3247
- var _proto = SdkRead.prototype;
3409
+ var _proto = PapermillRead.prototype;
3248
3410
 
3249
- _proto.getLockingDetails = /*#__PURE__*/function () {
3250
- var _getLockingDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3251
- var currentTime, currentWeek, denominator, promises, values;
3411
+ _proto.getPlyBalance = /*#__PURE__*/function () {
3412
+ var _getPlyBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
3413
+ var plyBalance;
3252
3414
  return runtime_1.wrap(function _callee$(_context) {
3253
3415
  while (1) {
3254
3416
  switch (_context.prev = _context.next) {
3417
+ case 0:
3418
+ _context.next = 2;
3419
+ return this._ply.balanceOf(userAddress);
3420
+
3421
+ case 2:
3422
+ plyBalance = _context.sent;
3423
+ return _context.abrupt("return", new TokenAmount(this.plyToken, plyBalance.toString()));
3424
+
3425
+ case 4:
3426
+ case "end":
3427
+ return _context.stop();
3428
+ }
3429
+ }
3430
+ }, _callee, this);
3431
+ }));
3432
+
3433
+ function getPlyBalance(_x) {
3434
+ return _getPlyBalance.apply(this, arguments);
3435
+ }
3436
+
3437
+ return getPlyBalance;
3438
+ }();
3439
+
3440
+ _proto.getPulpBalance = /*#__PURE__*/function () {
3441
+ var _getPulpBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
3442
+ var pulpBalance;
3443
+ return runtime_1.wrap(function _callee2$(_context2) {
3444
+ while (1) {
3445
+ switch (_context2.prev = _context2.next) {
3446
+ case 0:
3447
+ _context2.next = 2;
3448
+ return this._pulp.balanceOf(userAddress);
3449
+
3450
+ case 2:
3451
+ pulpBalance = _context2.sent;
3452
+ return _context2.abrupt("return", new TokenAmount(this.pulpToken, pulpBalance.toString()));
3453
+
3454
+ case 4:
3455
+ case "end":
3456
+ return _context2.stop();
3457
+ }
3458
+ }
3459
+ }, _callee2, this);
3460
+ }));
3461
+
3462
+ function getPulpBalance(_x2) {
3463
+ return _getPulpBalance.apply(this, arguments);
3464
+ }
3465
+
3466
+ return getPulpBalance;
3467
+ }();
3468
+
3469
+ _proto.getUnclaimedPlyReward = /*#__PURE__*/function () {
3470
+ var _getUnclaimedPlyReward = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(userAddress) {
3471
+ var rewardBalancesMetadata;
3472
+ return runtime_1.wrap(function _callee3$(_context3) {
3473
+ while (1) {
3474
+ switch (_context3.prev = _context3.next) {
3475
+ case 0:
3476
+ _context3.next = 2;
3477
+ return this._auriLens.callStatic.claimRewards(this._comptroller.address, this._auriFairLaunch.address, ALL_STAKING_POOLS, {
3478
+ from: userAddress
3479
+ });
3480
+
3481
+ case 2:
3482
+ rewardBalancesMetadata = _context3.sent;
3483
+ return _context3.abrupt("return", new TokenAmount(this.plyToken, rewardBalancesMetadata.plyAccrured.toString()));
3484
+
3485
+ case 4:
3486
+ case "end":
3487
+ return _context3.stop();
3488
+ }
3489
+ }
3490
+ }, _callee3, this);
3491
+ }));
3492
+
3493
+ function getUnclaimedPlyReward(_x3) {
3494
+ return _getUnclaimedPlyReward.apply(this, arguments);
3495
+ }
3496
+
3497
+ return getUnclaimedPlyReward;
3498
+ }();
3499
+
3500
+ _proto.getLockingDetails = /*#__PURE__*/function () {
3501
+ var _getLockingDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(userAddress) {
3502
+ var currentTime, currentWeek, denominator, promises, values, percentLockCurrentWeek, percentLockNextWeek, totalRewards, _yield$this$_pulp$cal, pulpAmountCurrentWeek, plyAmountCurrentWeek, plyAmountNextWeek, pulpAmountNextWeek, currentUnlockPortion, nextUnlockPortion;
3503
+
3504
+ return runtime_1.wrap(function _callee4$(_context4) {
3505
+ while (1) {
3506
+ switch (_context4.prev = _context4.next) {
3255
3507
  case 0:
3256
3508
  currentTime = getCurrentTimestamp();
3257
- currentWeek = ethers.BigNumber.from(currentTime - REWARDCLAIMSTART).div(7 * ONE_DAY).toNumber();
3258
- denominator = 10000;
3509
+ currentWeek = ethers.BigNumber.from(currentTime - REWARD_CLAIM_START).div(ONE_WEEK).toNumber();
3510
+ denominator = ethers.BigNumber.from(10000);
3259
3511
  promises = [];
3260
- promises.push(this._tokenLock.percentageLock(currentWeek));
3261
- promises.push(this._tokenLock.percentageLock(currentWeek + 1)["catch"](function (err) {
3262
- return denominator;
3263
- }));
3264
- _context.next = 8;
3265
- return Promise.all(promises).then(function (res) {
3266
- return res.map(function (v) {
3267
- return v.toString();
3268
- });
3269
- });
3512
+ promises.push(this._auriLens.getPercentLock(this._pulp.address, userAddress, currentWeek));
3513
+ promises.push(this._auriLens.getPercentLock(this._pulp.address, userAddress, currentWeek + 1));
3514
+ promises.push(this.getUnclaimedPlyReward(userAddress));
3515
+ _context4.next = 9;
3516
+ return Promise.all(promises);
3270
3517
 
3271
- case 8:
3272
- values = _context.sent;
3273
- return _context.abrupt("return", {
3274
- vestingStart: REWARDCLAIMSTART,
3275
- currentUnlockPortion: new BigNumber(denominator).minus(values[0]).div(denominator).toNumber(),
3276
- nextUnlockPortion: new BigNumber(denominator).minus(values[1]).div(denominator).toNumber()
3518
+ case 9:
3519
+ values = _context4.sent;
3520
+ percentLockCurrentWeek = ethers.BigNumber.from(values[0]);
3521
+ percentLockNextWeek = ethers.BigNumber.from(values[1]);
3522
+ totalRewards = values[2];
3523
+ _context4.next = 15;
3524
+ return this._pulp.calcLockAmount(userAddress, totalRewards.rawAmount());
3525
+
3526
+ case 15:
3527
+ _yield$this$_pulp$cal = _context4.sent;
3528
+ pulpAmountCurrentWeek = _yield$this$_pulp$cal[0];
3529
+ plyAmountCurrentWeek = _yield$this$_pulp$cal[1];
3530
+ plyAmountNextWeek = percentLockNextWeek.mul(totalRewards.rawAmount()).div(denominator);
3531
+ pulpAmountNextWeek = ethers.BigNumber.from(totalRewards.rawAmount()).sub(plyAmountNextWeek);
3532
+ currentUnlockPortion = denominator.sub(percentLockCurrentWeek).toString();
3533
+ nextUnlockPortion = denominator.sub(percentLockNextWeek).toString();
3534
+ return _context4.abrupt("return", {
3535
+ vestingStart: REWARD_CLAIM_START,
3536
+ currentUnlockPortion: new BigNumber(currentUnlockPortion).dividedBy(100).toNumber(),
3537
+ accruedPly: totalRewards,
3538
+ currentPly: new TokenAmount(this.plyToken, plyAmountCurrentWeek.toString()),
3539
+ currentPulp: new TokenAmount(this.pulpToken, pulpAmountCurrentWeek.toString()),
3540
+ nextUnlockPortion: new BigNumber(nextUnlockPortion).dividedBy(100).toNumber(),
3541
+ nextPly: new TokenAmount(this.plyToken, plyAmountNextWeek.toString()),
3542
+ nextPulp: new TokenAmount(this.pulpToken, pulpAmountNextWeek.toString())
3277
3543
  });
3278
3544
 
3279
- case 10:
3545
+ case 23:
3280
3546
  case "end":
3281
- return _context.stop();
3547
+ return _context4.stop();
3282
3548
  }
3283
3549
  }
3284
- }, _callee, this);
3550
+ }, _callee4, this);
3285
3551
  }));
3286
3552
 
3287
- function getLockingDetails() {
3553
+ function getLockingDetails(_x4) {
3288
3554
  return _getLockingDetails.apply(this, arguments);
3289
3555
  }
3290
3556
 
3291
3557
  return getLockingDetails;
3292
3558
  }();
3293
3559
 
3560
+ _proto.getTimestampToUnlock = function getTimestampToUnlock(userAddress, targetUnlockPortion) {
3561
+ var lockPortion = 100 - targetUnlockPortion;
3562
+
3563
+ if (lockPortion >= 95) {
3564
+ return REWARD_CLAIM_START;
3565
+ }
3566
+
3567
+ return REWARD_CLAIM_START + ONE_WEEK * Math.round((95 - lockPortion) / 2);
3568
+ };
3569
+
3570
+ return PapermillRead;
3571
+ }(BlockchainEntityRead);
3572
+ var PapermillReadWrite = /*#__PURE__*/function (_PapermillRead) {
3573
+ _inheritsLoose(PapermillReadWrite, _PapermillRead);
3574
+
3575
+ function PapermillReadWrite(networkConnection) {
3576
+ return _PapermillRead.call(this, networkConnection) || this;
3577
+ }
3578
+
3579
+ var _proto2 = PapermillReadWrite.prototype;
3580
+
3581
+ _proto2.redeem = /*#__PURE__*/function () {
3582
+ var _redeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(recipient, amount) {
3583
+ return runtime_1.wrap(function _callee5$(_context5) {
3584
+ while (1) {
3585
+ switch (_context5.prev = _context5.next) {
3586
+ case 0:
3587
+ return _context5.abrupt("return", this._pulp.connect(this._networkConnection.signer).redeem(recipient, amount.rawAmount()));
3588
+
3589
+ case 1:
3590
+ case "end":
3591
+ return _context5.stop();
3592
+ }
3593
+ }
3594
+ }, _callee5, this);
3595
+ }));
3596
+
3597
+ function redeem(_x5, _x6) {
3598
+ return _redeem.apply(this, arguments);
3599
+ }
3600
+
3601
+ return redeem;
3602
+ }();
3603
+
3604
+ _proto2.selfRedeem = /*#__PURE__*/function () {
3605
+ var _selfRedeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(amount) {
3606
+ var msgSender;
3607
+ return runtime_1.wrap(function _callee6$(_context6) {
3608
+ while (1) {
3609
+ switch (_context6.prev = _context6.next) {
3610
+ case 0:
3611
+ _context6.next = 2;
3612
+ return this._networkConnection.signer.getAddress();
3613
+
3614
+ case 2:
3615
+ msgSender = _context6.sent;
3616
+ return _context6.abrupt("return", this.redeem(msgSender, amount));
3617
+
3618
+ case 4:
3619
+ case "end":
3620
+ return _context6.stop();
3621
+ }
3622
+ }
3623
+ }, _callee6, this);
3624
+ }));
3625
+
3626
+ function selfRedeem(_x7) {
3627
+ return _selfRedeem.apply(this, arguments);
3628
+ }
3629
+
3630
+ return selfRedeem;
3631
+ }();
3632
+
3633
+ return PapermillReadWrite;
3634
+ }(PapermillRead);
3635
+ var Papermill = /*#__PURE__*/function (_BlockchainEntity) {
3636
+ _inheritsLoose(Papermill, _BlockchainEntity);
3637
+
3638
+ function Papermill() {
3639
+ return _BlockchainEntity.call(this) || this;
3640
+ }
3641
+
3642
+ var _proto3 = Papermill.prototype;
3643
+
3644
+ _proto3.read = function read(networkConnection) {
3645
+ return new PapermillRead(networkConnection);
3646
+ };
3647
+
3648
+ _proto3.readWrite = function readWrite(networkConnection) {
3649
+ return new PapermillReadWrite(networkConnection);
3650
+ };
3651
+
3652
+ return Papermill;
3653
+ }(BlockchainEntity);
3654
+
3655
+ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3656
+ _inheritsLoose(SdkRead, _BlockchainEntityRead);
3657
+
3658
+ function SdkRead(networkConnection) {
3659
+ var _this;
3660
+
3661
+ _this = _BlockchainEntityRead.call(this, networkConnection) || this;
3662
+ _this._comptroller = new ethers.Contract(networkAddresses.misc.COMPTROLLER, ComptrollerABI.abi, networkConnection.provider);
3663
+ _this._auriFairLaunch = new ethers.Contract(networkAddresses.misc.AURIFAIRLAUNCH, AuriFairLaunchABI.abi, networkConnection.provider);
3664
+ _this._auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, AuriLensABI.abi, networkConnection.provider);
3665
+ return _this;
3666
+ }
3667
+
3668
+ var _proto = SdkRead.prototype;
3669
+
3294
3670
  _proto.getUserDetails = /*#__PURE__*/function () {
3295
- var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
3671
+ var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
3296
3672
  var _this2 = this;
3297
3673
 
3298
- var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, rewardBalancesMetadata, lockedAmount, _yield$Promise$all, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
3674
+ var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
3299
3675
 
3300
- return runtime_1.wrap(function _callee2$(_context2) {
3676
+ return runtime_1.wrap(function _callee$(_context) {
3301
3677
  while (1) {
3302
- switch (_context2.prev = _context2.next) {
3678
+ switch (_context.prev = _context.next) {
3303
3679
  case 0:
3304
3680
  marketCount = networkAddresses.auTokens.length;
3305
3681
  userMarketDetails = [];
@@ -3335,15 +3711,15 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3335
3711
  promises.push(this._comptroller.getAssetsIn(userAddress).then(function (res) {
3336
3712
  assetsIn = res;
3337
3713
  }));
3338
- _context2.next = 10;
3714
+ _context.next = 10;
3339
3715
  return Promise.all(promises);
3340
3716
 
3341
3717
  case 10:
3342
- _context2.next = 12;
3718
+ _context.next = 12;
3343
3719
  return Promise.all(pricePromises);
3344
3720
 
3345
3721
  case 12:
3346
- underlyingPrices = _context2.sent;
3722
+ underlyingPrices = _context.sent;
3347
3723
  depositValues = [];
3348
3724
 
3349
3725
  _loop = function _loop() {
@@ -3368,23 +3744,14 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3368
3744
  if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
3369
3745
  return p;
3370
3746
  }, new BigNumber(0));
3371
- promises = new Array(3);
3372
- promises[0] = this._comptroller.getAccountLiquidity(userAddress);
3373
- promises[1] = this._auriLens.callStatic.claimRewards(this._comptroller.address, this._auriFairLaunch.address, [], {
3374
- from: userAddress
3375
- });
3376
- promises[2] = this._tokenLock.lockedAmounts(userAddress);
3377
- _context2.next = 23;
3378
- return Promise.all(promises);
3747
+ _context.next = 19;
3748
+ return this._comptroller.getAccountLiquidity(userAddress);
3379
3749
 
3380
- case 23:
3381
- _yield$Promise$all = _context2.sent;
3382
- accountLiquidity = _yield$Promise$all[0];
3383
- rewardBalancesMetadata = _yield$Promise$all[1];
3384
- lockedAmount = _yield$Promise$all[2];
3750
+ case 19:
3751
+ accountLiquidity = _context.sent;
3385
3752
  borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
3386
3753
 
3387
- if (borrowedvaluation.lt("0.00001")) {
3754
+ if (borrowedvaluation.lt('0.00001')) {
3388
3755
  borrowedvaluation = new BigNumber(0);
3389
3756
  }
3390
3757
 
@@ -3405,26 +3772,33 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3405
3772
  userMarketDetails[i].maxWithdrawableAmount = userMarketDetails[i].isCollateral && maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount()) ? new TokenAmount(moneyMarket.underlying, maxWithdrawCap.toFixed(24), false) : new TokenAmount(moneyMarket.underlying, userMarketDetails[i].depositBalance.rawAmount());
3406
3773
  }
3407
3774
 
3408
- return _context2.abrupt("return", {
3409
- markets: userMarketDetails,
3410
- borrowLimit: {
3411
- currency: "USD",
3412
- amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
3413
- },
3414
- accruedPly: new TokenAmount(PLYToken, rewardBalancesMetadata.plyAccrured.toString()),
3415
- lockedPly: new TokenAmount(PLYToken, lockedAmount.toString()),
3416
- borrowableAmount: {
3417
- currency: "USD",
3418
- amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
3419
- }
3775
+ _context.t0 = userMarketDetails;
3776
+ _context.t1 = {
3777
+ currency: 'USD',
3778
+ amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
3779
+ };
3780
+ _context.next = 30;
3781
+ return new PapermillRead(this._networkConnection).getLockingDetails(userAddress);
3782
+
3783
+ case 30:
3784
+ _context.t2 = _context.sent;
3785
+ _context.t3 = {
3786
+ currency: 'USD',
3787
+ amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
3788
+ };
3789
+ return _context.abrupt("return", {
3790
+ markets: _context.t0,
3791
+ borrowLimit: _context.t1,
3792
+ userLockingDetails: _context.t2,
3793
+ borrowableAmount: _context.t3
3420
3794
  });
3421
3795
 
3422
- case 34:
3796
+ case 33:
3423
3797
  case "end":
3424
- return _context2.stop();
3798
+ return _context.stop();
3425
3799
  }
3426
3800
  }
3427
- }, _callee2, this);
3801
+ }, _callee, this);
3428
3802
  }));
3429
3803
 
3430
3804
  function getUserDetails(_x) {
@@ -3434,76 +3808,92 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3434
3808
  return getUserDetails;
3435
3809
  }();
3436
3810
 
3437
- _proto.getPlyAuroraPoolDetails = /*#__PURE__*/function () {
3438
- var _getPlyAuroraPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
3439
- var stakedLiquidity, rewardPerSecond, promises, rewardPerSecondValuation, totalStakeValuation;
3440
- return runtime_1.wrap(function _callee3$(_context3) {
3811
+ _proto.getPlyUsdcPoolDetails = /*#__PURE__*/function () {
3812
+ var _getPlyUsdcPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
3813
+ var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, promises, _i, rewardTokenAddress, rewardToken, rewardPerSecond, rewardPerSecondValuation, totalStakeValuation;
3814
+
3815
+ return runtime_1.wrap(function _callee2$(_context2) {
3441
3816
  while (1) {
3442
- switch (_context3.prev = _context3.next) {
3817
+ switch (_context2.prev = _context2.next) {
3443
3818
  case 0:
3444
- promises = [];
3445
- promises.push(this._auriFairLaunch.getPoolInfo(AurPlyPid).then(function (res) {
3819
+ _context2.next = 2;
3820
+ return this._auriFairLaunch.getPoolInfo(PlyUsdcPid).then(function (res) {
3446
3821
  stakedLiquidity = res.totalStake;
3447
- rewardPerSecond = res.rewardPerSeconds[0];
3448
- }));
3449
- _context3.next = 4;
3450
- return Promise.all(promises);
3822
+ rewardPerSeconds = res.rewardPerSeconds;
3823
+ });
3451
3824
 
3452
- case 4:
3825
+ case 2:
3826
+ stakedLiquidityAmount = new TokenAmount(PLYUSDCToken, stakedLiquidity.toString());
3453
3827
  promises = [];
3454
- promises.push(fetchValuation(new TokenAmount(PLYToken, rewardPerSecond.toString()), this._networkConnection.provider).then(function (res) {
3455
- return rewardPerSecondValuation = res;
3456
- }));
3457
- promises.push(fetchValuation(new TokenAmount(AURPLYToken, stakedLiquidity.toString()), this._networkConnection.provider).then(function (res) {
3458
- return totalStakeValuation = res;
3459
- }));
3460
- _context3.next = 9;
3828
+
3829
+ for (_i = 0; _i < rewardPerSeconds.length; _i++) {
3830
+ rewardTokenAddress = PLYUSDCRewardTokens[_i];
3831
+ rewardToken = new Token(rewardTokenAddress, getDecimal(rewardTokenAddress));
3832
+ rewardPerSecond = rewardPerSeconds[_i];
3833
+ promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
3834
+ }
3835
+
3836
+ _context2.next = 7;
3461
3837
  return Promise.all(promises);
3462
3838
 
3463
- case 9:
3464
- return _context3.abrupt("return", {
3465
- totalStakedLiquidity: new TokenAmount(AURPLYToken, stakedLiquidity.toString()),
3839
+ case 7:
3840
+ rewardPerSecondValuation = _context2.sent.reduce(function (p, v) {
3841
+ return p.plus(v);
3842
+ }, new BigNumber(0));
3843
+ _context2.next = 10;
3844
+ return fetchValuation(stakedLiquidityAmount, this._networkConnection.provider);
3845
+
3846
+ case 10:
3847
+ totalStakeValuation = _context2.sent;
3848
+ return _context2.abrupt("return", {
3849
+ totalStakedLiquidity: {
3850
+ tokenAmount: stakedLiquidityAmount,
3851
+ currencyAmount: {
3852
+ currency: 'USD',
3853
+ amount: totalStakeValuation.toFixed(DECIMAL_PRECISION)
3854
+ }
3855
+ },
3466
3856
  apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
3467
3857
  });
3468
3858
 
3469
- case 10:
3859
+ case 12:
3470
3860
  case "end":
3471
- return _context3.stop();
3861
+ return _context2.stop();
3472
3862
  }
3473
3863
  }
3474
- }, _callee3, this);
3864
+ }, _callee2, this);
3475
3865
  }));
3476
3866
 
3477
- function getPlyAuroraPoolDetails() {
3478
- return _getPlyAuroraPoolDetails.apply(this, arguments);
3867
+ function getPlyUsdcPoolDetails() {
3868
+ return _getPlyUsdcPoolDetails.apply(this, arguments);
3479
3869
  }
3480
3870
 
3481
- return getPlyAuroraPoolDetails;
3871
+ return getPlyUsdcPoolDetails;
3482
3872
  }();
3483
3873
 
3484
3874
  _proto.getTokenPrice = /*#__PURE__*/function () {
3485
- var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(token) {
3875
+ var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(token) {
3486
3876
  var price;
3487
- return runtime_1.wrap(function _callee4$(_context4) {
3877
+ return runtime_1.wrap(function _callee3$(_context3) {
3488
3878
  while (1) {
3489
- switch (_context4.prev = _context4.next) {
3879
+ switch (_context3.prev = _context3.next) {
3490
3880
  case 0:
3491
- _context4.next = 2;
3881
+ _context3.next = 2;
3492
3882
  return fetchPrice(token.address, this._networkConnection.provider);
3493
3883
 
3494
3884
  case 2:
3495
- price = _context4.sent;
3496
- return _context4.abrupt("return", {
3497
- currency: "USD",
3885
+ price = _context3.sent;
3886
+ return _context3.abrupt("return", {
3887
+ currency: 'USD',
3498
3888
  amount: price.toFixed(DECIMAL_PRECISION)
3499
3889
  });
3500
3890
 
3501
3891
  case 4:
3502
3892
  case "end":
3503
- return _context4.stop();
3893
+ return _context3.stop();
3504
3894
  }
3505
3895
  }
3506
- }, _callee4, this);
3896
+ }, _callee3, this);
3507
3897
  }));
3508
3898
 
3509
3899
  function getTokenPrice(_x2) {
@@ -3514,25 +3904,26 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3514
3904
  }();
3515
3905
 
3516
3906
  _proto.stakeBalanceOf = /*#__PURE__*/function () {
3517
- var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(user) {
3518
- var userInfo;
3519
- return runtime_1.wrap(function _callee5$(_context5) {
3907
+ var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(user) {
3908
+ var userInfo, stakeAmount;
3909
+ return runtime_1.wrap(function _callee4$(_context4) {
3520
3910
  while (1) {
3521
- switch (_context5.prev = _context5.next) {
3911
+ switch (_context4.prev = _context4.next) {
3522
3912
  case 0:
3523
- _context5.next = 2;
3524
- return this._auriFairLaunch.getUserInfo(AurPlyPid, user);
3913
+ _context4.next = 2;
3914
+ return this._auriFairLaunch.getUserInfo(PlyUsdcPid, user);
3525
3915
 
3526
3916
  case 2:
3527
- userInfo = _context5.sent;
3528
- return _context5.abrupt("return", new TokenAmount(AURPLYToken, userInfo.amount.toString()));
3917
+ userInfo = _context4.sent;
3918
+ stakeAmount = new TokenAmount(PLYUSDCToken, userInfo.amount.toString());
3919
+ return _context4.abrupt("return", valuateToken(stakeAmount, this._networkConnection.provider));
3529
3920
 
3530
- case 4:
3921
+ case 5:
3531
3922
  case "end":
3532
- return _context5.stop();
3923
+ return _context4.stop();
3533
3924
  }
3534
3925
  }
3535
- }, _callee5, this);
3926
+ }, _callee4, this);
3536
3927
  }));
3537
3928
 
3538
3929
  function stakeBalanceOf(_x3) {
@@ -3542,6 +3933,36 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3542
3933
  return stakeBalanceOf;
3543
3934
  }();
3544
3935
 
3936
+ _proto.LpBalanceOf = /*#__PURE__*/function () {
3937
+ var _LpBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(user) {
3938
+ var lpERC20, balance;
3939
+ return runtime_1.wrap(function _callee5$(_context5) {
3940
+ while (1) {
3941
+ switch (_context5.prev = _context5.next) {
3942
+ case 0:
3943
+ lpERC20 = new ethers.Contract(networkAddresses.tokens.PLYUSDC, EIP20InterfaceABI.abi, this._networkConnection.provider);
3944
+ _context5.next = 3;
3945
+ return lpERC20.balanceOf(user);
3946
+
3947
+ case 3:
3948
+ balance = _context5.sent;
3949
+ return _context5.abrupt("return", valuateToken(new TokenAmount(PLYUSDCToken, balance.toString()), this._networkConnection.provider));
3950
+
3951
+ case 5:
3952
+ case "end":
3953
+ return _context5.stop();
3954
+ }
3955
+ }
3956
+ }, _callee5, this);
3957
+ }));
3958
+
3959
+ function LpBalanceOf(_x4) {
3960
+ return _LpBalanceOf.apply(this, arguments);
3961
+ }
3962
+
3963
+ return LpBalanceOf;
3964
+ }();
3965
+
3545
3966
  _proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
3546
3967
  var userMarketDetail = _ref.userMarketDetail,
3547
3968
  currentBorrowLimit = _ref.currentBorrowLimit,
@@ -3574,7 +3995,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3574
3995
  return {
3575
3996
  newBorrowLimit: {
3576
3997
  amount: newBorrowLimit.toFixed(DECIMAL_PRECISION),
3577
- currency: "USD"
3998
+ currency: 'USD'
3578
3999
  },
3579
4000
  newBorrowUtilization: newBorrowLimit.eq(0) ? newBorrowValuation.eq(0) ? 0 : 9999.99 : newBorrowValuation.div(newBorrowLimit).toNumber()
3580
4001
  };
@@ -3597,7 +4018,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3597
4018
  while (1) {
3598
4019
  switch (_context6.prev = _context6.next) {
3599
4020
  case 0:
3600
- return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid]));
4021
+ return _context6.abrupt("return", this._auriLens.connect(this._networkConnection.signer).claimRewards(this._comptroller.address, this._auriFairLaunch.address, ALL_STAKING_POOLS));
3601
4022
 
3602
4023
  case 1:
3603
4024
  case "end":
@@ -3620,7 +4041,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3620
4041
  while (1) {
3621
4042
  switch (_context7.prev = _context7.next) {
3622
4043
  case 0:
3623
- return _context7.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).deposit(AurPlyPid, amount.rawAmount()));
4044
+ return _context7.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).deposit(PlyUsdcPid, amount.rawAmount()));
3624
4045
 
3625
4046
  case 1:
3626
4047
  case "end":
@@ -3630,7 +4051,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3630
4051
  }, _callee7, this);
3631
4052
  }));
3632
4053
 
3633
- function stake(_x4) {
4054
+ function stake(_x5) {
3634
4055
  return _stake.apply(this, arguments);
3635
4056
  }
3636
4057
 
@@ -3643,7 +4064,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3643
4064
  while (1) {
3644
4065
  switch (_context8.prev = _context8.next) {
3645
4066
  case 0:
3646
- return _context8.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).withdraw(AurPlyPid, amount.rawAmount()));
4067
+ return _context8.abrupt("return", this._auriFairLaunch.connect(this._networkConnection.signer).withdraw(PlyUsdcPid, amount.rawAmount()));
3647
4068
 
3648
4069
  case 1:
3649
4070
  case "end":
@@ -3653,7 +4074,7 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
3653
4074
  }, _callee8, this);
3654
4075
  }));
3655
4076
 
3656
- function unstake(_x5) {
4077
+ function unstake(_x6) {
3657
4078
  return _unstake.apply(this, arguments);
3658
4079
  }
3659
4080
 
@@ -3722,7 +4143,7 @@ var dummyUserMarketDetails = {
3722
4143
  isCollateral: true,
3723
4144
  maxWithdrawableAmount: dummyTokenAmount,
3724
4145
  collateralRatio: 0.5,
3725
- underlyingPrice: "1"
4146
+ underlyingPrice: '1'
3726
4147
  };
3727
4148
 
3728
4149
  var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
@@ -106833,7 +107254,7 @@ var AirdropReadWrite = /*#__PURE__*/function (_AirdropRead) {
106833
107254
  while (1) {
106834
107255
  switch (_context6.prev = _context6.next) {
106835
107256
  case 0:
106836
- assert(campaigns.length == tokens.length, "campaigns and tokens must have the same length");
107257
+ assert(campaigns.length == tokens.length, 'campaigns and tokens must have the same length');
106837
107258
  _context6.t0 = this._airDrop.connect(this._networkConnection.signer);
106838
107259
  _context6.t1 = campaigns.map(function (e) {
106839
107260
  return ethers.utils.formatBytes32String(e);
@@ -106914,12 +107335,11 @@ BigNumber.config({
106914
107335
  exports.AIRDROP_END_TIMESTAMP = AIRDROP_END_TIMESTAMP;
106915
107336
  exports.AIRDROP_KEEP_THRESHOLD = AIRDROP_KEEP_THRESHOLD;
106916
107337
  exports.AIRDROP_START_TIMESTAMP = AIRDROP_START_TIMESTAMP;
107338
+ exports.ALL_STAKING_POOLS = ALL_STAKING_POOLS;
106917
107339
  exports.AURORA_CHAINID = AURORA_CHAINID;
106918
- exports.AURPLYToken = AURPLYToken;
106919
107340
  exports.Airdrop = Airdrop;
106920
107341
  exports.AirdropRead = AirdropRead;
106921
107342
  exports.AirdropReadWrite = AirdropReadWrite;
106922
- exports.AurPlyPid = AurPlyPid;
106923
107343
  exports.BORROW_LIMIT_BUFFER = BORROW_LIMIT_BUFFER;
106924
107344
  exports.BORROW_NEAR_REWARDS_PER_WEEK = BORROW_NEAR_REWARDS_PER_WEEK;
106925
107345
  exports.BlockchainEntity = BlockchainEntity;
@@ -106933,9 +107353,17 @@ exports.MoneyMarket = MoneyMarket;
106933
107353
  exports.MoneyMarketRead = MoneyMarketRead;
106934
107354
  exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
106935
107355
  exports.ONE_DAY = ONE_DAY;
107356
+ exports.ONE_WEEK = ONE_WEEK;
106936
107357
  exports.ONE_YEAR = ONE_YEAR;
106937
107358
  exports.PLYToken = PLYToken;
106938
- exports.REWARDCLAIMSTART = REWARDCLAIMSTART;
107359
+ exports.PLYUSDCRewardTokens = PLYUSDCRewardTokens;
107360
+ exports.PLYUSDCToken = PLYUSDCToken;
107361
+ exports.PRICE_WHITELISTED = PRICE_WHITELISTED;
107362
+ exports.Papermill = Papermill;
107363
+ exports.PapermillRead = PapermillRead;
107364
+ exports.PapermillReadWrite = PapermillReadWrite;
107365
+ exports.PlyUsdcPid = PlyUsdcPid;
107366
+ exports.REWARD_CLAIM_START = REWARD_CLAIM_START;
106939
107367
  exports.SDK = SDK;
106940
107368
  exports.SdkRead = SdkRead;
106941
107369
  exports.SdkReadWrite = SdkReadWrite;
@@ -106957,6 +107385,7 @@ exports.dummyUserMarketDetails = dummyUserMarketDetails;
106957
107385
  exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
106958
107386
  exports.fetchLPPositions = fetchLPPositions;
106959
107387
  exports.fetchLPPrice = fetchLPPrice;
107388
+ exports.fetchPLYPrice = fetchPLYPrice;
106960
107389
  exports.fetchPrice = fetchPrice;
106961
107390
  exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
106962
107391
  exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
@@ -106972,4 +107401,5 @@ exports.getDecimal = getDecimal;
106972
107401
  exports.isSameAddress = isSameAddress;
106973
107402
  exports.networkAddresses = networkAddresses;
106974
107403
  exports.validateAndParseAddress = validateAndParseAddress;
107404
+ exports.valuateToken = valuateToken;
106975
107405
  //# sourceMappingURL=sdk.cjs.development.js.map