@aurigami/sdk 1.3.4 → 1.3.5

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
@@ -2,6 +2,7 @@ import BigNumber from 'bignumber.js';
2
2
  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
+ import EIP20InterfaceABI from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
5
6
  import AuErc20ABI from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
6
7
  import AuETHABI from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
7
8
  import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
@@ -12,6 +13,8 @@ import TokenLockABI from '@aurigami/contracts/artifacts/contracts/TokenLock.sol/
12
13
  import AuriFairLaunchABI from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
13
14
  import FaucetABI from '@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json';
14
15
  import AuTokenABI from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
16
+ import AuriAirdropABI from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json';
17
+ import assert from 'assert';
15
18
 
16
19
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17
20
  try {
@@ -960,7 +963,8 @@ var networkAddresses = {
960
963
  AURIFAIRLAUNCH: /*#__PURE__*/"0x9F9ceE911509abC6Af899c12ED625B0A6580D6e6".toLowerCase(),
961
964
  AURILENS: /*#__PURE__*/'0xC41a5C1625d492436600789469c1CE2eA20CEA6B'.toLowerCase(),
962
965
  TOKENLOCK: /*#__PURE__*/'0xDACC02a4Ff16Ea3c1515AdbfdCeb7B1F448B79c8'.toLowerCase(),
963
- ETHREPAYHELPER: /*#__PURE__*/"0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6".toLowerCase()
966
+ ETHREPAYHELPER: /*#__PURE__*/"0xa308A5003fA1A25BFdD9418FcEE51d48Dbe441e6".toLowerCase(),
967
+ AURI_AIRDROP: /*#__PURE__*/"0x6C42aA5b128B62D6CCf357726D7d13F3888335EC".toLowerCase()
964
968
  },
965
969
  tokens: {
966
970
  AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
@@ -1001,7 +1005,8 @@ var decimalRecords = {
1001
1005
  '0x8888682e24dd4df7b7ff2b91fccb575737e433bf': 8,
1002
1006
  '0xae4fac24dcdae0132c6d04f564dcf059616e9423': 8,
1003
1007
  '0xce4166363e3a584dac84a47bcd3414b43efcdd1c': 8,
1004
- '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8
1008
+ '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
1009
+ '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24
1005
1010
  };
1006
1011
 
1007
1012
  function formatObject(object) {
@@ -1026,6 +1031,40 @@ function validateAndParseAddress(address) {
1026
1031
  function getDecimal(address) {
1027
1032
  return decimalRecords[address.toLowerCase()];
1028
1033
  }
1034
+ function getDecimalsViaContract(_x, _x2) {
1035
+ return _getDecimalsViaContract.apply(this, arguments);
1036
+ }
1037
+
1038
+ function _getDecimalsViaContract() {
1039
+ _getDecimalsViaContract = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(address, provider) {
1040
+ var result, token;
1041
+ return runtime_1.wrap(function _callee$(_context) {
1042
+ while (1) {
1043
+ switch (_context.prev = _context.next) {
1044
+ case 0:
1045
+ result = getDecimal(address);
1046
+
1047
+ if (!result) {
1048
+ _context.next = 3;
1049
+ break;
1050
+ }
1051
+
1052
+ return _context.abrupt("return", result);
1053
+
1054
+ case 3:
1055
+ token = new Contract(address, EIP20InterfaceABI.abi, provider);
1056
+ return _context.abrupt("return", token.decimals());
1057
+
1058
+ case 5:
1059
+ case "end":
1060
+ return _context.stop();
1061
+ }
1062
+ }
1063
+ }, _callee);
1064
+ }));
1065
+ return _getDecimalsViaContract.apply(this, arguments);
1066
+ }
1067
+
1029
1068
  function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1030
1069
  if (totalStakeValue.lte(0)) {
1031
1070
  return new BigNumber('999999999');
@@ -1033,71 +1072,71 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1033
1072
 
1034
1073
  return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
1035
1074
  }
1036
- function getBlockTimestamp(_x, _x2) {
1075
+ function getBlockTimestamp(_x3, _x4) {
1037
1076
  return _getBlockTimestamp.apply(this, arguments);
1038
1077
  }
1039
1078
 
1040
1079
  function _getBlockTimestamp() {
1041
- _getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider, blockNumber) {
1080
+ _getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(provider, blockNumber) {
1042
1081
  var block;
1043
- return runtime_1.wrap(function _callee$(_context) {
1082
+ return runtime_1.wrap(function _callee2$(_context2) {
1044
1083
  while (1) {
1045
- switch (_context.prev = _context.next) {
1084
+ switch (_context2.prev = _context2.next) {
1046
1085
  case 0:
1047
- _context.next = 2;
1086
+ _context2.next = 2;
1048
1087
  return provider.getBlock(blockNumber);
1049
1088
 
1050
1089
  case 2:
1051
- block = _context.sent;
1052
- return _context.abrupt("return", block.timestamp);
1090
+ block = _context2.sent;
1091
+ return _context2.abrupt("return", block.timestamp);
1053
1092
 
1054
1093
  case 4:
1055
1094
  case "end":
1056
- return _context.stop();
1095
+ return _context2.stop();
1057
1096
  }
1058
1097
  }
1059
- }, _callee);
1098
+ }, _callee2);
1060
1099
  }));
1061
1100
  return _getBlockTimestamp.apply(this, arguments);
1062
1101
  }
1063
1102
 
1064
- function getBlockBeforeTimestamp(_x3, _x4, _x5) {
1103
+ function getBlockBeforeTimestamp(_x5, _x6, _x7) {
1065
1104
  return _getBlockBeforeTimestamp.apply(this, arguments);
1066
1105
  }
1067
1106
 
1068
1107
  function _getBlockBeforeTimestamp() {
1069
- _getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(provider, timestamp, startBlock) {
1108
+ _getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(provider, timestamp, startBlock) {
1070
1109
  var blockThreshold, K, leftBlock, rightBlock, size, promises, i, blockTimestamps, nextLeftBlock, _i, _i2;
1071
1110
 
1072
- return runtime_1.wrap(function _callee2$(_context2) {
1111
+ return runtime_1.wrap(function _callee3$(_context3) {
1073
1112
  while (1) {
1074
- switch (_context2.prev = _context2.next) {
1113
+ switch (_context3.prev = _context3.next) {
1075
1114
  case 0:
1076
1115
  blockThreshold = 50 * 10;
1077
1116
  K = 8;
1078
1117
  leftBlock = startBlock || 1;
1079
- _context2.next = 5;
1118
+ _context3.next = 5;
1080
1119
  return provider.getBlockNumber();
1081
1120
 
1082
1121
  case 5:
1083
- rightBlock = _context2.sent;
1084
- _context2.next = 8;
1122
+ rightBlock = _context3.sent;
1123
+ _context3.next = 8;
1085
1124
  return getBlockTimestamp(provider, rightBlock);
1086
1125
 
1087
1126
  case 8:
1088
- _context2.t0 = _context2.sent;
1089
- _context2.t1 = timestamp;
1127
+ _context3.t0 = _context3.sent;
1128
+ _context3.t1 = timestamp;
1090
1129
 
1091
- if (!(_context2.t0 < _context2.t1)) {
1092
- _context2.next = 12;
1130
+ if (!(_context3.t0 < _context3.t1)) {
1131
+ _context3.next = 12;
1093
1132
  break;
1094
1133
  }
1095
1134
 
1096
- return _context2.abrupt("return", rightBlock);
1135
+ return _context3.abrupt("return", rightBlock);
1097
1136
 
1098
1137
  case 12:
1099
1138
  if (!(rightBlock - leftBlock >= blockThreshold)) {
1100
- _context2.next = 25;
1139
+ _context3.next = 25;
1101
1140
  break;
1102
1141
  }
1103
1142
 
@@ -1108,11 +1147,11 @@ function _getBlockBeforeTimestamp() {
1108
1147
  promises.push(getBlockTimestamp(provider, leftBlock + i * size));
1109
1148
  }
1110
1149
 
1111
- _context2.next = 18;
1150
+ _context3.next = 18;
1112
1151
  return Promise.all(promises);
1113
1152
 
1114
1153
  case 18:
1115
- blockTimestamps = _context2.sent;
1154
+ blockTimestamps = _context3.sent;
1116
1155
  nextLeftBlock = leftBlock;
1117
1156
 
1118
1157
  for (_i = 1; _i < K; _i++) {
@@ -1128,18 +1167,18 @@ function _getBlockBeforeTimestamp() {
1128
1167
  }
1129
1168
 
1130
1169
  leftBlock = nextLeftBlock;
1131
- _context2.next = 12;
1170
+ _context3.next = 12;
1132
1171
  break;
1133
1172
 
1134
1173
  case 25:
1135
- return _context2.abrupt("return", leftBlock);
1174
+ return _context3.abrupt("return", leftBlock);
1136
1175
 
1137
1176
  case 26:
1138
1177
  case "end":
1139
- return _context2.stop();
1178
+ return _context3.stop();
1140
1179
  }
1141
1180
  }
1142
- }, _callee2);
1181
+ }, _callee3);
1143
1182
  }));
1144
1183
  return _getBlockBeforeTimestamp.apply(this, arguments);
1145
1184
  }
@@ -106618,6 +106657,7 @@ var AirdropRead = /*#__PURE__*/function (_BlockchainEntityRead2) {
106618
106657
 
106619
106658
  _this2 = _BlockchainEntityRead2.call(this, networkConnection) || this;
106620
106659
  _this2.keepTrackers = [];
106660
+ _this2._airDrop = new Contract(networkAddresses.misc.AURI_AIRDROP, AuriAirdropABI.abi, networkConnection.provider);
106621
106661
  _this2._whitelistedAddresses = new Set(AIRDROP_WHITELIST_ADDRESSES.map(function (e) {
106622
106662
  return e.toLocaleLowerCase();
106623
106663
  }));
@@ -106723,8 +106763,106 @@ var AirdropRead = /*#__PURE__*/function (_BlockchainEntityRead2) {
106723
106763
  return hasCompletedChallenge;
106724
106764
  }();
106725
106765
 
106766
+ _proto2.getRedeemableReward = /*#__PURE__*/function () {
106767
+ var _getRedeemableReward = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(campaign, token, user) {
106768
+ var tokenInstance, rewards;
106769
+ return runtime_1.wrap(function _callee5$(_context5) {
106770
+ while (1) {
106771
+ switch (_context5.prev = _context5.next) {
106772
+ case 0:
106773
+ tokenInstance = new Token(token, getDecimal(token));
106774
+ _context5.next = 3;
106775
+ return this._airDrop.getRedeemableReward(utils.formatBytes32String(campaign), token, user);
106776
+
106777
+ case 3:
106778
+ rewards = _context5.sent;
106779
+ return _context5.abrupt("return", new TokenAmount(tokenInstance, rewards.toString()));
106780
+
106781
+ case 5:
106782
+ case "end":
106783
+ return _context5.stop();
106784
+ }
106785
+ }
106786
+ }, _callee5, this);
106787
+ }));
106788
+
106789
+ function getRedeemableReward(_x5, _x6, _x7) {
106790
+ return _getRedeemableReward.apply(this, arguments);
106791
+ }
106792
+
106793
+ return getRedeemableReward;
106794
+ }();
106795
+
106726
106796
  return AirdropRead;
106727
106797
  }(BlockchainEntityRead);
106798
+ var AirdropReadWrite = /*#__PURE__*/function (_AirdropRead) {
106799
+ _inheritsLoose(AirdropReadWrite, _AirdropRead);
106800
+
106801
+ function AirdropReadWrite() {
106802
+ return _AirdropRead.apply(this, arguments) || this;
106803
+ }
106804
+
106805
+ var _proto3 = AirdropReadWrite.prototype;
106806
+
106807
+ _proto3.redeemMultiple = /*#__PURE__*/function () {
106808
+ var _redeemMultiple = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(campaigns, tokens) {
106809
+ return runtime_1.wrap(function _callee6$(_context6) {
106810
+ while (1) {
106811
+ switch (_context6.prev = _context6.next) {
106812
+ case 0:
106813
+ assert(campaigns.length == tokens.length, "campaigns and tokens must have the same length");
106814
+ _context6.t0 = this._airDrop.connect(this._networkConnection.signer);
106815
+ _context6.t1 = campaigns.map(function (e) {
106816
+ return utils.formatBytes32String(e);
106817
+ });
106818
+ _context6.t2 = tokens;
106819
+ _context6.next = 6;
106820
+ return this._networkConnection.signer.getAddress();
106821
+
106822
+ case 6:
106823
+ _context6.t3 = _context6.sent;
106824
+ return _context6.abrupt("return", _context6.t0.redeem.call(_context6.t0, _context6.t1, _context6.t2, _context6.t3));
106825
+
106826
+ case 8:
106827
+ case "end":
106828
+ return _context6.stop();
106829
+ }
106830
+ }
106831
+ }, _callee6, this);
106832
+ }));
106833
+
106834
+ function redeemMultiple(_x8, _x9) {
106835
+ return _redeemMultiple.apply(this, arguments);
106836
+ }
106837
+
106838
+ return redeemMultiple;
106839
+ }();
106840
+
106841
+ _proto3.redeemSingle = /*#__PURE__*/function () {
106842
+ var _redeemSingle = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(campaign, token) {
106843
+ return runtime_1.wrap(function _callee7$(_context7) {
106844
+ while (1) {
106845
+ switch (_context7.prev = _context7.next) {
106846
+ case 0:
106847
+ return _context7.abrupt("return", this.redeemMultiple([campaign], [token]));
106848
+
106849
+ case 1:
106850
+ case "end":
106851
+ return _context7.stop();
106852
+ }
106853
+ }
106854
+ }, _callee7, this);
106855
+ }));
106856
+
106857
+ function redeemSingle(_x10, _x11) {
106858
+ return _redeemSingle.apply(this, arguments);
106859
+ }
106860
+
106861
+ return redeemSingle;
106862
+ }();
106863
+
106864
+ return AirdropReadWrite;
106865
+ }(AirdropRead);
106728
106866
  var Airdrop = /*#__PURE__*/function (_BlockchainEntity) {
106729
106867
  _inheritsLoose(Airdrop, _BlockchainEntity);
106730
106868
 
@@ -106732,12 +106870,16 @@ var Airdrop = /*#__PURE__*/function (_BlockchainEntity) {
106732
106870
  return _BlockchainEntity.call(this) || this;
106733
106871
  }
106734
106872
 
106735
- var _proto3 = Airdrop.prototype;
106873
+ var _proto4 = Airdrop.prototype;
106736
106874
 
106737
- _proto3.read = function read(networkConnection) {
106875
+ _proto4.read = function read(networkConnection) {
106738
106876
  return new AirdropRead(networkConnection);
106739
106877
  };
106740
106878
 
106879
+ _proto4.readWrite = function readWrite(networkConnection) {
106880
+ return new AirdropReadWrite(networkConnection);
106881
+ };
106882
+
106741
106883
  return Airdrop;
106742
106884
  }(BlockchainEntity);
106743
106885
 
@@ -106746,5 +106888,5 @@ BigNumber.config({
106746
106888
  DECIMAL_PLACES: 50
106747
106889
  });
106748
106890
 
106749
- export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, AURORA_CHAINID, AURPLYToken, Airdrop, AirdropRead, AurPlyPid, BORROW_LIMIT_BUFFER, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, 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 };
106891
+ export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, AURORA_CHAINID, AURPLYToken, Airdrop, AirdropRead, AirdropReadWrite, AurPlyPid, BORROW_LIMIT_BUFFER, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, 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, getDecimalsViaContract, isSameAddress, networkAddresses, validateAndParseAddress };
106750
106892
  //# sourceMappingURL=sdk.esm.js.map