@aurigami/sdk 1.6.0 → 1.6.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
@@ -17,6 +17,7 @@ import AuriFairLaunchABI from '@aurigami/contracts/artifacts/contracts/AuriFairL
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
19
  import FaucetABI from '@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json';
20
+ import Multicall2ABI from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
20
21
 
21
22
  var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
22
23
  var ETHAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
@@ -70,7 +71,10 @@ var networkAddresses = {
70
71
  AURIFAIRLAUNCH: /*#__PURE__*/MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
71
72
  AURILENS: /*#__PURE__*/MAINNET_ADDRESSES.auriLens.toLowerCase(),
72
73
  ETHREPAYHELPER: /*#__PURE__*/MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
73
- AURI_AIRDROP: /*#__PURE__*/MAINNET_ADDRESSES.auriAirdrop.toLowerCase()
74
+ AURI_AIRDROP: /*#__PURE__*/MAINNET_ADDRESSES.auriAirdrop.toLowerCase(),
75
+ MULTICALL: /*#__PURE__*/MAINNET_ADDRESSES.multicall.toLowerCase(),
76
+ TEAM_MULTISIG: /*#__PURE__*/'0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE'.toLowerCase(),
77
+ PLY_TOKEN_LOCK: /*#__PURE__*/MAINNET_ADDRESSES.plyTokenLock.toLowerCase()
74
78
  },
75
79
  tokens: {
76
80
  AURORA: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
@@ -107019,7 +107023,20 @@ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
107019
107023
  }
107020
107024
 
107021
107025
  return getTimestampToUnlock;
107022
- }();
107026
+ }()
107027
+ /**
107028
+ * Get the start timestamp of next week of the papermill contract.
107029
+ *
107030
+ * This is a sync function!
107031
+ *
107032
+ * @returns the timestamp in seconds
107033
+ */
107034
+ ;
107035
+
107036
+ _proto.getNextWeekTimestamp = function getNextWeekTimestamp() {
107037
+ var nextWeek = this.getWeek(getCurrentTimestamp()) + 1;
107038
+ return REWARD_CLAIM_START + ONE_WEEK * nextWeek;
107039
+ };
107023
107040
 
107024
107041
  _proto.getUnlockPortionAt = /*#__PURE__*/function () {
107025
107042
  var _getUnlockPortionAt = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(userAddress, timestamp) {
@@ -107431,6 +107448,92 @@ var Staking = /*#__PURE__*/function (_BlockchainEntity) {
107431
107448
  return Staking;
107432
107449
  }(BlockchainEntity);
107433
107450
 
107451
+ var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
107452
+ _inheritsLoose(MulticallRead, _BlockchainEntityRead);
107453
+
107454
+ function MulticallRead(networkConnection) {
107455
+ var _this;
107456
+
107457
+ _this = _BlockchainEntityRead.call(this, networkConnection) || this;
107458
+ _this._multicall = new Contract(networkAddresses.misc.MULTICALL, Multicall2ABI.abi, networkConnection.provider);
107459
+ return _this;
107460
+ }
107461
+ /**
107462
+ * Run multiple calls via multicall contract
107463
+ */
107464
+
107465
+
107466
+ var _proto = MulticallRead.prototype;
107467
+
107468
+ _proto.aggregate =
107469
+ /*#__PURE__*/
107470
+ function () {
107471
+ var _aggregate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(calls) {
107472
+ var txns, i, _call$contract$popula, call, txn, response, decodedReturn, _i;
107473
+
107474
+ return runtime_1.wrap(function _callee$(_context) {
107475
+ while (1) {
107476
+ switch (_context.prev = _context.next) {
107477
+ case 0:
107478
+ txns = []; // prepare transactions
107479
+
107480
+ i = 0;
107481
+
107482
+ case 2:
107483
+ if (!(i < calls.length)) {
107484
+ _context.next = 11;
107485
+ break;
107486
+ }
107487
+
107488
+ call = calls[i];
107489
+ _context.next = 6;
107490
+ return (_call$contract$popula = call.contract.populateTransaction)[call.method].apply(_call$contract$popula, call.args);
107491
+
107492
+ case 6:
107493
+ txn = _context.sent;
107494
+ txns.push({
107495
+ target: txn.to,
107496
+ callData: txn.data
107497
+ });
107498
+
107499
+ case 8:
107500
+ i++;
107501
+ _context.next = 2;
107502
+ break;
107503
+
107504
+ case 11:
107505
+ _context.next = 13;
107506
+ return this._multicall.callStatic.aggregate(txns);
107507
+
107508
+ case 13:
107509
+ response = _context.sent;
107510
+ // parse results
107511
+ decodedReturn = [];
107512
+
107513
+ for (_i = 0; _i < calls.length; _i++) {
107514
+ decodedReturn.push(ethers.utils.defaultAbiCoder.decode(calls[_i].returnTypes, response.returnData[_i]));
107515
+ }
107516
+
107517
+ return _context.abrupt("return", decodedReturn);
107518
+
107519
+ case 17:
107520
+ case "end":
107521
+ return _context.stop();
107522
+ }
107523
+ }
107524
+ }, _callee, this);
107525
+ }));
107526
+
107527
+ function aggregate(_x) {
107528
+ return _aggregate.apply(this, arguments);
107529
+ }
107530
+
107531
+ return aggregate;
107532
+ }();
107533
+
107534
+ return MulticallRead;
107535
+ }(BlockchainEntityRead);
107536
+
107434
107537
  var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
