@aurigami/sdk 1.7.8-dummy → 1.8.0

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.
@@ -37,3 +37,9 @@ export declare const BORROW_NEAR_REWARDS_PER_WEEK: {
37
37
  export declare const HARDCODE_PRICE_TOKENS: {
38
38
  [k: string]: string;
39
39
  };
40
+ export declare const REFERRAL_CAMPAIGNS: {
41
+ [k: string]: {
42
+ start: number;
43
+ end: number;
44
+ };
45
+ };
@@ -37,7 +37,7 @@ export declare class ReferralRead extends BlockchainEntityRead {
37
37
  /**
38
38
  * Top 50 reward earners from the last round, sorted by token amount
39
39
  */
40
- leaderboard(): Promise<ReferralReward[]>;
40
+ leaderboard(campaign: string): Promise<ReferralReward[]>;
41
41
  }
42
42
  export declare class ReferralReadWrite extends ReferralRead {
43
43
  /**
@@ -7,5 +7,6 @@ export declare class TokenAmount {
7
7
  formattedAmount(): string;
8
8
  formattedAmountWithSymbol(): string;
9
9
  rawAmount(): string;
10
+ compare(other: TokenAmount): number;
10
11
  static fromAddressAndAmount(tokenAddress: Address, amount: string, isRaw?: boolean): TokenAmount;
11
12
  }
@@ -160,6 +160,13 @@ Object.entries({
160
160
  var BORROW_NEAR_REWARDS_PER_WEEK = {// currently 0 for all markets
161
161
  };
162
162
  var HARDCODE_PRICE_TOKENS = /*#__PURE__*/Object.fromEntries([[/*#__PURE__*/networkAddresses.tokens.USN.toLowerCase(), '1']]);
163
+ var REFERRAL_CAMPAIGNS = /*#__PURE__*/Object.fromEntries([['referral-1805', {
164
+ start: 1652882400,
165
+ end: 1653487199
166
+ }], ['referrer-1805', {
167
+ start: 1652882400,
168
+ end: 1653487199
169
+ }]]);
163
170
 
164
171
  var decimalRecords = {
165
172
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
@@ -1633,6 +1640,10 @@ var TokenAmount = /*#__PURE__*/function () {
1633
1640
  return this.rawAmnt;
1634
1641
  };
1635
1642
 
1643
+ _proto.compare = function compare(other) {
1644
+ return new BigNumber(this.rawAmnt).comparedTo(new BigNumber(other.rawAmnt));
1645
+ };
1646
+
1636
1647
  TokenAmount.fromAddressAndAmount = function fromAddressAndAmount(tokenAddress, amount, isRaw) {
1637
1648
  if (isRaw === void 0) {
1638
1649
  isRaw = true;
@@ -1668,7 +1679,8 @@ var referralRewardDummy1 = {
1668
1679
  endTime: 1653573599,
1669
1680
  isReferrer: false,
1670
1681
  rewardTokenAmount: dummyTokenAmount,
1671
- transactionHash: null
1682
+ transactionHash: null,
1683
+ userAddr: '0x...123'
1672
1684
  };
1673
1685
  var referralRewardDummy2 = {
1674
1686
  campaign: 'testb',
@@ -1676,7 +1688,8 @@ var referralRewardDummy2 = {
1676
1688
  endTime: 1653573599,
1677
1689
  isReferrer: true,
1678
1690
  rewardTokenAmount: dummyTokenAmount2,
1679
- transactionHash: '0x4da9657663b46ef18d150b897b28c7b717f16421978b52e3a06d91b54ca3548b'
1691
+ transactionHash: '0x4da9657663b46ef18d150b897b28c7b717f16421978b52e3a06d91b54ca3548b',
1692
+ userAddr: '0x...456'
1680
1693
  };
1681
1694
 
1682
1695
  var AURIGAMI_API_END_POINT = 'https://api.aurigami.finance/app/';
@@ -4666,13 +4679,32 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4666
4679
  /*#__PURE__*/
4667
4680
  function () {
4668
4681
  var _referralRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(userAddr) {
4682
+ var result, items;
4669
4683
  return runtime_1.wrap(function _callee5$(_context5) {
4670
4684
  while (1) {
4671
4685
  switch (_context5.prev = _context5.next) {
4672
4686
  case 0:
4673
- return _context5.abrupt("return", [referralRewardDummy1, referralRewardDummy2]);
4687
+ _context5.next = 2;
4688
+ return getPaginatedApi('/referral/rewards', {
4689
+ address: userAddr
4690
+ });
4674
4691
 
4675
- case 1:
4692
+ case 2:
4693
+ result = _context5.sent;
4694
+ items = result.items.map(function (item, i) {
4695
+ return {
4696
+ campaign: item.campaign,
4697
+ userAddr: userAddr,
4698
+ isReferrer: item.campaign.includes('referrer'),
4699
+ rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
4700
+ startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
4701
+ endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
4702
+ transactionHash: item == null ? void 0 : item.transactionHash
4703
+ };
4704
+ });
4705
+ return _context5.abrupt("return", items);
4706
+
4707
+ case 5:
4676
4708
  case "end":
4677
4709
  return _context5.stop();
4678
4710
  }
@@ -4694,14 +4726,36 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4694
4726
  _proto.leaderboard =
4695
4727
  /*#__PURE__*/
4696
4728
  function () {
4697
- var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
4729
+ var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(campaign) {
4730
+ var result, items;
4698
4731
  return runtime_1.wrap(function _callee6$(_context6) {
4699
4732
  while (1) {
4700
4733
  switch (_context6.prev = _context6.next) {
4701
4734
  case 0:
4702
- return _context6.abrupt("return", [referralRewardDummy2, referralRewardDummy1]);
4735
+ _context6.next = 2;
4736
+ return getPaginatedApi('/referral/leaderboard', {
4737
+ campaign: campaign
4738
+ });
4703
4739
 
4704
- case 1:
4740
+ case 2:
4741
+ result = _context6.sent;
4742
+ items = result.items.map(function (item, i) {
4743
+ return {
4744
+ campaign: campaign,
4745
+ userAddr: item.user,
4746
+ isReferrer: item.campaign.includes('referrer'),
4747
+ rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
4748
+ startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
4749
+ endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
4750
+ transactionHash: null
4751
+ };
4752
+ });
4753
+ items.sort(function (a, b) {
4754
+ return b.rewardTokenAmount.compare(a.rewardTokenAmount);
4755
+ });
4756
+ return _context6.abrupt("return", items);
4757
+
4758
+ case 6:
4705
4759
  case "end":
4706
4760
  return _context6.stop();
4707
4761
  }
@@ -4709,7 +4763,7 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4709
4763
  }, _callee6);
4710
4764
  }));
4711
4765
 
4712
- function leaderboard() {
4766
+ function leaderboard(_x6) {
4713
4767
  return _leaderboard.apply(this, arguments);
4714
4768
  }
4715
4769
 
@@ -4783,7 +4837,7 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
4783
4837
  }, _callee8, this);
4784
4838
  }));
4785
4839
 
4786
- function useReferralCode(_x6) {
4840
+ function useReferralCode(_x7) {
4787
4841
  return _useReferralCode.apply(this, arguments);
4788
4842
  }
4789
4843
 
@@ -5306,6 +5360,7 @@ exports.PRICE_WHITELISTED = PRICE_WHITELISTED;
5306
5360
  exports.Papermill = Papermill;
5307
5361
  exports.PapermillRead = PapermillRead;
5308
5362
  exports.PapermillReadWrite = PapermillReadWrite;
5363
+ exports.REFERRAL_CAMPAIGNS = REFERRAL_CAMPAIGNS;
5309
5364
  exports.REWARD_CLAIM_START = REWARD_CLAIM_START;
5310
5365
  exports.Referral = Referral;
5311
5366
  exports.ReferralRead = ReferralRead;