@aurigami/sdk 1.7.2 → 1.7.4

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
@@ -1,27 +1,48 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { BigNumber as BigNumber$1, Contract, utils, ethers } from 'ethers';
3
3
  import { Logger } from 'ethers/lib/utils';
4
- import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
5
- export { default as MAINNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_mainnet.json';
6
- export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
7
- import abis$7 from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
8
- import abis$6 from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
4
+ import abis$6 from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
5
+ import abis$7 from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
9
6
  import AuriAirdropABI from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json';
10
7
  import abis$1 from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
11
8
  import abis$2 from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
12
9
  import AuriOracleABI from '@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json';
13
- import AuTokenABI from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
14
- import abis from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
10
+ import abis from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
11
+ import abis$3 from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
15
12
  import abis$8 from '@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json';
16
- import abis$3 from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
17
- import abis$5 from '@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json';
13
+ import abis$4 from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
14
+ import abis$b from '@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json';
18
15
  import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
19
16
  import abis$9 from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
20
- import abis$4 from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
21
- import abis$a from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
17
+ import abis$a from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
18
+ import abis$5 from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
19
+ import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
20
+ export { default as MAINNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_mainnet.json';
21
+ export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
22
22
  import { Signer } from '@ethersproject/abstract-signer';
23
23
  import axios from 'axios';
24
24
 
25
+
26
+
27
+ var index = {
28
+ __proto__: null,
29
+ AuriOracleABI: AuriOracleABI,
30
+ AuTokenABI: abis,
31
+ IUniswapV2PairABI: IUniswapV2PairABI,
32
+ AuriAirdropABI: AuriAirdropABI,
33
+ AuriFairLaunchABI: abis$1,
34
+ AuriLensABI: abis$2,
35
+ ComptrollerABI: abis$3,
36
+ EIP20InterfaceABI: abis$4,
37
+ ReferralDirectoryABI: abis$5,
38
+ AuErc20ABI: abis$6,
39
+ AuETHABI: abis$7,
40
+ EthRepayHelperABI: abis$8,
41
+ Multicall2ABI: abis$9,
42
+ PulpABI: abis$a,
43
+ AuriInternalLensABI: abis$b
44
+ };
45
+
25
46
  var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
26
47
  var ETHAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
27
48
  var AURORA_CHAINID = 1313161554;
@@ -97,7 +118,8 @@ var networkAddresses = {
97
118
  PLYWNEAR: /*#__PURE__*/MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
98
119
  USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
99
120
  }
100
- }; // All token that we can calculate the price via oracle + coingecko
121
+ };
122
+ var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.STNEAR.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase()]; // All token that we can calculate the price via oracle + coingecko
101
123
 
102
124
  var PRICE_WHITELISTED = /*#__PURE__*/new Set( /*#__PURE__*/[].concat( /*#__PURE__*/networkAddresses.auTokens.map(function (t) {
103
125
  return t.underlying;
@@ -307,13 +329,13 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
307
329
  var _this;
308
330
 
309
331
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
310
- _this.comptroller = _this.getContract(networkAddresses.misc.COMPTROLLER, abis.abi);
332
+ _this.comptroller = _this.getContract(networkAddresses.misc.COMPTROLLER, abis$3.abi);
311
333
  _this.auriFairLaunch = _this.getContract(networkAddresses.misc.AURIFAIRLAUNCH, abis$1.abi);
312
334
  _this.auriLens = _this.getContract(networkAddresses.misc.AURILENS, abis$2.abi);
313
- _this.ply = _this.getContract(networkAddresses.tokens.PLY, abis$3.abi);
314
- _this.pulp = _this.getContract(networkAddresses.tokens.PULP, abis$4.abi); // this.faucet = this.getContract<Faucet>(networkAddresses.misc.FAUCET, abis.FaucetABI.abi);
335
+ _this.ply = _this.getContract(networkAddresses.tokens.PLY, abis$4.abi);
336
+ _this.pulp = _this.getContract(networkAddresses.tokens.PULP, abis$a.abi); // this.faucet = this.getContract<Faucet>(networkAddresses.misc.FAUCET, abis.FaucetABI.abi);
315
337
 
316
- _this.auriInternalLens = _this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$5.abi);
338
+ _this.auriInternalLens = _this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$b.abi);
317
339
  return _this;
318
340
  } // public faucet: Faucet;
319
341
 
@@ -324,6 +346,17 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
324
346
  return new Contract(address, abi, this._networkConnection.provider);
325
347
  };
326
348
 
349
+ _proto.getAuTokenContracts = function getAuTokenContracts() {
350
+ var _this2 = this;
351
+
352
+ return networkAddresses.auTokens.map(function (auToken) {
353
+ var contract = _this2.getContract(auToken.address, abis.abi);
354
+
355
+ contract.underlying = auToken.underlying;
356
+ return contract;
357
+ });
358
+ };
359
+
327
360
  return AuriEnv;
328
361
  }(BlockchainEntityRead);
329
362
 
