@aurigami/sdk 1.10.0 → 1.11.0-beta

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 IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUni
16
16
  import abis$b from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
17
17
  import abis$c from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
18
18
  import abis$7 from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
19
+ import abis$e from '@aurigami/contracts/artifacts/contracts/plygame/PlyGame.sol/PlyGame.json';
19
20
  import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
20
21
  export { default as MAINNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_mainnet.json';
21
22
  export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
@@ -40,7 +41,8 @@ var index = {
40
41
  EthRepayHelperABI: abis$a,
41
42
  Multicall2ABI: abis$b,
42
43
  PulpABI: abis$c,
43
- AuriInternalLensABI: abis$d
44
+ AuriInternalLensABI: abis$d,
45
+ PlyGameABI: abis$e
44
46
  };
45
47
 
46
48
  var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
@@ -107,7 +109,8 @@ var networkAddresses = {
107
109
  PULP_CONTRACT: /*#__PURE__*/'0x04ac48711bcdc45b4d223fb021e09da73c71095e'.toLowerCase(),
108
110
  PLY_TOKEN_LOCK: /*#__PURE__*/MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
109
111
  REFERRAL: /*#__PURE__*/MAINNET_ADDRESSES.referralDirectory.toLowerCase(),
110
- AURI_INTERNAL_LENS: /*#__PURE__*/MAINNET_ADDRESSES.auriInternalLens.toLowerCase()
112
+ AURI_INTERNAL_LENS: /*#__PURE__*/MAINNET_ADDRESSES.auriInternalLens.toLowerCase(),
113
+ PLYGAME: /*#__PURE__*/'0x60bf668CA101060BD83BD644531a38719586B89f'.toLowerCase()
111
114
  },
112
115
  tokens: {
113
116
  AURORA: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
@@ -1098,10 +1101,17 @@ try {
1098
1101
  });
1099
1102
 
1100
1103
  var symbolRecords = /*#__PURE__*/Object.fromEntries( /*#__PURE__*/networkAddresses.auTokens.map(function (e) {
1101
- return [e.address.toLowerCase(), e.name];
1102
- }).concat( /*#__PURE__*/networkAddresses.auTokens.map(function (e) {
1103
- return [e.underlying.toLowerCase(), e.name.slice(2)];
1104
- })));
1104
+ return [e.address, e.name];
1105
+ }) // AuToken
1106
+ .concat(networkAddresses.auTokens.map(function (e) {
1107
+ return [e.underlying, e.name.slice(2)];
1108
+ })) // underlying token
1109
+ .concat([['0x04ac48711bcdc45b4d223fb021e09da73c71095e', 'PULP']]) // others
1110
+ .map(function (_ref) {
1111
+ var address = _ref[0],
1112
+ name = _ref[1];
1113
+ return [address.toLowerCase(), name];
1114
+ }));
1105
1115
 
1106
1116
  var AURORA_API_BASE_URL = 'https://api.aurorascan.dev/api';
1107
1117
  function getQuery(_x, _x2, _x3) {
@@ -1524,6 +1534,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1524
1534
  _this._auriAirdrop = null;
1525
1535
  _this._referralDirectory = null;
1526
1536
  _this._oracle = null;
1537
+ _this._plygame = null;
1527
1538
  return _this;
1528
1539
  }
1529
1540
 
@@ -1562,7 +1573,6 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1562
1573
  address = (_networkAddresses$auT = networkAddresses.auTokens.find(function (auToken) {
1563
1574
  return auToken.name == 'au' + underlyingName;
1564
1575
  })) == null ? void 0 : _networkAddresses$auT.address;
1565
- console.log(address);
1566
1576
  assert(address !== undefined, "AuToken with underlying " + underlyingName + " not found");
1567
1577
  }
1568
1578
 
@@ -1650,6 +1660,15 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1650
1660
 
1651
1661
  return this._oracle;
1652
1662
  }
1663
+ }, {
1664
+ key: "plygame",
1665
+ get: function get() {
1666
+ if (!this._plygame) {
1667
+ this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$e.abi);
1668
+ }
1669
+
1670
+ return this._plygame;
1671
+ }
1653
1672
  }]);
1654
1673
 
1655
1674
  return AuriEnv;
@@ -4609,6 +4628,347 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4609
4628
  return MiscRead;
4610
4629
  }(BlockchainEntityRead);
4611
4630
 
