@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.
Files changed (123) hide show
  1. package/dist/SDK.d.ts +48 -65
  2. package/dist/SDK.js +165 -0
  3. package/dist/abis/index.d.ts +18 -18
  4. package/dist/abis/index.js +39 -0
  5. package/dist/consts/constants.d.ts +139 -139
  6. package/dist/consts/constants.js +185 -0
  7. package/dist/consts/decimals.d.ts +1 -1
  8. package/dist/consts/decimals.js +35 -0
  9. package/dist/consts/deployments.d.ts +3 -3
  10. package/dist/consts/deployments.js +9 -0
  11. package/dist/consts/dummy.d.ts +13 -13
  12. package/dist/consts/dummy.js +43 -0
  13. package/dist/consts/index.d.ts +5 -5
  14. package/dist/consts/index.js +9 -0
  15. package/dist/consts/symbols.d.ts +1 -1
  16. package/dist/consts/symbols.js +10 -0
  17. package/dist/entities/BlockchainEntity.d.ts +13 -13
  18. package/dist/entities/BlockchainEntity.js +36 -0
  19. package/dist/entities/auriEnv.d.ts +34 -40
  20. package/dist/entities/auriEnv.js +166 -0
  21. package/dist/entities/index.d.ts +4 -4
  22. package/dist/entities/index.js +8 -0
  23. package/dist/entities/token.d.ts +7 -7
  24. package/dist/entities/token.js +27 -0
  25. package/dist/entities/tokenAmount.d.ts +13 -13
  26. package/dist/entities/tokenAmount.js +52 -0
  27. package/dist/helpers/aurigami-api.d.ts +13 -13
  28. package/dist/helpers/aurigami-api.js +26 -0
  29. package/dist/helpers/aurora-api-helpers.d.ts +1 -1
  30. package/dist/helpers/aurora-api-helpers.js +15 -0
  31. package/dist/helpers/graphql-helpers.d.ts +1 -1
  32. package/dist/helpers/graphql-helpers.js +13 -0
  33. package/dist/helpers/helpers.d.ts +23 -40
  34. package/dist/helpers/helpers.js +148 -0
  35. package/dist/helpers/historicalPriceFetcher.d.ts +15 -15
  36. package/dist/helpers/historicalPriceFetcher.js +142 -0
  37. package/dist/helpers/index.d.ts +7 -7
  38. package/dist/helpers/index.js +11 -0
  39. package/dist/helpers/kyber-aggregator-api.d.ts +5 -5
  40. package/dist/helpers/kyber-aggregator-api.js +27 -0
  41. package/dist/helpers/multicall.d.ts +40 -0
  42. package/dist/helpers/multicall.js +203 -0
  43. package/dist/helpers/notification-api.d.ts +2 -2
  44. package/dist/helpers/notification-api.js +21 -0
  45. package/dist/helpers/one-inch-aggregator-api.d.ts +21 -21
  46. package/dist/helpers/one-inch-aggregator-api.js +19 -0
  47. package/dist/helpers/priceFetcher.d.ts +36 -36
  48. package/dist/helpers/priceFetcher.js +292 -0
  49. package/dist/helpers/subgraphQuery.d.ts +1 -1
  50. package/dist/helpers/subgraphQuery.js +22 -0
  51. package/dist/helpers/transfer-event-query.d.ts +17 -26
  52. package/dist/helpers/transfer-event-query.js +41 -0
  53. package/dist/index.d.ts +7 -7
  54. package/dist/index.js +17 -8
  55. package/dist/interactors/Airdrop.d.ts +17 -26
  56. package/dist/interactors/Airdrop.js +48 -0
  57. package/dist/interactors/MoneyMarket.d.ts +63 -63
  58. package/dist/interactors/MoneyMarket.js +392 -0
  59. package/dist/interactors/Multicall.d.ts +15 -18
  60. package/dist/interactors/Multicall.js +36 -0
  61. package/dist/interactors/Papermill.d.ts +27 -57
  62. package/dist/interactors/Papermill.js +125 -0
  63. package/dist/interactors/PlyGame.d.ts +30 -42
  64. package/dist/interactors/PlyGame.js +146 -0
  65. package/dist/interactors/PlyTokenLock.d.ts +16 -16
  66. package/dist/interactors/PlyTokenLock.js +44 -0
  67. package/dist/interactors/Pulp.d.ts +17 -17
  68. package/dist/interactors/Pulp.js +43 -0
  69. package/dist/interactors/Referral.d.ts +35 -78
  70. package/dist/interactors/Referral.js +158 -0
  71. package/dist/interactors/Staking.d.ts +20 -26
  72. package/dist/interactors/Staking.js +106 -0
  73. package/dist/interactors/index.d.ts +9 -9
  74. package/dist/interactors/index.js +13 -0
  75. package/dist/interactors/misc.d.ts +31 -39
  76. package/dist/interactors/misc.js +318 -0
  77. package/dist/types/index.d.ts +175 -197
  78. package/dist/types/index.js +18 -0
  79. package/package.json +4 -16
  80. package/dist/sdk.cjs.development.js +0 -6325
  81. package/dist/sdk.cjs.development.js.map +0 -1
  82. package/dist/sdk.cjs.production.min.js +0 -2
  83. package/dist/sdk.cjs.production.min.js.map +0 -1
  84. package/dist/sdk.esm.js +0 -6193
  85. package/dist/sdk.esm.js.map +0 -1
  86. package/src/SDK.ts +0 -223
  87. package/src/abis/index.ts +0 -38
  88. package/src/consts/constants.ts +0 -210
  89. package/src/consts/decimals.ts +0 -31
  90. package/src/consts/deployments.ts +0 -4
  91. package/src/consts/dummy.ts +0 -51
  92. package/src/consts/index.ts +0 -5
  93. package/src/consts/symbols.ts +0 -9
  94. package/src/entities/BlockchainEntity.ts +0 -29
  95. package/src/entities/auriEnv.ts +0 -178
  96. package/src/entities/index.ts +0 -4
  97. package/src/entities/token.ts +0 -21
  98. package/src/entities/tokenAmount.ts +0 -48
  99. package/src/helpers/aurigami-api.ts +0 -42
  100. package/src/helpers/aurora-api-helpers.ts +0 -17
  101. package/src/helpers/graphql-helpers.ts +0 -8
  102. package/src/helpers/helpers.ts +0 -212
  103. package/src/helpers/historicalPriceFetcher.ts +0 -203
  104. package/src/helpers/index.ts +0 -7
  105. package/src/helpers/kyber-aggregator-api.ts +0 -37
  106. package/src/helpers/notification-api.ts +0 -22
  107. package/src/helpers/one-inch-aggregator-api.ts +0 -45
  108. package/src/helpers/priceFetcher.ts +0 -389
  109. package/src/helpers/subgraphQuery.ts +0 -17
  110. package/src/helpers/transfer-event-query.ts +0 -68
  111. package/src/index.ts +0 -14
  112. package/src/interactors/Airdrop.ts +0 -72
  113. package/src/interactors/MoneyMarket.ts +0 -482
  114. package/src/interactors/Multicall.ts +0 -50
  115. package/src/interactors/Papermill.ts +0 -185
  116. package/src/interactors/PlyGame.ts +0 -172
  117. package/src/interactors/PlyTokenLock.ts +0 -47
  118. package/src/interactors/Pulp.ts +0 -39
  119. package/src/interactors/Referral.ts +0 -214
  120. package/src/interactors/Staking.ts +0 -152
  121. package/src/interactors/index.ts +0 -9
  122. package/src/interactors/misc.ts +0 -431
  123. package/src/types/index.ts +0 -222
