@aurigami/sdk 1.11.0-beta2 → 1.11.0-beta4

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
@@ -1485,6 +1485,20 @@ function devLog(message) {
1485
1485
  (_console = console).log.apply(_console, ['[DEV LOG]', message].concat(optionalParams));
1486
1486
  }
1487
1487
  }
1488
+ /**
1489
+ * Sorts (in place) an array of Events by blocknumber.
1490
+ * This method mutates the array and returns a reference to the same array.
1491
+ **/
1492
+
1493
+ function sortEvents(events) {
1494
+ return events.sort(function (a, b) {
1495
+ if (a.blockNumber == b.blockNumber) {
1496
+ return a.logIndex - b.logIndex;
1497
+ }
1498
+
1499
+ return a.blockNumber - b.blockNumber;
1500
+ });
1501
+ }
1488
1502
 
1489
1503
  var BlockchainEntityRead = function BlockchainEntityRead(networkConnection) {
1490
1504
  this._networkConnection = networkConnection;
@@ -2593,6 +2607,7 @@ var helpers = {
2593
2607
  getBlocksTimestamp: getBlocksTimestamp,
2594
2608
  getBlockBeforeTimestamp: getBlockBeforeTimestamp,
2595
2609
  devLog: devLog,
2610
+ sortEvents: sortEvents,
2596
2611
  fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
2597
2612
  fetchPriceFromCoingecko: fetchPriceFromCoingecko,
2598
2613
  fetchLPPositions: fetchLPPositions,
@@ -4647,11 +4662,14 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4647
4662
 
4648
4663
  _proto.parseBetMakeEvent = function parseBetMakeEvent(event) {
4649
4664
  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]);
4665
+ var betAmount = event.args.amount; // 0%, 0%, 100%, 2%
4666
+ // big win, win, lose, no impact
4667
+
4668
+ var lostAmount = betAmount.mul([0, 0, 100, 2][event.args.outcome]).div(100);
4669
+ var unlock = betAmount.mul([10, 1, 0, 0][event.args.outcome]);
4652
4670
  return {
4653
4671
  player: event.args.player,
4654
- amount: new TokenAmount(this.plyToken, amount.toString()),
4672
+ lostAmount: new TokenAmount(this.plyToken, lostAmount.toString()),
4655
4673
  unlockedPulpAmount: new TokenAmount(this.pulpToken, unlock.toString()),
4656
4674
  outcome: outcome,
4657
4675
  transactionHash: event.transactionHash,
@@ -4731,11 +4749,13 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4731
4749
 
4732
4750
  case 8:
4733
4751
  events = _context2.sent;
4752
+ // Sort descending by block number
4753
+ sortEvents(events).reverse();
4734
4754
  return _context2.abrupt("return", this.attachTimestamp(events.map(function (event) {
4735
4755
  return _this2.parseBetMakeEvent(event);
4736
4756
  })));
4737
4757
 
4738
- case 10:
4758
+ case 11:
4739
4759
  case "end":
4740
4760
  return _context2.stop();
4741
4761
  }
@@ -5842,5 +5862,5 @@ BigNumber.config({
5842
5862
  DECIMAL_PLACES: 50
5843
5863
  });
5844
5864
 
5845
- 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 };
5865
+ 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, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
5846
5866
  //# sourceMappingURL=sdk.esm.js.map