107435
107538
  _inheritsLoose(SdkRead, _BlockchainEntityRead);
107436
107539
 
@@ -107761,7 +107864,78 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
107761
107864
  },
107762
107865
  newBorrowUtilization: newBorrowLimit.eq(0) ? newBorrowValuation.eq(0) ? 0 : 9999.99 : newBorrowValuation.div(newBorrowLimit).toNumber()
107763
107866
  };
107764
- };
107867
+ }
107868
+ /**
107869
+ * Get ply circulating supply.
107870
+ * It is calculated by the total supply, minus:
107871
+ * - Ply in team multisig contract
107872
+ * - Ply in comptroller contract
107873
+ * - Ply in fairlaunch contract
107874
+ * - Ply in vesting contract
107875
+ */
107876
+ ;
107877
+
107878
+ _proto.getPlyCirculatingSupply =
107879
+ /*#__PURE__*/
107880
+ function () {
107881
+ var _getPlyCirculatingSupply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
107882
+ var plyContract, multicallRead, baseBalanceOfCall, callResults, circulatingSupply;
107883
+ return runtime_1.wrap(function _callee7$(_context7) {
107884
+ while (1) {
107885
+ switch (_context7.prev = _context7.next) {
107886
+ case 0:
107887
+ plyContract = new Contract(networkAddresses.tokens.PLY, EIP20InterfaceABI.abi, this._networkConnection.provider);
107888
+ multicallRead = new MulticallRead(this._networkConnection);
107889
+ baseBalanceOfCall = {
107890
+ contract: plyContract,
107891
+ method: 'balanceOf',
107892
+ returnTypes: ['uint256']
107893
+ };
107894
+ _context7.next = 5;
107895
+ return multicallRead.aggregate([// Get total supply
107896
+ _extends({}, baseBalanceOfCall, {
107897
+ method: 'totalSupply',
107898
+ args: []
107899
+ }), // balance in team multisig
107900
+ _extends({}, baseBalanceOfCall, {
107901
+ args: [networkAddresses.misc.TEAM_MULTISIG]
107902
+ }), // balance in comptroller
107903
+ _extends({}, baseBalanceOfCall, {
107904
+ args: [networkAddresses.misc.COMPTROLLER]
107905
+ }), // balance in fair launch
107906
+ _extends({}, baseBalanceOfCall, {
107907
+ args: [networkAddresses.misc.AURIFAIRLAUNCH]
107908
+ }), // balance in vesting contract
107909
+ _extends({}, baseBalanceOfCall, {
107910
+ args: [networkAddresses.misc.PLY_TOKEN_LOCK]
107911
+ })]);
107912
+
107913
+ case 5:
107914
+ callResults = _context7.sent;
107915
+ circulatingSupply = BigNumber$1.from(0);
107916
+ callResults.forEach(function (result, i) {
107917
+ if (i === 0) {
107918
+ circulatingSupply = result[0];
107919
+ } else {
107920
+ circulatingSupply = circulatingSupply.sub(result[0]);
107921
+ }
107922
+ });
107923
+ return _context7.abrupt("return", new TokenAmount(PLYToken, circulatingSupply.toString()));
107924
+
107925
+ case 9:
107926
+ case "end":
107927
+ return _context7.stop();
107928
+ }
107929
+ }
107930
+ }, _callee7, this);
107931
+ }));
107932
+
107933
+ function getPlyCirculatingSupply() {
107934
+ return _getPlyCirculatingSupply.apply(this, arguments);
107935
+ }
107936
+
107937
+ return getPlyCirculatingSupply;
107938
+ }();
107765
107939
 