@@ -1089,7 +1122,9 @@ try {
1089
1122
 
1090
1123
  var symbolRecords = /*#__PURE__*/Object.fromEntries( /*#__PURE__*/networkAddresses.auTokens.map(function (e) {
1091
1124
  return [e.address.toLowerCase(), e.name];
1092
- }));
1125
+ }).concat( /*#__PURE__*/networkAddresses.auTokens.map(function (e) {
1126
+ return [e.underlying.toLowerCase(), e.name.slice(2)];
1127
+ })));
1093
1128
 
1094
1129
  var AURORA_API_BASE_URL = 'https://api.aurorascan.dev/api';
1095
1130
  function getQuery(_x, _x2, _x3) {
@@ -1202,6 +1237,18 @@ function getSymbol(address) {
1202
1237
  assert(symbolRecords[addressLowercase] != undefined, 'Symbol not found for ' + address);
1203
1238
  return symbolRecords[addressLowercase];
1204
1239
  }
1240
+ function getUnderlying(address) {
1241
+ var addressLowercase = address.toLowerCase();
1242
+ var matching = networkAddresses.auTokens.filter(function (e) {
1243
+ return e.address == addressLowercase;
1244
+ });
1245
+
1246
+ if (matching.length == 0) {
1247
+ throw new Error('Underlying not found for ' + address);
1248
+ }
1249
+
1250
+ return matching[0].underlying;
1251
+ }
1205
1252
  function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1206
1253
  if (rewardsValue.isZero()) {
1207
1254
  return new BigNumber(0);
@@ -1472,6 +1519,10 @@ var TokenAmount = /*#__PURE__*/function () {
1472
1519
  return new BigNumber(this.rawAmnt).div(decimalFactor(this.token.decimals)).toString();
1473
1520
  };
1474
1521
 
1522
+ _proto.formattedAmountWithSymbol = function formattedAmountWithSymbol() {
1523
+ return this.formattedAmount() + " " + getSymbol(this.token.address);
1524
+ };
1525
+
1475
1526
  _proto.rawAmount = function rawAmount() {
1476
1527
  return this.rawAmnt;
1477
1528
  };
@@ -2188,7 +2239,7 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
2188
2239
  var _this;
2189
2240
 
2190
2241
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
2191
- _this.auToken = new Contract(tokenAddr, AuTokenABI.abi, _this._networkConnection.provider);
2242
+ _this.auToken = new Contract(tokenAddr, abis.abi, _this._networkConnection.provider);
2192
2243
  return _this;
2193
2244
  }
2194
2245
  /**
@@ -2298,6 +2349,7 @@ var helpers = {
2298
2349
  validateAndParseAddress: validateAndParseAddress,
2299
2350
  getDecimal: getDecimal,
2300
2351
  getSymbol: getSymbol,
2352
+ getUnderlying: getUnderlying,
2301
2353
  calcLMRewardApr: calcLMRewardApr,
2302
2354
  getBlockTimestamp: getBlockTimestamp,
2303
2355
  getBlocksTimestampViaRPC: getBlocksTimestampViaRPC,
@@ -2499,9 +2551,9 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2499
2551
  _this.env = new AuriEnv(networkConnection);
2500
2552
 
2501
2553
  if (isSameAddress(underlyingAsset, ETHAddress)) {
2502
- _this.auToken = new Contract(auToken, abis$6.abi, networkConnection.provider);
2503
- } else {
2504
2554
  _this.auToken = new Contract(auToken, abis$7.abi, networkConnection.provider);
2555
+ } else {
2556
+ _this.auToken = new Contract(auToken, abis$6.abi, networkConnection.provider);
2505
2557
  }
2506
2558
 
2507
2559
  _this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
@@ -3750,7 +3802,7 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3750
3802
  while (1) {
3751
3803
  switch (_context3.prev = _context3.next) {
3752
3804
  case 0:
3753
- lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$3.abi, this._networkConnection.provider);
3805
+ lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$4.abi, this._networkConnection.provider);
3754
3806
  _context3.next = 3;
3755
3807
  return lpContract.balanceOf(user);
3756
3808
 
@@ -4243,7 +4295,7 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4243
4295
  dust = new BigNumber(0.1);
4244
4296
  oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
4245
4297
  tokens = tokenAddresses.map(function (addr) {
4246
- return _this3.env.getContract(addr, AuTokenABI.abi);
4298
+ return _this3.env.getContract(addr, abis.abi);
4247
4299
  });
4248
4300
  _context5.next = 6;
4249
4301
  return oracle.getUnderlyingPrices(tokenAddresses);
@@ -4341,7 +4393,7 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4341
4393
  var _this;
4342
4394
 
4343
4395
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
4344
- _this.referral = new Contract(networkAddresses.misc.REFERRAL, abis$a.abi, networkConnection.provider);
4396
+ _this.referral = new Contract(networkAddresses.misc.REFERRAL, abis$5.abi, networkConnection.provider);
4345
4397
  return _this;
4346
4398
  }
4347
4399
  /**
@@ -5023,5 +5075,5 @@ BigNumber.config({
5023
5075
  DECIMAL_PLACES: 50
5024
5076
  });
5025
5077
 
5026
- export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, isSameAddress, networkAddresses, queryGraphQL, symbolRecords, validateAndParseAddress, valuateToken };
5078
+ export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, symbolRecords, validateAndParseAddress, valuateToken };
5027
5079
  //# sourceMappingURL=sdk.esm.js.map