@aurigami/sdk 1.7.9-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.
- package/dist/consts/constants.d.ts +6 -0
- package/dist/contracts/Referral.d.ts +1 -1
- package/dist/entities/tokenAmount.d.ts +1 -0
- package/dist/sdk.cjs.development.js +60 -7
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +60 -8
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/consts/constants.ts +6 -0
- package/src/contracts/Referral.ts +26 -7
- package/src/entities/tokenAmount.ts +4 -0
package/package.json
CHANGED
package/src/consts/constants.ts
CHANGED
|
@@ -162,3 +162,9 @@ export const BORROW_NEAR_REWARDS_PER_WEEK: { [k: string]: string } = {
|
|
|
162
162
|
export const HARDCODE_PRICE_TOKENS: { [k: string]: string } = Object.fromEntries([
|
|
163
163
|
[networkAddresses.tokens.USN.toLowerCase(), '1'],
|
|
164
164
|
]);
|
|
165
|
+
|
|
166
|
+
export const REFERRAL_CAMPAIGNS: { [k: string]: { start: number; end: number } } =
|
|
167
|
+
Object.fromEntries([
|
|
168
|
+
['referral-1805', { start: 1652882400, end: 1653487199 }],
|
|
169
|
+
['referrer-1805', { start: 1652882400, end: 1653487199 }],
|
|
170
|
+
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
|
-
import {
|
|
4
|
-
import { AuriEnv, BlockchainEntity, BlockchainEntityRead } from '../entities';
|
|
3
|
+
import { REFERRAL_CAMPAIGNS } from '../consts';
|
|
4
|
+
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, TokenAmount } from '../entities';
|
|
5
5
|
import { getBlocksTimestamp } from '../helpers';
|
|
6
6
|
import * as AuriAPI from '../helpers/aurigami-api';
|
|
7
7
|
import { Address, NetworkConnection, ReferralReward } from '../types';
|
|
@@ -71,16 +71,35 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
71
71
|
* Array of rewards, sorted by time of the referral period (from latest to oldest)
|
|
72
72
|
*/
|
|
73
73
|
public async referralRewards(userAddr: Address): Promise<ReferralReward[]> {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const result = await AuriAPI.getPaginatedApi('/referral/rewards', { address: userAddr });
|
|
75
|
+
const items: ReferralReward[] = result.items.map((item, i) => ({
|
|
76
|
+
campaign: item.campaign!,
|
|
77
|
+
userAddr: userAddr,
|
|
78
|
+
isReferrer: (item.campaign as string).includes('referrer'),
|
|
79
|
+
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
80
|
+
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
81
|
+
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
82
|
+
transactionHash: item?.transactionHash,
|
|
83
|
+
}));
|
|
84
|
+
return items;
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
/**
|
|
79
88
|
* Top 50 reward earners from the last round, sorted by token amount
|
|
80
89
|
*/
|
|
81
|
-
public async leaderboard(): Promise<ReferralReward[]> {
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
public async leaderboard(campaign: string): Promise<ReferralReward[]> {
|
|
91
|
+
const result = await AuriAPI.getPaginatedApi('/referral/leaderboard', { campaign: campaign });
|
|
92
|
+
const items: ReferralReward[] = result.items.map((item, i) => ({
|
|
93
|
+
campaign: campaign,
|
|
94
|
+
userAddr: item.user!,
|
|
95
|
+
isReferrer: (item.campaign as string).includes('referrer'),
|
|
96
|
+
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
97
|
+
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
98
|
+
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
99
|
+
transactionHash: null,
|
|
100
|
+
}));
|
|
101
|
+
items.sort((a, b) => b.rewardTokenAmount.compare(a.rewardTokenAmount));
|
|
102
|
+
return items;
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
|
|
@@ -28,6 +28,10 @@ export class TokenAmount {
|
|
|
28
28
|
return this.rawAmnt;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
public compare(other: TokenAmount): number {
|
|
32
|
+
return new BigNumber(this.rawAmnt).comparedTo(new BigNumber(other.rawAmnt));
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
public static fromAddressAndAmount(
|
|
32
36
|
tokenAddress: Address,
|
|
33
37
|
amount: string,
|