@aurigami/sdk 1.23.1 → 1.24.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.d.ts +48 -65
- package/dist/SDK.js +165 -0
- package/dist/abis/index.d.ts +18 -18
- package/dist/abis/index.js +39 -0
- package/dist/consts/constants.d.ts +139 -139
- package/dist/consts/constants.js +185 -0
- package/dist/consts/decimals.d.ts +1 -1
- package/dist/consts/decimals.js +35 -0
- package/dist/consts/deployments.d.ts +3 -3
- package/dist/consts/deployments.js +9 -0
- package/dist/consts/dummy.d.ts +13 -13
- package/dist/consts/dummy.js +43 -0
- package/dist/consts/index.d.ts +5 -5
- package/dist/consts/index.js +9 -0
- package/dist/consts/symbols.d.ts +1 -1
- package/dist/consts/symbols.js +10 -0
- package/dist/entities/BlockchainEntity.d.ts +13 -13
- package/dist/entities/BlockchainEntity.js +36 -0
- package/dist/entities/auriEnv.d.ts +34 -40
- package/dist/entities/auriEnv.js +166 -0
- package/dist/entities/index.d.ts +4 -4
- package/dist/entities/index.js +8 -0
- package/dist/entities/token.d.ts +7 -7
- package/dist/entities/token.js +27 -0
- package/dist/entities/tokenAmount.d.ts +13 -13
- package/dist/entities/tokenAmount.js +52 -0
- package/dist/helpers/aurigami-api.d.ts +13 -13
- package/dist/helpers/aurigami-api.js +26 -0
- package/dist/helpers/aurora-api-helpers.d.ts +1 -1
- package/dist/helpers/aurora-api-helpers.js +15 -0
- package/dist/helpers/graphql-helpers.d.ts +1 -1
- package/dist/helpers/graphql-helpers.js +13 -0
- package/dist/helpers/helpers.d.ts +23 -40
- package/dist/helpers/helpers.js +148 -0
- package/dist/helpers/historicalPriceFetcher.d.ts +15 -15
- package/dist/helpers/historicalPriceFetcher.js +142 -0
- package/dist/helpers/index.d.ts +7 -7
- package/dist/helpers/index.js +11 -0
- package/dist/helpers/kyber-aggregator-api.d.ts +5 -5
- package/dist/helpers/kyber-aggregator-api.js +27 -0
- package/dist/helpers/multicall.d.ts +40 -0
- package/dist/helpers/multicall.js +203 -0
- package/dist/helpers/notification-api.d.ts +2 -2
- package/dist/helpers/notification-api.js +21 -0
- package/dist/helpers/one-inch-aggregator-api.d.ts +21 -21
- package/dist/helpers/one-inch-aggregator-api.js +19 -0
- package/dist/helpers/priceFetcher.d.ts +36 -36
- package/dist/helpers/priceFetcher.js +292 -0
- package/dist/helpers/subgraphQuery.d.ts +1 -1
- package/dist/helpers/subgraphQuery.js +22 -0
- package/dist/helpers/transfer-event-query.d.ts +17 -26
- package/dist/helpers/transfer-event-query.js +41 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +17 -8
- package/dist/interactors/Airdrop.d.ts +17 -26
- package/dist/interactors/Airdrop.js +48 -0
- package/dist/interactors/MoneyMarket.d.ts +63 -63
- package/dist/interactors/MoneyMarket.js +392 -0
- package/dist/interactors/Multicall.d.ts +15 -18
- package/dist/interactors/Multicall.js +36 -0
- package/dist/interactors/Papermill.d.ts +27 -57
- package/dist/interactors/Papermill.js +125 -0
- package/dist/interactors/PlyGame.d.ts +30 -42
- package/dist/interactors/PlyGame.js +146 -0
- package/dist/interactors/PlyTokenLock.d.ts +16 -16
- package/dist/interactors/PlyTokenLock.js +44 -0
- package/dist/interactors/Pulp.d.ts +17 -17
- package/dist/interactors/Pulp.js +43 -0
- package/dist/interactors/Referral.d.ts +35 -78
- package/dist/interactors/Referral.js +158 -0
- package/dist/interactors/Staking.d.ts +20 -26
- package/dist/interactors/Staking.js +106 -0
- package/dist/interactors/index.d.ts +9 -9
- package/dist/interactors/index.js +13 -0
- package/dist/interactors/misc.d.ts +31 -39
- package/dist/interactors/misc.js +318 -0
- package/dist/types/index.d.ts +175 -197
- package/dist/types/index.js +18 -0
- package/package.json +4 -16
- package/dist/sdk.cjs.development.js +0 -6325
- package/dist/sdk.cjs.development.js.map +0 -1
- package/dist/sdk.cjs.production.min.js +0 -2
- package/dist/sdk.cjs.production.min.js.map +0 -1
- package/dist/sdk.esm.js +0 -6193
- package/dist/sdk.esm.js.map +0 -1
- package/src/SDK.ts +0 -223
- package/src/abis/index.ts +0 -38
- package/src/consts/constants.ts +0 -210
- package/src/consts/decimals.ts +0 -31
- package/src/consts/deployments.ts +0 -4
- package/src/consts/dummy.ts +0 -51
- package/src/consts/index.ts +0 -5
- package/src/consts/symbols.ts +0 -9
- package/src/entities/BlockchainEntity.ts +0 -29
- package/src/entities/auriEnv.ts +0 -178
- package/src/entities/index.ts +0 -4
- package/src/entities/token.ts +0 -21
- package/src/entities/tokenAmount.ts +0 -48
- package/src/helpers/aurigami-api.ts +0 -42
- package/src/helpers/aurora-api-helpers.ts +0 -17
- package/src/helpers/graphql-helpers.ts +0 -8
- package/src/helpers/helpers.ts +0 -212
- package/src/helpers/historicalPriceFetcher.ts +0 -203
- package/src/helpers/index.ts +0 -7
- package/src/helpers/kyber-aggregator-api.ts +0 -37
- package/src/helpers/notification-api.ts +0 -22
- package/src/helpers/one-inch-aggregator-api.ts +0 -45
- package/src/helpers/priceFetcher.ts +0 -389
- package/src/helpers/subgraphQuery.ts +0 -17
- package/src/helpers/transfer-event-query.ts +0 -68
- package/src/index.ts +0 -14
- package/src/interactors/Airdrop.ts +0 -72
- package/src/interactors/MoneyMarket.ts +0 -482
- package/src/interactors/Multicall.ts +0 -50
- package/src/interactors/Papermill.ts +0 -185
- package/src/interactors/PlyGame.ts +0 -172
- package/src/interactors/PlyTokenLock.ts +0 -47
- package/src/interactors/Pulp.ts +0 -39
- package/src/interactors/Referral.ts +0 -214
- package/src/interactors/Staking.ts +0 -152
- package/src/interactors/index.ts +0 -9
- package/src/interactors/misc.ts +0 -431
- package/src/types/index.ts +0 -222
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { ethers } from 'ethers';
|
|
4
|
-
import { AURORA_PLUS_API_PREFIX, REFERRAL_CAMPAIGNS } from '../consts';
|
|
5
|
-
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, TokenAmount } from '../entities';
|
|
6
|
-
import { getBlocksTimestamp } from '../helpers';
|
|
7
|
-
import * as AuriAPI from '../helpers/aurigami-api';
|
|
8
|
-
import { Address, NetworkConnection, ReferralReward } from '../types';
|
|
9
|
-
import { AirdropReadWrite } from './Airdrop';
|
|
10
|
-
|
|
11
|
-
export class ReferralRead extends BlockchainEntityRead {
|
|
12
|
-
public readonly env: AuriEnv;
|
|
13
|
-
constructor(networkConnection: NetworkConnection) {
|
|
14
|
-
super(networkConnection);
|
|
15
|
-
this.env = new AuriEnv(networkConnection);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generate a 10-character referral code
|
|
20
|
-
* containing alphanumeric characters.
|
|
21
|
-
*/
|
|
22
|
-
protected generateReferralCode(): string {
|
|
23
|
-
let letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
24
|
-
let numbers = '1234567890';
|
|
25
|
-
let charset = letters + letters.toUpperCase() + numbers;
|
|
26
|
-
let R = '';
|
|
27
|
-
for (var i = 0; i < 10; i++) R += charset[Math.floor(Math.random() * charset.length)];
|
|
28
|
-
return R;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get the referral code for a given address, returns empty string if not found.
|
|
33
|
-
*
|
|
34
|
-
* Called to check if a user has a referral code.
|
|
35
|
-
*/
|
|
36
|
-
public async getUserReferralCode(userAddr: Address): Promise<string> {
|
|
37
|
-
const result = await this.env.referralDirectoryV2.userReferralCode(userAddr);
|
|
38
|
-
return ethers.utils.parseBytes32String(result);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get referral code that a user was referred by, returns empty string if not found.
|
|
43
|
-
*/
|
|
44
|
-
public async getReferralCodeUsed(userAddr: Address): Promise<string> {
|
|
45
|
-
const result = await this.env.referralDirectoryV2.referralCodeUsed(userAddr);
|
|
46
|
-
return ethers.utils.parseBytes32String(result);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get owner of a referral code, returns zero address if not found.
|
|
51
|
-
*/
|
|
52
|
-
public async getReferralCodeOwner(code: string): Promise<Address> {
|
|
53
|
-
const referralCode = ethers.utils.formatBytes32String(code);
|
|
54
|
-
return this.env.referralDirectoryV2.referralCodeOwner(referralCode);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get referrals of a user, sorted descending by timestamp.
|
|
59
|
-
*/
|
|
60
|
-
public async getReferralsList(userAddr: Address): Promise<{ user: string; timestamp: number }[]> {
|
|
61
|
-
const result = await AuriAPI.getPaginatedApi('/referral/list', { address: userAddr });
|
|
62
|
-
const blocks = result.items.map((item) => item.blockNumber!);
|
|
63
|
-
const blocksTimestamp = await getBlocksTimestamp(this._networkConnection.provider, blocks);
|
|
64
|
-
const items = result.items.map((item, i) => ({
|
|
65
|
-
user: item.user!,
|
|
66
|
-
timestamp: blocksTimestamp[i],
|
|
67
|
-
}));
|
|
68
|
-
return items;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Array of rewards, sorted by time of the referral period (from latest to oldest)
|
|
73
|
-
*/
|
|
74
|
-
public async referralRewards(userAddr: Address): Promise<ReferralReward[]> {
|
|
75
|
-
const result = await AuriAPI.getPaginatedApi('/referral/rewards', { address: userAddr });
|
|
76
|
-
let items: ReferralReward[] = result.items.map((item, i) => ({
|
|
77
|
-
campaign: item.campaign!,
|
|
78
|
-
userAddr: userAddr,
|
|
79
|
-
isReferrer: (item.campaign as string).includes('referrer'),
|
|
80
|
-
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
81
|
-
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
82
|
-
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
83
|
-
transactionHash: item.transactionHash ?? null,
|
|
84
|
-
refereeAddress: null,
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
return items;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Top 50 reward earners from the last round, sorted by token amount
|
|
92
|
-
*/
|
|
93
|
-
public async leaderboard(campaign: string): Promise<ReferralReward[]> {
|
|
94
|
-
const result = await AuriAPI.getPaginatedApi('/referral/leaderboard', { campaign: campaign });
|
|
95
|
-
const items: ReferralReward[] = result.items.map((item, i) => ({
|
|
96
|
-
campaign: campaign,
|
|
97
|
-
userAddr: item.user!,
|
|
98
|
-
isReferrer: (item.campaign as string).includes('referrer'),
|
|
99
|
-
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
100
|
-
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
101
|
-
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
102
|
-
transactionHash: null,
|
|
103
|
-
refereeAddress: null,
|
|
104
|
-
}));
|
|
105
|
-
items.sort((a, b) => b.rewardTokenAmount.compare(a.rewardTokenAmount));
|
|
106
|
-
return items;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* current number of slots under a referral code being used that exceed minimum deposit amount
|
|
111
|
-
*/
|
|
112
|
-
public async slotsInUse(): Promise<number> {
|
|
113
|
-
let result = await AuriAPI.getApi('/referral/slotsInUse');
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public totalReferralSlots() {
|
|
118
|
-
return 500;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public async queuePosition(address: Address): Promise<number> {
|
|
122
|
-
let result = await AuriAPI.getApi('/referral/queuePosition', { address: address });
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* a way to determine qualification status of a user. null if not referred yet,
|
|
128
|
-
* qualified if referred + min deposit, notQualified if referred + min deposit
|
|
129
|
-
* not reached or withdrew too early
|
|
130
|
-
*/
|
|
131
|
-
public async userReferralStatus(userAddr: Address): Promise<string> {
|
|
132
|
-
let result: number = await AuriAPI.getApi('/referral/referralStatus', { address: userAddr });
|
|
133
|
-
switch (result) {
|
|
134
|
-
case -1:
|
|
135
|
-
return 'notReferred';
|
|
136
|
-
case 0:
|
|
137
|
-
return 'notQualified';
|
|
138
|
-
case 1:
|
|
139
|
-
return 'Qualified';
|
|
140
|
-
default:
|
|
141
|
-
return 'Withdrawn';
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public async isWhitelistedAddress(address: Address): Promise<boolean> {
|
|
146
|
-
let result = await this.env.referralDirectoryV2.isUserWhitelisted(address);
|
|
147
|
-
return result.eq(1);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public async isOnAuroraPlus(address: Address): Promise<boolean> {
|
|
151
|
-
let resp = await axios.get(AURORA_PLUS_API_PREFIX + address);
|
|
152
|
-
|
|
153
|
-
return resp.data.status == 'active';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public async isNewUserAtReferralTime(address: Address): Promise<boolean> {
|
|
157
|
-
let result: boolean = await AuriAPI.getApi('/referral/isNewUser', { address: address });
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
public async depositedMoreThanMinimumAmount(address: Address): Promise<boolean> {
|
|
162
|
-
let result: boolean = await AuriAPI.getApi('/referral/depositedEnough', { address: address });
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export class ReferralReadWrite extends ReferralRead {
|
|
168
|
-
/**
|
|
169
|
-
* Generate a referral code for a given address.
|
|
170
|
-
*
|
|
171
|
-
* Called when an user want to creates his own referral code
|
|
172
|
-
*/
|
|
173
|
-
public async registerNewReferralCode(): Promise<TransactionResponse> {
|
|
174
|
-
const referralCode = ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
175
|
-
return this.env.referralDirectoryV2
|
|
176
|
-
.connect(this._networkConnection.signer!)
|
|
177
|
-
.registerNewUserReferralCode(referralCode);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Called when an user confirms he is referred by a specified code
|
|
182
|
-
*/
|
|
183
|
-
public async useReferralCode(code: string): Promise<TransactionResponse> {
|
|
184
|
-
const referralCode = ethers.utils.formatBytes32String(code);
|
|
185
|
-
return this.env.referralDirectoryV2
|
|
186
|
-
.connect(this._networkConnection.signer!)
|
|
187
|
-
.registerReferralCodeUsed(referralCode);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Claim all unclaimed rewards for a given user
|
|
192
|
-
*/
|
|
193
|
-
public async claimReferralRewards(): Promise<TransactionResponse> {
|
|
194
|
-
const unclaimedRewards = (
|
|
195
|
-
await this.referralRewards(await this._networkConnection.signer!.getAddress())
|
|
196
|
-
).filter((reward) => reward.transactionHash == null);
|
|
197
|
-
const campaigns = unclaimedRewards.map((reward) => reward.campaign);
|
|
198
|
-
const tokens = unclaimedRewards.map((reward) => reward.rewardTokenAmount.token.address);
|
|
199
|
-
return new AirdropReadWrite(this._networkConnection).redeemMultiple(campaigns, tokens);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export class Referral extends BlockchainEntity {
|
|
204
|
-
constructor() {
|
|
205
|
-
super();
|
|
206
|
-
}
|
|
207
|
-
public read(networkConnection: NetworkConnection): ReferralRead {
|
|
208
|
-
return new ReferralRead(networkConnection);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
public readWrite(networkConnection: NetworkConnection): ReferralReadWrite {
|
|
212
|
-
return new ReferralReadWrite(networkConnection);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { IERC20 } from '@aurigami/contracts/typechain';
|
|
2
|
-
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { BigNumber as BN, Contract } from 'ethers';
|
|
5
|
-
import { EIP20InterfaceABI } from '../abis';
|
|
6
|
-
import * as consts from '../consts';
|
|
7
|
-
import {
|
|
8
|
-
AuriEnv,
|
|
9
|
-
BlockchainEntity,
|
|
10
|
-
BlockchainEntityRead,
|
|
11
|
-
PLYWNEARToken,
|
|
12
|
-
Token,
|
|
13
|
-
TokenAmount,
|
|
14
|
-
} from '../entities';
|
|
15
|
-
import { calcLMRewardApr, getDecimal } from '../helpers';
|
|
16
|
-
import { fetchValuation } from '../helpers/priceFetcher';
|
|
17
|
-
import { NetworkConnection, PLYWNEARPoolDetails, TokenAPY } from '../types';
|
|
18
|
-
|
|
19
|
-
export class StakingRead extends BlockchainEntityRead {
|
|
20
|
-
public readonly env: AuriEnv;
|
|
21
|
-
constructor(networkConnection: NetworkConnection) {
|
|
22
|
-
super(networkConnection);
|
|
23
|
-
this.env = new AuriEnv(networkConnection);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async getPLYWNEARPoolDetails(): Promise<PLYWNEARPoolDetails> {
|
|
27
|
-
const { stakedLiquidity, rewardPerSeconds } = await this.env.auriFairLaunch
|
|
28
|
-
.getPoolInfo(consts.PLYWNEAR_POOL_ID)
|
|
29
|
-
.then((res) => {
|
|
30
|
-
const endedTime = res.endTime;
|
|
31
|
-
const startTime = res.startTime;
|
|
32
|
-
const now = Date.now() / 1000;
|
|
33
|
-
// If the pool has ended or not started, return 0 reward per second
|
|
34
|
-
if (endedTime < now || startTime > now) {
|
|
35
|
-
return {
|
|
36
|
-
stakedLiquidity: res.totalStake,
|
|
37
|
-
rewardPerSeconds: res.rewardPerSeconds.map((_) => BN.from(0)),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return { stakedLiquidity: res.totalStake, rewardPerSeconds: res.rewardPerSeconds };
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
let stakedLiquidityAmount = new TokenAmount(PLYWNEARToken, stakedLiquidity!.toString());
|
|
44
|
-
|
|
45
|
-
var totalStakeValuation: BigNumber = await fetchValuation(
|
|
46
|
-
stakedLiquidityAmount,
|
|
47
|
-
this._networkConnection.provider
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
var promises = [];
|
|
51
|
-
|
|
52
|
-
// Calculate the reward per second in USD
|
|
53
|
-
for (let i = 0; i < rewardPerSeconds!.length; i++) {
|
|
54
|
-
let rewardTokenAddress = consts.PLYWNEAR_REWARD_TOKENS[i];
|
|
55
|
-
let rewardToken = new Token(rewardTokenAddress, getDecimal(rewardTokenAddress));
|
|
56
|
-
let rewardPerSecond = rewardPerSeconds![i];
|
|
57
|
-
promises.push(
|
|
58
|
-
fetchValuation(
|
|
59
|
-
new TokenAmount(rewardToken, rewardPerSecond!.toString()),
|
|
60
|
-
this._networkConnection.provider
|
|
61
|
-
)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let APYs: TokenAPY[] = [];
|
|
66
|
-
(await Promise.all(promises)).forEach((rewardPerSecondValuation, i) => {
|
|
67
|
-
let rewardTokenAddress = consts.PLYWNEAR_REWARD_TOKENS[i];
|
|
68
|
-
let apy = calcLMRewardApr(
|
|
69
|
-
rewardPerSecondValuation,
|
|
70
|
-
totalStakeValuation,
|
|
71
|
-
consts.ONE_DAY * 365
|
|
72
|
-
).toFixed(consts.DECIMAL_PRECISION);
|
|
73
|
-
|
|
74
|
-
APYs.push({
|
|
75
|
-
address: rewardTokenAddress,
|
|
76
|
-
apy: apy,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
totalStakedLiquidity: stakedLiquidityAmount,
|
|
82
|
-
APYs: APYs,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get amount of staked LP tokens
|
|
88
|
-
*/
|
|
89
|
-
public async stakeBalanceOf(user: string): Promise<TokenAmount> {
|
|
90
|
-
const userInfo = await this.env.auriFairLaunch.getUserInfo(consts.PLYWNEAR_POOL_ID, user);
|
|
91
|
-
return new TokenAmount(PLYWNEARToken, userInfo.amount.toString());
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get amount of LP token in user wallet
|
|
96
|
-
*/
|
|
97
|
-
public async LpBalanceOf(user: string): Promise<TokenAmount> {
|
|
98
|
-
let lpContract = new Contract(
|
|
99
|
-
consts.networkAddresses.tokens.PLYWNEAR,
|
|
100
|
-
EIP20InterfaceABI.abi,
|
|
101
|
-
this._networkConnection.provider
|
|
102
|
-
) as IERC20;
|
|
103
|
-
let balance = await lpContract.balanceOf(user);
|
|
104
|
-
|
|
105
|
-
return new TokenAmount(PLYWNEARToken, balance.toString());
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public async unclaimedRewardsOf(user: string): Promise<TokenAmount[]> {
|
|
109
|
-
let userInfo = await this.env.auriFairLaunch.callStatic.updateAndGetUserInfo(
|
|
110
|
-
consts.PLYWNEAR_POOL_ID,
|
|
111
|
-
user,
|
|
112
|
-
{ from: user }
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
let rewards = userInfo.unclaimedRewards;
|
|
116
|
-
return rewards.map((reward, i) =>
|
|
117
|
-
TokenAmount.fromAddressAndAmount(consts.PLYWNEAR_REWARD_TOKENS[i], reward.toString())
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export class StakingReadWrite extends StakingRead {
|
|
123
|
-
public async stake(amount: TokenAmount): Promise<TransactionResponse> {
|
|
124
|
-
return this.env.auriFairLaunch
|
|
125
|
-
.connect(this._networkConnection.signer!)
|
|
126
|
-
.deposit(consts.PLYWNEAR_POOL_ID, amount.rawAmount());
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public async unstake(amount: TokenAmount): Promise<TransactionResponse> {
|
|
130
|
-
const msgSender = await this._networkConnection.signer!.getAddress();
|
|
131
|
-
const amountInput = BN.from(amount.rawAmount());
|
|
132
|
-
const stakedAmount = BN.from((await this.stakeBalanceOf(msgSender)).rawAmount());
|
|
133
|
-
// unstakeAmount = min(amountInput, stakedAmount - 1)
|
|
134
|
-
const unstakeAmount = amountInput.lt(stakedAmount) ? amountInput : stakedAmount.sub(1);
|
|
135
|
-
return this.env.auriFairLaunch
|
|
136
|
-
.connect(this._networkConnection.signer!)
|
|
137
|
-
.withdraw(consts.PLYWNEAR_POOL_ID, unstakeAmount);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export class Staking extends BlockchainEntity {
|
|
142
|
-
constructor() {
|
|
143
|
-
super();
|
|
144
|
-
}
|
|
145
|
-
public read(networkConnection: NetworkConnection): StakingRead {
|
|
146
|
-
return new StakingRead(networkConnection);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
public readWrite(networkConnection: NetworkConnection): StakingReadWrite {
|
|
150
|
-
return new StakingReadWrite(networkConnection);
|
|
151
|
-
}
|
|
152
|
-
}
|
package/src/interactors/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './Airdrop';
|
|
2
|
-
export * from './MoneyMarket';
|
|
3
|
-
export * from './Papermill';
|
|
4
|
-
export * from './PlyGame';
|
|
5
|
-
export * from './Pulp';
|
|
6
|
-
export * from './Referral';
|
|
7
|
-
export * from './Staking';
|
|
8
|
-
export * from './misc';
|
|
9
|
-
export * from './PlyTokenLock';
|