@aurigami/sdk 1.6.1 → 1.6.3

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
@@ -16,6 +16,7 @@ import EthRepayHelperABI from '@aurigami/contracts/artifacts/contracts/EthRepayH
16
16
  import AuriFairLaunchABI from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
17
17
  import EIP20InterfaceABI from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
18
18
  import PulpABI from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
19
+ import ReferralDirectoryABI from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
19
20
  import FaucetABI from '@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json';
20
21
  import Multicall2ABI from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
21
22
 
@@ -64,6 +65,10 @@ var networkAddresses = {
64
65
  name: 'auPLY',
65
66
  address: /*#__PURE__*/MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(),
66
67
  underlying: /*#__PURE__*/'0x09c9d464b58d96837f8d8b6f4d9fe4ad408d3a4f'.toLowerCase()
68
+ }, {
69
+ name: 'auUSN',
70
+ address: /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
71
+ underlying: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
67
72
  }],
68
73
  misc: {
69
74
  COMPTROLLER: /*#__PURE__*/MAINNET_ADDRESSES.comptroller.toLowerCase(),
@@ -74,7 +79,8 @@ var networkAddresses = {
74
79
  AURI_AIRDROP: /*#__PURE__*/MAINNET_ADDRESSES.auriAirdrop.toLowerCase(),
75
80
  MULTICALL: /*#__PURE__*/MAINNET_ADDRESSES.multicall.toLowerCase(),
76
81
  TEAM_MULTISIG: /*#__PURE__*/'0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE'.toLowerCase(),
77
- PLY_TOKEN_LOCK: /*#__PURE__*/MAINNET_ADDRESSES.plyTokenLock.toLowerCase()
82
+ PLY_TOKEN_LOCK: /*#__PURE__*/MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
83
+ REFERRAL: /*#__PURE__*/MAINNET_ADDRESSES.referralDirectory.toLocaleLowerCase()
78
84
  },
79
85
  tokens: {
80
86
  AURORA: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
@@ -83,9 +89,10 @@ var networkAddresses = {
83
89
  USDC: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
84
90
  WNEAR: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
85
91
  TRI: /*#__PURE__*/'0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
86
- META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
92
+ META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLowerCase(),
87
93
  PULP: /*#__PURE__*/MAINNET_ADDRESSES.PULP.toLowerCase(),
88
- PLYWNEAR: /*#__PURE__*/MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase()
94
+ PLYWNEAR: /*#__PURE__*/MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
95
+ USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
89
96
  }
90
97
  }; // All token that we can calculate the price via oracle + coingecko
91
98
 
@@ -122,6 +129,7 @@ Object.entries({
122
129
  }));
123
130
  var BORROW_NEAR_REWARDS_PER_WEEK = {// currently 0 for all markets
124
131
  };
132
+ var HARDCODE_PRICE_TOKENS = /*#__PURE__*/Object.fromEntries([[/*#__PURE__*/networkAddresses.tokens.USN.toLowerCase(), '1']]);
125
133
 
126
134
  var decimalRecords = {
127
135
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
@@ -145,7 +153,8 @@ var decimalRecords = {
145
153
  '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
146
154
  '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
147
155
  '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18,
148
- '0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18
156
+ '0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18,
157
+ '0x5183e1b1091804bc2602586919e6880ac1cf2896': 18
149
158
  };
150
159
 
151
160
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -2619,33 +2628,41 @@ function _fetchPrice3() {
2619
2628
  while (1) {
2620
2629
  switch (_context10.prev = _context10.next) {
2621
2630
  case 0:
2622
- if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
2631
+ if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
2623
2632
  _context10.next = 4;
2624
2633
  break;
2625
2634
  }
2626
2635
 
2627
- return _context10.abrupt("return", fetchLPPrice(address, provider));
2636
+ return _context10.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2628
2637
 
2629
2638
  case 4:
2630
- if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2639
+ if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
2631
2640
  _context10.next = 8;
2632
2641
  break;
2633
2642
  }
2634
2643
 
2635
- return _context10.abrupt("return", fetchPLYPrice(provider));
2644
+ return _context10.abrupt("return", fetchLPPrice(address, provider));
2636
2645
 
2637
2646
  case 8:
2647
+ if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2648
+ _context10.next = 12;
2649
+ break;
2650
+ }
2651
+
2652
+ return _context10.abrupt("return", fetchPLYPrice(provider));
2653
+
2654
+ case 12:
2638
2655
  if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
2639
- _context10.next = 10;
2656
+ _context10.next = 14;
2640
2657
  break;
2641
2658
  }
2642
2659
 
2643
2660
  return _context10.abrupt("return", fetchPULPPrice(provider));
2644
2661
 
