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