@@ -1,50 +0,0 @@
1
- import { Multicall2 } from '@aurigami/contracts/typechain';
2
- import { Contract, ethers } from 'ethers';
3
- import { Result } from 'ethers/lib/utils';
4
- import * as abis from '../abis';
5
- import * as consts from '../consts';
6
- import { BlockchainEntityRead } from '../entities';
7
- import { NetworkConnection } from '../types';
8
-
9
- export class MulticallRead extends BlockchainEntityRead {
10
- public readonly multicall: Multicall2;
11
- constructor(networkConnection: NetworkConnection) {
12
- super(networkConnection);
13
- this.multicall = new Contract(
14
- consts.networkAddresses.misc.MULTICALL,
15
- abis.Multicall2ABI.abi,
16
- networkConnection.provider
17
- ) as Multicall2;
18
- }
19
-
20
- /**
21
- * Run multiple calls via multicall contract
22
- */
23
- public async aggregate(
24
- calls: {
25
- contract: Contract;
26
- method: string;
27
- args: any[];
28
- returnTypes: string[];
29
- }[]
30
- ): Promise<Result[]> {
31
- const txns = [];
32
- // prepare transactions
33
- for (let i = 0; i < calls.length; i++) {
34
- const call = calls[i];
35
- let txn = await call.contract.populateTransaction[call.method](...call.args);
36
- txns.push({ target: txn.to!, callData: txn.data! });
37
- }
38
-
39
- const response = await this.multicall.callStatic.aggregate(txns);
40
-
41
- // parse results
42
- const decodedReturn = [];
43
- for (let i = 0; i < calls.length; i++) {
44
- decodedReturn.push(
45
- ethers.utils.defaultAbiCoder.decode(calls[i].returnTypes, response.returnData[i])
46
- );
47
- }
48
- return decodedReturn;
49
- }
50
- }
@@ -1,185 +0,0 @@
1
- import { TransactionResponse } from '@ethersproject/abstract-provider';
2
- import BigNumber from 'bignumber.js';
3
- import { BigNumber as BN } from 'ethers';
4
- import * as consts from '../consts';
5
- import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from '../entities';
6
- import * as helpers from '../helpers';
7
- import { Address, NetworkConnection, UserLockingDetails } from '../types';
8
-
9
- const LOCKING_DENOMINATOR = BN.from(10000);
10
- export class PapermillRead extends BlockchainEntityRead {
11
- public readonly plyToken: Token;
12
- public readonly pulpToken: Token;
13
- public readonly env: AuriEnv;
14
-
15
- constructor(networkConnection: NetworkConnection) {
16
- super(networkConnection);
17
- this.env = new AuriEnv(networkConnection);
18
-
19
- let plyAddress = consts.networkAddresses.tokens.PLY;
20
- let pulpAddress = consts.networkAddresses.tokens.PULP;
21
-
22
- this.plyToken = new Token(plyAddress, helpers.getDecimal(plyAddress));
23
- this.pulpToken = new Token(pulpAddress, helpers.getDecimal(pulpAddress));
24
- }
25
-
26
- public async getPlyBalance(userAddress: Address): Promise<TokenAmount> {
27
- const plyBalance = await this.env.ply.balanceOf(userAddress);
28
- return new TokenAmount(this.plyToken, plyBalance.toString());
29
- }
30
-
31
- public async getPulpBalance(userAddress: Address): Promise<TokenAmount> {
32
- const pulpBalance = await this.env.pulp.balanceOf(userAddress);
33
- return new TokenAmount(this.pulpToken, pulpBalance.toString());
34
- }
35
-
36
- /**
37
- * Get all unclaimed PLY reward of the user in all markets + all staking pools
38
- */
39
- public async getUnclaimedPlyReward(userAddress: Address): Promise<TokenAmount> {
40
- let rewardBalancesMetadata = await this.env.auriLens.callStatic.claimRewards(
41
- this.env.comptroller.address,
42
- this.env.auriFairLaunch.address,
43
- consts.ALL_STAKING_POOLS,
44
- { from: userAddress }
45
- );
46
-
47
- return new TokenAmount(this.plyToken, rewardBalancesMetadata.plyAccrured.toString());
48
- }
49
-
50
- public getWeek(timestamp: number): number {
51
- return BN.from(timestamp - consts.REWARD_CLAIM_START)
52
- .div(consts.ONE_WEEK)
53
- .toNumber();
54
- }
55
-
56
- /**
57
- * Get all locking details of the user in all markets + all staking pools
58
- */
59
- public async getLockingDetails(userAddress: Address): Promise<UserLockingDetails> {
60
- const currentWeek = this.getWeek(helpers.getCurrentTimestamp());
61
-
62
- const values = await Promise.all([
63
- this.env.auriLens.getPercentLock(this.env.pulp.address, userAddress, currentWeek),
64
- this.env.auriLens.getPercentLock(this.env.pulp.address, userAddress, currentWeek + 1),
65
- this.getUnclaimedPlyReward(userAddress),
66
- ]);
67
-
68
- let percentLockCurrentWeek = BN.from(values[0]);
69
- let percentLockNextWeek = BN.from(values[1]);
70
- let totalRewards = values[2] as TokenAmount;
71
-
72
- let [pulpAmountCurrentWeek, plyAmountCurrentWeek] = await this.env.pulp.calcLockAmount(
73
- userAddress,
74
- totalRewards.rawAmount()
75
- );
76
-
77
- // Predict next week lock amount = totalRewards * percentLock next week
78
- // This doesn't take (the reward that user might earn in the next week) into account
79
- let plyAmountNextWeek = percentLockNextWeek
80
- .mul(totalRewards.rawAmount())
81
- .div(LOCKING_DENOMINATOR);
82
- let pulpAmountNextWeek = BN.from(totalRewards.rawAmount()).sub(plyAmountNextWeek);
83
-
84
- // we need to divide these two number by 10000 and multiple by 100 to get the percentage
85
- // I need to use BigNumber to do this because BN of ethers.js doesn't support floating point
86
- let currentUnlockPortion = LOCKING_DENOMINATOR.sub(percentLockCurrentWeek).toString();
87
- let nextUnlockPortion = LOCKING_DENOMINATOR.sub(percentLockNextWeek).toString();
88
-
89
- return {
90
- vestingStart: consts.REWARD_CLAIM_START,
91
- currentUnlockPortion: new BigNumber(currentUnlockPortion).dividedBy(100).toNumber(),
92
- accruedPly: totalRewards,
93
- currentPly: new TokenAmount(this.plyToken, plyAmountCurrentWeek.toString()),
94
- currentPulp: new TokenAmount(this.pulpToken, pulpAmountCurrentWeek.toString()),
95
- //
96
- nextUnlockPortion: new BigNumber(nextUnlockPortion).dividedBy(100).toNumber(),
97
- nextPly: new TokenAmount(this.plyToken, plyAmountNextWeek.toString()),
98
- nextPulp: new TokenAmount(this.pulpToken, pulpAmountNextWeek.toString()),
99
- };
100
- }
101
-
102
- /**
103
- * Get the first timestamp that the unlockPortion reach the target
104
- *
105
- * @param userAddress currently doesn't matter
106
- * @param targetUnlockPortion unlockPortion target
107
- */
108
- public async getTimestampToUnlock(
109
- userAddress: Address,
110
- targetUnlockPortion: number
111
- ): Promise<number> {
112
- let weekId = await this.env.auriLens.getWeekToUnlock(
113
- this.env.pulp.address,
114
- userAddress,
115
- targetUnlockPortion * 100
116
- );
117
-
118
- return consts.REWARD_CLAIM_START + consts.ONE_WEEK * weekId.toNumber();
119
- }
120
-
121
- /**
122
- * Get the start timestamp of next week of the papermill contract.
123
- *
124
- * This is a sync function!
125
- *
126
- * @returns the timestamp in seconds
127
- */
128
- public getNextWeekTimestamp(): number {
129
- const nextWeek = this.getWeek(helpers.getCurrentTimestamp()) + 1;
130
- return consts.REWARD_CLAIM_START + consts.ONE_WEEK * nextWeek;
131
- }
132
-
133
- public async getUnlockPortionAt(userAddress: Address, timestamp: number): Promise<number> {
134
- let lockPortion = await this.env.auriLens.getPercentLock(
135
- this.env.pulp.address,
136
- userAddress,
137
- this.getWeek(timestamp)
138
- );
139
-
140
- let unlockPortion = LOCKING_DENOMINATOR.sub(lockPortion);
141
-
142
- return unlockPortion.toNumber() / 100;
143
- }
144
- }
145
-
146
- export class PapermillReadWrite extends PapermillRead {
147
- constructor(networkConnection: NetworkConnection) {
148
- super(networkConnection);
149
- }
150
-
151
- /**
152
- * Redeem PLY from PULP and transfer PLY to another address
153
- * @param recipient Address that will receive the PLY.
154
- * @param amount Amount of PULP to be converted to PLY.
155
- * Set to ethers.constants.MaxUint256 for max redeem.
156
- */
157
- public async redeem(recipient: Address, amount: TokenAmount): Promise<TransactionResponse> {
158
- return this.env.pulp
159
- .connect(this._networkConnection.signer!)
160
- .redeem(recipient, amount.rawAmount());
161
- }
162
-
163
- /**
164
- * Redeem PLY from PULP and transfer PLY to msg.sender
165
- * @param amount Amount of PULP to be converted to PLY.
166
- * Set to ethers.constants.MaxUint256 for max redeem.
167
- */
168
- public async selfRedeem(amount: TokenAmount): Promise<TransactionResponse> {
169
- let msgSender: string = await this._networkConnection.signer!.getAddress();
170
- return this.redeem(msgSender, amount);
171
- }
172
- }
173
-
174
- export class Papermill extends BlockchainEntity {
175
- constructor() {
176
- super();
177
- }
178
- public read(networkConnection: NetworkConnection): PapermillRead {
179
- return new PapermillRead(networkConnection);
180
- }
181
-
182
- public readWrite(networkConnection: NetworkConnection): PapermillReadWrite {
183
- return new PapermillReadWrite(networkConnection);
184
- }
185
- }
@@ -1,172 +0,0 @@
1
- import { TransactionResponse } from '@ethersproject/abstract-provider';
2
- import { BigNumber as BN } from 'ethers';
3
- import * as consts from '../consts';
4
- import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from '../entities';
5
- import * as helpers from '../helpers';
6
- import { getBlocksTimestamp, isSameAddress, sleep, sortEvents } from '../helpers';
7
- import * as AuriAPI from '../helpers/aurigami-api';
8
- import {
9
- Address,
10
- NetworkConnection,
11
- PlyBetMadeEvent,
12
- PlyGameBetResult,
13
- PlyGameLeaderboardItem,
14
- } from '../types';
15
-
16
- export class PlyGameRead extends BlockchainEntityRead {
17
- public readonly plyToken: Token;
18
- public readonly pulpToken: Token;
19
- public readonly env: AuriEnv;
20
-
21
- public constructor(networkConnection: NetworkConnection) {
22
- super(networkConnection);
23
- this.env = new AuriEnv(networkConnection);
24
-
25
- let plyAddress = consts.networkAddresses.tokens.PLY;
26
- let pulpAddress = consts.networkAddresses.tokens.PULP;
27
- this.plyToken = new Token(plyAddress, helpers.getDecimal(plyAddress));
28
- this.pulpToken = new Token(pulpAddress, helpers.getDecimal(pulpAddress));
29
- }
30
-
31
- private parseBetMakeEvent(event: PlyBetMadeEvent): PlyGameBetResult {
32
- let outcome = ['bigWin', 'win', 'lose', 'noImpact'][event.args.outcome];
33
- let betAmount = event.args.amount;
34
- // 0%, 0%, 100%, 2%
35
- // big win, win, lose, no impact
36
- let lostAmount = betAmount.mul([0, 0, 100, 2][event.args.outcome]).div(100);
37
- let unlock = betAmount.mul([10, 1, 0, 0][event.args.outcome]);
38
- return {
39
- player: event.args.player,
40
- lostAmount: new TokenAmount(this.plyToken, lostAmount.toString()),
41
- unlockedPulpAmount: new TokenAmount(this.pulpToken, unlock.toString()),
42
- outcome: outcome,
43
- transactionHash: event.transactionHash,
44
- block: event.blockNumber,
45
- timestamp: 0, // will be filled later
46
- };
47
- }
48
-
49
- private async attachTimestamp(results: PlyGameBetResult[]): Promise<PlyGameBetResult[]> {
50
- let blockNumbers = results.map((e) => e.block);
51
- let blockstimestamp = await getBlocksTimestamp(this._networkConnection.provider, blockNumbers);
52
- return results.map((e, i) => ({ ...e, timestamp: blockstimestamp[i] }));
53
- }
54
-
55
- /**
56
- * Get 100 most recent bets of the market users
57
- */
58
- public async getUserPlyGameHistory(user: Address): Promise<PlyGameBetResult[]> {
59
- let block100 = await this.env.plygame.getLastBlock(user, 100);
60
-
61
- if (block100.eq(0)) {
62
- return [];
63
- }
64
-
65
- let filter = this.env.plygame.filters.BetMade(user);
66
- let events = await this.env.plygame.queryFilter(filter, block100.toNumber());
67
- // Sort descending by block number
68
- sortEvents(events).reverse();
69
- return this.attachTimestamp(events.map((event) => this.parseBetMakeEvent(event)));
70
- }
71
-
72
- /**
73
- * Get current jackpot amount
74
- */
75
- public async currentJackpotAmount(): Promise<TokenAmount> {
76
- let jackpot = await this.env.plygame.currentJackpotAmount();
77
- return new TokenAmount(this.plyToken, jackpot.toString());
78
- }
79
-
80
- public async earlyUnlockedPulpAmount(user: Address): Promise<TokenAmount> {
81
- let earlyUnlockedPulpAmount = await this.env.plygame.totalPlyUnlockedEarly(user);
82
- return new TokenAmount(this.pulpToken, earlyUnlockedPulpAmount.toString());
83
- }
84
-
85
- public async getPlyGameResultsInTransaction(txHash: Address): Promise<PlyGameBetResult[]> {
86
- // wait for the tx to be mined if needed.
87
- // Don't use `waitForTransaction` because it will wait for longer than needed.
88
- let tx = await this._networkConnection.provider.getTransactionReceipt(txHash);
89
-
90
- for (let i = 0; i < 100 && !tx; i++) {
91
- await sleep(1000); // Sleep for 1 second before retrying
92
- tx = await this._networkConnection.provider.getTransactionReceipt(txHash);
93
- }
94
-
95
- if (!tx) {
96
- throw new Error(`Transaction ${txHash} takes too long to be mined`);
97
- }
98
-
99
- let filter = this.env.plygame.filters.BetMade();
100
- let betMadeEvents: PlyBetMadeEvent[] = tx.logs
101
- .filter((log) => isSameAddress(log.topics[0], filter.topics![0] as string))
102
- .map((log) => ({
103
- ...this.env.plygame.interface.parseLog(log),
104
- blockNumber: tx.blockNumber,
105
- transactionHash: txHash,
106
- })) as unknown as PlyBetMadeEvent[];
107
-
108
- return this.attachTimestamp(betMadeEvents.map((e) => this.parseBetMakeEvent(e)));
109
- }
110
-
111
- /**
112
- * Top 100 users by amount of PULP unlocked
113
- */
114
- public async leaderboard(): Promise<PlyGameLeaderboardItem[]> {
115
- const result = await AuriAPI.getPaginatedApi('/plygame/leaderboard');
116
- return result.items.map((item, i) => ({
117
- player: item.user!,
118
- unlockedPulpAmount: new TokenAmount(this.pulpToken, item.unlockedAmount!),
119
- gamesPlayed: item.count!,
120
- }));
121
- }
122
-
123
- public async getLastJackpotResult(): Promise<{ winner: Address; amount: TokenAmount }> {
124
- // 158 is the storage slot of the jackpot length
125
- let round = BN.from(
126
- await this._networkConnection.provider.getStorageAt(this.env.plygame.address, 158)
127
- );
128
- let result = await this.env.plygame.jackpotHistory(round.sub(1));
129
- return {
130
- winner: result.winner.slice(0, 5) + '...' + result.winner.slice(-3),
131
- amount: new TokenAmount(this.plyToken, result.amount.toString()),
132
- };
133
- }
134
-
135
- public async overallLeaderboard(): Promise<PlyGameLeaderboardItem[]> {
136
- const result = await AuriAPI.getPaginatedApi('/plygame/overallLeaderboard');
137
- return result.items.map((item) => ({
138
- player: item.user,
139
- unlockedPulpAmount: new TokenAmount(this.pulpToken, item.unlockedAmount!),
140
- gamesPlayed: item.count!,
141
- }));
142
- }
143
- }
144
-
145
- export class PlyGameReadWrite extends PlyGameRead {
146
- /**
147
- * Make a single bet
148
- */
149
- public async makeBetOnce(amount: TokenAmount): Promise<TransactionResponse> {
150
- return this.env.plygame
151
- .connect(this._networkConnection.signer!)
152
- .makeBetOnce(amount.rawAmount());
153
- }
154
-
155
- public async approve(amount: TokenAmount): Promise<TransactionResponse> {
156
- return this.env.ply
157
- .connect(this._networkConnection.signer!)
158
- .approve(this.env.plygame.address, amount.rawAmount());
159
- }
160
- }
161
-
162
- export class PlyGame extends BlockchainEntity {
163
- constructor() {
164
- super();
165
- }
166
- public read(networkConnection: NetworkConnection): PlyGameRead {
167
- return new PlyGameRead(networkConnection);
168
- }
169
- public readWrite(networkConnection: NetworkConnection): PlyGameReadWrite {
170
- return new PlyGameReadWrite(networkConnection);
171
- }
172
- }
@@ -1,47 +0,0 @@
1
- import { TransactionResponse } from '@ethersproject/abstract-provider';
2
- import { BigNumber as BN, utils } from 'ethers';
3
- import {
4
- AuriEnv,
5
- BlockchainEntity,
6
- BlockchainEntityRead,
7
- PLYToken,
8
- Token,
9
- TokenAmount,
10
- } from '../entities';
11
- import * as helpers from '../helpers';
12
- import { Address, NetworkConnection } from '../types';
13
-
14
- export class PlyTokenLockRead extends BlockchainEntityRead {
15
- public readonly env: AuriEnv;
16
-
17
- public constructor(networkConnection: NetworkConnection) {
18
- super(networkConnection);
19
- this.env = new AuriEnv(networkConnection);
20
- }
21
-
22
- public async getClaimableAmount(recipient: Address): Promise<TokenAmount> {
23
- const claimableAmount = await this.env.plyTokenLock.callStatic.claimableBalance(recipient);
24
- return new TokenAmount(new Token(PLYToken.address, 18), claimableAmount.toString(), true);
25
- }
26
- }
27
-
28
- export class PlyTokenLockReadWrite extends PlyTokenLockRead {
29
- public async claim(recipient: Address, amount: TokenAmount): Promise<TransactionResponse> {
30
- const amountToClaim = BN.from(amount.rawAmount());
31
- return await this.env.plyTokenLock
32
- .connect(this._networkConnection.signer!)
33
- .claim(recipient, amountToClaim);
34
- }
35
- }
36
-
37
- export class PlyTokenLock extends BlockchainEntity {
38
- constructor() {
39
- super();
40
- }
41
- public read(networkConnection: NetworkConnection): PlyTokenLockRead {
42
- return new PlyTokenLockRead(networkConnection);
43
- }
44
- public readWrite(networkConnection: NetworkConnection): PlyTokenLockReadWrite {
45
- return new PlyTokenLockReadWrite(networkConnection);
46
- }
47
- }
@@ -1,39 +0,0 @@
1
- import { TransactionResponse } from '@ethersproject/abstract-provider';
2
- import { BigNumber as BN } from 'ethers';
3
- import { AuriEnv, BlockchainEntity, BlockchainEntityRead, TokenAmount } from '../entities';
4
- import { Address, NetworkConnection } from '../types';
5
-
6
- export class PulpRead extends BlockchainEntityRead {
7
- public readonly env: AuriEnv;
8
-
9
- public constructor(networkConnection: NetworkConnection) {
10
- super(networkConnection);
11
- this.env = new AuriEnv(networkConnection);
12
- }
13
-
14
- public async remainingEarlyUnlockPulp(user: Address): Promise<BN> {
15
- return this.env.pulp.earlyRedeems(user);
16
- }
17
- }
18
-
19
- export class PulpReadWrite extends PulpRead {
20
- public async convertEarlyPulp(
21
- recipient: Address,
22
- amount: TokenAmount
23
- ): Promise<TransactionResponse> {
24
- const amountToRedeem = BN.from(amount.rawAmount());
25
- return this.env.pulp.connect(this._networkConnection.signer!).redeem(recipient, amountToRedeem);
26
- }
27
- }
28
-
29
- export class Pulp extends BlockchainEntity {
30
- constructor() {
31
- super();
32
- }
33
- public read(networkConnection: NetworkConnection): PulpRead {
34
- return new PulpRead(networkConnection);
35
- }
36
- public readWrite(networkConnection: NetworkConnection): PulpReadWrite {
37
- return new PulpReadWrite(networkConnection);
38
- }
39
- }