2645
- case 10:
2662
+ case 14:
2646
2663
  return _context10.abrupt("return", _fetchPrice(address, provider));
2647
2664
 
2648
- case 11:
2665
+ case 15:
2649
2666
  case "end":
2650
2667
  return _context10.stop();
2651
2668
  }
@@ -107170,6 +107187,236 @@ var Papermill = /*#__PURE__*/function (_BlockchainEntity) {
107170
107187
  return Papermill;
107171
107188
  }(BlockchainEntity);
107172
107189
 
107190
+ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
107191
+ _inheritsLoose(ReferralRead, _BlockchainEntityRead);
107192
+
107193
+ function ReferralRead(networkConnection) {
107194
+ var _this;
107195
+
107196
+ _this = _BlockchainEntityRead.call(this, networkConnection) || this;
107197
+ _this._referral = new Contract(networkAddresses.misc.REFERRAL, ReferralDirectoryABI.abi, networkConnection.provider);
107198
+ return _this;
107199
+ }
107200
+ /**
107201
+ * Generate a 10-character referral code
107202
+ * containing alphanumeric characters.
107203
+ */
107204
+
107205
+
107206
+ var _proto = ReferralRead.prototype;
107207
+
107208
+ _proto.generateReferralCode = function generateReferralCode() {
107209
+ var letters = 'abcdefghijklmnopqrstuvwxyz';
107210
+ var numbers = '1234567890';
107211
+ var charset = letters + letters.toUpperCase() + numbers;
107212
+ var R = '';
107213
+
107214
+ for (var i = 0; i < 10; i++) {
107215
+ R += charset[Math.floor(Math.random() * charset.length)];
107216
+ }
107217
+
107218
+ return R;
107219
+ }
107220
+ /**
107221
+ * Get the referral code for a given address, returns empty string if not found.
107222
+ *
107223
+ * Called to check if a user has a referral code.
107224
+ */
107225
+ ;
107226
+
107227
+ _proto.getUserReferralCode =
107228
+ /*#__PURE__*/
107229
+ function () {
107230
+ var _getUserReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddr) {
107231
+ var result;
107232
+ return runtime_1.wrap(function _callee$(_context) {
107233
+ while (1) {
107234
+ switch (_context.prev = _context.next) {
107235
+ case 0:
107236
+ _context.next = 2;
107237
+ return this._referral.userReferralCode(userAddr);
107238
+
107239
+ case 2:
107240
+ result = _context.sent;
107241
+ return _context.abrupt("return", ethers.utils.parseBytes32String(result));
107242
+
107243
+ case 4:
107244
+ case "end":
107245
+ return _context.stop();
107246
+ }
107247
+ }
107248
+ }, _callee, this);
107249
+ }));
107250
+
107251
+ function getUserReferralCode(_x) {
107252
+ return _getUserReferralCode.apply(this, arguments);
107253
+ }
107254
+
107255
+ return getUserReferralCode;
107256
+ }()
107257
+ /**
107258
+ * Get referral code that a user was referred by, returns empty string if not found.
107259
+ */
107260
+ ;
107261
+
107262
+ _proto.getReferralCodeUsed =
107263
+ /*#__PURE__*/
107264
+ function () {
107265
+ var _getReferralCodeUsed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddr) {
107266
+ var result;
107267
+ return runtime_1.wrap(function _callee2$(_context2) {
107268
+ while (1) {
107269
+ switch (_context2.prev = _context2.next) {
107270
+ case 0:
107271
+ _context2.next = 2;
107272
+ return this._referral.referralCodeUsed(userAddr);
107273
+
107274
+ case 2:
107275
+ result = _context2.sent;
107276
+ return _context2.abrupt("return", ethers.utils.parseBytes32String(result));
107277
+
107278
+ case 4:
107279
+ case "end":
107280
+ return _context2.stop();
107281
+ }
107282
+ }
107283
+ }, _callee2, this);
107284
+ }));
107285
+
107286
+ function getReferralCodeUsed(_x2) {
107287
+ return _getReferralCodeUsed.apply(this, arguments);
107288
+ }
107289
+
107290
+ return getReferralCodeUsed;
107291
+ }()
107292
+ /**
107293
+ * Get owner of a referral code, returns zero address if not found.
107294
+ */
107295
+ ;
107296
+
107297
+ _proto.getReferralCodeOwner =
107298
+ /*#__PURE__*/
107299
+ function () {
107300
+ var _getReferralCodeOwner = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(code) {
107301
+ var referralCode;
107302
+ return runtime_1.wrap(function _callee3$(_context3) {
107303
+ while (1) {
107304
+ switch (_context3.prev = _context3.next) {
107305
+ case 0:
107306
+ referralCode = ethers.utils.formatBytes32String(code);
107307
+ return _context3.abrupt("return", this._referral.referralCodeOwner(referralCode));
107308
+
107309
+ case 2:
107310
+ case "end":
107311
+ return _context3.stop();
107312
+ }
107313
+ }
107314
+ }, _callee3, this);
107315
+ }));
107316
+
107317
+ function getReferralCodeOwner(_x3) {
107318
+ return _getReferralCodeOwner.apply(this, arguments);
107319
+ }
107320
+
107321
+ return getReferralCodeOwner;
107322
+ }();
107323
+
107324
+ return ReferralRead;
107325
+ }(BlockchainEntityRead);
107326
+ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
107327
+ _inheritsLoose(ReferralReadWrite, _ReferralRead);
107328
+
107329
+ function ReferralReadWrite() {
107330
+ return _ReferralRead.apply(this, arguments) || this;
107331
+ }
107332
+
107333
+ var _proto2 = ReferralReadWrite.prototype;
107334
+
107335
+ /**
107336
+ * Generate a referral code for a given address.
107337
+ *
107338
+ * Called when an user want to creates his own referral code
107339
+ */
107340
+ _proto2.registerNewReferralCode =
107341
+ /*#__PURE__*/
107342
+ function () {
107343
+ var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
107344
+ var referralCode;
107345
+ return runtime_1.wrap(function _callee4$(_context4) {
107346
+ while (1) {
107347
+ switch (_context4.prev = _context4.next) {
107348
+ case 0:
107349
+ referralCode = ethers.utils.formatBytes32String(this.generateReferralCode());
107350
+ return _context4.abrupt("return", this._referral.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
107351
+
107352
+ case 2:
107353
+ case "end":
107354
+ return _context4.stop();
107355
+ }
107356
+ }
107357
+ }, _callee4, this);
107358
+ }));
107359
+
107360
+ function registerNewReferralCode() {
107361
+ return _registerNewReferralCode.apply(this, arguments);
107362
+ }
107363
+
107364
+ return registerNewReferralCode;
107365
+ }()
107366
+ /**
107367
+ * Called when an user confirms he is referred by a specified code
107368
+ */
107369
+ ;
107370
+
107371
+ _proto2.useReferralCode =
107372
+ /*#__PURE__*/
107373
+ function () {
107374
+ var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(code) {
107375
+ var referralCode;
107376
+ return runtime_1.wrap(function _callee5$(_context5) {
107377
+ while (1) {
107378
+ switch (_context5.prev = _context5.next) {
107379
+ case 0:
107380
+ referralCode = ethers.utils.formatBytes32String(code);
107381
+ return _context5.abrupt("return", this._referral.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
107382
+
107383
+ case 2:
107384
+ case "end":
107385
+ return _context5.stop();
107386
+ }
107387
+ }
107388
+ }, _callee5, this);
107389
+ }));
107390
+
107391
+ function useReferralCode(_x4) {
107392
+ return _useReferralCode.apply(this, arguments);
107393
+ }
107394
+
107395
+ return useReferralCode;
107396
+ }();
107397
+
107398
+ return ReferralReadWrite;
107399
+ }(ReferralRead);
107400
+ var Referral = /*#__PURE__*/function (_BlockchainEntity) {
107401
+ _inheritsLoose(Referral, _BlockchainEntity);
107402
+
107403
+ function Referral() {
107404
+ return _BlockchainEntity.call(this) || this;
107405
+ }
107406
+
107407
+ var _proto3 = Referral.prototype;
107408
+
107409
+ _proto3.read = function read(networkConnection) {
107410
+ return new ReferralRead(networkConnection);
107411
+ };
107412
+
107413
+ _proto3.readWrite = function readWrite(networkConnection) {
107414
+ return new ReferralReadWrite(networkConnection);
107415
+ };
107416
+
107417
+ return Referral;
107418
+ }(BlockchainEntity);
107419
+
107173
107420
  var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
107174
107421
  _inheritsLoose(StakingRead, _BlockchainEntityRead);
107175
107422
 
@@ -108110,5 +108357,5 @@ BigNumber.config({
108110
108357
  DECIMAL_PLACES: 50
108111
108358
  });
108112
108359
 
108113
- 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, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, REWARD_CLAIM_START, 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, getBlockBeforeTimestamp, getBlockTimestamp, getCurrentTimestamp, getDecimal, getQuery, isSameAddress, networkAddresses, validateAndParseAddress, valuateToken };
108360
+ 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, HARDCODE_PRICE_TOKENS, INF, MarketAction, 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, getBlockBeforeTimestamp, getBlockTimestamp, getCurrentTimestamp, getDecimal, getQuery, isSameAddress, networkAddresses, validateAndParseAddress, valuateToken };
108114
108361
  //# sourceMappingURL=sdk.esm.js.map