4631
+ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4632
+ _inheritsLoose(PlyGameRead, _BlockchainEntityRead);
4633
+
4634
+ function PlyGameRead(networkConnection) {
4635
+ var _this;
4636
+
4637
+ _this = _BlockchainEntityRead.call(this, networkConnection) || this;
4638
+ _this.env = new AuriEnv(networkConnection);
4639
+ var plyAddress = networkAddresses.tokens.PLY;
4640
+ var pulpAddress = networkAddresses.tokens.PULP;
4641
+ _this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
4642
+ _this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
4643
+ return _this;
4644
+ }
4645
+
4646
+ var _proto = PlyGameRead.prototype;
4647
+
4648
+ _proto.parseBetMakeEvent = function parseBetMakeEvent(event) {
4649
+ var outcome = ['bigWin', 'win', 'lose', 'noImpact'][event.args.outcome];
4650
+ var amount = event.args.amount;
4651
+ var unlock = amount.mul([10, 1, 0, 0][event.args.outcome]);
4652
+ return {
4653
+ player: event.args.player,
4654
+ amount: new TokenAmount(this.plyToken, amount.toString()),
4655
+ unlockedPulpAmount: new TokenAmount(this.pulpToken, unlock.toString()),
4656
+ outcome: outcome,
4657
+ transactionHash: event.transactionHash,
4658
+ block: event.blockNumber,
4659
+ timestamp: 0
4660
+ };
4661
+ };
4662
+
4663
+ _proto.attachTimestamp = /*#__PURE__*/function () {
4664
+ var _attachTimestamp = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(results) {
4665
+ var blockNumbers, blockstimestamp;
4666
+ return runtime_1.wrap(function _callee$(_context) {
4667
+ while (1) {
4668
+ switch (_context.prev = _context.next) {
4669
+ case 0:
4670
+ blockNumbers = results.map(function (e) {
4671
+ return e.block;
4672
+ });
4673
+ _context.next = 3;
4674
+ return getBlocksTimestamp(this._networkConnection.provider, blockNumbers);
4675
+
4676
+ case 3:
4677
+ blockstimestamp = _context.sent;
4678
+ return _context.abrupt("return", results.map(function (e, i) {
4679
+ return _extends({}, e, {
4680
+ timestamp: blockstimestamp[i]
4681
+ });
4682
+ }));
4683
+
4684
+ case 5:
4685
+ case "end":
4686
+ return _context.stop();
4687
+ }
4688
+ }
4689
+ }, _callee, this);
4690
+ }));
4691
+
4692
+ function attachTimestamp(_x) {
4693
+ return _attachTimestamp.apply(this, arguments);
4694
+ }
4695
+
4696
+ return attachTimestamp;
4697
+ }()
4698
+ /**
4699
+ * Get 100 most recent bets of the market users
4700
+ */
4701
+ ;
4702
+
4703
+ _proto.getUserPlyGameHistory =
4704
+ /*#__PURE__*/
4705
+ function () {
4706
+ var _getUserPlyGameHistory = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(user) {
4707
+ var _this2 = this;
4708
+
4709
+ var block100, filter, events;
4710
+ return runtime_1.wrap(function _callee2$(_context2) {
4711
+ while (1) {
4712
+ switch (_context2.prev = _context2.next) {
4713
+ case 0:
4714
+ _context2.next = 2;
4715
+ return this.env.plygame.getLastBlock(user, 100);
4716
+
4717
+ case 2:
4718
+ block100 = _context2.sent;
4719
+
4720
+ if (!block100.eq(0)) {
4721
+ _context2.next = 5;
4722
+ break;
4723
+ }
4724
+
4725
+ return _context2.abrupt("return", []);
4726
+
4727
+ case 5:
4728
+ filter = this.env.plygame.filters.BetMade(user);
4729
+ _context2.next = 8;
4730
+ return this.env.plygame.queryFilter(filter, block100.toNumber());
4731
+
4732
+ case 8:
4733
+ events = _context2.sent;
4734
+ return _context2.abrupt("return", this.attachTimestamp(events.map(function (event) {
4735
+ return _this2.parseBetMakeEvent(event);
4736
+ })));
4737
+
4738
+ case 10:
4739
+ case "end":
4740
+ return _context2.stop();
4741
+ }
4742
+ }
4743
+ }, _callee2, this);
4744
+ }));
4745
+
4746
+ function getUserPlyGameHistory(_x2) {
4747
+ return _getUserPlyGameHistory.apply(this, arguments);
4748
+ }
4749
+
4750
+ return getUserPlyGameHistory;
4751
+ }()
4752
+ /**
4753
+ * Get current jackpot amount
4754
+ */
4755
+ ;
4756
+
4757
+ _proto.currentJackpotAmount =
4758
+ /*#__PURE__*/
4759
+ function () {
4760
+ var _currentJackpotAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
4761
+ var jackpot;
4762
+ return runtime_1.wrap(function _callee3$(_context3) {
4763
+ while (1) {
4764
+ switch (_context3.prev = _context3.next) {
4765
+ case 0:
4766
+ _context3.next = 2;
4767
+ return this.env.plygame.currentJackpotAmount();
4768
+
4769
+ case 2:
4770
+ jackpot = _context3.sent;
4771
+ return _context3.abrupt("return", new TokenAmount(this.plyToken, jackpot.toString()));
4772
+
4773
+ case 4:
4774
+ case "end":
4775
+ return _context3.stop();
4776
+ }
4777
+ }
4778
+ }, _callee3, this);
4779
+ }));
4780
+
4781
+ function currentJackpotAmount() {
4782
+ return _currentJackpotAmount.apply(this, arguments);
4783
+ }
4784
+
4785
+ return currentJackpotAmount;
4786
+ }();
4787
+
4788
+ _proto.nextJackpotRevealTime = /*#__PURE__*/function () {
4789
+ var _nextJackpotRevealTime = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
4790
+ return runtime_1.wrap(function _callee4$(_context4) {
4791
+ while (1) {
4792
+ switch (_context4.prev = _context4.next) {
4793
+ case 0:
4794
+ return _context4.abrupt("return", 0);
4795
+
4796
+ case 1:
4797
+ case "end":
4798
+ return _context4.stop();
4799
+ }
4800
+ }
4801
+ }, _callee4);
4802
+ }));
4803
+
4804
+ function nextJackpotRevealTime() {
4805
+ return _nextJackpotRevealTime.apply(this, arguments);
4806
+ }
4807
+
4808
+ return nextJackpotRevealTime;
4809
+ }();
4810
+
4811
+ _proto.earlyUnlockedPulpAmount = /*#__PURE__*/function () {
4812
+ var _earlyUnlockedPulpAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(user) {
4813
+ var earlyUnlockedPulpAmount;
4814
+ return runtime_1.wrap(function _callee5$(_context5) {
4815
+ while (1) {
4816
+ switch (_context5.prev = _context5.next) {
4817
+ case 0:
4818
+ _context5.next = 2;
4819
+ return this.env.plygame.totalPlyUnlockedEarly(user);
4820
+
4821
+ case 2:
4822
+ earlyUnlockedPulpAmount = _context5.sent;
4823
+ return _context5.abrupt("return", new TokenAmount(this.pulpToken, earlyUnlockedPulpAmount.toString()));
4824
+
4825
+ case 4:
4826
+ case "end":
4827
+ return _context5.stop();
4828
+ }
4829
+ }
4830
+ }, _callee5, this);
4831
+ }));
4832
+
4833
+ function earlyUnlockedPulpAmount(_x3) {
4834
+ return _earlyUnlockedPulpAmount.apply(this, arguments);
4835
+ }
4836
+
4837
+ return earlyUnlockedPulpAmount;
4838
+ }();
4839
+
4840
+ _proto.getPlyGameResultsInTransaction = /*#__PURE__*/function () {
4841
+ var _getPlyGameResultsInTransaction = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(txHash) {
4842
+ var _this3 = this;
4843
+
4844
+ var tx, filter, betMadeEvents;
4845
+ return runtime_1.wrap(function _callee6$(_context6) {
4846
+ while (1) {
4847
+ switch (_context6.prev = _context6.next) {
4848
+ case 0:
4849
+ _context6.next = 2;
4850
+ return this._networkConnection.provider.getTransactionReceipt(txHash);
4851
+
4852
+ case 2:
4853
+ tx = _context6.sent;
4854
+ filter = this.env.plygame.filters.BetMade();
4855
+ betMadeEvents = tx.logs.filter(function (log) {
4856
+ return isSameAddress(log.topics[0], filter.topics[0]);
4857
+ }).map(function (log) {
4858
+ return _extends({}, _this3.env.plygame["interface"].parseLog(log), {
4859
+ blockNumber: tx.blockNumber,
4860
+ transactionHash: txHash
4861
+ });
4862
+ });
4863
+ return _context6.abrupt("return", this.attachTimestamp(betMadeEvents.map(function (e) {
4864
+ return _this3.parseBetMakeEvent(e);
4865
+ })));
4866
+
4867
+ case 6:
4868
+ case "end":
4869
+ return _context6.stop();
4870
+ }
4871
+ }
4872
+ }, _callee6, this);
4873
+ }));
4874
+
4875
+ function getPlyGameResultsInTransaction(_x4) {
4876
+ return _getPlyGameResultsInTransaction.apply(this, arguments);
4877
+ }
4878
+
4879
+ return getPlyGameResultsInTransaction;
4880
+ }();
4881
+
4882
+ return PlyGameRead;
4883
+ }(BlockchainEntityRead);
4884
+ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
4885
+ _inheritsLoose(PlyGameReadWrite, _PlyGameRead);
4886
+
4887
+ function PlyGameReadWrite() {
4888
+ return _PlyGameRead.apply(this, arguments) || this;
4889
+ }
4890
+
4891
+ var _proto2 = PlyGameReadWrite.prototype;
4892
+
4893
+ /**
4894
+ * makes "times" independent bets, but consecutively, of the same amount
4895
+ */
4896
+ _proto2.makeBetMultiple =
4897
+ /*#__PURE__*/
4898
+ function () {
4899
+ var _makeBetMultiple = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(amount, times) {
4900
+ return runtime_1.wrap(function _callee7$(_context7) {
4901
+ while (1) {
4902
+ switch (_context7.prev = _context7.next) {
4903
+ case 0:
4904
+ return _context7.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetMultiple(amount.rawAmount(), times));
4905
+
4906
+ case 1:
4907
+ case "end":
4908
+ return _context7.stop();
4909
+ }
4910
+ }
4911
+ }, _callee7, this);
4912
+ }));
4913
+
4914
+ function makeBetMultiple(_x5, _x6) {
4915
+ return _makeBetMultiple.apply(this, arguments);
4916
+ }
4917
+
4918
+ return makeBetMultiple;
4919
+ }()
4920
+ /**
4921
+ * Make a single bet
4922
+ */
4923
+ ;
4924
+
4925
+ _proto2.makeBetOnce =
4926
+ /*#__PURE__*/
4927
+ function () {
4928
+ var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(amount) {
4929
+ return runtime_1.wrap(function _callee8$(_context8) {
4930
+ while (1) {
4931
+ switch (_context8.prev = _context8.next) {
4932
+ case 0:
4933
+ return _context8.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetOnce(amount.rawAmount()));
4934
+
4935
+ case 1:
4936
+ case "end":
4937
+ return _context8.stop();
4938
+ }
4939
+ }
4940
+ }, _callee8, this);
4941
+ }));
4942
+
4943
+ function makeBetOnce(_x7) {
4944
+ return _makeBetOnce.apply(this, arguments);
4945
+ }
4946
+
4947
+ return makeBetOnce;
4948
+ }();
4949
+
4950
+ return PlyGameReadWrite;
4951
+ }(PlyGameRead);
4952
+ var PlyGame = /*#__PURE__*/function (_BlockchainEntity) {
4953
+ _inheritsLoose(PlyGame, _BlockchainEntity);
4954
+
4955
+ function PlyGame() {
4956
+ return _BlockchainEntity.call(this) || this;
4957
+ }
4958
+
4959
+ var _proto3 = PlyGame.prototype;
4960
+
4961
+ _proto3.read = function read(networkConnection) {
4962
+ return new PlyGameRead(networkConnection);
4963
+ };
4964
+
4965
+ _proto3.readWrite = function readWrite(networkConnection) {
4966
+ return new PlyGameReadWrite(networkConnection);
4967
+ };
4968
+
4969
+ return PlyGame;
4970
+ }(BlockchainEntity);
4971
+
4612
4972
  var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4613
4973
  _inheritsLoose(ReferralRead, _BlockchainEntityRead);
4614
4974
 
@@ -5416,5 +5776,5 @@ BigNumber.config({
5416
5776
  DECIMAL_PLACES: 50
5417
5777
  });
5418
5778
 
5419
- 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, REFERRAL_CAMPAIGNS, 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, referralRewardDummy1, referralRewardDummy2, symbolRecords, validateAndParseAddress, valuateToken };
5779
+ 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, PlyGame, PlyGameRead, PlyGameReadWrite, REFERRAL_CAMPAIGNS, 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, referralRewardDummy1, referralRewardDummy2, symbolRecords, validateAndParseAddress, valuateToken };
5420
5780
  //# sourceMappingURL=sdk.esm.js.map