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