@aurigami/sdk 1.6.6 → 1.6.7
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 +2 -0
- package/dist/abis/index.d.ts +2 -1
- package/dist/contracts/misc.d.ts +1 -1
- package/dist/sdk.cjs.development.js +1404 -1371
- 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 +789 -756
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/SDK.ts +16 -0
- package/src/abis/index.ts +2 -0
- package/src/contracts/misc.ts +4 -2
- package/ChangeLog.md +0 -163
package/dist/sdk.esm.js
CHANGED
|
@@ -4,17 +4,18 @@ import { Logger } from 'ethers/lib/utils';
|
|
|
4
4
|
import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
|
|
5
5
|
export { default as MAINNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_mainnet.json';
|
|
6
6
|
export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
|
|
7
|
-
import abis$
|
|
8
|
-
import abis$
|
|
7
|
+
import abis$6 from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
|
|
8
|
+
import abis$5 from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
|
|
9
9
|
import AuriAirdropABI from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json';
|
|
10
10
|
import abis$1 from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
|
|
11
11
|
import abis$2 from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
|
|
12
12
|
import AuriOracleABI from '@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json';
|
|
13
13
|
import abis from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
14
|
-
import abis$
|
|
14
|
+
import abis$7 from '@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json';
|
|
15
15
|
import abis$3 from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
|
|
16
16
|
import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
|
|
17
|
-
import abis$
|
|
17
|
+
import abis$8 from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
|
|
18
|
+
import abis$a from '@aurigami/contracts/artifacts/contracts/mock/UltilizationHelper.sol/UltilizationHelper.json';
|
|
18
19
|
import abis$4 from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
|
|
19
20
|
import abis$9 from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
|
|
20
21
|
import { Signer } from '@ethersproject/abstract-signer';
|
|
@@ -2200,92 +2201,6 @@ var Airdrop = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
2200
2201
|
return Airdrop;
|
|
2201
2202
|
}(BlockchainEntity);
|
|
2202
2203
|
|
|
2203
|
-
var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2204
|
-
_inheritsLoose(MulticallRead, _BlockchainEntityRead);
|
|
2205
|
-
|
|
2206
|
-
function MulticallRead(networkConnection) {
|
|
2207
|
-
var _this;
|
|
2208
|
-
|
|
2209
|
-
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2210
|
-
_this.multicall = new Contract(networkAddresses.misc.MULTICALL, abis$5.abi, networkConnection.provider);
|
|
2211
|
-
return _this;
|
|
2212
|
-
}
|
|
2213
|
-
/**
|
|
2214
|
-
* Run multiple calls via multicall contract
|
|
2215
|
-
*/
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
var _proto = MulticallRead.prototype;
|
|
2219
|
-
|
|
2220
|
-
_proto.aggregate =
|
|
2221
|
-
/*#__PURE__*/
|
|
2222
|
-
function () {
|
|
2223
|
-
var _aggregate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(calls) {
|
|
2224
|
-
var txns, i, _call$contract$popula, call, txn, response, decodedReturn, _i;
|
|
2225
|
-
|
|
2226
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2227
|
-
while (1) {
|
|
2228
|
-
switch (_context.prev = _context.next) {
|
|
2229
|
-
case 0:
|
|
2230
|
-
txns = []; // prepare transactions
|
|
2231
|
-
|
|
2232
|
-
i = 0;
|
|
2233
|
-
|
|
2234
|
-
case 2:
|
|
2235
|
-
if (!(i < calls.length)) {
|
|
2236
|
-
_context.next = 11;
|
|
2237
|
-
break;
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
call = calls[i];
|
|
2241
|
-
_context.next = 6;
|
|
2242
|
-
return (_call$contract$popula = call.contract.populateTransaction)[call.method].apply(_call$contract$popula, call.args);
|
|
2243
|
-
|
|
2244
|
-
case 6:
|
|
2245
|
-
txn = _context.sent;
|
|
2246
|
-
txns.push({
|
|
2247
|
-
target: txn.to,
|
|
2248
|
-
callData: txn.data
|
|
2249
|
-
});
|
|
2250
|
-
|
|
2251
|
-
case 8:
|
|
2252
|
-
i++;
|
|
2253
|
-
_context.next = 2;
|
|
2254
|
-
break;
|
|
2255
|
-
|
|
2256
|
-
case 11:
|
|
2257
|
-
_context.next = 13;
|
|
2258
|
-
return this.multicall.callStatic.aggregate(txns);
|
|
2259
|
-
|
|
2260
|
-
case 13:
|
|
2261
|
-
response = _context.sent;
|
|
2262
|
-
// parse results
|
|
2263
|
-
decodedReturn = [];
|
|
2264
|
-
|
|
2265
|
-
for (_i = 0; _i < calls.length; _i++) {
|
|
2266
|
-
decodedReturn.push(ethers.utils.defaultAbiCoder.decode(calls[_i].returnTypes, response.returnData[_i]));
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
return _context.abrupt("return", decodedReturn);
|
|
2270
|
-
|
|
2271
|
-
case 17:
|
|
2272
|
-
case "end":
|
|
2273
|
-
return _context.stop();
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
}, _callee, this);
|
|
2277
|
-
}));
|
|
2278
|
-
|
|
2279
|
-
function aggregate(_x) {
|
|
2280
|
-
return _aggregate.apply(this, arguments);
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
return aggregate;
|
|
2284
|
-
}();
|
|
2285
|
-
|
|
2286
|
-
return MulticallRead;
|
|
2287
|
-
}(BlockchainEntityRead);
|
|
2288
|
-
|
|
2289
2204
|
var ComptrollerRewardType;
|
|
2290
2205
|
|
|
2291
2206
|
(function (ComptrollerRewardType) {
|
|
@@ -2304,148 +2219,42 @@ var MarketAction;
|
|
|
2304
2219
|
MarketAction[MarketAction["DisableCollateral"] = 5] = "DisableCollateral";
|
|
2305
2220
|
})(MarketAction || (MarketAction = {}));
|
|
2306
2221
|
|
|
2307
|
-
var
|
|
2308
|
-
_inheritsLoose(
|
|
2222
|
+
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2223
|
+
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
2309
2224
|
|
|
2310
|
-
function
|
|
2225
|
+
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
2311
2226
|
var _this;
|
|
2312
2227
|
|
|
2313
2228
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2314
|
-
_this.stakingRead = new StakingRead(networkConnection);
|
|
2315
2229
|
_this.env = new AuriEnv(networkConnection);
|
|
2316
|
-
return _this;
|
|
2317
|
-
}
|
|
2318
2230
|
|
|
2319
|
-
|
|
2231
|
+
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
2232
|
+
_this.auToken = new Contract(auToken, abis$5.abi, networkConnection.provider);
|
|
2233
|
+
} else {
|
|
2234
|
+
_this.auToken = new Contract(auToken, abis$6.abi, networkConnection.provider);
|
|
2235
|
+
}
|
|
2320
2236
|
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2237
|
+
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
2238
|
+
return _this;
|
|
2239
|
+
}
|
|
2324
2240
|
|
|
2325
|
-
|
|
2241
|
+
var _proto = MoneyMarketRead.prototype;
|
|
2326
2242
|
|
|
2243
|
+
_proto.getRewardSpeeds = /*#__PURE__*/function () {
|
|
2244
|
+
var _getRewardSpeeds = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2245
|
+
var speeds;
|
|
2327
2246
|
return runtime_1.wrap(function _callee$(_context) {
|
|
2328
2247
|
while (1) {
|
|
2329
2248
|
switch (_context.prev = _context.next) {
|
|
2330
2249
|
case 0:
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
promises = [];
|
|
2334
|
-
totalBorrowLimit = new BigNumber(0);
|
|
2335
|
-
pricePromises = [];
|
|
2336
|
-
|
|
2337
|
-
_loop2 = function _loop2() {
|
|
2338
|
-
var auToken = _step.value;
|
|
2339
|
-
var userMarketDetail = {};
|
|
2340
|
-
userMarketDetails.push(userMarketDetail);
|
|
2341
|
-
userMarketDetail.market = auToken.underlying;
|
|
2342
|
-
var moneyMarket = new MoneyMarketRead(_this2._networkConnection, auToken.address, auToken.underlying);
|
|
2343
|
-
promises.push(moneyMarket.getUserDepositBalance(userAddress).then(function (res) {
|
|
2344
|
-
userMarketDetail.depositBalance = res;
|
|
2345
|
-
}));
|
|
2346
|
-
promises.push(moneyMarket.getUserBorrowBalance(userAddress).then(function (res) {
|
|
2347
|
-
userMarketDetail.borrowBalance = res;
|
|
2348
|
-
}));
|
|
2349
|
-
promises.push(moneyMarket.getCollateralRatio().then(function (res) {
|
|
2350
|
-
userMarketDetail.collateralRatio = res.toNumber();
|
|
2351
|
-
}));
|
|
2352
|
-
pricePromises.push(fetchPrice(moneyMarket.underlying.address, _this2._networkConnection.provider).then(function (res) {
|
|
2353
|
-
userMarketDetail.underlyingPrice = res.toString();
|
|
2354
|
-
return res;
|
|
2355
|
-
}));
|
|
2356
|
-
};
|
|
2357
|
-
|
|
2358
|
-
for (_iterator = _createForOfIteratorHelperLoose(networkAddresses.auTokens); !(_step = _iterator()).done;) {
|
|
2359
|
-
_loop2();
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
promises.push(this.env.comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
2363
|
-
assetsIn = res;
|
|
2364
|
-
}));
|
|
2365
|
-
_context.next = 10;
|
|
2366
|
-
return Promise.all(promises);
|
|
2367
|
-
|
|
2368
|
-
case 10:
|
|
2369
|
-
_context.next = 12;
|
|
2370
|
-
return Promise.all(pricePromises);
|
|
2371
|
-
|
|
2372
|
-
case 12:
|
|
2373
|
-
underlyingPrices = _context.sent;
|
|
2374
|
-
depositValues = [];
|
|
2375
|
-
|
|
2376
|
-
_loop = function _loop() {
|
|
2377
|
-
var auToken = networkAddresses.auTokens[i];
|
|
2378
|
-
|
|
2379
|
-
if (assetsIn.find(function (auAddress) {
|
|
2380
|
-
return isSameAddress(auToken.address, auAddress);
|
|
2381
|
-
}) !== undefined) {
|
|
2382
|
-
userMarketDetails[i].isCollateral = true;
|
|
2383
|
-
} else {
|
|
2384
|
-
userMarketDetails[i].isCollateral = false;
|
|
2385
|
-
}
|
|
2386
|
-
|
|
2387
|
-
depositValues.push(calcValuation(userMarketDetails[i].depositBalance, underlyingPrices[i]));
|
|
2388
|
-
};
|
|
2389
|
-
|
|
2390
|
-
for (i = 0; i < marketCount; i++) {
|
|
2391
|
-
_loop();
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
2395
|
-
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
2396
|
-
return p;
|
|
2397
|
-
}, new BigNumber(0));
|
|
2398
|
-
_context.next = 19;
|
|
2399
|
-
return this.env.comptroller.getAccountLiquidity(userAddress);
|
|
2400
|
-
|
|
2401
|
-
case 19:
|
|
2402
|
-
accountLiquidity = _context.sent;
|
|
2403
|
-
borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
|
|
2404
|
-
|
|
2405
|
-
if (borrowedvaluation.lt('0.00001')) {
|
|
2406
|
-
// Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
|
|
2407
|
-
borrowedvaluation = new BigNumber(0);
|
|
2408
|
-
}
|
|
2409
|
-
|
|
2410
|
-
bufferedBorrowLimit = totalBorrowLimit.multipliedBy(BORROW_LIMIT_BUFFER);
|
|
2411
|
-
minimumBorrowLimitAllowed = borrowedvaluation.div(BORROW_LIMIT_BUFFER);
|
|
2412
|
-
|
|
2413
|
-
if (bufferedBorrowLimit.lte(borrowedvaluation)) {
|
|
2414
|
-
borrowableAmount = new BigNumber(0);
|
|
2415
|
-
} else {
|
|
2416
|
-
borrowableAmount = bufferedBorrowLimit.minus(borrowedvaluation);
|
|
2417
|
-
}
|
|
2418
|
-
|
|
2419
|
-
for (i = 0; i < marketCount; i++) {
|
|
2420
|
-
auToken = networkAddresses.auTokens[i];
|
|
2421
|
-
moneyMarket = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
|
|
2422
|
-
borrowLimitMargin = totalBorrowLimit.minus(minimumBorrowLimitAllowed).gt(0) ? totalBorrowLimit.minus(minimumBorrowLimitAllowed) : new BigNumber(0);
|
|
2423
|
-
maxWithdrawCap = borrowLimitMargin.div(userMarketDetails[i].collateralRatio).div(underlyingPrices[i]);
|
|
2424
|
-
userMarketDetails[i].maxWithdrawableAmount = userMarketDetails[i].isCollateral && maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount()) ? new TokenAmount(moneyMarket.underlying, maxWithdrawCap.toFixed(24), false) : new TokenAmount(moneyMarket.underlying, userMarketDetails[i].depositBalance.rawAmount());
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
_context.t0 = userMarketDetails;
|
|
2428
|
-
_context.t1 = {
|
|
2429
|
-
currency: 'USD',
|
|
2430
|
-
amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
|
|
2431
|
-
};
|
|
2432
|
-
_context.next = 30;
|
|
2433
|
-
return new PapermillRead(this._networkConnection).getLockingDetails(userAddress);
|
|
2250
|
+
_context.next = 2;
|
|
2251
|
+
return this.env.auriLens.getRewardSpeeds(this.env.comptroller.address, this.auToken.address);
|
|
2434
2252
|
|
|
2435
|
-
case
|
|
2436
|
-
|
|
2437
|
-
_context.
|
|
2438
|
-
currency: 'USD',
|
|
2439
|
-
amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
|
|
2440
|
-
};
|
|
2441
|
-
return _context.abrupt("return", {
|
|
2442
|
-
markets: _context.t0,
|
|
2443
|
-
borrowLimit: _context.t1,
|
|
2444
|
-
userLockingDetails: _context.t2,
|
|
2445
|
-
borrowableAmount: _context.t3
|
|
2446
|
-
});
|
|
2253
|
+
case 2:
|
|
2254
|
+
speeds = _context.sent;
|
|
2255
|
+
return _context.abrupt("return", speeds);
|
|
2447
2256
|
|
|
2448
|
-
case
|
|
2257
|
+
case 4:
|
|
2449
2258
|
case "end":
|
|
2450
2259
|
return _context.stop();
|
|
2451
2260
|
}
|
|
@@ -2453,216 +2262,23 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2453
2262
|
}, _callee, this);
|
|
2454
2263
|
}));
|
|
2455
2264
|
|
|
2456
|
-
function
|
|
2457
|
-
return
|
|
2265
|
+
function getRewardSpeeds() {
|
|
2266
|
+
return _getRewardSpeeds.apply(this, arguments);
|
|
2458
2267
|
}
|
|
2459
2268
|
|
|
2460
|
-
return
|
|
2269
|
+
return getRewardSpeeds;
|
|
2461
2270
|
}();
|
|
2462
2271
|
|
|
2463
|
-
_proto.
|
|
2464
|
-
var
|
|
2465
|
-
var price;
|
|
2272
|
+
_proto.getTotalTokenBorrowed = /*#__PURE__*/function () {
|
|
2273
|
+
var _getTotalTokenBorrowed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
2466
2274
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2467
2275
|
while (1) {
|
|
2468
2276
|
switch (_context2.prev = _context2.next) {
|
|
2469
2277
|
case 0:
|
|
2470
|
-
_context2.
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
price = _context2.sent;
|
|
2475
|
-
return _context2.abrupt("return", {
|
|
2476
|
-
currency: 'USD',
|
|
2477
|
-
amount: price.toFixed(DECIMAL_PRECISION)
|
|
2478
|
-
});
|
|
2479
|
-
|
|
2480
|
-
case 4:
|
|
2481
|
-
case "end":
|
|
2482
|
-
return _context2.stop();
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
}, _callee2, this);
|
|
2486
|
-
}));
|
|
2487
|
-
|
|
2488
|
-
function getTokenPrice(_x2) {
|
|
2489
|
-
return _getTokenPrice.apply(this, arguments);
|
|
2490
|
-
}
|
|
2491
|
-
|
|
2492
|
-
return getTokenPrice;
|
|
2493
|
-
}();
|
|
2494
|
-
|
|
2495
|
-
_proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
|
|
2496
|
-
var userMarketDetail = _ref.userMarketDetail,
|
|
2497
|
-
currentBorrowLimit = _ref.currentBorrowLimit,
|
|
2498
|
-
currentBorrowValuation = _ref.currentBorrowValuation,
|
|
2499
|
-
action = _ref.action,
|
|
2500
|
-
tokenAmount = _ref.tokenAmount;
|
|
2501
|
-
var newBorrowLimit = new BigNumber(currentBorrowLimit.amount),
|
|
2502
|
-
newBorrowValuation = new BigNumber(currentBorrowValuation.amount);
|
|
2503
|
-
|
|
2504
|
-
switch (action) {
|
|
2505
|
-
case MarketAction.EnableCollateral:
|
|
2506
|
-
case MarketAction.DisableCollateral:
|
|
2507
|
-
var deltaBorrowLimit = calcValuation(userMarketDetail.depositBalance, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
2508
|
-
newBorrowLimit = action == MarketAction.EnableCollateral ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
2509
|
-
break;
|
|
2510
|
-
|
|
2511
|
-
case MarketAction.Deposit:
|
|
2512
|
-
case MarketAction.Withdraw:
|
|
2513
|
-
deltaBorrowLimit = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
2514
|
-
newBorrowLimit = action == MarketAction.Deposit ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
2515
|
-
break;
|
|
2516
|
-
|
|
2517
|
-
case MarketAction.Borrow:
|
|
2518
|
-
case MarketAction.Repay:
|
|
2519
|
-
var deltaBorrowValuation = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice));
|
|
2520
|
-
newBorrowValuation = action == MarketAction.Borrow ? newBorrowValuation.plus(deltaBorrowValuation) : newBorrowValuation.minus(deltaBorrowValuation);
|
|
2521
|
-
break;
|
|
2522
|
-
}
|
|
2523
|
-
|
|
2524
|
-
return {
|
|
2525
|
-
newBorrowLimit: {
|
|
2526
|
-
amount: newBorrowLimit.toFixed(DECIMAL_PRECISION),
|
|
2527
|
-
currency: 'USD'
|
|
2528
|
-
},
|
|
2529
|
-
newBorrowUtilization: newBorrowLimit.eq(0) ? newBorrowValuation.eq(0) ? 0 : 9999.99 : newBorrowValuation.div(newBorrowLimit).toNumber()
|
|
2530
|
-
};
|
|
2531
|
-
}
|
|
2532
|
-
/**
|
|
2533
|
-
* Get ply circulating supply.
|
|
2534
|
-
* It is calculated by the total supply, minus:
|
|
2535
|
-
* - Ply in team multisig contract
|
|
2536
|
-
* - Ply in comptroller contract
|
|
2537
|
-
* - Ply in fairlaunch contract
|
|
2538
|
-
* - Ply in vesting contract
|
|
2539
|
-
*/
|
|
2540
|
-
;
|
|
2541
|
-
|
|
2542
|
-
_proto.getPlyCirculatingSupply =
|
|
2543
|
-
/*#__PURE__*/
|
|
2544
|
-
function () {
|
|
2545
|
-
var _getPlyCirculatingSupply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
2546
|
-
var multicallRead, baseBalanceOfCall, callResults, circulatingSupply;
|
|
2547
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2548
|
-
while (1) {
|
|
2549
|
-
switch (_context3.prev = _context3.next) {
|
|
2550
|
-
case 0:
|
|
2551
|
-
multicallRead = new MulticallRead(this._networkConnection);
|
|
2552
|
-
baseBalanceOfCall = {
|
|
2553
|
-
contract: this.env.ply,
|
|
2554
|
-
method: 'balanceOf',
|
|
2555
|
-
returnTypes: ['uint256']
|
|
2556
|
-
};
|
|
2557
|
-
_context3.next = 4;
|
|
2558
|
-
return multicallRead.aggregate([// Get total supply
|
|
2559
|
-
_extends({}, baseBalanceOfCall, {
|
|
2560
|
-
method: 'totalSupply',
|
|
2561
|
-
args: []
|
|
2562
|
-
}), // balance in team multisig
|
|
2563
|
-
_extends({}, baseBalanceOfCall, {
|
|
2564
|
-
args: [networkAddresses.misc.TEAM_MULTISIG]
|
|
2565
|
-
}), // balance in comptroller
|
|
2566
|
-
_extends({}, baseBalanceOfCall, {
|
|
2567
|
-
args: [networkAddresses.misc.COMPTROLLER]
|
|
2568
|
-
}), // balance in fair launch
|
|
2569
|
-
_extends({}, baseBalanceOfCall, {
|
|
2570
|
-
args: [networkAddresses.misc.AURIFAIRLAUNCH]
|
|
2571
|
-
}), // balance in vesting contract
|
|
2572
|
-
_extends({}, baseBalanceOfCall, {
|
|
2573
|
-
args: [networkAddresses.misc.PLY_TOKEN_LOCK]
|
|
2574
|
-
})]);
|
|
2575
|
-
|
|
2576
|
-
case 4:
|
|
2577
|
-
callResults = _context3.sent;
|
|
2578
|
-
circulatingSupply = BigNumber$1.from(0);
|
|
2579
|
-
callResults.forEach(function (result, i) {
|
|
2580
|
-
if (i === 0) {
|
|
2581
|
-
circulatingSupply = result[0];
|
|
2582
|
-
} else {
|
|
2583
|
-
circulatingSupply = circulatingSupply.sub(result[0]);
|
|
2584
|
-
}
|
|
2585
|
-
});
|
|
2586
|
-
return _context3.abrupt("return", new TokenAmount(PLYToken, circulatingSupply.toString()));
|
|
2587
|
-
|
|
2588
|
-
case 8:
|
|
2589
|
-
case "end":
|
|
2590
|
-
return _context3.stop();
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
|
-
}, _callee3, this);
|
|
2594
|
-
}));
|
|
2595
|
-
|
|
2596
|
-
function getPlyCirculatingSupply() {
|
|
2597
|
-
return _getPlyCirculatingSupply.apply(this, arguments);
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2600
|
-
return getPlyCirculatingSupply;
|
|
2601
|
-
}();
|
|
2602
|
-
|
|
2603
|
-
return MiscRead;
|
|
2604
|
-
}(BlockchainEntityRead);
|
|
2605
|
-
|
|
2606
|
-
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2607
|
-
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
2608
|
-
|
|
2609
|
-
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
2610
|
-
var _this;
|
|
2611
|
-
|
|
2612
|
-
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2613
|
-
_this.env = new AuriEnv(networkConnection);
|
|
2614
|
-
|
|
2615
|
-
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
2616
|
-
_this.auToken = new Contract(auToken, abis$6.abi, networkConnection.provider);
|
|
2617
|
-
} else {
|
|
2618
|
-
_this.auToken = new Contract(auToken, abis$7.abi, networkConnection.provider);
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
2622
|
-
return _this;
|
|
2623
|
-
}
|
|
2624
|
-
|
|
2625
|
-
var _proto = MoneyMarketRead.prototype;
|
|
2626
|
-
|
|
2627
|
-
_proto.getRewardSpeeds = /*#__PURE__*/function () {
|
|
2628
|
-
var _getRewardSpeeds = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
2629
|
-
var speeds;
|
|
2630
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
2631
|
-
while (1) {
|
|
2632
|
-
switch (_context.prev = _context.next) {
|
|
2633
|
-
case 0:
|
|
2634
|
-
_context.next = 2;
|
|
2635
|
-
return this.env.auriLens.getRewardSpeeds(this.env.comptroller.address, this.auToken.address);
|
|
2636
|
-
|
|
2637
|
-
case 2:
|
|
2638
|
-
speeds = _context.sent;
|
|
2639
|
-
return _context.abrupt("return", speeds);
|
|
2640
|
-
|
|
2641
|
-
case 4:
|
|
2642
|
-
case "end":
|
|
2643
|
-
return _context.stop();
|
|
2644
|
-
}
|
|
2645
|
-
}
|
|
2646
|
-
}, _callee, this);
|
|
2647
|
-
}));
|
|
2648
|
-
|
|
2649
|
-
function getRewardSpeeds() {
|
|
2650
|
-
return _getRewardSpeeds.apply(this, arguments);
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
|
-
return getRewardSpeeds;
|
|
2654
|
-
}();
|
|
2655
|
-
|
|
2656
|
-
_proto.getTotalTokenBorrowed = /*#__PURE__*/function () {
|
|
2657
|
-
var _getTotalTokenBorrowed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
2658
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2659
|
-
while (1) {
|
|
2660
|
-
switch (_context2.prev = _context2.next) {
|
|
2661
|
-
case 0:
|
|
2662
|
-
_context2.t0 = TokenAmount;
|
|
2663
|
-
_context2.t1 = this.underlying;
|
|
2664
|
-
_context2.next = 4;
|
|
2665
|
-
return this.auToken.totalBorrows();
|
|
2278
|
+
_context2.t0 = TokenAmount;
|
|
2279
|
+
_context2.t1 = this.underlying;
|
|
2280
|
+
_context2.next = 4;
|
|
2281
|
+
return this.auToken.totalBorrows();
|
|
2666
2282
|
|
|
2667
2283
|
case 4:
|
|
2668
2284
|
_context2.t2 = _context2.sent.toString();
|
|
@@ -3078,7 +2694,7 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3078
2694
|
var _this3;
|
|
3079
2695
|
|
|
3080
2696
|
_this3 = _MoneyMarketRead.call(this, networkConnection, auToken, underlyingAsset) || this;
|
|
3081
|
-
_this3._EthRepayHelper = new Contract(networkAddresses.misc.ETHREPAYHELPER, abis$
|
|
2697
|
+
_this3._EthRepayHelper = new Contract(networkAddresses.misc.ETHREPAYHELPER, abis$7.abi, networkConnection.provider);
|
|
3082
2698
|
return _this3;
|
|
3083
2699
|
}
|
|
3084
2700
|
|
|
@@ -3285,60 +2901,146 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
3285
2901
|
return MoneyMarket;
|
|
3286
2902
|
}(BlockchainEntity);
|
|
3287
2903
|
|
|
3288
|
-
var
|
|
3289
|
-
|
|
3290
|
-
_inheritsLoose(PapermillRead, _BlockchainEntityRead);
|
|
2904
|
+
var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2905
|
+
_inheritsLoose(MulticallRead, _BlockchainEntityRead);
|
|
3291
2906
|
|
|
3292
|
-
function
|
|
2907
|
+
function MulticallRead(networkConnection) {
|
|
3293
2908
|
var _this;
|
|
3294
2909
|
|
|
3295
2910
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3296
|
-
_this.
|
|
3297
|
-
var plyAddress = networkAddresses.tokens.PLY;
|
|
3298
|
-
var pulpAddress = networkAddresses.tokens.PULP;
|
|
3299
|
-
_this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
|
|
3300
|
-
_this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
|
|
2911
|
+
_this.multicall = new Contract(networkAddresses.misc.MULTICALL, abis$8.abi, networkConnection.provider);
|
|
3301
2912
|
return _this;
|
|
3302
2913
|
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Run multiple calls via multicall contract
|
|
2916
|
+
*/
|
|
3303
2917
|
|
|
3304
|
-
var _proto = PapermillRead.prototype;
|
|
3305
2918
|
|
|
3306
|
-
_proto
|
|
3307
|
-
|
|
3308
|
-
|
|
2919
|
+
var _proto = MulticallRead.prototype;
|
|
2920
|
+
|
|
2921
|
+
_proto.aggregate =
|
|
2922
|
+
/*#__PURE__*/
|
|
2923
|
+
function () {
|
|
2924
|
+
var _aggregate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(calls) {
|
|
2925
|
+
var txns, i, _call$contract$popula, call, txn, response, decodedReturn, _i;
|
|
2926
|
+
|
|
3309
2927
|
return runtime_1.wrap(function _callee$(_context) {
|
|
3310
2928
|
while (1) {
|
|
3311
2929
|
switch (_context.prev = _context.next) {
|
|
3312
2930
|
case 0:
|
|
3313
|
-
|
|
3314
|
-
|
|
2931
|
+
txns = []; // prepare transactions
|
|
2932
|
+
|
|
2933
|
+
i = 0;
|
|
3315
2934
|
|
|
3316
2935
|
case 2:
|
|
3317
|
-
|
|
3318
|
-
|
|
2936
|
+
if (!(i < calls.length)) {
|
|
2937
|
+
_context.next = 11;
|
|
2938
|
+
break;
|
|
2939
|
+
}
|
|
3319
2940
|
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
return
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
}, _callee, this);
|
|
3326
|
-
}));
|
|
2941
|
+
call = calls[i];
|
|
2942
|
+
_context.next = 6;
|
|
2943
|
+
return (_call$contract$popula = call.contract.populateTransaction)[call.method].apply(_call$contract$popula, call.args);
|
|
3327
2944
|
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
2945
|
+
case 6:
|
|
2946
|
+
txn = _context.sent;
|
|
2947
|
+
txns.push({
|
|
2948
|
+
target: txn.to,
|
|
2949
|
+
callData: txn.data
|
|
2950
|
+
});
|
|
3331
2951
|
|
|
3332
|
-
|
|
3333
|
-
|
|
2952
|
+
case 8:
|
|
2953
|
+
i++;
|
|
2954
|
+
_context.next = 2;
|
|
2955
|
+
break;
|
|
3334
2956
|
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
2957
|
+
case 11:
|
|
2958
|
+
_context.next = 13;
|
|
2959
|
+
return this.multicall.callStatic.aggregate(txns);
|
|
2960
|
+
|
|
2961
|
+
case 13:
|
|
2962
|
+
response = _context.sent;
|
|
2963
|
+
// parse results
|
|
2964
|
+
decodedReturn = [];
|
|
2965
|
+
|
|
2966
|
+
for (_i = 0; _i < calls.length; _i++) {
|
|
2967
|
+
decodedReturn.push(ethers.utils.defaultAbiCoder.decode(calls[_i].returnTypes, response.returnData[_i]));
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
return _context.abrupt("return", decodedReturn);
|
|
2971
|
+
|
|
2972
|
+
case 17:
|
|
2973
|
+
case "end":
|
|
2974
|
+
return _context.stop();
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
}, _callee, this);
|
|
2978
|
+
}));
|
|
2979
|
+
|
|
2980
|
+
function aggregate(_x) {
|
|
2981
|
+
return _aggregate.apply(this, arguments);
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
return aggregate;
|
|
2985
|
+
}();
|
|
2986
|
+
|
|
2987
|
+
return MulticallRead;
|
|
2988
|
+
}(BlockchainEntityRead);
|
|
2989
|
+
|
|
2990
|
+
var LOCKING_DENOMINATOR = /*#__PURE__*/BigNumber$1.from(10000);
|
|
2991
|
+
var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2992
|
+
_inheritsLoose(PapermillRead, _BlockchainEntityRead);
|
|
2993
|
+
|
|
2994
|
+
function PapermillRead(networkConnection) {
|
|
2995
|
+
var _this;
|
|
2996
|
+
|
|
2997
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2998
|
+
_this.env = new AuriEnv(networkConnection);
|
|
2999
|
+
var plyAddress = networkAddresses.tokens.PLY;
|
|
3000
|
+
var pulpAddress = networkAddresses.tokens.PULP;
|
|
3001
|
+
_this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
|
|
3002
|
+
_this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
|
|
3003
|
+
return _this;
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
var _proto = PapermillRead.prototype;
|
|
3007
|
+
|
|
3008
|
+
_proto.getPlyBalance = /*#__PURE__*/function () {
|
|
3009
|
+
var _getPlyBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
|
|
3010
|
+
var plyBalance;
|
|
3011
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
3012
|
+
while (1) {
|
|
3013
|
+
switch (_context.prev = _context.next) {
|
|
3014
|
+
case 0:
|
|
3015
|
+
_context.next = 2;
|
|
3016
|
+
return this.env.ply.balanceOf(userAddress);
|
|
3017
|
+
|
|
3018
|
+
case 2:
|
|
3019
|
+
plyBalance = _context.sent;
|
|
3020
|
+
return _context.abrupt("return", new TokenAmount(this.plyToken, plyBalance.toString()));
|
|
3021
|
+
|
|
3022
|
+
case 4:
|
|
3023
|
+
case "end":
|
|
3024
|
+
return _context.stop();
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
}, _callee, this);
|
|
3028
|
+
}));
|
|
3029
|
+
|
|
3030
|
+
function getPlyBalance(_x) {
|
|
3031
|
+
return _getPlyBalance.apply(this, arguments);
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
return getPlyBalance;
|
|
3035
|
+
}();
|
|
3036
|
+
|
|
3037
|
+
_proto.getPulpBalance = /*#__PURE__*/function () {
|
|
3038
|
+
var _getPulpBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
|
|
3039
|
+
var pulpBalance;
|
|
3040
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3041
|
+
while (1) {
|
|
3042
|
+
switch (_context2.prev = _context2.next) {
|
|
3043
|
+
case 0:
|
|
3342
3044
|
_context2.next = 2;
|
|
3343
3045
|
return this.env.pulp.balanceOf(userAddress);
|
|
3344
3046
|
|
|
@@ -3654,60 +3356,68 @@ var Papermill = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
3654
3356
|
return Papermill;
|
|
3655
3357
|
}(BlockchainEntity);
|
|
3656
3358
|
|
|
3657
|
-
var
|
|
3658
|
-
_inheritsLoose(
|
|
3359
|
+
var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3360
|
+
_inheritsLoose(StakingRead, _BlockchainEntityRead);
|
|
3659
3361
|
|
|
3660
|
-
function
|
|
3362
|
+
function StakingRead(networkConnection) {
|
|
3661
3363
|
var _this;
|
|
3662
3364
|
|
|
3663
3365
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3664
|
-
_this.
|
|
3366
|
+
_this.env = new AuriEnv(networkConnection);
|
|
3665
3367
|
return _this;
|
|
3666
3368
|
}
|
|
3667
|
-
/**
|
|
3668
|
-
* Generate a 10-character referral code
|
|
3669
|
-
* containing alphanumeric characters.
|
|
3670
|
-
*/
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
var _proto = ReferralRead.prototype;
|
|
3674
|
-
|
|
3675
|
-
_proto.generateReferralCode = function generateReferralCode() {
|
|
3676
|
-
var letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
3677
|
-
var numbers = '1234567890';
|
|
3678
|
-
var charset = letters + letters.toUpperCase() + numbers;
|
|
3679
|
-
var R = '';
|
|
3680
|
-
|
|
3681
|
-
for (var i = 0; i < 10; i++) {
|
|
3682
|
-
R += charset[Math.floor(Math.random() * charset.length)];
|
|
3683
|
-
}
|
|
3684
3369
|
|
|
3685
|
-
|
|
3686
|
-
}
|
|
3687
|
-
/**
|
|
3688
|
-
* Get the referral code for a given address, returns empty string if not found.
|
|
3689
|
-
*
|
|
3690
|
-
* Called to check if a user has a referral code.
|
|
3691
|
-
*/
|
|
3692
|
-
;
|
|
3370
|
+
var _proto = StakingRead.prototype;
|
|
3693
3371
|
|
|
3694
|
-
_proto.
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
var _getUserReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddr) {
|
|
3698
|
-
var result;
|
|
3372
|
+
_proto.getPLYWNEARPoolDetails = /*#__PURE__*/function () {
|
|
3373
|
+
var _getPLYWNEARPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
3374
|
+
var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, totalStakeValuation, promises, i, rewardTokenAddress, rewardToken, rewardPerSecond, APYs;
|
|
3699
3375
|
return runtime_1.wrap(function _callee$(_context) {
|
|
3700
3376
|
while (1) {
|
|
3701
3377
|
switch (_context.prev = _context.next) {
|
|
3702
3378
|
case 0:
|
|
3703
3379
|
_context.next = 2;
|
|
3704
|
-
return this.
|
|
3380
|
+
return this.env.auriFairLaunch.getPoolInfo(PLYWNEAR_POOL_ID).then(function (res) {
|
|
3381
|
+
stakedLiquidity = res.totalStake;
|
|
3382
|
+
rewardPerSeconds = res.rewardPerSeconds;
|
|
3383
|
+
});
|
|
3705
3384
|
|
|
3706
3385
|
case 2:
|
|
3707
|
-
|
|
3708
|
-
|
|
3386
|
+
stakedLiquidityAmount = new TokenAmount(PLYWNEARToken, stakedLiquidity.toString());
|
|
3387
|
+
_context.next = 5;
|
|
3388
|
+
return fetchValuation(stakedLiquidityAmount, this._networkConnection.provider);
|
|
3709
3389
|
|
|
3710
|
-
case
|
|
3390
|
+
case 5:
|
|
3391
|
+
totalStakeValuation = _context.sent;
|
|
3392
|
+
promises = []; // Calculate the reward per second in USD
|
|
3393
|
+
|
|
3394
|
+
for (i = 0; i < rewardPerSeconds.length; i++) {
|
|
3395
|
+
rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
|
|
3396
|
+
rewardToken = new Token(rewardTokenAddress, getDecimal(rewardTokenAddress));
|
|
3397
|
+
rewardPerSecond = rewardPerSeconds[i];
|
|
3398
|
+
promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
APYs = [];
|
|
3402
|
+
_context.next = 11;
|
|
3403
|
+
return Promise.all(promises);
|
|
3404
|
+
|
|
3405
|
+
case 11:
|
|
3406
|
+
_context.sent.forEach(function (rewardPerSecondValuation, i) {
|
|
3407
|
+
var rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
|
|
3408
|
+
var apy = calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION);
|
|
3409
|
+
APYs.push({
|
|
3410
|
+
address: rewardTokenAddress,
|
|
3411
|
+
apy: apy
|
|
3412
|
+
});
|
|
3413
|
+
});
|
|
3414
|
+
|
|
3415
|
+
return _context.abrupt("return", {
|
|
3416
|
+
totalStakedLiquidity: stakedLiquidityAmount,
|
|
3417
|
+
APYs: APYs
|
|
3418
|
+
});
|
|
3419
|
+
|
|
3420
|
+
case 13:
|
|
3711
3421
|
case "end":
|
|
3712
3422
|
return _context.stop();
|
|
3713
3423
|
}
|
|
@@ -3715,32 +3425,32 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3715
3425
|
}, _callee, this);
|
|
3716
3426
|
}));
|
|
3717
3427
|
|
|
3718
|
-
function
|
|
3719
|
-
return
|
|
3428
|
+
function getPLYWNEARPoolDetails() {
|
|
3429
|
+
return _getPLYWNEARPoolDetails.apply(this, arguments);
|
|
3720
3430
|
}
|
|
3721
3431
|
|
|
3722
|
-
return
|
|
3432
|
+
return getPLYWNEARPoolDetails;
|
|
3723
3433
|
}()
|
|
3724
3434
|
/**
|
|
3725
|
-
* Get
|
|
3435
|
+
* Get amount of staked LP tokens
|
|
3726
3436
|
*/
|
|
3727
3437
|
;
|
|
3728
3438
|
|
|
3729
|
-
_proto.
|
|
3439
|
+
_proto.stakeBalanceOf =
|
|
3730
3440
|
/*#__PURE__*/
|
|
3731
3441
|
function () {
|
|
3732
|
-
var
|
|
3733
|
-
var
|
|
3442
|
+
var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(user) {
|
|
3443
|
+
var userInfo;
|
|
3734
3444
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3735
3445
|
while (1) {
|
|
3736
3446
|
switch (_context2.prev = _context2.next) {
|
|
3737
3447
|
case 0:
|
|
3738
3448
|
_context2.next = 2;
|
|
3739
|
-
return this.
|
|
3449
|
+
return this.env.auriFairLaunch.getUserInfo(PLYWNEAR_POOL_ID, user);
|
|
3740
3450
|
|
|
3741
3451
|
case 2:
|
|
3742
|
-
|
|
3743
|
-
return _context2.abrupt("return",
|
|
3452
|
+
userInfo = _context2.sent;
|
|
3453
|
+
return _context2.abrupt("return", new TokenAmount(PLYWNEARToken, userInfo.amount.toString()));
|
|
3744
3454
|
|
|
3745
3455
|
case 4:
|
|
3746
3456
|
case "end":
|
|
@@ -3750,30 +3460,35 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3750
3460
|
}, _callee2, this);
|
|
3751
3461
|
}));
|
|
3752
3462
|
|
|
3753
|
-
function
|
|
3754
|
-
return
|
|
3463
|
+
function stakeBalanceOf(_x) {
|
|
3464
|
+
return _stakeBalanceOf.apply(this, arguments);
|
|
3755
3465
|
}
|
|
3756
3466
|
|
|
3757
|
-
return
|
|
3467
|
+
return stakeBalanceOf;
|
|
3758
3468
|
}()
|
|
3759
3469
|
/**
|
|
3760
|
-
* Get
|
|
3470
|
+
* Get amount of LP token in user wallet
|
|
3761
3471
|
*/
|
|
3762
3472
|
;
|
|
3763
3473
|
|
|
3764
|
-
_proto.
|
|
3474
|
+
_proto.LpBalanceOf =
|
|
3765
3475
|
/*#__PURE__*/
|
|
3766
3476
|
function () {
|
|
3767
|
-
var
|
|
3768
|
-
var
|
|
3477
|
+
var _LpBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(user) {
|
|
3478
|
+
var lpContract, balance;
|
|
3769
3479
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
3770
3480
|
while (1) {
|
|
3771
3481
|
switch (_context3.prev = _context3.next) {
|
|
3772
3482
|
case 0:
|
|
3773
|
-
|
|
3774
|
-
|
|
3483
|
+
lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$3.abi, this._networkConnection.provider);
|
|
3484
|
+
_context3.next = 3;
|
|
3485
|
+
return lpContract.balanceOf(user);
|
|
3775
3486
|
|
|
3776
|
-
case
|
|
3487
|
+
case 3:
|
|
3488
|
+
balance = _context3.sent;
|
|
3489
|
+
return _context3.abrupt("return", new TokenAmount(PLYWNEARToken, balance.toString()));
|
|
3490
|
+
|
|
3491
|
+
case 5:
|
|
3777
3492
|
case "end":
|
|
3778
3493
|
return _context3.stop();
|
|
3779
3494
|
}
|
|
@@ -3781,73 +3496,67 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3781
3496
|
}, _callee3, this);
|
|
3782
3497
|
}));
|
|
3783
3498
|
|
|
3784
|
-
function
|
|
3785
|
-
return
|
|
3499
|
+
function LpBalanceOf(_x2) {
|
|
3500
|
+
return _LpBalanceOf.apply(this, arguments);
|
|
3786
3501
|
}
|
|
3787
3502
|
|
|
3788
|
-
return
|
|
3503
|
+
return LpBalanceOf;
|
|
3789
3504
|
}();
|
|
3790
3505
|
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
var
|
|
3794
|
-
_inheritsLoose(ReferralReadWrite, _ReferralRead);
|
|
3795
|
-
|
|
3796
|
-
function ReferralReadWrite() {
|
|
3797
|
-
return _ReferralRead.apply(this, arguments) || this;
|
|
3798
|
-
}
|
|
3799
|
-
|
|
3800
|
-
var _proto2 = ReferralReadWrite.prototype;
|
|
3801
|
-
|
|
3802
|
-
/**
|
|
3803
|
-
* Generate a referral code for a given address.
|
|
3804
|
-
*
|
|
3805
|
-
* Called when an user want to creates his own referral code
|
|
3806
|
-
*/
|
|
3807
|
-
_proto2.registerNewReferralCode =
|
|
3808
|
-
/*#__PURE__*/
|
|
3809
|
-
function () {
|
|
3810
|
-
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
3811
|
-
var referralCode;
|
|
3506
|
+
_proto.unclaimedRewardsOf = /*#__PURE__*/function () {
|
|
3507
|
+
var _unclaimedRewardsOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(user) {
|
|
3508
|
+
var userInfo, rewards;
|
|
3812
3509
|
return runtime_1.wrap(function _callee4$(_context4) {
|
|
3813
3510
|
while (1) {
|
|
3814
3511
|
switch (_context4.prev = _context4.next) {
|
|
3815
3512
|
case 0:
|
|
3816
|
-
|
|
3817
|
-
return
|
|
3513
|
+
_context4.next = 2;
|
|
3514
|
+
return this.env.auriFairLaunch.callStatic.updateAndGetUserInfo(PLYWNEAR_POOL_ID, user, {
|
|
3515
|
+
from: user
|
|
3516
|
+
});
|
|
3818
3517
|
|
|
3819
3518
|
case 2:
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3519
|
+
userInfo = _context4.sent;
|
|
3520
|
+
rewards = userInfo.unclaimedRewards;
|
|
3521
|
+
return _context4.abrupt("return", rewards.map(function (reward, i) {
|
|
3522
|
+
return TokenAmount.fromAddressAndAmount(PLYWNEAR_REWARD_TOKENS[i], reward.toString());
|
|
3523
|
+
}));
|
|
3524
|
+
|
|
3525
|
+
case 5:
|
|
3526
|
+
case "end":
|
|
3527
|
+
return _context4.stop();
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3824
3530
|
}, _callee4, this);
|
|
3825
3531
|
}));
|
|
3826
3532
|
|
|
3827
|
-
function
|
|
3828
|
-
return
|
|
3533
|
+
function unclaimedRewardsOf(_x3) {
|
|
3534
|
+
return _unclaimedRewardsOf.apply(this, arguments);
|
|
3829
3535
|
}
|
|
3830
3536
|
|
|
3831
|
-
return
|
|
3832
|
-
}()
|
|
3833
|
-
/**
|
|
3834
|
-
* Called when an user confirms he is referred by a specified code
|
|
3835
|
-
*/
|
|
3836
|
-
;
|
|
3537
|
+
return unclaimedRewardsOf;
|
|
3538
|
+
}();
|
|
3837
3539
|
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3540
|
+
return StakingRead;
|
|
3541
|
+
}(BlockchainEntityRead);
|
|
3542
|
+
var StakingReadWrite = /*#__PURE__*/function (_StakingRead) {
|
|
3543
|
+
_inheritsLoose(StakingReadWrite, _StakingRead);
|
|
3544
|
+
|
|
3545
|
+
function StakingReadWrite() {
|
|
3546
|
+
return _StakingRead.apply(this, arguments) || this;
|
|
3547
|
+
}
|
|
3548
|
+
|
|
3549
|
+
var _proto2 = StakingReadWrite.prototype;
|
|
3550
|
+
|
|
3551
|
+
_proto2.stake = /*#__PURE__*/function () {
|
|
3552
|
+
var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(amount) {
|
|
3843
3553
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
3844
3554
|
while (1) {
|
|
3845
3555
|
switch (_context5.prev = _context5.next) {
|
|
3846
3556
|
case 0:
|
|
3847
|
-
|
|
3848
|
-
return _context5.abrupt("return", this.referral.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
|
|
3557
|
+
return _context5.abrupt("return", this.env.auriFairLaunch.connect(this._networkConnection.signer).deposit(PLYWNEAR_POOL_ID, amount.rawAmount()));
|
|
3849
3558
|
|
|
3850
|
-
case
|
|
3559
|
+
case 1:
|
|
3851
3560
|
case "end":
|
|
3852
3561
|
return _context5.stop();
|
|
3853
3562
|
}
|
|
@@ -3855,97 +3564,427 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
|
3855
3564
|
}, _callee5, this);
|
|
3856
3565
|
}));
|
|
3857
3566
|
|
|
3858
|
-
function
|
|
3859
|
-
return
|
|
3567
|
+
function stake(_x4) {
|
|
3568
|
+
return _stake.apply(this, arguments);
|
|
3860
3569
|
}
|
|
3861
3570
|
|
|
3862
|
-
return
|
|
3571
|
+
return stake;
|
|
3863
3572
|
}();
|
|
3864
3573
|
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
var
|
|
3868
|
-
|
|
3574
|
+
_proto2.unstake = /*#__PURE__*/function () {
|
|
3575
|
+
var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(amount) {
|
|
3576
|
+
var msgSender, amountInput, stakedAmount, unstakeAmount;
|
|
3577
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
3578
|
+
while (1) {
|
|
3579
|
+
switch (_context6.prev = _context6.next) {
|
|
3580
|
+
case 0:
|
|
3581
|
+
_context6.next = 2;
|
|
3582
|
+
return this._networkConnection.signer.getAddress();
|
|
3869
3583
|
|
|
3870
|
-
|
|
3584
|
+
case 2:
|
|
3585
|
+
msgSender = _context6.sent;
|
|
3586
|
+
amountInput = BigNumber$1.from(amount.rawAmount());
|
|
3587
|
+
_context6.t0 = BigNumber$1;
|
|
3588
|
+
_context6.next = 7;
|
|
3589
|
+
return this.stakeBalanceOf(msgSender);
|
|
3590
|
+
|
|
3591
|
+
case 7:
|
|
3592
|
+
_context6.t1 = _context6.sent.rawAmount();
|
|
3593
|
+
stakedAmount = _context6.t0.from.call(_context6.t0, _context6.t1);
|
|
3594
|
+
// unstakeAmount = min(amountInput, stakedAmount - 1)
|
|
3595
|
+
unstakeAmount = amountInput.lt(stakedAmount) ? amountInput : stakedAmount.sub(1);
|
|
3596
|
+
return _context6.abrupt("return", this.env.auriFairLaunch.connect(this._networkConnection.signer).withdraw(PLYWNEAR_POOL_ID, unstakeAmount));
|
|
3597
|
+
|
|
3598
|
+
case 11:
|
|
3599
|
+
case "end":
|
|
3600
|
+
return _context6.stop();
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
}, _callee6, this);
|
|
3604
|
+
}));
|
|
3605
|
+
|
|
3606
|
+
function unstake(_x5) {
|
|
3607
|
+
return _unstake.apply(this, arguments);
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
return unstake;
|
|
3611
|
+
}();
|
|
3612
|
+
|
|
3613
|
+
return StakingReadWrite;
|
|
3614
|
+
}(StakingRead);
|
|
3615
|
+
var Staking = /*#__PURE__*/function (_BlockchainEntity) {
|
|
3616
|
+
_inheritsLoose(Staking, _BlockchainEntity);
|
|
3617
|
+
|
|
3618
|
+
function Staking() {
|
|
3871
3619
|
return _BlockchainEntity.call(this) || this;
|
|
3872
3620
|
}
|
|
3873
3621
|
|
|
3874
|
-
var _proto3 =
|
|
3622
|
+
var _proto3 = Staking.prototype;
|
|
3875
3623
|
|
|
3876
3624
|
_proto3.read = function read(networkConnection) {
|
|
3877
|
-
return new
|
|
3625
|
+
return new StakingRead(networkConnection);
|
|
3878
3626
|
};
|
|
3879
3627
|
|
|
3880
3628
|
_proto3.readWrite = function readWrite(networkConnection) {
|
|
3881
|
-
return new
|
|
3629
|
+
return new StakingReadWrite(networkConnection);
|
|
3882
3630
|
};
|
|
3883
3631
|
|
|
3884
|
-
return
|
|
3632
|
+
return Staking;
|
|
3885
3633
|
}(BlockchainEntity);
|
|
3886
3634
|
|
|
3887
|
-
var
|
|
3888
|
-
_inheritsLoose(
|
|
3635
|
+
var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3636
|
+
_inheritsLoose(MiscRead, _BlockchainEntityRead);
|
|
3889
3637
|
|
|
3890
|
-
function
|
|
3638
|
+
function MiscRead(networkConnection) {
|
|
3891
3639
|
var _this;
|
|
3892
3640
|
|
|
3893
3641
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3642
|
+
_this.stakingRead = new StakingRead(networkConnection);
|
|
3894
3643
|
_this.env = new AuriEnv(networkConnection);
|
|
3895
3644
|
return _this;
|
|
3896
3645
|
}
|
|
3897
3646
|
|
|
3898
|
-
var _proto =
|
|
3647
|
+
var _proto = MiscRead.prototype;
|
|
3648
|
+
|
|
3649
|
+
_proto.getUserDetails = /*#__PURE__*/function () {
|
|
3650
|
+
var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddress) {
|
|
3651
|
+
var _this2 = this;
|
|
3652
|
+
|
|
3653
|
+
var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
|
|
3899
3654
|
|
|
3900
|
-
_proto.getPLYWNEARPoolDetails = /*#__PURE__*/function () {
|
|
3901
|
-
var _getPLYWNEARPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
3902
|
-
var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, totalStakeValuation, promises, i, rewardTokenAddress, rewardToken, rewardPerSecond, APYs;
|
|
3903
3655
|
return runtime_1.wrap(function _callee$(_context) {
|
|
3904
3656
|
while (1) {
|
|
3905
3657
|
switch (_context.prev = _context.next) {
|
|
3906
3658
|
case 0:
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3659
|
+
marketCount = networkAddresses.auTokens.length;
|
|
3660
|
+
userMarketDetails = [];
|
|
3661
|
+
promises = [];
|
|
3662
|
+
totalBorrowLimit = new BigNumber(0);
|
|
3663
|
+
pricePromises = [];
|
|
3664
|
+
|
|
3665
|
+
_loop2 = function _loop2() {
|
|
3666
|
+
var auToken = _step.value;
|
|
3667
|
+
var userMarketDetail = {};
|
|
3668
|
+
userMarketDetails.push(userMarketDetail);
|
|
3669
|
+
userMarketDetail.market = auToken.underlying;
|
|
3670
|
+
var moneyMarket = new MoneyMarketRead(_this2._networkConnection, auToken.address, auToken.underlying);
|
|
3671
|
+
promises.push(moneyMarket.getUserDepositBalance(userAddress).then(function (res) {
|
|
3672
|
+
userMarketDetail.depositBalance = res;
|
|
3673
|
+
}));
|
|
3674
|
+
promises.push(moneyMarket.getUserBorrowBalance(userAddress).then(function (res) {
|
|
3675
|
+
userMarketDetail.borrowBalance = res;
|
|
3676
|
+
}));
|
|
3677
|
+
promises.push(moneyMarket.getCollateralRatio().then(function (res) {
|
|
3678
|
+
userMarketDetail.collateralRatio = res.toNumber();
|
|
3679
|
+
}));
|
|
3680
|
+
pricePromises.push(fetchPrice(moneyMarket.underlying.address, _this2._networkConnection.provider).then(function (res) {
|
|
3681
|
+
userMarketDetail.underlyingPrice = res.toString();
|
|
3682
|
+
return res;
|
|
3683
|
+
}));
|
|
3684
|
+
};
|
|
3685
|
+
|
|
3686
|
+
for (_iterator = _createForOfIteratorHelperLoose(networkAddresses.auTokens); !(_step = _iterator()).done;) {
|
|
3687
|
+
_loop2();
|
|
3688
|
+
}
|
|
3689
|
+
|
|
3690
|
+
promises.push(this.env.comptroller.getAssetsIn(userAddress).then(function (res) {
|
|
3691
|
+
assetsIn = res;
|
|
3692
|
+
}));
|
|
3693
|
+
_context.next = 10;
|
|
3694
|
+
return Promise.all(promises);
|
|
3695
|
+
|
|
3696
|
+
case 10:
|
|
3697
|
+
_context.next = 12;
|
|
3698
|
+
return Promise.all(pricePromises);
|
|
3699
|
+
|
|
3700
|
+
case 12:
|
|
3701
|
+
underlyingPrices = _context.sent;
|
|
3702
|
+
depositValues = [];
|
|
3703
|
+
|
|
3704
|
+
_loop = function _loop() {
|
|
3705
|
+
var auToken = networkAddresses.auTokens[i];
|
|
3706
|
+
|
|
3707
|
+
if (assetsIn.find(function (auAddress) {
|
|
3708
|
+
return isSameAddress(auToken.address, auAddress);
|
|
3709
|
+
}) !== undefined) {
|
|
3710
|
+
userMarketDetails[i].isCollateral = true;
|
|
3711
|
+
} else {
|
|
3712
|
+
userMarketDetails[i].isCollateral = false;
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
depositValues.push(calcValuation(userMarketDetails[i].depositBalance, underlyingPrices[i]));
|
|
3716
|
+
};
|
|
3717
|
+
|
|
3718
|
+
for (i = 0; i < marketCount; i++) {
|
|
3719
|
+
_loop();
|
|
3720
|
+
}
|
|
3721
|
+
|
|
3722
|
+
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3723
|
+
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
3724
|
+
return p;
|
|
3725
|
+
}, new BigNumber(0));
|
|
3726
|
+
_context.next = 19;
|
|
3727
|
+
return this.env.comptroller.getAccountLiquidity(userAddress);
|
|
3728
|
+
|
|
3729
|
+
case 19:
|
|
3730
|
+
accountLiquidity = _context.sent;
|
|
3731
|
+
borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
|
|
3732
|
+
|
|
3733
|
+
if (borrowedvaluation.lt('0.00001')) {
|
|
3734
|
+
// Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
|
|
3735
|
+
borrowedvaluation = new BigNumber(0);
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
bufferedBorrowLimit = totalBorrowLimit.multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3739
|
+
minimumBorrowLimitAllowed = borrowedvaluation.div(BORROW_LIMIT_BUFFER);
|
|
3740
|
+
|
|
3741
|
+
if (bufferedBorrowLimit.lte(borrowedvaluation)) {
|
|
3742
|
+
borrowableAmount = new BigNumber(0);
|
|
3743
|
+
} else {
|
|
3744
|
+
borrowableAmount = bufferedBorrowLimit.minus(borrowedvaluation);
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3747
|
+
for (i = 0; i < marketCount; i++) {
|
|
3748
|
+
auToken = networkAddresses.auTokens[i];
|
|
3749
|
+
moneyMarket = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
|
|
3750
|
+
borrowLimitMargin = totalBorrowLimit.minus(minimumBorrowLimitAllowed).gt(0) ? totalBorrowLimit.minus(minimumBorrowLimitAllowed) : new BigNumber(0);
|
|
3751
|
+
maxWithdrawCap = borrowLimitMargin.div(userMarketDetails[i].collateralRatio).div(underlyingPrices[i]);
|
|
3752
|
+
userMarketDetails[i].maxWithdrawableAmount = userMarketDetails[i].isCollateral && maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount()) ? new TokenAmount(moneyMarket.underlying, maxWithdrawCap.toFixed(24), false) : new TokenAmount(moneyMarket.underlying, userMarketDetails[i].depositBalance.rawAmount());
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
_context.t0 = userMarketDetails;
|
|
3756
|
+
_context.t1 = {
|
|
3757
|
+
currency: 'USD',
|
|
3758
|
+
amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
|
|
3759
|
+
};
|
|
3760
|
+
_context.next = 30;
|
|
3761
|
+
return new PapermillRead(this._networkConnection).getLockingDetails(userAddress);
|
|
3762
|
+
|
|
3763
|
+
case 30:
|
|
3764
|
+
_context.t2 = _context.sent;
|
|
3765
|
+
_context.t3 = {
|
|
3766
|
+
currency: 'USD',
|
|
3767
|
+
amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
|
|
3768
|
+
};
|
|
3769
|
+
return _context.abrupt("return", {
|
|
3770
|
+
markets: _context.t0,
|
|
3771
|
+
borrowLimit: _context.t1,
|
|
3772
|
+
userLockingDetails: _context.t2,
|
|
3773
|
+
borrowableAmount: _context.t3
|
|
3911
3774
|
});
|
|
3912
3775
|
|
|
3776
|
+
case 33:
|
|
3777
|
+
case "end":
|
|
3778
|
+
return _context.stop();
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
}, _callee, this);
|
|
3782
|
+
}));
|
|
3783
|
+
|
|
3784
|
+
function getUserDetails(_x) {
|
|
3785
|
+
return _getUserDetails.apply(this, arguments);
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
return getUserDetails;
|
|
3789
|
+
}();
|
|
3790
|
+
|
|
3791
|
+
_proto.getTokenPrice = /*#__PURE__*/function () {
|
|
3792
|
+
var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(token) {
|
|
3793
|
+
var price;
|
|
3794
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3795
|
+
while (1) {
|
|
3796
|
+
switch (_context2.prev = _context2.next) {
|
|
3797
|
+
case 0:
|
|
3798
|
+
_context2.next = 2;
|
|
3799
|
+
return fetchPrice(token.address, this._networkConnection.provider);
|
|
3800
|
+
|
|
3913
3801
|
case 2:
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3802
|
+
price = _context2.sent;
|
|
3803
|
+
return _context2.abrupt("return", {
|
|
3804
|
+
currency: 'USD',
|
|
3805
|
+
amount: price.toFixed(DECIMAL_PRECISION)
|
|
3806
|
+
});
|
|
3917
3807
|
|
|
3918
|
-
case
|
|
3919
|
-
|
|
3920
|
-
|
|
3808
|
+
case 4:
|
|
3809
|
+
case "end":
|
|
3810
|
+
return _context2.stop();
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
}, _callee2, this);
|
|
3814
|
+
}));
|
|
3921
3815
|
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
rewardPerSecond = rewardPerSeconds[i];
|
|
3926
|
-
promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
|
|
3927
|
-
}
|
|
3816
|
+
function getTokenPrice(_x2) {
|
|
3817
|
+
return _getTokenPrice.apply(this, arguments);
|
|
3818
|
+
}
|
|
3928
3819
|
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
return Promise.all(promises);
|
|
3820
|
+
return getTokenPrice;
|
|
3821
|
+
}();
|
|
3932
3822
|
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3823
|
+
_proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
|
|
3824
|
+
var userMarketDetail = _ref.userMarketDetail,
|
|
3825
|
+
currentBorrowLimit = _ref.currentBorrowLimit,
|
|
3826
|
+
currentBorrowValuation = _ref.currentBorrowValuation,
|
|
3827
|
+
action = _ref.action,
|
|
3828
|
+
tokenAmount = _ref.tokenAmount;
|
|
3829
|
+
var newBorrowLimit = new BigNumber(currentBorrowLimit.amount),
|
|
3830
|
+
newBorrowValuation = new BigNumber(currentBorrowValuation.amount);
|
|
3831
|
+
|
|
3832
|
+
switch (action) {
|
|
3833
|
+
case MarketAction.EnableCollateral:
|
|
3834
|
+
case MarketAction.DisableCollateral:
|
|
3835
|
+
var deltaBorrowLimit = calcValuation(userMarketDetail.depositBalance, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3836
|
+
newBorrowLimit = action == MarketAction.EnableCollateral ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
3837
|
+
break;
|
|
3838
|
+
|
|
3839
|
+
case MarketAction.Deposit:
|
|
3840
|
+
case MarketAction.Withdraw:
|
|
3841
|
+
deltaBorrowLimit = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3842
|
+
newBorrowLimit = action == MarketAction.Deposit ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
3843
|
+
break;
|
|
3844
|
+
|
|
3845
|
+
case MarketAction.Borrow:
|
|
3846
|
+
case MarketAction.Repay:
|
|
3847
|
+
var deltaBorrowValuation = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice));
|
|
3848
|
+
newBorrowValuation = action == MarketAction.Borrow ? newBorrowValuation.plus(deltaBorrowValuation) : newBorrowValuation.minus(deltaBorrowValuation);
|
|
3849
|
+
break;
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3852
|
+
return {
|
|
3853
|
+
newBorrowLimit: {
|
|
3854
|
+
amount: newBorrowLimit.toFixed(DECIMAL_PRECISION),
|
|
3855
|
+
currency: 'USD'
|
|
3856
|
+
},
|
|
3857
|
+
newBorrowUtilization: newBorrowLimit.eq(0) ? newBorrowValuation.eq(0) ? 0 : 9999.99 : newBorrowValuation.div(newBorrowLimit).toNumber()
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
/**
|
|
3861
|
+
* Get ply circulating supply.
|
|
3862
|
+
* It is calculated by the total supply, minus:
|
|
3863
|
+
* - Ply in team multisig contract
|
|
3864
|
+
* - Ply in comptroller contract
|
|
3865
|
+
* - Ply in fairlaunch contract
|
|
3866
|
+
* - Ply in vesting contract
|
|
3867
|
+
*/
|
|
3868
|
+
;
|
|
3869
|
+
|
|
3870
|
+
_proto.getPlyCirculatingSupply =
|
|
3871
|
+
/*#__PURE__*/
|
|
3872
|
+
function () {
|
|
3873
|
+
var _getPlyCirculatingSupply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
3874
|
+
var multicallRead, baseBalanceOfCall, callResults, circulatingSupply;
|
|
3875
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
3876
|
+
while (1) {
|
|
3877
|
+
switch (_context3.prev = _context3.next) {
|
|
3878
|
+
case 0:
|
|
3879
|
+
multicallRead = new MulticallRead(this._networkConnection);
|
|
3880
|
+
baseBalanceOfCall = {
|
|
3881
|
+
contract: this.env.ply,
|
|
3882
|
+
method: 'balanceOf',
|
|
3883
|
+
returnTypes: ['uint256']
|
|
3884
|
+
};
|
|
3885
|
+
_context3.next = 4;
|
|
3886
|
+
return multicallRead.aggregate([// Get total supply
|
|
3887
|
+
_extends({}, baseBalanceOfCall, {
|
|
3888
|
+
method: 'totalSupply',
|
|
3889
|
+
args: []
|
|
3890
|
+
}), // balance in team multisig
|
|
3891
|
+
_extends({}, baseBalanceOfCall, {
|
|
3892
|
+
args: [networkAddresses.misc.TEAM_MULTISIG]
|
|
3893
|
+
}), // balance in comptroller
|
|
3894
|
+
_extends({}, baseBalanceOfCall, {
|
|
3895
|
+
args: [networkAddresses.misc.COMPTROLLER]
|
|
3896
|
+
}), // balance in fair launch
|
|
3897
|
+
_extends({}, baseBalanceOfCall, {
|
|
3898
|
+
args: [networkAddresses.misc.AURIFAIRLAUNCH]
|
|
3899
|
+
}), // balance in vesting contract
|
|
3900
|
+
_extends({}, baseBalanceOfCall, {
|
|
3901
|
+
args: [networkAddresses.misc.PLY_TOKEN_LOCK]
|
|
3902
|
+
})]);
|
|
3903
|
+
|
|
3904
|
+
case 4:
|
|
3905
|
+
callResults = _context3.sent;
|
|
3906
|
+
circulatingSupply = BigNumber$1.from(0);
|
|
3907
|
+
callResults.forEach(function (result, i) {
|
|
3908
|
+
if (i === 0) {
|
|
3909
|
+
circulatingSupply = result[0];
|
|
3910
|
+
} else {
|
|
3911
|
+
circulatingSupply = circulatingSupply.sub(result[0]);
|
|
3912
|
+
}
|
|
3941
3913
|
});
|
|
3914
|
+
return _context3.abrupt("return", new TokenAmount(PLYToken, circulatingSupply.toString()));
|
|
3915
|
+
|
|
3916
|
+
case 8:
|
|
3917
|
+
case "end":
|
|
3918
|
+
return _context3.stop();
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
}, _callee3, this);
|
|
3922
|
+
}));
|
|
3923
|
+
|
|
3924
|
+
function getPlyCirculatingSupply() {
|
|
3925
|
+
return _getPlyCirculatingSupply.apply(this, arguments);
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
return getPlyCirculatingSupply;
|
|
3929
|
+
}();
|
|
3930
|
+
|
|
3931
|
+
return MiscRead;
|
|
3932
|
+
}(BlockchainEntityRead);
|
|
3933
|
+
|
|
3934
|
+
var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3935
|
+
_inheritsLoose(ReferralRead, _BlockchainEntityRead);
|
|
3936
|
+
|
|
3937
|
+
function ReferralRead(networkConnection) {
|
|
3938
|
+
var _this;
|
|
3939
|
+
|
|
3940
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3941
|
+
_this.referral = new Contract(networkAddresses.misc.REFERRAL, abis$9.abi, networkConnection.provider);
|
|
3942
|
+
return _this;
|
|
3943
|
+
}
|
|
3944
|
+
/**
|
|
3945
|
+
* Generate a 10-character referral code
|
|
3946
|
+
* containing alphanumeric characters.
|
|
3947
|
+
*/
|
|
3948
|
+
|
|
3949
|
+
|
|
3950
|
+
var _proto = ReferralRead.prototype;
|
|
3951
|
+
|
|
3952
|
+
_proto.generateReferralCode = function generateReferralCode() {
|
|
3953
|
+
var letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
3954
|
+
var numbers = '1234567890';
|
|
3955
|
+
var charset = letters + letters.toUpperCase() + numbers;
|
|
3956
|
+
var R = '';
|
|
3957
|
+
|
|
3958
|
+
for (var i = 0; i < 10; i++) {
|
|
3959
|
+
R += charset[Math.floor(Math.random() * charset.length)];
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
return R;
|
|
3963
|
+
}
|
|
3964
|
+
/**
|
|
3965
|
+
* Get the referral code for a given address, returns empty string if not found.
|
|
3966
|
+
*
|
|
3967
|
+
* Called to check if a user has a referral code.
|
|
3968
|
+
*/
|
|
3969
|
+
;
|
|
3970
|
+
|
|
3971
|
+
_proto.getUserReferralCode =
|
|
3972
|
+
/*#__PURE__*/
|
|
3973
|
+
function () {
|
|
3974
|
+
var _getUserReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddr) {
|
|
3975
|
+
var result;
|
|
3976
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
3977
|
+
while (1) {
|
|
3978
|
+
switch (_context.prev = _context.next) {
|
|
3979
|
+
case 0:
|
|
3980
|
+
_context.next = 2;
|
|
3981
|
+
return this.referral.userReferralCode(userAddr);
|
|
3942
3982
|
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
});
|
|
3983
|
+
case 2:
|
|
3984
|
+
result = _context.sent;
|
|
3985
|
+
return _context.abrupt("return", ethers.utils.parseBytes32String(result));
|
|
3947
3986
|
|
|
3948
|
-
case
|
|
3987
|
+
case 4:
|
|
3949
3988
|
case "end":
|
|
3950
3989
|
return _context.stop();
|
|
3951
3990
|
}
|
|
@@ -3953,32 +3992,32 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3953
3992
|
}, _callee, this);
|
|
3954
3993
|
}));
|
|
3955
3994
|
|
|
3956
|
-
function
|
|
3957
|
-
return
|
|
3995
|
+
function getUserReferralCode(_x) {
|
|
3996
|
+
return _getUserReferralCode.apply(this, arguments);
|
|
3958
3997
|
}
|
|
3959
3998
|
|
|
3960
|
-
return
|
|
3999
|
+
return getUserReferralCode;
|
|
3961
4000
|
}()
|
|
3962
4001
|
/**
|
|
3963
|
-
* Get
|
|
4002
|
+
* Get referral code that a user was referred by, returns empty string if not found.
|
|
3964
4003
|
*/
|
|
3965
4004
|
;
|
|
3966
4005
|
|
|
3967
|
-
_proto.
|
|
4006
|
+
_proto.getReferralCodeUsed =
|
|
3968
4007
|
/*#__PURE__*/
|
|
3969
4008
|
function () {
|
|
3970
|
-
var
|
|
3971
|
-
var
|
|
4009
|
+
var _getReferralCodeUsed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddr) {
|
|
4010
|
+
var result;
|
|
3972
4011
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3973
4012
|
while (1) {
|
|
3974
4013
|
switch (_context2.prev = _context2.next) {
|
|
3975
4014
|
case 0:
|
|
3976
4015
|
_context2.next = 2;
|
|
3977
|
-
return this.
|
|
4016
|
+
return this.referral.referralCodeUsed(userAddr);
|
|
3978
4017
|
|
|
3979
4018
|
case 2:
|
|
3980
|
-
|
|
3981
|
-
return _context2.abrupt("return",
|
|
4019
|
+
result = _context2.sent;
|
|
4020
|
+
return _context2.abrupt("return", ethers.utils.parseBytes32String(result));
|
|
3982
4021
|
|
|
3983
4022
|
case 4:
|
|
3984
4023
|
case "end":
|
|
@@ -3988,35 +4027,30 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3988
4027
|
}, _callee2, this);
|
|
3989
4028
|
}));
|
|
3990
4029
|
|
|
3991
|
-
function
|
|
3992
|
-
return
|
|
4030
|
+
function getReferralCodeUsed(_x2) {
|
|
4031
|
+
return _getReferralCodeUsed.apply(this, arguments);
|
|
3993
4032
|
}
|
|
3994
4033
|
|
|
3995
|
-
return
|
|
4034
|
+
return getReferralCodeUsed;
|
|
3996
4035
|
}()
|
|
3997
4036
|
/**
|
|
3998
|
-
* Get
|
|
4037
|
+
* Get owner of a referral code, returns zero address if not found.
|
|
3999
4038
|
*/
|
|
4000
4039
|
;
|
|
4001
4040
|
|
|
4002
|
-
_proto.
|
|
4041
|
+
_proto.getReferralCodeOwner =
|
|
4003
4042
|
/*#__PURE__*/
|
|
4004
4043
|
function () {
|
|
4005
|
-
var
|
|
4006
|
-
var
|
|
4044
|
+
var _getReferralCodeOwner = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(code) {
|
|
4045
|
+
var referralCode;
|
|
4007
4046
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
4008
4047
|
while (1) {
|
|
4009
4048
|
switch (_context3.prev = _context3.next) {
|
|
4010
4049
|
case 0:
|
|
4011
|
-
|
|
4012
|
-
_context3.
|
|
4013
|
-
return lpContract.balanceOf(user);
|
|
4014
|
-
|
|
4015
|
-
case 3:
|
|
4016
|
-
balance = _context3.sent;
|
|
4017
|
-
return _context3.abrupt("return", new TokenAmount(PLYWNEARToken, balance.toString()));
|
|
4050
|
+
referralCode = ethers.utils.formatBytes32String(code);
|
|
4051
|
+
return _context3.abrupt("return", this.referral.referralCodeOwner(referralCode));
|
|
4018
4052
|
|
|
4019
|
-
case
|
|
4053
|
+
case 2:
|
|
4020
4054
|
case "end":
|
|
4021
4055
|
return _context3.stop();
|
|
4022
4056
|
}
|
|
@@ -4024,33 +4058,42 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4024
4058
|
}, _callee3, this);
|
|
4025
4059
|
}));
|
|
4026
4060
|
|
|
4027
|
-
function
|
|
4028
|
-
return
|
|
4061
|
+
function getReferralCodeOwner(_x3) {
|
|
4062
|
+
return _getReferralCodeOwner.apply(this, arguments);
|
|
4029
4063
|
}
|
|
4030
4064
|
|
|
4031
|
-
return
|
|
4065
|
+
return getReferralCodeOwner;
|
|
4032
4066
|
}();
|
|
4033
4067
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4068
|
+
return ReferralRead;
|
|
4069
|
+
}(BlockchainEntityRead);
|
|
4070
|
+
var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
4071
|
+
_inheritsLoose(ReferralReadWrite, _ReferralRead);
|
|
4072
|
+
|
|
4073
|
+
function ReferralReadWrite() {
|
|
4074
|
+
return _ReferralRead.apply(this, arguments) || this;
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
var _proto2 = ReferralReadWrite.prototype;
|
|
4078
|
+
|
|
4079
|
+
/**
|
|
4080
|
+
* Generate a referral code for a given address.
|
|
4081
|
+
*
|
|
4082
|
+
* Called when an user want to creates his own referral code
|
|
4083
|
+
*/
|
|
4084
|
+
_proto2.registerNewReferralCode =
|
|
4085
|
+
/*#__PURE__*/
|
|
4086
|
+
function () {
|
|
4087
|
+
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
4088
|
+
var referralCode;
|
|
4037
4089
|
return runtime_1.wrap(function _callee4$(_context4) {
|
|
4038
4090
|
while (1) {
|
|
4039
4091
|
switch (_context4.prev = _context4.next) {
|
|
4040
4092
|
case 0:
|
|
4041
|
-
|
|
4042
|
-
return this.
|
|
4043
|
-
from: user
|
|
4044
|
-
});
|
|
4093
|
+
referralCode = ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
4094
|
+
return _context4.abrupt("return", this.referral.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
|
|
4045
4095
|
|
|
4046
4096
|
case 2:
|
|
4047
|
-
userInfo = _context4.sent;
|
|
4048
|
-
rewards = userInfo.unclaimedRewards;
|
|
4049
|
-
return _context4.abrupt("return", rewards.map(function (reward, i) {
|
|
4050
|
-
return TokenAmount.fromAddressAndAmount(PLYWNEAR_REWARD_TOKENS[i], reward.toString());
|
|
4051
|
-
}));
|
|
4052
|
-
|
|
4053
|
-
case 5:
|
|
4054
4097
|
case "end":
|
|
4055
4098
|
return _context4.stop();
|
|
4056
4099
|
}
|
|
@@ -4058,33 +4101,30 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4058
4101
|
}, _callee4, this);
|
|
4059
4102
|
}));
|
|
4060
4103
|
|
|
4061
|
-
function
|
|
4062
|
-
return
|
|
4104
|
+
function registerNewReferralCode() {
|
|
4105
|
+
return _registerNewReferralCode.apply(this, arguments);
|
|
4063
4106
|
}
|
|
4064
4107
|
|
|
4065
|
-
return
|
|
4066
|
-
}()
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
_inheritsLoose(StakingReadWrite, _StakingRead);
|
|
4072
|
-
|
|
4073
|
-
function StakingReadWrite() {
|
|
4074
|
-
return _StakingRead.apply(this, arguments) || this;
|
|
4075
|
-
}
|
|
4076
|
-
|
|
4077
|
-
var _proto2 = StakingReadWrite.prototype;
|
|
4108
|
+
return registerNewReferralCode;
|
|
4109
|
+
}()
|
|
4110
|
+
/**
|
|
4111
|
+
* Called when an user confirms he is referred by a specified code
|
|
4112
|
+
*/
|
|
4113
|
+
;
|
|
4078
4114
|
|
|
4079
|
-
_proto2.
|
|
4080
|
-
|
|
4115
|
+
_proto2.useReferralCode =
|
|
4116
|
+
/*#__PURE__*/
|
|
4117
|
+
function () {
|
|
4118
|
+
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(code) {
|
|
4119
|
+
var referralCode;
|
|
4081
4120
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
4082
4121
|
while (1) {
|
|
4083
4122
|
switch (_context5.prev = _context5.next) {
|
|
4084
4123
|
case 0:
|
|
4085
|
-
|
|
4124
|
+
referralCode = ethers.utils.formatBytes32String(code);
|
|
4125
|
+
return _context5.abrupt("return", this.referral.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
|
|
4086
4126
|
|
|
4087
|
-
case
|
|
4127
|
+
case 2:
|
|
4088
4128
|
case "end":
|
|
4089
4129
|
return _context5.stop();
|
|
4090
4130
|
}
|
|
@@ -4092,72 +4132,33 @@ var StakingReadWrite = /*#__PURE__*/function (_StakingRead) {
|
|
|
4092
4132
|
}, _callee5, this);
|
|
4093
4133
|
}));
|
|
4094
4134
|
|
|
4095
|
-
function
|
|
4096
|
-
return
|
|
4097
|
-
}
|
|
4098
|
-
|
|
4099
|
-
return stake;
|
|
4100
|
-
}();
|
|
4101
|
-
|
|
4102
|
-
_proto2.unstake = /*#__PURE__*/function () {
|
|
4103
|
-
var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(amount) {
|
|
4104
|
-
var msgSender, amountInput, stakedAmount, unstakeAmount;
|
|
4105
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
4106
|
-
while (1) {
|
|
4107
|
-
switch (_context6.prev = _context6.next) {
|
|
4108
|
-
case 0:
|
|
4109
|
-
_context6.next = 2;
|
|
4110
|
-
return this._networkConnection.signer.getAddress();
|
|
4111
|
-
|
|
4112
|
-
case 2:
|
|
4113
|
-
msgSender = _context6.sent;
|
|
4114
|
-
amountInput = BigNumber$1.from(amount.rawAmount());
|
|
4115
|
-
_context6.t0 = BigNumber$1;
|
|
4116
|
-
_context6.next = 7;
|
|
4117
|
-
return this.stakeBalanceOf(msgSender);
|
|
4118
|
-
|
|
4119
|
-
case 7:
|
|
4120
|
-
_context6.t1 = _context6.sent.rawAmount();
|
|
4121
|
-
stakedAmount = _context6.t0.from.call(_context6.t0, _context6.t1);
|
|
4122
|
-
// unstakeAmount = min(amountInput, stakedAmount - 1)
|
|
4123
|
-
unstakeAmount = amountInput.lt(stakedAmount) ? amountInput : stakedAmount.sub(1);
|
|
4124
|
-
return _context6.abrupt("return", this.env.auriFairLaunch.connect(this._networkConnection.signer).withdraw(PLYWNEAR_POOL_ID, unstakeAmount));
|
|
4125
|
-
|
|
4126
|
-
case 11:
|
|
4127
|
-
case "end":
|
|
4128
|
-
return _context6.stop();
|
|
4129
|
-
}
|
|
4130
|
-
}
|
|
4131
|
-
}, _callee6, this);
|
|
4132
|
-
}));
|
|
4133
|
-
|
|
4134
|
-
function unstake(_x5) {
|
|
4135
|
-
return _unstake.apply(this, arguments);
|
|
4135
|
+
function useReferralCode(_x4) {
|
|
4136
|
+
return _useReferralCode.apply(this, arguments);
|
|
4136
4137
|
}
|
|
4137
4138
|
|
|
4138
|
-
return
|
|
4139
|
+
return useReferralCode;
|
|
4139
4140
|
}();
|
|
4140
4141
|
|
|
4141
|
-
return
|
|
4142
|
-
}(
|
|
4143
|
-
var
|
|
4144
|
-
_inheritsLoose(
|
|
4142
|
+
return ReferralReadWrite;
|
|
4143
|
+
}(ReferralRead);
|
|
4144
|
+
var Referral = /*#__PURE__*/function (_BlockchainEntity) {
|
|
4145
|
+
_inheritsLoose(Referral, _BlockchainEntity);
|
|
4145
4146
|
|
|
4146
|
-
function
|
|
4147
|
+
function Referral() {
|
|
4147
4148
|
return _BlockchainEntity.call(this) || this;
|
|
4148
4149
|
}
|
|
4149
4150
|
|
|
4150
|
-
var _proto3 =
|
|
4151
|
+
var _proto3 = Referral.prototype;
|
|
4151
4152
|
|
|
4152
4153
|
_proto3.read = function read(networkConnection) {
|
|
4153
|
-
return new
|
|
4154
|
+
return new ReferralRead(networkConnection);
|
|
4154
4155
|
};
|
|
4155
4156
|
|
|
4156
4157
|
_proto3.readWrite = function readWrite(networkConnection) {
|
|
4157
|
-
return new
|
|
4158
|
+
return new ReferralReadWrite(networkConnection);
|
|
4158
4159
|
};
|
|
4159
4160
|
|
|
4160
|
-
return
|
|
4161
|
+
return Referral;
|
|
4161
4162
|
}(BlockchainEntity);
|
|
4162
4163
|
|
|
4163
4164
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
@@ -4374,6 +4375,38 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4374
4375
|
return getPlyCirculatingSupply;
|
|
4375
4376
|
}();
|
|
4376
4377
|
|
|
4378
|
+
_proto.getUltilizations = /*#__PURE__*/function () {
|
|
4379
|
+
var _getUltilizations = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(userAddr) {
|
|
4380
|
+
var helper, accountDetail, sumBorrow, sumCol;
|
|
4381
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
4382
|
+
while (1) {
|
|
4383
|
+
switch (_context8.prev = _context8.next) {
|
|
4384
|
+
case 0:
|
|
4385
|
+
helper = new Contract(networkAddresses.misc.ultilizationHelper, abis$a.abi, this._networkConnection.provider);
|
|
4386
|
+
_context8.next = 3;
|
|
4387
|
+
return helper.getAccountLiquidity(userAddr);
|
|
4388
|
+
|
|
4389
|
+
case 3:
|
|
4390
|
+
accountDetail = _context8.sent;
|
|
4391
|
+
sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
|
|
4392
|
+
sumCol = new BigNumber(accountDetail.sumCollateral.toString());
|
|
4393
|
+
return _context8.abrupt("return", sumBorrow.dividedBy(sumCol));
|
|
4394
|
+
|
|
4395
|
+
case 7:
|
|
4396
|
+
case "end":
|
|
4397
|
+
return _context8.stop();
|
|
4398
|
+
}
|
|
4399
|
+
}
|
|
4400
|
+
}, _callee8, this);
|
|
4401
|
+
}));
|
|
4402
|
+
|
|
4403
|
+
function getUltilizations(_x6) {
|
|
4404
|
+
return _getUltilizations.apply(this, arguments);
|
|
4405
|
+
}
|
|
4406
|
+
|
|
4407
|
+
return getUltilizations;
|
|
4408
|
+
}();
|
|
4409
|
+
|
|
4377
4410
|
return SdkRead;
|
|
4378
4411
|
}(BlockchainEntityRead);
|
|
4379
4412
|
var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
@@ -4391,25 +4424,25 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
4391
4424
|
_proto2.claim =
|
|
4392
4425
|
/*#__PURE__*/
|
|
4393
4426
|
function () {
|
|
4394
|
-
var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4395
|
-
return runtime_1.wrap(function
|
|
4427
|
+
var _claim = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
|
|
4428
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
4396
4429
|
while (1) {
|
|
4397
|
-
switch (
|
|
4430
|
+
switch (_context9.prev = _context9.next) {
|
|
4398
4431
|
case 0:
|
|
4399
|
-
|
|
4400
|
-
|
|
4432
|
+
_context9.t0 = this.env.comptroller.connect(this._networkConnection.signer);
|
|
4433
|
+
_context9.next = 3;
|
|
4401
4434
|
return this._networkConnection.signer.getAddress();
|
|
4402
4435
|
|
|
4403
4436
|
case 3:
|
|
4404
|
-
|
|
4405
|
-
return
|
|
4437
|
+
_context9.t1 = _context9.sent;
|
|
4438
|
+
return _context9.abrupt("return", _context9.t0['claimReward(uint8,address)'].call(_context9.t0, 0, _context9.t1));
|
|
4406
4439
|
|
|
4407
4440
|
case 5:
|
|
4408
4441
|
case "end":
|
|
4409
|
-
return
|
|
4442
|
+
return _context9.stop();
|
|
4410
4443
|
}
|
|
4411
4444
|
}
|
|
4412
|
-
},
|
|
4445
|
+
}, _callee9, this);
|
|
4413
4446
|
}));
|
|
4414
4447
|
|
|
4415
4448
|
function claim() {
|
|
@@ -4420,26 +4453,26 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
4420
4453
|
}();
|
|
4421
4454
|
|
|
4422
4455
|
_proto2.claimLpRewards = /*#__PURE__*/function () {
|
|
4423
|
-
var _claimLpRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4424
|
-
return runtime_1.wrap(function
|
|
4456
|
+
var _claimLpRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10() {
|
|
4457
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
4425
4458
|
while (1) {
|
|
4426
|
-
switch (
|
|
4459
|
+
switch (_context10.prev = _context10.next) {
|
|
4427
4460
|
case 0:
|
|
4428
|
-
|
|
4429
|
-
|
|
4461
|
+
_context10.t0 = this.env.auriFairLaunch.connect(this._networkConnection.signer);
|
|
4462
|
+
_context10.next = 3;
|
|
4430
4463
|
return this._networkConnection.signer.getAddress();
|
|
4431
4464
|
|
|
4432
4465
|
case 3:
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
return
|
|
4466
|
+
_context10.t1 = _context10.sent;
|
|
4467
|
+
_context10.t2 = INF;
|
|
4468
|
+
return _context10.abrupt("return", _context10.t0.harvest.call(_context10.t0, _context10.t1, 0, _context10.t2));
|
|
4436
4469
|
|
|
4437
4470
|
case 6:
|
|
4438
4471
|
case "end":
|
|
4439
|
-
return
|
|
4472
|
+
return _context10.stop();
|
|
4440
4473
|
}
|
|
4441
4474
|
}
|
|
4442
|
-
},
|
|
4475
|
+
}, _callee10, this);
|
|
4443
4476
|
}));
|
|
4444
4477
|
|
|
4445
4478
|
function claimLpRewards() {
|
|
@@ -4450,22 +4483,22 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
4450
4483
|
}();
|
|
4451
4484
|
|
|
4452
4485
|
_proto2.stake = /*#__PURE__*/function () {
|
|
4453
|
-
var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4454
|
-
return runtime_1.wrap(function
|
|
4486
|
+
var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(amount) {
|
|
4487
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
4455
4488
|
while (1) {
|
|
4456
|
-
switch (
|
|
4489
|
+
switch (_context11.prev = _context11.next) {
|
|
4457
4490
|
case 0:
|
|
4458
|
-
return
|
|
4491
|
+
return _context11.abrupt("return", new StakingReadWrite(this._networkConnection).stake(amount));
|
|
4459
4492
|
|
|
4460
4493
|
case 1:
|
|
4461
4494
|
case "end":
|
|
4462
|
-
return
|
|
4495
|
+
return _context11.stop();
|
|
4463
4496
|
}
|
|
4464
4497
|
}
|
|
4465
|
-
},
|
|
4498
|
+
}, _callee11, this);
|
|
4466
4499
|
}));
|
|
4467
4500
|
|
|
4468
|
-
function stake(
|
|
4501
|
+
function stake(_x7) {
|
|
4469
4502
|
return _stake.apply(this, arguments);
|
|
4470
4503
|
}
|
|
4471
4504
|
|
|
@@ -4473,22 +4506,22 @@ var SdkReadWrite = /*#__PURE__*/function (_SdkRead) {
|
|
|
4473
4506
|
}();
|
|
4474
4507
|
|
|
4475
4508
|
_proto2.unstake = /*#__PURE__*/function () {
|
|
4476
|
-
var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4477
|
-
return runtime_1.wrap(function
|
|
4509
|
+
var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
|
|
4510
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
4478
4511
|
while (1) {
|
|
4479
|
-
switch (
|
|
4512
|
+
switch (_context12.prev = _context12.next) {
|
|
4480
4513
|
case 0:
|
|
4481
|
-
return
|
|
4514
|
+
return _context12.abrupt("return", new StakingReadWrite(this._networkConnection).unstake(amount));
|
|
4482
4515
|
|
|
4483
4516
|
case 1:
|
|
4484
4517
|
case "end":
|
|
4485
|
-
return
|
|
4518
|
+
return _context12.stop();
|
|
4486
4519
|
}
|
|
4487
4520
|
}
|
|
4488
|
-
},
|
|
4521
|
+
}, _callee12, this);
|
|
4489
4522
|
}));
|
|
4490
4523
|
|
|
4491
|
-
function unstake(
|
|
4524
|
+
function unstake(_x8) {
|
|
4492
4525
|
return _unstake.apply(this, arguments);
|
|
4493
4526
|
}
|
|
4494
4527
|
|