107766
107940
  return SdkRead;
107767
107941
  }(BlockchainEntityRead);
@@ -107780,25 +107954,25 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
107780
107954
  _proto2.claim =
107781
107955
  /*#__PURE__*/
107782
107956
  function () {
107783
- var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
107784
- return runtime_1.wrap(function _callee7$(_context7) {
107957
+ var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
107958
+ return runtime_1.wrap(function _callee8$(_context8) {
107785
107959
  while (1) {
107786
- switch (_context7.prev = _context7.next) {
107960
+ switch (_context8.prev = _context8.next) {
107787
107961
  case 0:
107788
- _context7.t0 = this._comptroller.connect(this._networkConnection.signer);
107789
- _context7.next = 3;
107962
+ _context8.t0 = this._comptroller.connect(this._networkConnection.signer);
107963
+ _context8.next = 3;
107790
107964
  return this._networkConnection.signer.getAddress();
107791
107965
 
107792
107966
  case 3:
107793
- _context7.t1 = _context7.sent;
107794
- return _context7.abrupt("return", _context7.t0['claimReward(uint8,address)'].call(_context7.t0, 0, _context7.t1));
107967
+ _context8.t1 = _context8.sent;
107968
+ return _context8.abrupt("return", _context8.t0['claimReward(uint8,address)'].call(_context8.t0, 0, _context8.t1));
107795
107969
 
107796
107970
  case 5:
107797
107971
  case "end":
107798
- return _context7.stop();
107972
+ return _context8.stop();
107799
107973
  }
107800
107974
  }
107801
- }, _callee7, this);
107975
+ }, _callee8, this);
107802
107976
  }));
107803
107977
 
107804
107978
  function claim() {
@@ -107809,26 +107983,26 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
107809
107983
  }();
107810
107984
 
107811
107985
  _proto2.claimLpRewards = /*#__PURE__*/function () {
107812
- var _claimLpRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
107813
- return runtime_1.wrap(function _callee8$(_context8) {
107986
+ var _claimLpRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
107987
+ return runtime_1.wrap(function _callee9$(_context9) {
107814
107988
  while (1) {
107815
- switch (_context8.prev = _context8.next) {
107989
+ switch (_context9.prev = _context9.next) {
107816
107990
  case 0:
107817
- _context8.t0 = this._auriFairLaunch.connect(this._networkConnection.signer);
107818
- _context8.next = 3;
107991
+ _context9.t0 = this._auriFairLaunch.connect(this._networkConnection.signer);
107992
+ _context9.next = 3;
107819
107993
  return this._networkConnection.signer.getAddress();
107820
107994
 
107821
107995
  case 3:
107822
- _context8.t1 = _context8.sent;
107823
- _context8.t2 = INF;
107824
- return _context8.abrupt("return", _context8.t0.harvest.call(_context8.t0, _context8.t1, 0, _context8.t2));
107996
+ _context9.t1 = _context9.sent;
107997
+ _context9.t2 = INF;
107998
+ return _context9.abrupt("return", _context9.t0.harvest.call(_context9.t0, _context9.t1, 0, _context9.t2));
107825
107999
 
107826
108000
  case 6:
107827
108001
  case "end":
107828
- return _context8.stop();
108002
+ return _context9.stop();
107829
108003
  }
107830
108004
  }
107831
- }, _callee8, this);
108005
+ }, _callee9, this);
107832
108006
  }));
