@aurigami/sdk 1.5.0 → 1.5.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
@@ -3384,6 +3384,7 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
3384
3384
  return MoneyMarket;
3385
3385
  }(BlockchainEntity);
3386
3386
 
3387
+ var LOCKING_DENOMINATOR = /*#__PURE__*/BigNumber$1.from(10000);
3387
3388
  var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3388
3389
  _inheritsLoose(PapermillRead, _BlockchainEntityRead);
3389
3390
 
@@ -3494,40 +3495,42 @@ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3494
3495
  return getUnclaimedPlyReward;
3495
3496
  }();
3496
3497
 
3498
+ _proto.getWeek = function getWeek(timestamp) {
3499
+ return BigNumber$1.from(timestamp - REWARD_CLAIM_START).div(ONE_WEEK).toNumber();
3500
+ };
3501
+
3497
3502
  _proto.getLockingDetails = /*#__PURE__*/function () {
3498
3503
  var _getLockingDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(userAddress) {
3499
- var currentTime, currentWeek, denominator, promises, values, percentLockCurrentWeek, percentLockNextWeek, totalRewards, _yield$this$_pulp$cal, pulpAmountCurrentWeek, plyAmountCurrentWeek, plyAmountNextWeek, pulpAmountNextWeek, currentUnlockPortion, nextUnlockPortion;
3504
+ var currentWeek, promises, values, percentLockCurrentWeek, percentLockNextWeek, totalRewards, _yield$this$_pulp$cal, pulpAmountCurrentWeek, plyAmountCurrentWeek, plyAmountNextWeek, pulpAmountNextWeek, currentUnlockPortion, nextUnlockPortion;
3500
3505
 
3501
3506
  return runtime_1.wrap(function _callee4$(_context4) {
3502
3507
  while (1) {
3503
3508
  switch (_context4.prev = _context4.next) {
3504
3509
  case 0:
3505
- currentTime = getCurrentTimestamp();
3506
- currentWeek = BigNumber$1.from(currentTime - REWARD_CLAIM_START).div(ONE_WEEK).toNumber();
3507
- denominator = BigNumber$1.from(10000);
3510
+ currentWeek = this.getWeek(getCurrentTimestamp());
3508
3511
  promises = [];
3509
3512
  promises.push(this._auriLens.getPercentLock(this._pulp.address, userAddress, currentWeek));
3510
3513
  promises.push(this._auriLens.getPercentLock(this._pulp.address, userAddress, currentWeek + 1));
3511
3514
  promises.push(this.getUnclaimedPlyReward(userAddress));
3512
- _context4.next = 9;
3515
+ _context4.next = 7;
3513
3516
  return Promise.all(promises);
3514
3517
 
3515
- case 9:
3518
+ case 7:
3516
3519
  values = _context4.sent;
3517
3520
  percentLockCurrentWeek = BigNumber$1.from(values[0]);
3518
3521
  percentLockNextWeek = BigNumber$1.from(values[1]);
3519
3522
  totalRewards = values[2];
3520
- _context4.next = 15;
3523
+ _context4.next = 13;
3521
3524
  return this._pulp.calcLockAmount(userAddress, totalRewards.rawAmount());
3522
3525
 
3523
- case 15:
3526
+ case 13:
3524
3527
  _yield$this$_pulp$cal = _context4.sent;
3525
3528
  pulpAmountCurrentWeek = _yield$this$_pulp$cal[0];
3526
3529
  plyAmountCurrentWeek = _yield$this$_pulp$cal[1];
3527
- plyAmountNextWeek = percentLockNextWeek.mul(totalRewards.rawAmount()).div(denominator);
3530
+ plyAmountNextWeek = percentLockNextWeek.mul(totalRewards.rawAmount()).div(LOCKING_DENOMINATOR);
3528
3531
  pulpAmountNextWeek = BigNumber$1.from(totalRewards.rawAmount()).sub(plyAmountNextWeek);
3529
- currentUnlockPortion = denominator.sub(percentLockCurrentWeek).toString();
3530
- nextUnlockPortion = denominator.sub(percentLockNextWeek).toString();
3532
+ currentUnlockPortion = LOCKING_DENOMINATOR.sub(percentLockCurrentWeek).toString();
3533
+ nextUnlockPortion = LOCKING_DENOMINATOR.sub(percentLockNextWeek).toString();
3531
3534
  return _context4.abrupt("return", {
3532
3535
  vestingStart: REWARD_CLAIM_START,
3533
3536
  currentUnlockPortion: new BigNumber(currentUnlockPortion).dividedBy(100).toNumber(),
@@ -3539,7 +3542,7 @@ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3539
3542
  nextPulp: new TokenAmount(this.pulpToken, pulpAmountNextWeek.toString())
3540
3543
  });
3541
3544
 
3542
- case 23:
3545
+ case 21:
3543
3546
  case "end":
3544
3547
  return _context4.stop();
3545
3548
  }
@@ -3583,6 +3586,36 @@ var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3583
3586
  return getTimestampToUnlock;
3584
3587
  }();
3585
3588
 
3589
+ _proto.getUnlockPortionAt = /*#__PURE__*/function () {
3590
+ var _getUnlockPortionAt = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(userAddress, timestamp) {
3591
+ var lockPortion, unlockPortion;
3592
+ return runtime_1.wrap(function _callee6$(_context6) {
3593
+ while (1) {
3594
+ switch (_context6.prev = _context6.next) {
3595
+ case 0:
3596
+ _context6.next = 2;
3597
+ return this._auriLens.getPercentLock(this._pulp.address, userAddress, this.getWeek(timestamp));
3598
+
3599
+ case 2:
3600
+ lockPortion = _context6.sent;
3601
+ unlockPortion = LOCKING_DENOMINATOR.sub(lockPortion);
3602
+ return _context6.abrupt("return", unlockPortion.toNumber() / 100);
3603
+
3604
+ case 5:
3605
+ case "end":
3606
+ return _context6.stop();
3607
+ }
3608
+ }
3609
+ }, _callee6, this);
3610
+ }));
3611
+
3612
+ function getUnlockPortionAt(_x7, _x8) {
3613
+ return _getUnlockPortionAt.apply(this, arguments);
3614
+ }
3615
+
3616
+ return getUnlockPortionAt;
3617
+ }();
3618
+
3586
3619
  return PapermillRead;
3587
3620
  }(BlockchainEntityRead);
3588
3621
  var PapermillReadWrite = /*#__PURE__*/function (_PapermillRead) {
@@ -3595,22 +3628,22 @@ var PapermillReadWrite = /*#__PURE__*/function (_PapermillRead) {
3595
3628
  var _proto2 = PapermillReadWrite.prototype;
3596
3629
 
3597
3630
  _proto2.redeem = /*#__PURE__*/function () {
3598
- var _redeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(recipient, amount) {
3599
- return runtime_1.wrap(function _callee6$(_context6) {
3631
+ var _redeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(recipient, amount) {
3632
+ return runtime_1.wrap(function _callee7$(_context7) {
3600
3633
  while (1) {
3601
- switch (_context6.prev = _context6.next) {
3634
+ switch (_context7.prev = _context7.next) {
3602
3635
  case 0:
3603
- return _context6.abrupt("return", this._pulp.connect(this._networkConnection.signer).redeem(recipient, amount.rawAmount()));
3636
+ return _context7.abrupt("return", this._pulp.connect(this._networkConnection.signer).redeem(recipient, amount.rawAmount()));
3604
3637
 
3605
3638
  case 1:
3606
3639
  case "end":
3607
- return _context6.stop();
3640
+ return _context7.stop();
3608
3641
  }
3609
3642
  }
3610
- }, _callee6, this);
3643
+ }, _callee7, this);
3611
3644
  }));
3612
3645
 
3613
- function redeem(_x7, _x8) {
3646
+ function redeem(_x9, _x10) {
3614
3647
  return _redeem.apply(this, arguments);
3615
3648
  }
3616
3649
 
@@ -3618,28 +3651,28 @@ var PapermillReadWrite = /*#__PURE__*/function (_PapermillRead) {
3618
3651
  }();
3619
3652
 
3620
3653
  _proto2.selfRedeem = /*#__PURE__*/function () {
3621
- var _selfRedeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(amount) {
3654
+ var _selfRedeem = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(amount) {
3622
3655
  var msgSender;
3623
- return runtime_1.wrap(function _callee7$(_context7) {
3656
+ return runtime_1.wrap(function _callee8$(_context8) {
3624
3657
  while (1) {
3625
- switch (_context7.prev = _context7.next) {
3658
+ switch (_context8.prev = _context8.next) {
3626
3659
  case 0:
3627
- _context7.next = 2;
3660
+ _context8.next = 2;
3628
3661
  return this._networkConnection.signer.getAddress();
3629
3662
 
3630
3663
  case 2:
3631
- msgSender = _context7.sent;
3632
- return _context7.abrupt("return", this.redeem(msgSender, amount));
3664
+ msgSender = _context8.sent;
3665
+ return _context8.abrupt("return", this.redeem(msgSender, amount));
3633
3666
 
3634
3667
  case 4:
3635
3668
  case "end":
3636
- return _context7.stop();
3669
+ return _context8.stop();
3637
3670
  }
3638
3671
  }
3639
- }, _callee7, this);
3672
+ }, _callee8, this);
3640
3673
  }));
3641
3674
 
3642
- function selfRedeem(_x9) {
3675
+ function selfRedeem(_x11) {
3643
3676
  return _selfRedeem.apply(this, arguments);
3644
3677
  }
3645
3678
 
@@ -3826,7 +3859,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3826
3859
 
3827
3860
  _proto.getPLYWNEARPoolDetails = /*#__PURE__*/function () {
3828
3861
  var _getPLYWNEARPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
3829
- var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, promises, _i, rewardTokenAddress, rewardToken, rewardPerSecond, rewardPerSecondValuation, totalStakeValuation;
3862
+ var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, totalStakeValuation, promises, _i, rewardTokenAddress, rewardToken, rewardPerSecond, APYs;
3830
3863
 
3831
3864
  return runtime_1.wrap(function _callee2$(_context2) {
3832
3865
  while (1) {
@@ -3840,6 +3873,11 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3840
3873
 
3841
3874
  case 2:
3842
3875
  stakedLiquidityAmount = new TokenAmount(PLYWNEARToken, stakedLiquidity.toString());
3876
+ _context2.next = 5;
3877
+ return fetchValuation(stakedLiquidityAmount, this._networkConnection.provider);
3878
+
3879
+ case 5:
3880
+ totalStakeValuation = _context2.sent;
3843
3881
  promises = [];
3844
3882
 
3845
3883
  for (_i = 0; _i < rewardPerSeconds.length; _i++) {
@@ -3849,18 +3887,20 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3849
3887
  promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
3850
3888
  }
3851
3889
 
3852
- _context2.next = 7;
3890
+ APYs = [];
3891
+ _context2.next = 11;
3853
3892
  return Promise.all(promises);
3854
3893
 
3855
- case 7:
3856
- rewardPerSecondValuation = _context2.sent.reduce(function (p, v) {
3857
- return p.plus(v);
3858
- }, new BigNumber(0));
3859
- _context2.next = 10;
3860
- return fetchValuation(stakedLiquidityAmount, this._networkConnection.provider);
3894
+ case 11:
3895
+ _context2.sent.forEach(function (rewardPerSecondValuation, i) {
3896
+ var rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
3897
+ var apy = calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION);
3898
+ APYs.push({
3899
+ address: rewardTokenAddress,
3900
+ apy: apy
3901
+ });
3902
+ });
3861
3903
 
3862
- case 10:
3863
- totalStakeValuation = _context2.sent;
3864
3904
  return _context2.abrupt("return", {
3865
3905
  totalStakedLiquidity: {
3866
3906
  tokenAmount: stakedLiquidityAmount,
@@ -3869,10 +3909,10 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3869
3909
  amount: totalStakeValuation.toFixed(DECIMAL_PRECISION)
3870
3910
  }
3871
3911
  },
3872
- apy: calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION)
3912
+ APYs: APYs
3873
3913
  });
3874
3914
 
3875
- case 12:
3915
+ case 13:
3876
3916
  case "end":
3877
3917
  return _context2.stop();
3878
3918
  }