@aurigami/sdk 1.6.0-no-src → 1.6.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 +9 -0
- package/dist/contracts/Multicall.d.ts +18 -0
- package/dist/contracts/Papermill.d.ts +8 -0
- package/dist/sdk.cjs.development.js +102841 -40
- 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 +102841 -40
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +4 -3
- package/src/SDK.ts +430 -0
- package/src/abis/Faucet.json +157 -0
- package/src/abis/IUniswapV2Pair.json +663 -0
- package/src/abis/Oracle.json +247 -0
- package/src/abis/dummy.json +3 -0
- package/src/consts/constants.ts +146 -0
- package/src/consts/decimals.ts +24 -0
- package/src/consts/deployments.ts +4 -0
- package/src/consts/dummy.ts +38 -0
- package/src/consts/index.ts +4 -0
- package/src/contracts/MoneyMarket.ts +510 -0
- package/src/contracts/Multicall.ts +55 -0
- package/src/contracts/Papermill.ts +271 -0
- package/src/contracts/Staking.ts +183 -0
- package/src/contracts/airdrop-lottery.ts +320 -0
- package/src/contracts/index.ts +4 -0
- package/src/entities/BlockchainEntity.ts +33 -0
- package/src/entities/index.ts +3 -0
- package/src/entities/token.ts +21 -0
- package/src/entities/tokenAmount.ts +42 -0
- package/src/helpers/aurora-api-helpers.ts +20 -0
- package/src/helpers/helpers.ts +97 -0
- package/src/helpers/index.ts +4 -0
- package/src/helpers/priceFetcher.ts +317 -0
- package/src/helpers/transfer-event-query.ts +70 -0
- package/src/index.ts +13 -0
- package/src/misc/airdrop_misc/auTokensInfo.json +34 -0
- package/src/misc/airdrop_misc/whitelist.json +102629 -0
- package/src/types/index.ts +106 -0
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.
|
|
2
|
+
"version": "1.6.1",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
7
|
-
"dist"
|
|
7
|
+
"dist",
|
|
8
|
+
"src"
|
|
8
9
|
],
|
|
9
10
|
"engines": {
|
|
10
11
|
"node": ">=10"
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
"typescript": "^4.5.4"
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@aurigami/contracts": "3.
|
|
63
|
+
"@aurigami/contracts": "3.4.0",
|
|
63
64
|
"axios": "^0.26.1",
|
|
64
65
|
"bignumber.js": "^9.0.2",
|
|
65
66
|
"dotenv": "^16.0.0",
|
package/src/SDK.ts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import AuriFairLaunchABI from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
|
|
2
|
+
import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
|
|
3
|
+
import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
4
|
+
import FaucetABI from '@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json';
|
|
5
|
+
import EIP20InterfaceABI from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
|
|
6
|
+
import {
|
|
7
|
+
AuriFairLaunch,
|
|
8
|
+
AuriLens,
|
|
9
|
+
Comptroller,
|
|
10
|
+
IERC20,
|
|
11
|
+
} from '@aurigami/contracts/typechain';
|
|
12
|
+
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
13
|
+
import BigNumber from 'bignumber.js';
|
|
14
|
+
import { BigNumber as BN, Contract } from 'ethers';
|
|
15
|
+
import * as consts from './consts';
|
|
16
|
+
import {
|
|
17
|
+
MoneyMarketRead,
|
|
18
|
+
PapermillRead,
|
|
19
|
+
StakingRead,
|
|
20
|
+
StakingReadWrite,
|
|
21
|
+
} from './contracts';
|
|
22
|
+
import {
|
|
23
|
+
BlockchainEntity,
|
|
24
|
+
BlockchainEntityRead,
|
|
25
|
+
PLYToken,
|
|
26
|
+
Token,
|
|
27
|
+
TokenAmount,
|
|
28
|
+
} from './entities';
|
|
29
|
+
import { decimalFactor, isSameAddress } from './helpers/helpers';
|
|
30
|
+
import { calcValuation, fetchPrice } from './helpers/priceFetcher';
|
|
31
|
+
import * as types from './types';
|
|
32
|
+
import { MulticallRead } from './contracts/Multicall';
|
|
33
|
+
|
|
34
|
+
export class SdkRead extends BlockchainEntityRead {
|
|
35
|
+
protected _comptroller: Comptroller;
|
|
36
|
+
protected _auriFairLaunch: AuriFairLaunch;
|
|
37
|
+
protected _auriLens: AuriLens;
|
|
38
|
+
protected _stakingRead: StakingRead;
|
|
39
|
+
constructor(networkConnection: types.NetworkConnection) {
|
|
40
|
+
super(networkConnection);
|
|
41
|
+
this._stakingRead = new StakingRead(networkConnection);
|
|
42
|
+
this._comptroller = new Contract(
|
|
43
|
+
consts.networkAddresses.misc.COMPTROLLER,
|
|
44
|
+
ComptrollerABI.abi,
|
|
45
|
+
networkConnection.provider
|
|
46
|
+
) as Comptroller;
|
|
47
|
+
this._auriFairLaunch = new Contract(
|
|
48
|
+
consts.networkAddresses.misc.AURIFAIRLAUNCH,
|
|
49
|
+
AuriFairLaunchABI.abi,
|
|
50
|
+
networkConnection.provider
|
|
51
|
+
) as AuriFairLaunch;
|
|
52
|
+
this._auriLens = new Contract(
|
|
53
|
+
consts.networkAddresses.misc.AURILENS,
|
|
54
|
+
AuriLensABI.abi,
|
|
55
|
+
networkConnection.provider
|
|
56
|
+
) as AuriLens;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public async getUserDetails(userAddress: string): Promise<types.UserDetails> {
|
|
60
|
+
const marketCount = consts.networkAddresses.auTokens.length;
|
|
61
|
+
var userMarketDetails: types.UserMarketDetails[] = [],
|
|
62
|
+
assetsIn: string[];
|
|
63
|
+
var promises = [];
|
|
64
|
+
var totalBorrowLimit = new BigNumber(0);
|
|
65
|
+
var pricePromises = [];
|
|
66
|
+
for (const auToken of consts.networkAddresses.auTokens) {
|
|
67
|
+
const userMarketDetail: types.UserMarketDetails =
|
|
68
|
+
{} as types.UserMarketDetails;
|
|
69
|
+
userMarketDetails.push(userMarketDetail);
|
|
70
|
+
userMarketDetail.market = auToken.underlying;
|
|
71
|
+
const moneyMarket: MoneyMarketRead = new MoneyMarketRead(
|
|
72
|
+
this._networkConnection,
|
|
73
|
+
auToken.address,
|
|
74
|
+
auToken.underlying
|
|
75
|
+
);
|
|
76
|
+
promises.push(
|
|
77
|
+
moneyMarket
|
|
78
|
+
.getUserDepositBalance(userAddress)
|
|
79
|
+
.then((res: TokenAmount) => {
|
|
80
|
+
userMarketDetail.depositBalance = res;
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
promises.push(
|
|
84
|
+
moneyMarket
|
|
85
|
+
.getUserBorrowBalance(userAddress)
|
|
86
|
+
.then((res: TokenAmount) => {
|
|
87
|
+
userMarketDetail.borrowBalance = res;
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
promises.push(
|
|
91
|
+
moneyMarket.getCollateralRatio().then((res: BigNumber) => {
|
|
92
|
+
userMarketDetail.collateralRatio = res.toNumber();
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
pricePromises.push(
|
|
96
|
+
fetchPrice(
|
|
97
|
+
moneyMarket.underlying.address,
|
|
98
|
+
this._networkConnection.provider
|
|
99
|
+
).then((res) => {
|
|
100
|
+
userMarketDetail.underlyingPrice = res.toString();
|
|
101
|
+
return res;
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
promises.push(
|
|
107
|
+
this._comptroller.getAssetsIn(userAddress).then((res: string[]) => {
|
|
108
|
+
assetsIn = res;
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
await Promise.all(promises);
|
|
113
|
+
var underlyingPrices = await Promise.all(pricePromises);
|
|
114
|
+
var depositValues = [];
|
|
115
|
+
for (var i = 0; i < marketCount; i++) {
|
|
116
|
+
const auToken = consts.networkAddresses.auTokens[i];
|
|
117
|
+
if (
|
|
118
|
+
assetsIn!.find((auAddress: types.Address) =>
|
|
119
|
+
isSameAddress(auToken.address, auAddress)
|
|
120
|
+
) !== undefined
|
|
121
|
+
) {
|
|
122
|
+
userMarketDetails[i].isCollateral = true;
|
|
123
|
+
} else {
|
|
124
|
+
userMarketDetails[i].isCollateral = false;
|
|
125
|
+
}
|
|
126
|
+
depositValues.push(
|
|
127
|
+
calcValuation(userMarketDetails[i].depositBalance, underlyingPrices[i])
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
totalBorrowLimit = depositValues.reduce(
|
|
132
|
+
(p: BigNumber, v: BigNumber, index: number) => {
|
|
133
|
+
if (userMarketDetails[index].isCollateral)
|
|
134
|
+
return p.plus(
|
|
135
|
+
v.multipliedBy(userMarketDetails[index].collateralRatio)
|
|
136
|
+
);
|
|
137
|
+
return p;
|
|
138
|
+
},
|
|
139
|
+
new BigNumber(0)
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
var accountLiquidity: [BN, BN] =
|
|
143
|
+
await this._comptroller.getAccountLiquidity(userAddress);
|
|
144
|
+
|
|
145
|
+
var borrowedvaluation: BigNumber = totalBorrowLimit.minus(
|
|
146
|
+
new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18))
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
if (borrowedvaluation.lt('0.00001')) {
|
|
150
|
+
// Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
|
|
151
|
+
borrowedvaluation = new BigNumber(0);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const bufferedBorrowLimit: BigNumber = totalBorrowLimit.multipliedBy(
|
|
155
|
+
consts.BORROW_LIMIT_BUFFER
|
|
156
|
+
);
|
|
157
|
+
const minimumBorrowLimitAllowed = borrowedvaluation.div(
|
|
158
|
+
consts.BORROW_LIMIT_BUFFER
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
var borrowableAmount: BigNumber;
|
|
162
|
+
if (bufferedBorrowLimit.lte(borrowedvaluation)) {
|
|
163
|
+
borrowableAmount = new BigNumber(0);
|
|
164
|
+
} else {
|
|
165
|
+
borrowableAmount = bufferedBorrowLimit.minus(borrowedvaluation);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
for (var i = 0; i < marketCount; i++) {
|
|
169
|
+
const auToken = consts.networkAddresses.auTokens[i];
|
|
170
|
+
const moneyMarket: MoneyMarketRead = new MoneyMarketRead(
|
|
171
|
+
this._networkConnection,
|
|
172
|
+
auToken.address,
|
|
173
|
+
auToken.underlying
|
|
174
|
+
);
|
|
175
|
+
const borrowLimitMargin = totalBorrowLimit
|
|
176
|
+
.minus(minimumBorrowLimitAllowed)
|
|
177
|
+
.gt(0)
|
|
178
|
+
? totalBorrowLimit.minus(minimumBorrowLimitAllowed)
|
|
179
|
+
: new BigNumber(0);
|
|
180
|
+
const maxWithdrawCap: BigNumber = borrowLimitMargin
|
|
181
|
+
.div(userMarketDetails[i].collateralRatio)
|
|
182
|
+
.div(underlyingPrices[i]);
|
|
183
|
+
userMarketDetails[i].maxWithdrawableAmount =
|
|
184
|
+
userMarketDetails[i].isCollateral &&
|
|
185
|
+
maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount())
|
|
186
|
+
? new TokenAmount(
|
|
187
|
+
moneyMarket.underlying,
|
|
188
|
+
maxWithdrawCap.toFixed(24),
|
|
189
|
+
false
|
|
190
|
+
)
|
|
191
|
+
: new TokenAmount(
|
|
192
|
+
moneyMarket.underlying,
|
|
193
|
+
userMarketDetails[i].depositBalance.rawAmount()
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
markets: userMarketDetails,
|
|
199
|
+
borrowLimit: {
|
|
200
|
+
currency: 'USD',
|
|
201
|
+
amount: bufferedBorrowLimit.toFixed(consts.DECIMAL_PRECISION),
|
|
202
|
+
},
|
|
203
|
+
userLockingDetails: await new PapermillRead(
|
|
204
|
+
this._networkConnection
|
|
205
|
+
).getLockingDetails(userAddress),
|
|
206
|
+
borrowableAmount: {
|
|
207
|
+
currency: 'USD',
|
|
208
|
+
amount: borrowableAmount.toFixed(consts.DECIMAL_PRECISION),
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public async getPLYWNEARPoolDetails(): Promise<types.PLYWNEARPoolDetails> {
|
|
214
|
+
return this._stakingRead.getPLYWNEARPoolDetails();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public async getTokenPrice(token: Token): Promise<types.CurrencyAmount> {
|
|
218
|
+
const price = await fetchPrice(
|
|
219
|
+
token.address,
|
|
220
|
+
this._networkConnection.provider
|
|
221
|
+
);
|
|
222
|
+
return {
|
|
223
|
+
currency: 'USD',
|
|
224
|
+
amount: price.toFixed(consts.DECIMAL_PRECISION),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Get amount of staked LP tokens
|
|
230
|
+
*/
|
|
231
|
+
public async stakeBalanceOf(user: string): Promise<TokenAmount> {
|
|
232
|
+
return this._stakingRead.stakeBalanceOf(user);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Get amount of LP token in user wallet
|
|
237
|
+
*/
|
|
238
|
+
public async LpBalanceOf(user: string): Promise<TokenAmount> {
|
|
239
|
+
return this._stakingRead.LpBalanceOf(user);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public async unclaimedRewardsOf(user: string): Promise<TokenAmount[]> {
|
|
243
|
+
return this._stakingRead.unclaimedRewardsOf(user);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public calcHypotheticalStats({
|
|
247
|
+
userMarketDetail,
|
|
248
|
+
currentBorrowLimit,
|
|
249
|
+
currentBorrowValuation,
|
|
250
|
+
action,
|
|
251
|
+
tokenAmount,
|
|
252
|
+
}: {
|
|
253
|
+
userMarketDetail: types.UserMarketDetails;
|
|
254
|
+
currentBorrowLimit: types.CurrencyAmount;
|
|
255
|
+
currentBorrowValuation: types.CurrencyAmount;
|
|
256
|
+
action: types.MarketAction;
|
|
257
|
+
tokenAmount?: TokenAmount;
|
|
258
|
+
}): types.HypotheticalStats {
|
|
259
|
+
var newBorrowLimit = new BigNumber(currentBorrowLimit.amount),
|
|
260
|
+
newBorrowValuation = new BigNumber(currentBorrowValuation.amount);
|
|
261
|
+
switch (action) {
|
|
262
|
+
case types.MarketAction.EnableCollateral:
|
|
263
|
+
case types.MarketAction.DisableCollateral:
|
|
264
|
+
var deltaBorrowLimit = calcValuation(
|
|
265
|
+
userMarketDetail.depositBalance,
|
|
266
|
+
new BigNumber(userMarketDetail.underlyingPrice)
|
|
267
|
+
)
|
|
268
|
+
.multipliedBy(userMarketDetail.collateralRatio)
|
|
269
|
+
.multipliedBy(consts.BORROW_LIMIT_BUFFER);
|
|
270
|
+
newBorrowLimit =
|
|
271
|
+
action == types.MarketAction.EnableCollateral
|
|
272
|
+
? newBorrowLimit.plus(deltaBorrowLimit)
|
|
273
|
+
: newBorrowLimit.minus(deltaBorrowLimit);
|
|
274
|
+
break;
|
|
275
|
+
|
|
276
|
+
case types.MarketAction.Deposit:
|
|
277
|
+
case types.MarketAction.Withdraw:
|
|
278
|
+
deltaBorrowLimit = calcValuation(
|
|
279
|
+
tokenAmount!,
|
|
280
|
+
new BigNumber(userMarketDetail.underlyingPrice)
|
|
281
|
+
)
|
|
282
|
+
.multipliedBy(userMarketDetail.collateralRatio)
|
|
283
|
+
.multipliedBy(consts.BORROW_LIMIT_BUFFER);
|
|
284
|
+
newBorrowLimit =
|
|
285
|
+
action == types.MarketAction.Deposit
|
|
286
|
+
? newBorrowLimit.plus(deltaBorrowLimit)
|
|
287
|
+
: newBorrowLimit.minus(deltaBorrowLimit);
|
|
288
|
+
break;
|
|
289
|
+
|
|
290
|
+
case types.MarketAction.Borrow:
|
|
291
|
+
case types.MarketAction.Repay:
|
|
292
|
+
var deltaBorrowValuation = calcValuation(
|
|
293
|
+
tokenAmount!,
|
|
294
|
+
new BigNumber(userMarketDetail.underlyingPrice)
|
|
295
|
+
);
|
|
296
|
+
newBorrowValuation =
|
|
297
|
+
action == types.MarketAction.Borrow
|
|
298
|
+
? newBorrowValuation.plus(deltaBorrowValuation)
|
|
299
|
+
: newBorrowValuation.minus(deltaBorrowValuation);
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
newBorrowLimit: {
|
|
304
|
+
amount: newBorrowLimit!.toFixed(consts.DECIMAL_PRECISION),
|
|
305
|
+
currency: 'USD',
|
|
306
|
+
},
|
|
307
|
+
newBorrowUtilization: newBorrowLimit.eq(0)
|
|
308
|
+
? newBorrowValuation.eq(0)
|
|
309
|
+
? 0
|
|
310
|
+
: 9999.99
|
|
311
|
+
: newBorrowValuation!.div(newBorrowLimit!).toNumber(),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Get ply circulating supply.
|
|
317
|
+
* It is calculated by the total supply, minus:
|
|
318
|
+
* - Ply in team multisig contract
|
|
319
|
+
* - Ply in comptroller contract
|
|
320
|
+
* - Ply in fairlaunch contract
|
|
321
|
+
* - Ply in vesting contract
|
|
322
|
+
*/
|
|
323
|
+
public async getPlyCirculatingSupply(): Promise<TokenAmount> {
|
|
324
|
+
const plyContract: IERC20 = new Contract(
|
|
325
|
+
consts.networkAddresses.tokens.PLY,
|
|
326
|
+
EIP20InterfaceABI.abi,
|
|
327
|
+
this._networkConnection.provider
|
|
328
|
+
) as IERC20;
|
|
329
|
+
|
|
330
|
+
const multicallRead = new MulticallRead(this._networkConnection);
|
|
331
|
+
const baseBalanceOfCall = {
|
|
332
|
+
contract: plyContract,
|
|
333
|
+
method: 'balanceOf',
|
|
334
|
+
returnTypes: ['uint256'],
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const callResults = (await multicallRead.aggregate([
|
|
338
|
+
// Get total supply
|
|
339
|
+
{
|
|
340
|
+
...baseBalanceOfCall,
|
|
341
|
+
method: 'totalSupply',
|
|
342
|
+
args: [],
|
|
343
|
+
},
|
|
344
|
+
// balance in team multisig
|
|
345
|
+
{
|
|
346
|
+
...baseBalanceOfCall,
|
|
347
|
+
args: [consts.networkAddresses.misc.TEAM_MULTISIG],
|
|
348
|
+
},
|
|
349
|
+
// balance in comptroller
|
|
350
|
+
{
|
|
351
|
+
...baseBalanceOfCall,
|
|
352
|
+
args: [consts.networkAddresses.misc.COMPTROLLER],
|
|
353
|
+
},
|
|
354
|
+
// balance in fair launch
|
|
355
|
+
{
|
|
356
|
+
...baseBalanceOfCall,
|
|
357
|
+
args: [consts.networkAddresses.misc.AURIFAIRLAUNCH],
|
|
358
|
+
},
|
|
359
|
+
// balance in vesting contract
|
|
360
|
+
{
|
|
361
|
+
...baseBalanceOfCall,
|
|
362
|
+
args: [consts.networkAddresses.misc.PLY_TOKEN_LOCK],
|
|
363
|
+
},
|
|
364
|
+
])) as BN[][];
|
|
365
|
+
let circulatingSupply: BN = BN.from(0);
|
|
366
|
+
callResults.forEach((result, i) => {
|
|
367
|
+
if (i === 0) {
|
|
368
|
+
circulatingSupply = result[0];
|
|
369
|
+
} else {
|
|
370
|
+
circulatingSupply = circulatingSupply.sub(result[0]);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
return new TokenAmount(PLYToken, circulatingSupply.toString());
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export class SdkReadWrite extends SdkRead {
|
|
379
|
+
/**
|
|
380
|
+
* Claim PLY reward in all markets + staking pools
|
|
381
|
+
*/
|
|
382
|
+
public async claim(): Promise<TransactionResponse> {
|
|
383
|
+
return this._comptroller
|
|
384
|
+
.connect(this._networkConnection.signer!)
|
|
385
|
+
['claimReward(uint8,address)'](
|
|
386
|
+
0,
|
|
387
|
+
await this._networkConnection.signer!.getAddress()
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
public async claimLpRewards(): Promise<TransactionResponse> {
|
|
392
|
+
return this._auriFairLaunch
|
|
393
|
+
.connect(this._networkConnection.signer!)
|
|
394
|
+
.harvest(
|
|
395
|
+
await this._networkConnection.signer!.getAddress(),
|
|
396
|
+
0,
|
|
397
|
+
consts.INF
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
public async stake(amount: TokenAmount): Promise<TransactionResponse> {
|
|
402
|
+
return new StakingReadWrite(this._networkConnection).stake(amount);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
public async unstake(amount: TokenAmount): Promise<TransactionResponse> {
|
|
406
|
+
return new StakingReadWrite(this._networkConnection).unstake(amount);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public async faucetDrip(): Promise<TransactionResponse> {
|
|
410
|
+
const faucet = new Contract(
|
|
411
|
+
consts.networkAddresses.misc.FAUCET,
|
|
412
|
+
FaucetABI.abi,
|
|
413
|
+
this._networkConnection.provider
|
|
414
|
+
);
|
|
415
|
+
return faucet.connect(this._networkConnection.signer!).drip();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export class SDK extends BlockchainEntity {
|
|
420
|
+
constructor() {
|
|
421
|
+
super();
|
|
422
|
+
}
|
|
423
|
+
public read(networkConnection: types.NetworkConnection): SdkRead {
|
|
424
|
+
return new SdkRead(networkConnection);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
public readWrite(networkConnection: types.NetworkConnection): SdkReadWrite {
|
|
428
|
+
return new SdkReadWrite(networkConnection);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "Faucet",
|
|
4
|
+
"sourceName": "contracts/mock/Faucet.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"components": [
|
|
10
|
+
{
|
|
11
|
+
"internalType": "address",
|
|
12
|
+
"name": "token",
|
|
13
|
+
"type": "address"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"internalType": "uint256",
|
|
17
|
+
"name": "dripAmount",
|
|
18
|
+
"type": "uint256"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"internalType": "struct Faucet.TokenConfig[]",
|
|
22
|
+
"name": "_testTokensConfigs",
|
|
23
|
+
"type": "tuple[]"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"stateMutability": "nonpayable",
|
|
27
|
+
"type": "constructor"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"anonymous": false,
|
|
31
|
+
"inputs": [
|
|
32
|
+
{
|
|
33
|
+
"indexed": true,
|
|
34
|
+
"internalType": "address",
|
|
35
|
+
"name": "previousOwner",
|
|
36
|
+
"type": "address"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"indexed": true,
|
|
40
|
+
"internalType": "address",
|
|
41
|
+
"name": "newOwner",
|
|
42
|
+
"type": "address"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"name": "OwnershipTransferred",
|
|
46
|
+
"type": "event"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"inputs": [],
|
|
50
|
+
"name": "drip",
|
|
51
|
+
"outputs": [],
|
|
52
|
+
"stateMutability": "nonpayable",
|
|
53
|
+
"type": "function"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"inputs": [
|
|
57
|
+
{
|
|
58
|
+
"internalType": "address",
|
|
59
|
+
"name": "",
|
|
60
|
+
"type": "address"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"name": "dripAmounts",
|
|
64
|
+
"outputs": [
|
|
65
|
+
{
|
|
66
|
+
"internalType": "uint256",
|
|
67
|
+
"name": "",
|
|
68
|
+
"type": "uint256"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"stateMutability": "view",
|
|
72
|
+
"type": "function"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"inputs": [],
|
|
76
|
+
"name": "owner",
|
|
77
|
+
"outputs": [
|
|
78
|
+
{
|
|
79
|
+
"internalType": "address",
|
|
80
|
+
"name": "",
|
|
81
|
+
"type": "address"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"stateMutability": "view",
|
|
85
|
+
"type": "function"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"inputs": [],
|
|
89
|
+
"name": "renounceOwnership",
|
|
90
|
+
"outputs": [],
|
|
91
|
+
"stateMutability": "nonpayable",
|
|
92
|
+
"type": "function"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"inputs": [
|
|
96
|
+
{
|
|
97
|
+
"internalType": "uint256",
|
|
98
|
+
"name": "",
|
|
99
|
+
"type": "uint256"
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"name": "testTokens",
|
|
103
|
+
"outputs": [
|
|
104
|
+
{
|
|
105
|
+
"internalType": "address",
|
|
106
|
+
"name": "",
|
|
107
|
+
"type": "address"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"stateMutability": "view",
|
|
111
|
+
"type": "function"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"inputs": [
|
|
115
|
+
{
|
|
116
|
+
"internalType": "address",
|
|
117
|
+
"name": "newOwner",
|
|
118
|
+
"type": "address"
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"name": "transferOwnership",
|
|
122
|
+
"outputs": [],
|
|
123
|
+
"stateMutability": "nonpayable",
|
|
124
|
+
"type": "function"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"inputs": [
|
|
128
|
+
{
|
|
129
|
+
"components": [
|
|
130
|
+
{
|
|
131
|
+
"internalType": "address",
|
|
132
|
+
"name": "token",
|
|
133
|
+
"type": "address"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"internalType": "uint256",
|
|
137
|
+
"name": "dripAmount",
|
|
138
|
+
"type": "uint256"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"internalType": "struct Faucet.TokenConfig[]",
|
|
142
|
+
"name": "_testTokensConfigs",
|
|
143
|
+
"type": "tuple[]"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"name": "updateTokenConfigs",
|
|
147
|
+
"outputs": [],
|
|
148
|
+
"stateMutability": "nonpayable",
|
|
149
|
+
"type": "function"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"bytecode": "0x60806040523480156200001157600080fd5b5060405162000c4038038062000c40833981016040819052620000349162000272565b6200003f33620000f9565b60005b8151811015620000f1576200007d82828151811062000065576200006562000363565b6020026020010151600001516200014960201b60201c565b81818151811062000092576200009262000363565b60200260200101516020015160026000848481518110620000b757620000b762000363565b602090810291909101810151516001600160a01b031682528101919091526040016000205580620000e88162000379565b91505062000042565b5050620003a3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b600154811015620001ac57816001600160a01b03166001828154811062000177576200017762000363565b6000918252602090912001546001600160a01b0316141562000197575050565b80620001a38162000379565b9150506200014c565b506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180546001600160a01b0319166001600160a01b0392909216919091179055565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715620002395762000239620001fe565b60405290565b604051601f8201601f191681016001600160401b03811182821017156200026a576200026a620001fe565b604052919050565b600060208083850312156200028657600080fd5b82516001600160401b03808211156200029e57600080fd5b818501915085601f830112620002b357600080fd5b815181811115620002c857620002c8620001fe565b620002d8848260051b016200023f565b818152848101925060069190911b830184019087821115620002f957600080fd5b928401925b81841015620003585760408489031215620003195760008081fd5b6200032362000214565b84516001600160a01b03811681146200033c5760008081fd5b81528486015186820152835260409093019291840191620002fe565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b60006000198214156200039c57634e487b7160e01b600052601160045260246000fd5b5060010190565b61088d80620003b36000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80639f678cca1161005b5780639f678cca146100c9578063b9293286146100d1578063e980416a146100e4578063f2fde38b1461011257600080fd5b8063715018a614610082578063741f83ef1461008c5780638da5cb5b1461009f575b600080fd5b61008a610125565b005b61008a61009a366004610697565b610190565b6000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b61008a61028b565b6100ac6100df36600461076b565b6103a2565b6101046100f2366004610784565b60026020526000908152604090205481565b6040519081526020016100c0565b61008a610120366004610784565b6103cc565b6000546001600160a01b031633146101845760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61018e60006104a7565b565b6000546001600160a01b031633146101ea5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017b565b60005b81518110156102875761021c82828151811061020b5761020b6107a6565b60200260200101516000015161050f565b81818151811061022e5761022e6107a6565b60200260200101516020015160026000848481518110610250576102506107a6565b602090810291909101810151516001600160a01b03168252810191909152604001600020558061027f816107d5565b9150506101ed565b5050565b60005b60015481101561039f57600181815481106102ab576102ab6107a6565b6000918252602082200154600180546001600160a01b039092169263a9059cbb92339260029291879081106102e2576102e26107a6565b6000918252602080832091909101546001600160a01b039081168452908301939093526040918201902054905160e085901b7fffffffff0000000000000000000000000000000000000000000000000000000016815292909116600483015260248201526044016020604051808303816000875af1158015610368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038c9190610835565b5080610397816107d5565b91505061028e565b50565b600181815481106103b257600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031633146104265760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017b565b6001600160a01b0381166104a25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161017b565b61039f815b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b60015481101561056a57816001600160a01b031660018281548110610539576105396107a6565b6000918252602090912001546001600160a01b03161415610558575050565b80610562816107d5565b915050610512565b506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610626576106266105d4565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610673576106736105d4565b604052919050565b80356001600160a01b038116811461069257600080fd5b919050565b600060208083850312156106aa57600080fd5b823567ffffffffffffffff808211156106c257600080fd5b818501915085601f8301126106d657600080fd5b8135818111156106e8576106e86105d4565b6106f6848260051b0161062c565b818152848101925060069190911b83018401908782111561071657600080fd5b928401925b8184101561076057604084890312156107345760008081fd5b61073c610603565b6107458561067b565b8152848601358682015283526040909301929184019161071b565b979650505050505050565b60006020828403121561077d57600080fd5b5035919050565b60006020828403121561079657600080fd5b61079f8261067b565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561082e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561084757600080fd5b8151801515811461079f57600080fdfea26469706673582212200b56248e3867f8c6afaf02091fa7b57d47168960cfdfc133122e492377adaa3264736f6c634300080b0033",
|
|
153
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80639f678cca1161005b5780639f678cca146100c9578063b9293286146100d1578063e980416a146100e4578063f2fde38b1461011257600080fd5b8063715018a614610082578063741f83ef1461008c5780638da5cb5b1461009f575b600080fd5b61008a610125565b005b61008a61009a366004610697565b610190565b6000546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b61008a61028b565b6100ac6100df36600461076b565b6103a2565b6101046100f2366004610784565b60026020526000908152604090205481565b6040519081526020016100c0565b61008a610120366004610784565b6103cc565b6000546001600160a01b031633146101845760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61018e60006104a7565b565b6000546001600160a01b031633146101ea5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017b565b60005b81518110156102875761021c82828151811061020b5761020b6107a6565b60200260200101516000015161050f565b81818151811061022e5761022e6107a6565b60200260200101516020015160026000848481518110610250576102506107a6565b602090810291909101810151516001600160a01b03168252810191909152604001600020558061027f816107d5565b9150506101ed565b5050565b60005b60015481101561039f57600181815481106102ab576102ab6107a6565b6000918252602082200154600180546001600160a01b039092169263a9059cbb92339260029291879081106102e2576102e26107a6565b6000918252602080832091909101546001600160a01b039081168452908301939093526040918201902054905160e085901b7fffffffff0000000000000000000000000000000000000000000000000000000016815292909116600483015260248201526044016020604051808303816000875af1158015610368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038c9190610835565b5080610397816107d5565b91505061028e565b50565b600181815481106103b257600080fd5b6000918252602090912001546001600160a01b0316905081565b6000546001600160a01b031633146104265760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161017b565b6001600160a01b0381166104a25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161017b565b61039f815b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005b60015481101561056a57816001600160a01b031660018281548110610539576105396107a6565b6000918252602090912001546001600160a01b03161415610558575050565b80610562816107d5565b915050610512565b506001805480820182556000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610626576106266105d4565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610673576106736105d4565b604052919050565b80356001600160a01b038116811461069257600080fd5b919050565b600060208083850312156106aa57600080fd5b823567ffffffffffffffff808211156106c257600080fd5b818501915085601f8301126106d657600080fd5b8135818111156106e8576106e86105d4565b6106f6848260051b0161062c565b818152848101925060069190911b83018401908782111561071657600080fd5b928401925b8184101561076057604084890312156107345760008081fd5b61073c610603565b6107458561067b565b8152848601358682015283526040909301929184019161071b565b979650505050505050565b60006020828403121561077d57600080fd5b5035919050565b60006020828403121561079657600080fd5b61079f8261067b565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561082e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b60006020828403121561084757600080fd5b8151801515811461079f57600080fdfea26469706673582212200b56248e3867f8c6afaf02091fa7b57d47168960cfdfc133122e492377adaa3264736f6c634300080b0033",
|
|
154
|
+
"linkReferences": {},
|
|
155
|
+
"deployedLinkReferences": {}
|
|
156
|
+
}
|
|
157
|
+
|