107833
108007
 
107834
108008
  function claimLpRewards() {
@@ -107839,19 +108013,19 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
107839
108013
  }();
107840
108014
 
107841
108015
  _proto2.stake = /*#__PURE__*/function () {
107842
- var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(amount) {
107843
- return runtime_1.wrap(function _callee9$(_context9) {
108016
+ var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(amount) {
108017
+ return runtime_1.wrap(function _callee10$(_context10) {
107844
108018
  while (1) {
107845
- switch (_context9.prev = _context9.next) {
108019
+ switch (_context10.prev = _context10.next) {
107846
108020
  case 0:
107847
- return _context9.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
108021
+ return _context10.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
107848
108022
 
107849
108023
  case 1:
107850
108024
  case "end":
107851
- return _context9.stop();
108025
+ return _context10.stop();
107852
108026
  }
107853
108027
  }
107854
- }, _callee9, this);
108028
+ }, _callee10, this);
107855
108029
  }));
107856
108030
 
107857
108031
  function stake(_x6) {
@@ -107862,19 +108036,19 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
107862
108036
  }();
107863
108037
 
107864
108038
  _proto2.unstake = /*#__PURE__*/function () {
107865
- var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(amount) {
107866
- return runtime_1.wrap(function _callee10$(_context10) {
108039
+ var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
108040
+ return runtime_1.wrap(function _callee11$(_context11) {
107867
108041
  while (1) {
107868
- switch (_context10.prev = _context10.next) {
108042
+ switch (_context11.prev = _context11.next) {
107869
108043
  case 0:
107870
- return _context10.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
108044
+ return _context11.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
107871
108045
 
107872
108046
  case 1:
107873
108047
  case "end":
107874
- return _context10.stop();
108048
+ return _context11.stop();
107875
108049
  }
107876
108050
  }
107877
- }, _callee10, this);
108051
+ }, _callee11, this);
107878
108052
  }));
107879
108053
 
107880
108054
  function unstake(_x7) {
@@ -107885,21 +108059,21 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
107885
108059
  }();
107886
108060
 
107887
108061
  _proto2.faucetDrip = /*#__PURE__*/function () {
107888
- var _faucetDrip = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11() {
108062
+ var _faucetDrip = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12() {
107889
108063
  var faucet;
107890
- return runtime_1.wrap(function _callee11$(_context11) {
108064
+ return runtime_1.wrap(function _callee12$(_context12) {
107891
108065
  while (1) {
107892
- switch (_context11.prev = _context11.next) {
108066
+ switch (_context12.prev = _context12.next) {
107893
108067
  case 0:
107894
108068
  faucet = new Contract(networkAddresses.misc.FAUCET, FaucetABI.abi, this._networkConnection.provider);
107895
- return _context11.abrupt("return", faucet.connect(this._networkConnection.signer).drip());
108069
+ return _context12.abrupt("return", faucet.connect(this._networkConnection.signer).drip());
107896
108070
 
107897
108071
  case 2:
107898
108072
  case "end":
107899
- return _context11.stop();
108073
+ return _context12.stop();
107900
108074
  }
107901
108075
  }
107902
- }, _callee11, this);
108076
+ }, _callee12, this);
107903
108077
  }));
107904
108078
 
107905
108079
  function faucetDrip() {