@aurigami/sdk 1.17.0 → 1.17.2
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/interactors/index.d.ts +2 -1
- package/dist/sdk.cjs.development.js +1359 -1286
- 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 +1358 -1288
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/aurora-api-helpers.ts +1 -1
- package/src/helpers/helpers.ts +1 -1
- package/src/interactors/index.ts +2 -1
package/dist/sdk.esm.js
CHANGED
|
@@ -662,7 +662,7 @@ var symbolRecords = /*#__PURE__*/Object.fromEntries( /*#__PURE__*/networkAddress
|
|
|
662
662
|
return [address.toLowerCase(), name];
|
|
663
663
|
}));
|
|
664
664
|
|
|
665
|
-
var AURORA_API_BASE_URL = 'https://
|
|
665
|
+
var AURORA_API_BASE_URL = 'https://explorer.mainnet.aurora.dev/api';
|
|
666
666
|
function getQuery(_x, _x2, _x3) {
|
|
667
667
|
return _getQuery.apply(this, arguments);
|
|
668
668
|
}
|
|
@@ -966,7 +966,7 @@ function _getBlockBeforeTimestamp() {
|
|
|
966
966
|
});
|
|
967
967
|
case 2:
|
|
968
968
|
result = _context6.sent;
|
|
969
|
-
_context6.t0 = parseInt(result);
|
|
969
|
+
_context6.t0 = parseInt(result.blockNumber);
|
|
970
970
|
if (_context6.t0) {
|
|
971
971
|
_context6.next = 8;
|
|
972
972
|
break;
|
|
@@ -2409,21 +2409,6 @@ var Airdrop = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
2409
2409
|
return Airdrop;
|
|
2410
2410
|
}(BlockchainEntity);
|
|
2411
2411
|
|
|
2412
|
-
var ComptrollerRewardType;
|
|
2413
|
-
(function (ComptrollerRewardType) {
|
|
2414
|
-
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
2415
|
-
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
2416
|
-
})(ComptrollerRewardType || (ComptrollerRewardType = {}));
|
|
2417
|
-
var MarketAction;
|
|
2418
|
-
(function (MarketAction) {
|
|
2419
|
-
MarketAction[MarketAction["Deposit"] = 0] = "Deposit";
|
|
2420
|
-
MarketAction[MarketAction["Borrow"] = 1] = "Borrow";
|
|
2421
|
-
MarketAction[MarketAction["Withdraw"] = 2] = "Withdraw";
|
|
2422
|
-
MarketAction[MarketAction["Repay"] = 3] = "Repay";
|
|
2423
|
-
MarketAction[MarketAction["EnableCollateral"] = 4] = "EnableCollateral";
|
|
2424
|
-
MarketAction[MarketAction["DisableCollateral"] = 5] = "DisableCollateral";
|
|
2425
|
-
})(MarketAction || (MarketAction = {}));
|
|
2426
|
-
|
|
2427
2412
|
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2428
2413
|
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
2429
2414
|
function MoneyMarketRead(networkConnection, auToken, underlyingAsset) {
|
|
@@ -3265,71 +3250,6 @@ var MoneyMarket = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
3265
3250
|
return MoneyMarket;
|
|
3266
3251
|
}(BlockchainEntity);
|
|
3267
3252
|
|
|
3268
|
-
var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3269
|
-
_inheritsLoose(MulticallRead, _BlockchainEntityRead);
|
|
3270
|
-
function MulticallRead(networkConnection) {
|
|
3271
|
-
var _this;
|
|
3272
|
-
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3273
|
-
_this.multicall = new Contract(networkAddresses.misc.MULTICALL, abis$a.abi, networkConnection.provider);
|
|
3274
|
-
return _this;
|
|
3275
|
-
}
|
|
3276
|
-
/**
|
|
3277
|
-
* Run multiple calls via multicall contract
|
|
3278
|
-
*/
|
|
3279
|
-
var _proto = MulticallRead.prototype;
|
|
3280
|
-
_proto.aggregate =
|
|
3281
|
-
/*#__PURE__*/
|
|
3282
|
-
function () {
|
|
3283
|
-
var _aggregate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(calls) {
|
|
3284
|
-
var txns, i, _call$contract$popula, call, txn, response, decodedReturn, _i;
|
|
3285
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3286
|
-
while (1) switch (_context.prev = _context.next) {
|
|
3287
|
-
case 0:
|
|
3288
|
-
txns = []; // prepare transactions
|
|
3289
|
-
i = 0;
|
|
3290
|
-
case 2:
|
|
3291
|
-
if (!(i < calls.length)) {
|
|
3292
|
-
_context.next = 11;
|
|
3293
|
-
break;
|
|
3294
|
-
}
|
|
3295
|
-
call = calls[i];
|
|
3296
|
-
_context.next = 6;
|
|
3297
|
-
return (_call$contract$popula = call.contract.populateTransaction)[call.method].apply(_call$contract$popula, call.args);
|
|
3298
|
-
case 6:
|
|
3299
|
-
txn = _context.sent;
|
|
3300
|
-
txns.push({
|
|
3301
|
-
target: txn.to,
|
|
3302
|
-
callData: txn.data
|
|
3303
|
-
});
|
|
3304
|
-
case 8:
|
|
3305
|
-
i++;
|
|
3306
|
-
_context.next = 2;
|
|
3307
|
-
break;
|
|
3308
|
-
case 11:
|
|
3309
|
-
_context.next = 13;
|
|
3310
|
-
return this.multicall.callStatic.aggregate(txns);
|
|
3311
|
-
case 13:
|
|
3312
|
-
response = _context.sent;
|
|
3313
|
-
// parse results
|
|
3314
|
-
decodedReturn = [];
|
|
3315
|
-
for (_i = 0; _i < calls.length; _i++) {
|
|
3316
|
-
decodedReturn.push(ethers.utils.defaultAbiCoder.decode(calls[_i].returnTypes, response.returnData[_i]));
|
|
3317
|
-
}
|
|
3318
|
-
return _context.abrupt("return", decodedReturn);
|
|
3319
|
-
case 17:
|
|
3320
|
-
case "end":
|
|
3321
|
-
return _context.stop();
|
|
3322
|
-
}
|
|
3323
|
-
}, _callee, this);
|
|
3324
|
-
}));
|
|
3325
|
-
function aggregate(_x) {
|
|
3326
|
-
return _aggregate.apply(this, arguments);
|
|
3327
|
-
}
|
|
3328
|
-
return aggregate;
|
|
3329
|
-
}();
|
|
3330
|
-
return MulticallRead;
|
|
3331
|
-
}(BlockchainEntityRead);
|
|
3332
|
-
|
|
3333
3253
|
var LOCKING_DENOMINATOR = /*#__PURE__*/BigNumber$1.from(10000);
|
|
3334
3254
|
var PapermillRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3335
3255
|
_inheritsLoose(PapermillRead, _BlockchainEntityRead);
|
|
@@ -3621,1571 +3541,1721 @@ var Papermill = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
3621
3541
|
return Papermill;
|
|
3622
3542
|
}(BlockchainEntity);
|
|
3623
3543
|
|
|
3624
|
-
var
|
|
3625
|
-
_inheritsLoose(
|
|
3626
|
-
function
|
|
3544
|
+
var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3545
|
+
_inheritsLoose(PlyGameRead, _BlockchainEntityRead);
|
|
3546
|
+
function PlyGameRead(networkConnection) {
|
|
3627
3547
|
var _this;
|
|
3628
3548
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3629
3549
|
_this.env = new AuriEnv(networkConnection);
|
|
3550
|
+
var plyAddress = networkAddresses.tokens.PLY;
|
|
3551
|
+
var pulpAddress = networkAddresses.tokens.PULP;
|
|
3552
|
+
_this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
|
|
3553
|
+
_this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
|
|
3630
3554
|
return _this;
|
|
3631
3555
|
}
|
|
3632
|
-
var _proto =
|
|
3633
|
-
_proto.
|
|
3634
|
-
var
|
|
3635
|
-
|
|
3556
|
+
var _proto = PlyGameRead.prototype;
|
|
3557
|
+
_proto.parseBetMakeEvent = function parseBetMakeEvent(event) {
|
|
3558
|
+
var outcome = ['bigWin', 'win', 'lose', 'noImpact'][event.args.outcome];
|
|
3559
|
+
var betAmount = event.args.amount;
|
|
3560
|
+
// 0%, 0%, 100%, 2%
|
|
3561
|
+
// big win, win, lose, no impact
|
|
3562
|
+
var lostAmount = betAmount.mul([0, 0, 100, 2][event.args.outcome]).div(100);
|
|
3563
|
+
var unlock = betAmount.mul([10, 1, 0, 0][event.args.outcome]);
|
|
3564
|
+
return {
|
|
3565
|
+
player: event.args.player,
|
|
3566
|
+
lostAmount: new TokenAmount(this.plyToken, lostAmount.toString()),
|
|
3567
|
+
unlockedPulpAmount: new TokenAmount(this.pulpToken, unlock.toString()),
|
|
3568
|
+
outcome: outcome,
|
|
3569
|
+
transactionHash: event.transactionHash,
|
|
3570
|
+
block: event.blockNumber,
|
|
3571
|
+
timestamp: 0
|
|
3572
|
+
};
|
|
3573
|
+
};
|
|
3574
|
+
_proto.attachTimestamp = /*#__PURE__*/function () {
|
|
3575
|
+
var _attachTimestamp = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(results) {
|
|
3576
|
+
var blockNumbers, blockstimestamp;
|
|
3636
3577
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3637
3578
|
while (1) switch (_context.prev = _context.next) {
|
|
3638
3579
|
case 0:
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
stakedLiquidity = res.totalStake;
|
|
3642
|
-
rewardPerSeconds = res.rewardPerSeconds;
|
|
3580
|
+
blockNumbers = results.map(function (e) {
|
|
3581
|
+
return e.block;
|
|
3643
3582
|
});
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
for (i = 0; i < rewardPerSeconds.length; i++) {
|
|
3652
|
-
rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
|
|
3653
|
-
rewardToken = new Token(rewardTokenAddress, getDecimal(rewardTokenAddress));
|
|
3654
|
-
rewardPerSecond = rewardPerSeconds[i];
|
|
3655
|
-
promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
|
|
3656
|
-
}
|
|
3657
|
-
APYs = [];
|
|
3658
|
-
_context.next = 11;
|
|
3659
|
-
return Promise.all(promises);
|
|
3660
|
-
case 11:
|
|
3661
|
-
_context.sent.forEach(function (rewardPerSecondValuation, i) {
|
|
3662
|
-
var rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
|
|
3663
|
-
var apy = calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION);
|
|
3664
|
-
APYs.push({
|
|
3665
|
-
address: rewardTokenAddress,
|
|
3666
|
-
apy: apy
|
|
3583
|
+
_context.next = 3;
|
|
3584
|
+
return getBlocksTimestamp(this._networkConnection.provider, blockNumbers);
|
|
3585
|
+
case 3:
|
|
3586
|
+
blockstimestamp = _context.sent;
|
|
3587
|
+
return _context.abrupt("return", results.map(function (e, i) {
|
|
3588
|
+
return _extends({}, e, {
|
|
3589
|
+
timestamp: blockstimestamp[i]
|
|
3667
3590
|
});
|
|
3668
|
-
});
|
|
3669
|
-
|
|
3670
|
-
totalStakedLiquidity: stakedLiquidityAmount,
|
|
3671
|
-
APYs: APYs
|
|
3672
|
-
});
|
|
3673
|
-
case 13:
|
|
3591
|
+
}));
|
|
3592
|
+
case 5:
|
|
3674
3593
|
case "end":
|
|
3675
3594
|
return _context.stop();
|
|
3676
3595
|
}
|
|
3677
3596
|
}, _callee, this);
|
|
3678
3597
|
}));
|
|
3679
|
-
function
|
|
3680
|
-
return
|
|
3598
|
+
function attachTimestamp(_x) {
|
|
3599
|
+
return _attachTimestamp.apply(this, arguments);
|
|
3681
3600
|
}
|
|
3682
|
-
return
|
|
3601
|
+
return attachTimestamp;
|
|
3683
3602
|
}()
|
|
3684
3603
|
/**
|
|
3685
|
-
* Get
|
|
3604
|
+
* Get 100 most recent bets of the market users
|
|
3686
3605
|
*/
|
|
3687
3606
|
;
|
|
3688
|
-
_proto.
|
|
3607
|
+
_proto.getUserPlyGameHistory =
|
|
3689
3608
|
/*#__PURE__*/
|
|
3690
3609
|
function () {
|
|
3691
|
-
var
|
|
3692
|
-
var
|
|
3610
|
+
var _getUserPlyGameHistory = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(user) {
|
|
3611
|
+
var _this2 = this;
|
|
3612
|
+
var block100, filter, events;
|
|
3693
3613
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3694
3614
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3695
3615
|
case 0:
|
|
3696
3616
|
_context2.next = 2;
|
|
3697
|
-
return this.env.
|
|
3617
|
+
return this.env.plygame.getLastBlock(user, 100);
|
|
3698
3618
|
case 2:
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3619
|
+
block100 = _context2.sent;
|
|
3620
|
+
if (!block100.eq(0)) {
|
|
3621
|
+
_context2.next = 5;
|
|
3622
|
+
break;
|
|
3623
|
+
}
|
|
3624
|
+
return _context2.abrupt("return", []);
|
|
3625
|
+
case 5:
|
|
3626
|
+
filter = this.env.plygame.filters.BetMade(user);
|
|
3627
|
+
_context2.next = 8;
|
|
3628
|
+
return this.env.plygame.queryFilter(filter, block100.toNumber());
|
|
3629
|
+
case 8:
|
|
3630
|
+
events = _context2.sent;
|
|
3631
|
+
// Sort descending by block number
|
|
3632
|
+
sortEvents(events).reverse();
|
|
3633
|
+
return _context2.abrupt("return", this.attachTimestamp(events.map(function (event) {
|
|
3634
|
+
return _this2.parseBetMakeEvent(event);
|
|
3635
|
+
})));
|
|
3636
|
+
case 11:
|
|
3702
3637
|
case "end":
|
|
3703
3638
|
return _context2.stop();
|
|
3704
3639
|
}
|
|
3705
3640
|
}, _callee2, this);
|
|
3706
3641
|
}));
|
|
3707
|
-
function
|
|
3708
|
-
return
|
|
3642
|
+
function getUserPlyGameHistory(_x2) {
|
|
3643
|
+
return _getUserPlyGameHistory.apply(this, arguments);
|
|
3709
3644
|
}
|
|
3710
|
-
return
|
|
3645
|
+
return getUserPlyGameHistory;
|
|
3711
3646
|
}()
|
|
3712
3647
|
/**
|
|
3713
|
-
* Get
|
|
3648
|
+
* Get current jackpot amount
|
|
3714
3649
|
*/
|
|
3715
3650
|
;
|
|
3716
|
-
_proto.
|
|
3651
|
+
_proto.currentJackpotAmount =
|
|
3717
3652
|
/*#__PURE__*/
|
|
3718
3653
|
function () {
|
|
3719
|
-
var
|
|
3720
|
-
var
|
|
3654
|
+
var _currentJackpotAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
3655
|
+
var jackpot;
|
|
3721
3656
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3722
3657
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3723
3658
|
case 0:
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
case 5:
|
|
3659
|
+
_context3.next = 2;
|
|
3660
|
+
return this.env.plygame.currentJackpotAmount();
|
|
3661
|
+
case 2:
|
|
3662
|
+
jackpot = _context3.sent;
|
|
3663
|
+
return _context3.abrupt("return", new TokenAmount(this.plyToken, jackpot.toString()));
|
|
3664
|
+
case 4:
|
|
3731
3665
|
case "end":
|
|
3732
3666
|
return _context3.stop();
|
|
3733
3667
|
}
|
|
3734
3668
|
}, _callee3, this);
|
|
3735
3669
|
}));
|
|
3736
|
-
function
|
|
3737
|
-
return
|
|
3670
|
+
function currentJackpotAmount() {
|
|
3671
|
+
return _currentJackpotAmount.apply(this, arguments);
|
|
3738
3672
|
}
|
|
3739
|
-
return
|
|
3673
|
+
return currentJackpotAmount;
|
|
3740
3674
|
}();
|
|
3741
|
-
_proto.
|
|
3742
|
-
var
|
|
3743
|
-
var
|
|
3675
|
+
_proto.earlyUnlockedPulpAmount = /*#__PURE__*/function () {
|
|
3676
|
+
var _earlyUnlockedPulpAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(user) {
|
|
3677
|
+
var earlyUnlockedPulpAmount;
|
|
3744
3678
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
3745
3679
|
while (1) switch (_context4.prev = _context4.next) {
|
|
3746
3680
|
case 0:
|
|
3747
3681
|
_context4.next = 2;
|
|
3748
|
-
return this.env.
|
|
3749
|
-
from: user
|
|
3750
|
-
});
|
|
3682
|
+
return this.env.plygame.totalPlyUnlockedEarly(user);
|
|
3751
3683
|
case 2:
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
return TokenAmount.fromAddressAndAmount(PLYWNEAR_REWARD_TOKENS[i], reward.toString());
|
|
3756
|
-
}));
|
|
3757
|
-
case 5:
|
|
3684
|
+
earlyUnlockedPulpAmount = _context4.sent;
|
|
3685
|
+
return _context4.abrupt("return", new TokenAmount(this.pulpToken, earlyUnlockedPulpAmount.toString()));
|
|
3686
|
+
case 4:
|
|
3758
3687
|
case "end":
|
|
3759
3688
|
return _context4.stop();
|
|
3760
3689
|
}
|
|
3761
3690
|
}, _callee4, this);
|
|
3762
3691
|
}));
|
|
3763
|
-
function
|
|
3764
|
-
return
|
|
3692
|
+
function earlyUnlockedPulpAmount(_x3) {
|
|
3693
|
+
return _earlyUnlockedPulpAmount.apply(this, arguments);
|
|
3765
3694
|
}
|
|
3766
|
-
return
|
|
3695
|
+
return earlyUnlockedPulpAmount;
|
|
3767
3696
|
}();
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
var
|
|
3771
|
-
|
|
3772
|
-
function StakingReadWrite() {
|
|
3773
|
-
return _StakingRead.apply(this, arguments) || this;
|
|
3774
|
-
}
|
|
3775
|
-
var _proto2 = StakingReadWrite.prototype;
|
|
3776
|
-
_proto2.stake = /*#__PURE__*/function () {
|
|
3777
|
-
var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(amount) {
|
|
3697
|
+
_proto.getPlyGameResultsInTransaction = /*#__PURE__*/function () {
|
|
3698
|
+
var _getPlyGameResultsInTransaction = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(txHash) {
|
|
3699
|
+
var _this3 = this;
|
|
3700
|
+
var tx, i, filter, betMadeEvents;
|
|
3778
3701
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
3779
3702
|
while (1) switch (_context5.prev = _context5.next) {
|
|
3780
3703
|
case 0:
|
|
3781
|
-
|
|
3782
|
-
|
|
3704
|
+
_context5.next = 2;
|
|
3705
|
+
return this._networkConnection.provider.getTransactionReceipt(txHash);
|
|
3706
|
+
case 2:
|
|
3707
|
+
tx = _context5.sent;
|
|
3708
|
+
i = 0;
|
|
3709
|
+
case 4:
|
|
3710
|
+
if (!(i < 100 && !tx)) {
|
|
3711
|
+
_context5.next = 13;
|
|
3712
|
+
break;
|
|
3713
|
+
}
|
|
3714
|
+
_context5.next = 7;
|
|
3715
|
+
return sleep(1000);
|
|
3716
|
+
case 7:
|
|
3717
|
+
_context5.next = 9;
|
|
3718
|
+
return this._networkConnection.provider.getTransactionReceipt(txHash);
|
|
3719
|
+
case 9:
|
|
3720
|
+
tx = _context5.sent;
|
|
3721
|
+
case 10:
|
|
3722
|
+
i++;
|
|
3723
|
+
_context5.next = 4;
|
|
3724
|
+
break;
|
|
3725
|
+
case 13:
|
|
3726
|
+
if (tx) {
|
|
3727
|
+
_context5.next = 15;
|
|
3728
|
+
break;
|
|
3729
|
+
}
|
|
3730
|
+
throw new Error("Transaction " + txHash + " takes too long to be mined");
|
|
3731
|
+
case 15:
|
|
3732
|
+
filter = this.env.plygame.filters.BetMade();
|
|
3733
|
+
betMadeEvents = tx.logs.filter(function (log) {
|
|
3734
|
+
return isSameAddress(log.topics[0], filter.topics[0]);
|
|
3735
|
+
}).map(function (log) {
|
|
3736
|
+
return _extends({}, _this3.env.plygame["interface"].parseLog(log), {
|
|
3737
|
+
blockNumber: tx.blockNumber,
|
|
3738
|
+
transactionHash: txHash
|
|
3739
|
+
});
|
|
3740
|
+
});
|
|
3741
|
+
return _context5.abrupt("return", this.attachTimestamp(betMadeEvents.map(function (e) {
|
|
3742
|
+
return _this3.parseBetMakeEvent(e);
|
|
3743
|
+
})));
|
|
3744
|
+
case 18:
|
|
3783
3745
|
case "end":
|
|
3784
3746
|
return _context5.stop();
|
|
3785
3747
|
}
|
|
3786
3748
|
}, _callee5, this);
|
|
3787
3749
|
}));
|
|
3788
|
-
function
|
|
3789
|
-
return
|
|
3750
|
+
function getPlyGameResultsInTransaction(_x4) {
|
|
3751
|
+
return _getPlyGameResultsInTransaction.apply(this, arguments);
|
|
3790
3752
|
}
|
|
3791
|
-
return
|
|
3792
|
-
}()
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3753
|
+
return getPlyGameResultsInTransaction;
|
|
3754
|
+
}()
|
|
3755
|
+
/**
|
|
3756
|
+
* Top 100 users by amount of PULP unlocked
|
|
3757
|
+
*/
|
|
3758
|
+
;
|
|
3759
|
+
_proto.leaderboard =
|
|
3760
|
+
/*#__PURE__*/
|
|
3761
|
+
function () {
|
|
3762
|
+
var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
3763
|
+
var _this4 = this;
|
|
3764
|
+
var result;
|
|
3796
3765
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
3797
3766
|
while (1) switch (_context6.prev = _context6.next) {
|
|
3798
3767
|
case 0:
|
|
3799
3768
|
_context6.next = 2;
|
|
3800
|
-
return
|
|
3769
|
+
return getPaginatedApi('/plygame/leaderboard');
|
|
3801
3770
|
case 2:
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
unstakeAmount = amountInput.lt(stakedAmount) ? amountInput : stakedAmount.sub(1);
|
|
3812
|
-
return _context6.abrupt("return", this.env.auriFairLaunch.connect(this._networkConnection.signer).withdraw(PLYWNEAR_POOL_ID, unstakeAmount));
|
|
3813
|
-
case 11:
|
|
3771
|
+
result = _context6.sent;
|
|
3772
|
+
return _context6.abrupt("return", result.items.map(function (item, i) {
|
|
3773
|
+
return {
|
|
3774
|
+
player: item.user,
|
|
3775
|
+
unlockedPulpAmount: new TokenAmount(_this4.pulpToken, item.unlockedAmount),
|
|
3776
|
+
gamesPlayed: item.count
|
|
3777
|
+
};
|
|
3778
|
+
}));
|
|
3779
|
+
case 4:
|
|
3814
3780
|
case "end":
|
|
3815
3781
|
return _context6.stop();
|
|
3816
3782
|
}
|
|
3817
|
-
}, _callee6
|
|
3783
|
+
}, _callee6);
|
|
3818
3784
|
}));
|
|
3819
|
-
function
|
|
3820
|
-
return
|
|
3785
|
+
function leaderboard() {
|
|
3786
|
+
return _leaderboard.apply(this, arguments);
|
|
3821
3787
|
}
|
|
3822
|
-
return
|
|
3788
|
+
return leaderboard;
|
|
3823
3789
|
}();
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
var
|
|
3827
|
-
|
|
3828
|
-
|
|
3790
|
+
_proto.getLastJackpotResult = /*#__PURE__*/function () {
|
|
3791
|
+
var _getLastJackpotResult = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
3792
|
+
var round, result;
|
|
3793
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
3794
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
3795
|
+
case 0:
|
|
3796
|
+
_context7.t0 = BigNumber$1;
|
|
3797
|
+
_context7.next = 3;
|
|
3798
|
+
return this._networkConnection.provider.getStorageAt(this.env.plygame.address, 158);
|
|
3799
|
+
case 3:
|
|
3800
|
+
_context7.t1 = _context7.sent;
|
|
3801
|
+
round = _context7.t0.from.call(_context7.t0, _context7.t1);
|
|
3802
|
+
_context7.next = 7;
|
|
3803
|
+
return this.env.plygame.jackpotHistory(round.sub(1));
|
|
3804
|
+
case 7:
|
|
3805
|
+
result = _context7.sent;
|
|
3806
|
+
return _context7.abrupt("return", {
|
|
3807
|
+
winner: result.winner.slice(0, 5) + '...' + result.winner.slice(-3),
|
|
3808
|
+
amount: new TokenAmount(this.plyToken, result.amount.toString())
|
|
3809
|
+
});
|
|
3810
|
+
case 9:
|
|
3811
|
+
case "end":
|
|
3812
|
+
return _context7.stop();
|
|
3813
|
+
}
|
|
3814
|
+
}, _callee7, this);
|
|
3815
|
+
}));
|
|
3816
|
+
function getLastJackpotResult() {
|
|
3817
|
+
return _getLastJackpotResult.apply(this, arguments);
|
|
3818
|
+
}
|
|
3819
|
+
return getLastJackpotResult;
|
|
3820
|
+
}();
|
|
3821
|
+
_proto.overallLeaderboard = /*#__PURE__*/function () {
|
|
3822
|
+
var _overallLeaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
3823
|
+
var _this5 = this;
|
|
3824
|
+
var result;
|
|
3825
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
3826
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
3827
|
+
case 0:
|
|
3828
|
+
_context8.next = 2;
|
|
3829
|
+
return getPaginatedApi('/plygame/overallLeaderboard');
|
|
3830
|
+
case 2:
|
|
3831
|
+
result = _context8.sent;
|
|
3832
|
+
return _context8.abrupt("return", result.items.map(function (item) {
|
|
3833
|
+
return {
|
|
3834
|
+
player: item.user,
|
|
3835
|
+
unlockedPulpAmount: new TokenAmount(_this5.pulpToken, item.unlockedAmount),
|
|
3836
|
+
gamesPlayed: item.count
|
|
3837
|
+
};
|
|
3838
|
+
}));
|
|
3839
|
+
case 4:
|
|
3840
|
+
case "end":
|
|
3841
|
+
return _context8.stop();
|
|
3842
|
+
}
|
|
3843
|
+
}, _callee8);
|
|
3844
|
+
}));
|
|
3845
|
+
function overallLeaderboard() {
|
|
3846
|
+
return _overallLeaderboard.apply(this, arguments);
|
|
3847
|
+
}
|
|
3848
|
+
return overallLeaderboard;
|
|
3849
|
+
}();
|
|
3850
|
+
return PlyGameRead;
|
|
3851
|
+
}(BlockchainEntityRead);
|
|
3852
|
+
var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
3853
|
+
_inheritsLoose(PlyGameReadWrite, _PlyGameRead);
|
|
3854
|
+
function PlyGameReadWrite() {
|
|
3855
|
+
return _PlyGameRead.apply(this, arguments) || this;
|
|
3856
|
+
}
|
|
3857
|
+
var _proto2 = PlyGameReadWrite.prototype;
|
|
3858
|
+
/**
|
|
3859
|
+
* Make a single bet
|
|
3860
|
+
*/
|
|
3861
|
+
_proto2.makeBetOnce =
|
|
3862
|
+
/*#__PURE__*/
|
|
3863
|
+
function () {
|
|
3864
|
+
var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(amount) {
|
|
3865
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
3866
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
3867
|
+
case 0:
|
|
3868
|
+
return _context9.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetOnce(amount.rawAmount()));
|
|
3869
|
+
case 1:
|
|
3870
|
+
case "end":
|
|
3871
|
+
return _context9.stop();
|
|
3872
|
+
}
|
|
3873
|
+
}, _callee9, this);
|
|
3874
|
+
}));
|
|
3875
|
+
function makeBetOnce(_x5) {
|
|
3876
|
+
return _makeBetOnce.apply(this, arguments);
|
|
3877
|
+
}
|
|
3878
|
+
return makeBetOnce;
|
|
3879
|
+
}();
|
|
3880
|
+
_proto2.approve = /*#__PURE__*/function () {
|
|
3881
|
+
var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(amount) {
|
|
3882
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
3883
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
3884
|
+
case 0:
|
|
3885
|
+
return _context10.abrupt("return", this.env.ply.connect(this._networkConnection.signer).approve(this.env.plygame.address, amount.rawAmount()));
|
|
3886
|
+
case 1:
|
|
3887
|
+
case "end":
|
|
3888
|
+
return _context10.stop();
|
|
3889
|
+
}
|
|
3890
|
+
}, _callee10, this);
|
|
3891
|
+
}));
|
|
3892
|
+
function approve(_x6) {
|
|
3893
|
+
return _approve.apply(this, arguments);
|
|
3894
|
+
}
|
|
3895
|
+
return approve;
|
|
3896
|
+
}();
|
|
3897
|
+
return PlyGameReadWrite;
|
|
3898
|
+
}(PlyGameRead);
|
|
3899
|
+
var PlyGame = /*#__PURE__*/function (_BlockchainEntity) {
|
|
3900
|
+
_inheritsLoose(PlyGame, _BlockchainEntity);
|
|
3901
|
+
function PlyGame() {
|
|
3829
3902
|
return _BlockchainEntity.call(this) || this;
|
|
3830
3903
|
}
|
|
3831
|
-
var _proto3 =
|
|
3904
|
+
var _proto3 = PlyGame.prototype;
|
|
3832
3905
|
_proto3.read = function read(networkConnection) {
|
|
3833
|
-
return new
|
|
3906
|
+
return new PlyGameRead(networkConnection);
|
|
3834
3907
|
};
|
|
3835
3908
|
_proto3.readWrite = function readWrite(networkConnection) {
|
|
3836
|
-
return new
|
|
3909
|
+
return new PlyGameReadWrite(networkConnection);
|
|
3837
3910
|
};
|
|
3838
|
-
return
|
|
3911
|
+
return PlyGame;
|
|
3839
3912
|
}(BlockchainEntity);
|
|
3840
3913
|
|
|
3841
|
-
var
|
|
3842
|
-
_inheritsLoose(
|
|
3843
|
-
function
|
|
3914
|
+
var PulpRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3915
|
+
_inheritsLoose(PulpRead, _BlockchainEntityRead);
|
|
3916
|
+
function PulpRead(networkConnection) {
|
|
3844
3917
|
var _this;
|
|
3845
3918
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3846
|
-
_this.stakingRead = new StakingRead(networkConnection);
|
|
3847
3919
|
_this.env = new AuriEnv(networkConnection);
|
|
3848
3920
|
return _this;
|
|
3849
3921
|
}
|
|
3850
|
-
var _proto =
|
|
3851
|
-
_proto.
|
|
3852
|
-
var
|
|
3853
|
-
|
|
3854
|
-
|
|
3922
|
+
var _proto = PulpRead.prototype;
|
|
3923
|
+
_proto.remainingEarlyUnlockPulp = /*#__PURE__*/function () {
|
|
3924
|
+
var _remainingEarlyUnlockPulp = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(user) {
|
|
3925
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3926
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3927
|
+
case 0:
|
|
3928
|
+
return _context.abrupt("return", this.env.pulp.getMaxAmountRedeemable(user));
|
|
3929
|
+
case 1:
|
|
3930
|
+
case "end":
|
|
3931
|
+
return _context.stop();
|
|
3932
|
+
}
|
|
3933
|
+
}, _callee, this);
|
|
3934
|
+
}));
|
|
3935
|
+
function remainingEarlyUnlockPulp(_x) {
|
|
3936
|
+
return _remainingEarlyUnlockPulp.apply(this, arguments);
|
|
3937
|
+
}
|
|
3938
|
+
return remainingEarlyUnlockPulp;
|
|
3939
|
+
}();
|
|
3940
|
+
return PulpRead;
|
|
3941
|
+
}(BlockchainEntityRead);
|
|
3942
|
+
var PulpReadWrite = /*#__PURE__*/function (_PulpRead) {
|
|
3943
|
+
_inheritsLoose(PulpReadWrite, _PulpRead);
|
|
3944
|
+
function PulpReadWrite() {
|
|
3945
|
+
return _PulpRead.apply(this, arguments) || this;
|
|
3946
|
+
}
|
|
3947
|
+
var _proto2 = PulpReadWrite.prototype;
|
|
3948
|
+
_proto2.convertEarlyPulp = /*#__PURE__*/function () {
|
|
3949
|
+
var _convertEarlyPulp = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(recipient, amount) {
|
|
3950
|
+
var amountToRedeem;
|
|
3951
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3855
3952
|
while (1) switch (_context2.prev = _context2.next) {
|
|
3856
3953
|
case 0:
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
_iterator = _createForOfIteratorHelperLoose(networkAddresses.auTokens);
|
|
3861
|
-
case 4:
|
|
3862
|
-
if ((_step = _iterator()).done) {
|
|
3863
|
-
_context2.next = 23;
|
|
3864
|
-
break;
|
|
3865
|
-
}
|
|
3866
|
-
_auToken = _step.value;
|
|
3867
|
-
userMarketDetail = {};
|
|
3868
|
-
userMarketDetails.push(userMarketDetail);
|
|
3869
|
-
userMarketDetail.market = _auToken.underlying;
|
|
3870
|
-
_moneyMarket = new MoneyMarketRead(this._networkConnection, _auToken.address, _auToken.underlying);
|
|
3871
|
-
_context2.next = 12;
|
|
3872
|
-
return Promise.all([_moneyMarket.getUserDepositBalance(userAddress), _moneyMarket.getUserBorrowBalance(userAddress), _moneyMarket.getCollateralRatio(), fetchPrice(_moneyMarket.underlying.address, this._networkConnection.provider)]);
|
|
3873
|
-
case 12:
|
|
3874
|
-
_yield$Promise$all = _context2.sent;
|
|
3875
|
-
depositBalance = _yield$Promise$all[0];
|
|
3876
|
-
borrowBalance = _yield$Promise$all[1];
|
|
3877
|
-
collateralRatio = _yield$Promise$all[2];
|
|
3878
|
-
underlyingPrice = _yield$Promise$all[3];
|
|
3879
|
-
userMarketDetail.depositBalance = depositBalance;
|
|
3880
|
-
userMarketDetail.borrowBalance = borrowBalance;
|
|
3881
|
-
userMarketDetail.collateralRatio = collateralRatio.toNumber();
|
|
3882
|
-
userMarketDetail.underlyingPrice = underlyingPrice.toString();
|
|
3883
|
-
case 21:
|
|
3884
|
-
_context2.next = 4;
|
|
3885
|
-
break;
|
|
3886
|
-
case 23:
|
|
3887
|
-
_context2.next = 25;
|
|
3888
|
-
return this.env.comptroller.getAssetsIn(userAddress);
|
|
3889
|
-
case 25:
|
|
3890
|
-
assetsIn = _context2.sent;
|
|
3891
|
-
depositValues = [];
|
|
3892
|
-
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
3893
|
-
var auToken;
|
|
3894
|
-
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
3895
|
-
while (1) switch (_context.prev = _context.next) {
|
|
3896
|
-
case 0:
|
|
3897
|
-
auToken = networkAddresses.auTokens[i];
|
|
3898
|
-
if (assetsIn.find(function (auAddress) {
|
|
3899
|
-
return isSameAddress(auToken.address, auAddress);
|
|
3900
|
-
}) !== undefined) {
|
|
3901
|
-
userMarketDetails[i].isCollateral = true;
|
|
3902
|
-
} else {
|
|
3903
|
-
userMarketDetails[i].isCollateral = false;
|
|
3904
|
-
}
|
|
3905
|
-
depositValues.push(calcValuation(userMarketDetails[i].depositBalance, new BigNumber(userMarketDetails[i].underlyingPrice)));
|
|
3906
|
-
case 3:
|
|
3907
|
-
case "end":
|
|
3908
|
-
return _context.stop();
|
|
3909
|
-
}
|
|
3910
|
-
}, _loop);
|
|
3911
|
-
});
|
|
3912
|
-
i = 0;
|
|
3913
|
-
case 29:
|
|
3914
|
-
if (!(i < marketCount)) {
|
|
3915
|
-
_context2.next = 34;
|
|
3916
|
-
break;
|
|
3917
|
-
}
|
|
3918
|
-
return _context2.delegateYield(_loop(), "t0", 31);
|
|
3919
|
-
case 31:
|
|
3920
|
-
i++;
|
|
3921
|
-
_context2.next = 29;
|
|
3922
|
-
break;
|
|
3923
|
-
case 34:
|
|
3924
|
-
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3925
|
-
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
3926
|
-
return p;
|
|
3927
|
-
}, new BigNumber(0));
|
|
3928
|
-
_context2.next = 37;
|
|
3929
|
-
return this.env.comptroller.getAccountLiquidity(userAddress);
|
|
3930
|
-
case 37:
|
|
3931
|
-
accountLiquidity = _context2.sent;
|
|
3932
|
-
borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
|
|
3933
|
-
if (borrowedvaluation.lt('0.00001')) {
|
|
3934
|
-
// Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
|
|
3935
|
-
borrowedvaluation = new BigNumber(0);
|
|
3936
|
-
}
|
|
3937
|
-
bufferedBorrowLimit = totalBorrowLimit.multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3938
|
-
minimumBorrowLimitAllowed = borrowedvaluation.div(BORROW_LIMIT_BUFFER);
|
|
3939
|
-
if (bufferedBorrowLimit.lte(borrowedvaluation)) {
|
|
3940
|
-
borrowableAmount = new BigNumber(0);
|
|
3941
|
-
} else {
|
|
3942
|
-
borrowableAmount = bufferedBorrowLimit.minus(borrowedvaluation);
|
|
3943
|
-
}
|
|
3944
|
-
for (i = 0; i < marketCount; i++) {
|
|
3945
|
-
auToken = networkAddresses.auTokens[i];
|
|
3946
|
-
moneyMarket = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
|
|
3947
|
-
borrowLimitMargin = totalBorrowLimit.minus(minimumBorrowLimitAllowed).gt(0) ? totalBorrowLimit.minus(minimumBorrowLimitAllowed) : new BigNumber(0);
|
|
3948
|
-
maxWithdrawCap = borrowLimitMargin.div(userMarketDetails[i].collateralRatio).div(userMarketDetails[i].underlyingPrice);
|
|
3949
|
-
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());
|
|
3950
|
-
}
|
|
3951
|
-
_context2.t1 = userMarketDetails;
|
|
3952
|
-
_context2.t2 = {
|
|
3953
|
-
currency: 'USD',
|
|
3954
|
-
amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
|
|
3955
|
-
};
|
|
3956
|
-
_context2.next = 48;
|
|
3957
|
-
return new PapermillRead(this._networkConnection).getLockingDetails(userAddress);
|
|
3958
|
-
case 48:
|
|
3959
|
-
_context2.t3 = _context2.sent;
|
|
3960
|
-
_context2.t4 = {
|
|
3961
|
-
currency: 'USD',
|
|
3962
|
-
amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
|
|
3963
|
-
};
|
|
3964
|
-
return _context2.abrupt("return", {
|
|
3965
|
-
markets: _context2.t1,
|
|
3966
|
-
borrowLimit: _context2.t2,
|
|
3967
|
-
userLockingDetails: _context2.t3,
|
|
3968
|
-
borrowableAmount: _context2.t4
|
|
3969
|
-
});
|
|
3970
|
-
case 51:
|
|
3954
|
+
amountToRedeem = BigNumber$1.from(amount.rawAmount);
|
|
3955
|
+
return _context2.abrupt("return", this.env.pulp.redeem(recipient, amountToRedeem));
|
|
3956
|
+
case 2:
|
|
3971
3957
|
case "end":
|
|
3972
3958
|
return _context2.stop();
|
|
3973
3959
|
}
|
|
3974
|
-
},
|
|
3960
|
+
}, _callee2, this);
|
|
3975
3961
|
}));
|
|
3976
|
-
function
|
|
3977
|
-
return
|
|
3962
|
+
function convertEarlyPulp(_x2, _x3) {
|
|
3963
|
+
return _convertEarlyPulp.apply(this, arguments);
|
|
3978
3964
|
}
|
|
3979
|
-
return
|
|
3965
|
+
return convertEarlyPulp;
|
|
3980
3966
|
}();
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3967
|
+
return PulpReadWrite;
|
|
3968
|
+
}(PulpRead);
|
|
3969
|
+
var Pulp = /*#__PURE__*/function (_BlockchainEntity) {
|
|
3970
|
+
_inheritsLoose(Pulp, _BlockchainEntity);
|
|
3971
|
+
function Pulp() {
|
|
3972
|
+
return _BlockchainEntity.call(this) || this;
|
|
3973
|
+
}
|
|
3974
|
+
var _proto3 = Pulp.prototype;
|
|
3975
|
+
_proto3.read = function read(networkConnection) {
|
|
3976
|
+
return new PulpRead(networkConnection);
|
|
3977
|
+
};
|
|
3978
|
+
_proto3.readWrite = function readWrite(networkConnection) {
|
|
3979
|
+
return new PulpReadWrite(networkConnection);
|
|
3980
|
+
};
|
|
3981
|
+
return Pulp;
|
|
3982
|
+
}(BlockchainEntity);
|
|
3983
|
+
|
|
3984
|
+
var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
3985
|
+
_inheritsLoose(ReferralRead, _BlockchainEntityRead);
|
|
3986
|
+
function ReferralRead(networkConnection) {
|
|
3987
|
+
var _this;
|
|
3988
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3989
|
+
_this.env = new AuriEnv(networkConnection);
|
|
3990
|
+
return _this;
|
|
3991
|
+
}
|
|
3992
|
+
/**
|
|
3993
|
+
* Generate a 10-character referral code
|
|
3994
|
+
* containing alphanumeric characters.
|
|
3995
|
+
*/
|
|
3996
|
+
var _proto = ReferralRead.prototype;
|
|
3997
|
+
_proto.generateReferralCode = function generateReferralCode() {
|
|
3998
|
+
var letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
3999
|
+
var numbers = '1234567890';
|
|
4000
|
+
var charset = letters + letters.toUpperCase() + numbers;
|
|
4001
|
+
var R = '';
|
|
4002
|
+
for (var i = 0; i < 10; i++) R += charset[Math.floor(Math.random() * charset.length)];
|
|
4003
|
+
return R;
|
|
4004
|
+
}
|
|
4005
|
+
/**
|
|
4006
|
+
* Get the referral code for a given address, returns empty string if not found.
|
|
4007
|
+
*
|
|
4008
|
+
* Called to check if a user has a referral code.
|
|
4009
|
+
*/;
|
|
4010
|
+
_proto.getUserReferralCode =
|
|
4011
|
+
/*#__PURE__*/
|
|
4012
|
+
function () {
|
|
4013
|
+
var _getUserReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(userAddr) {
|
|
4014
|
+
var result;
|
|
4015
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4016
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3986
4017
|
case 0:
|
|
3987
|
-
|
|
3988
|
-
return
|
|
4018
|
+
_context.next = 2;
|
|
4019
|
+
return this.env.referralDirectoryV2.userReferralCode(userAddr);
|
|
3989
4020
|
case 2:
|
|
3990
|
-
|
|
3991
|
-
return
|
|
3992
|
-
currency: 'USD',
|
|
3993
|
-
amount: price.toFixed(DECIMAL_PRECISION)
|
|
3994
|
-
});
|
|
4021
|
+
result = _context.sent;
|
|
4022
|
+
return _context.abrupt("return", ethers.utils.parseBytes32String(result));
|
|
3995
4023
|
case 4:
|
|
3996
4024
|
case "end":
|
|
3997
|
-
return
|
|
4025
|
+
return _context.stop();
|
|
3998
4026
|
}
|
|
3999
|
-
},
|
|
4027
|
+
}, _callee, this);
|
|
4000
4028
|
}));
|
|
4001
|
-
function
|
|
4002
|
-
return
|
|
4003
|
-
}
|
|
4004
|
-
return getTokenPrice;
|
|
4005
|
-
}();
|
|
4006
|
-
_proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
|
|
4007
|
-
var userMarketDetail = _ref.userMarketDetail,
|
|
4008
|
-
currentBorrowLimit = _ref.currentBorrowLimit,
|
|
4009
|
-
currentBorrowValuation = _ref.currentBorrowValuation,
|
|
4010
|
-
action = _ref.action,
|
|
4011
|
-
tokenAmount = _ref.tokenAmount;
|
|
4012
|
-
var newBorrowLimit = new BigNumber(currentBorrowLimit.amount),
|
|
4013
|
-
newBorrowValuation = new BigNumber(currentBorrowValuation.amount);
|
|
4014
|
-
switch (action) {
|
|
4015
|
-
case MarketAction.EnableCollateral:
|
|
4016
|
-
case MarketAction.DisableCollateral:
|
|
4017
|
-
var deltaBorrowLimit = calcValuation(userMarketDetail.depositBalance, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
4018
|
-
newBorrowLimit = action == MarketAction.EnableCollateral ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
4019
|
-
break;
|
|
4020
|
-
case MarketAction.Deposit:
|
|
4021
|
-
case MarketAction.Withdraw:
|
|
4022
|
-
deltaBorrowLimit = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
4023
|
-
newBorrowLimit = action == MarketAction.Deposit ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
4024
|
-
break;
|
|
4025
|
-
case MarketAction.Borrow:
|
|
4026
|
-
case MarketAction.Repay:
|
|
4027
|
-
var deltaBorrowValuation = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice));
|
|
4028
|
-
newBorrowValuation = action == MarketAction.Borrow ? newBorrowValuation.plus(deltaBorrowValuation) : newBorrowValuation.minus(deltaBorrowValuation);
|
|
4029
|
-
break;
|
|
4029
|
+
function getUserReferralCode(_x) {
|
|
4030
|
+
return _getUserReferralCode.apply(this, arguments);
|
|
4030
4031
|
}
|
|
4031
|
-
return
|
|
4032
|
-
|
|
4033
|
-
amount: newBorrowLimit.toFixed(DECIMAL_PRECISION),
|
|
4034
|
-
currency: 'USD'
|
|
4035
|
-
},
|
|
4036
|
-
newBorrowUtilization: newBorrowLimit.eq(0) ? newBorrowValuation.eq(0) ? 0 : 9999.99 : newBorrowValuation.div(newBorrowLimit).toNumber()
|
|
4037
|
-
};
|
|
4038
|
-
}
|
|
4032
|
+
return getUserReferralCode;
|
|
4033
|
+
}()
|
|
4039
4034
|
/**
|
|
4040
|
-
* Get
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
* - Ply in fairlaunch contract
|
|
4045
|
-
* - Ply in vesting contract
|
|
4046
|
-
*/;
|
|
4047
|
-
_proto.getPlyCirculatingSupply =
|
|
4035
|
+
* Get referral code that a user was referred by, returns empty string if not found.
|
|
4036
|
+
*/
|
|
4037
|
+
;
|
|
4038
|
+
_proto.getReferralCodeUsed =
|
|
4048
4039
|
/*#__PURE__*/
|
|
4049
4040
|
function () {
|
|
4050
|
-
var
|
|
4051
|
-
var
|
|
4052
|
-
return _regeneratorRuntime().wrap(function
|
|
4053
|
-
while (1) switch (
|
|
4041
|
+
var _getReferralCodeUsed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(userAddr) {
|
|
4042
|
+
var result;
|
|
4043
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4044
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4054
4045
|
case 0:
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4046
|
+
_context2.next = 2;
|
|
4047
|
+
return this.env.referralDirectoryV2.referralCodeUsed(userAddr);
|
|
4048
|
+
case 2:
|
|
4049
|
+
result = _context2.sent;
|
|
4050
|
+
return _context2.abrupt("return", ethers.utils.parseBytes32String(result));
|
|
4051
|
+
case 4:
|
|
4052
|
+
case "end":
|
|
4053
|
+
return _context2.stop();
|
|
4054
|
+
}
|
|
4055
|
+
}, _callee2, this);
|
|
4056
|
+
}));
|
|
4057
|
+
function getReferralCodeUsed(_x2) {
|
|
4058
|
+
return _getReferralCodeUsed.apply(this, arguments);
|
|
4059
|
+
}
|
|
4060
|
+
return getReferralCodeUsed;
|
|
4061
|
+
}()
|
|
4062
|
+
/**
|
|
4063
|
+
* Get owner of a referral code, returns zero address if not found.
|
|
4064
|
+
*/
|
|
4065
|
+
;
|
|
4066
|
+
_proto.getReferralCodeOwner =
|
|
4067
|
+
/*#__PURE__*/
|
|
4068
|
+
function () {
|
|
4069
|
+
var _getReferralCodeOwner = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code) {
|
|
4070
|
+
var referralCode;
|
|
4071
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4072
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4073
|
+
case 0:
|
|
4074
|
+
referralCode = ethers.utils.formatBytes32String(code);
|
|
4075
|
+
return _context3.abrupt("return", this.env.referralDirectoryV2.referralCodeOwner(referralCode));
|
|
4076
|
+
case 2:
|
|
4077
|
+
case "end":
|
|
4078
|
+
return _context3.stop();
|
|
4079
|
+
}
|
|
4080
|
+
}, _callee3, this);
|
|
4081
|
+
}));
|
|
4082
|
+
function getReferralCodeOwner(_x3) {
|
|
4083
|
+
return _getReferralCodeOwner.apply(this, arguments);
|
|
4084
|
+
}
|
|
4085
|
+
return getReferralCodeOwner;
|
|
4086
|
+
}()
|
|
4087
|
+
/**
|
|
4088
|
+
* Get referrals of a user, sorted descending by timestamp.
|
|
4089
|
+
*/
|
|
4090
|
+
;
|
|
4091
|
+
_proto.getReferralsList =
|
|
4092
|
+
/*#__PURE__*/
|
|
4093
|
+
function () {
|
|
4094
|
+
var _getReferralsList = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(userAddr) {
|
|
4095
|
+
var result, blocks, blocksTimestamp, items;
|
|
4096
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4097
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4098
|
+
case 0:
|
|
4099
|
+
_context4.next = 2;
|
|
4100
|
+
return getPaginatedApi('/referral/list', {
|
|
4101
|
+
address: userAddr
|
|
4102
|
+
});
|
|
4103
|
+
case 2:
|
|
4104
|
+
result = _context4.sent;
|
|
4105
|
+
blocks = result.items.map(function (item) {
|
|
4106
|
+
return item.blockNumber;
|
|
4107
|
+
});
|
|
4108
|
+
_context4.next = 6;
|
|
4109
|
+
return getBlocksTimestamp(this._networkConnection.provider, blocks);
|
|
4069
4110
|
case 6:
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4111
|
+
blocksTimestamp = _context4.sent;
|
|
4112
|
+
items = result.items.map(function (item, i) {
|
|
4113
|
+
return {
|
|
4114
|
+
user: item.user,
|
|
4115
|
+
timestamp: blocksTimestamp[i]
|
|
4116
|
+
};
|
|
4074
4117
|
});
|
|
4075
|
-
return _context4.abrupt("return",
|
|
4076
|
-
case
|
|
4118
|
+
return _context4.abrupt("return", items);
|
|
4119
|
+
case 9:
|
|
4077
4120
|
case "end":
|
|
4078
4121
|
return _context4.stop();
|
|
4079
4122
|
}
|
|
4080
|
-
},
|
|
4123
|
+
}, _callee4, this);
|
|
4081
4124
|
}));
|
|
4082
|
-
function
|
|
4083
|
-
return
|
|
4125
|
+
function getReferralsList(_x4) {
|
|
4126
|
+
return _getReferralsList.apply(this, arguments);
|
|
4084
4127
|
}
|
|
4085
|
-
return
|
|
4086
|
-
}()
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4128
|
+
return getReferralsList;
|
|
4129
|
+
}()
|
|
4130
|
+
/**
|
|
4131
|
+
* Array of rewards, sorted by time of the referral period (from latest to oldest)
|
|
4132
|
+
*/
|
|
4133
|
+
;
|
|
4134
|
+
_proto.referralRewards =
|
|
4135
|
+
/*#__PURE__*/
|
|
4136
|
+
function () {
|
|
4137
|
+
var _referralRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(userAddr) {
|
|
4138
|
+
var result, items;
|
|
4139
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
4091
4140
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4092
4141
|
case 0:
|
|
4093
4142
|
_context5.next = 2;
|
|
4094
|
-
return
|
|
4143
|
+
return getPaginatedApi('/referral/rewards', {
|
|
4144
|
+
address: userAddr
|
|
4145
|
+
});
|
|
4095
4146
|
case 2:
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4147
|
+
result = _context5.sent;
|
|
4148
|
+
items = result.items.map(function (item, i) {
|
|
4149
|
+
var _item$transactionHash;
|
|
4150
|
+
return {
|
|
4151
|
+
campaign: item.campaign,
|
|
4152
|
+
userAddr: userAddr,
|
|
4153
|
+
isReferrer: item.campaign.includes('referrer'),
|
|
4154
|
+
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
4155
|
+
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
4156
|
+
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
4157
|
+
transactionHash: (_item$transactionHash = item.transactionHash) != null ? _item$transactionHash : null,
|
|
4158
|
+
refereeAddress: null
|
|
4159
|
+
};
|
|
4160
|
+
});
|
|
4161
|
+
return _context5.abrupt("return", items);
|
|
4162
|
+
case 5:
|
|
4101
4163
|
case "end":
|
|
4102
4164
|
return _context5.stop();
|
|
4103
4165
|
}
|
|
4104
|
-
},
|
|
4166
|
+
}, _callee5);
|
|
4105
4167
|
}));
|
|
4106
|
-
function
|
|
4107
|
-
return
|
|
4168
|
+
function referralRewards(_x5) {
|
|
4169
|
+
return _referralRewards.apply(this, arguments);
|
|
4108
4170
|
}
|
|
4109
|
-
return
|
|
4110
|
-
}()
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4171
|
+
return referralRewards;
|
|
4172
|
+
}()
|
|
4173
|
+
/**
|
|
4174
|
+
* Top 50 reward earners from the last round, sorted by token amount
|
|
4175
|
+
*/
|
|
4176
|
+
;
|
|
4177
|
+
_proto.leaderboard =
|
|
4178
|
+
/*#__PURE__*/
|
|
4179
|
+
function () {
|
|
4180
|
+
var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(campaign) {
|
|
4181
|
+
var result, items;
|
|
4182
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
4116
4183
|
while (1) switch (_context6.prev = _context6.next) {
|
|
4117
4184
|
case 0:
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
_1E18 = BigNumber$1.from(10).pow(18);
|
|
4122
|
-
oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
|
|
4123
|
-
tokens = tokenAddresses.map(function (addr) {
|
|
4124
|
-
return _this2.env.getContract(addr, abis.abi);
|
|
4185
|
+
_context6.next = 2;
|
|
4186
|
+
return getPaginatedApi('/referral/leaderboard', {
|
|
4187
|
+
campaign: campaign
|
|
4125
4188
|
});
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
break;
|
|
4140
|
-
}
|
|
4141
|
-
addr = _step2.value;
|
|
4142
|
-
infos = [];
|
|
4143
|
-
i = 0;
|
|
4144
|
-
case 16:
|
|
4145
|
-
if (!(i < tokens.length)) {
|
|
4146
|
-
_context6.next = 30;
|
|
4147
|
-
break;
|
|
4148
|
-
}
|
|
4149
|
-
_context6.next = 19;
|
|
4150
|
-
return tokens[i].getAccountSnapshot(addr);
|
|
4151
|
-
case 19:
|
|
4152
|
-
snapshot = _context6.sent;
|
|
4153
|
-
bal = snapshot[0].mul(exrate[i]).div(_1E18).mul(prices[i]).div(_1E18);
|
|
4154
|
-
bor = snapshot[1].mul(prices[i]).div(_1E18);
|
|
4155
|
-
balR = new BigNumber(bal.toString()).dividedBy(_1E18.toString());
|
|
4156
|
-
borR = new BigNumber(bor.toString()).dividedBy(_1E18.toString());
|
|
4157
|
-
if (!(balR.lte(dust) && borR.lte(dust))) {
|
|
4158
|
-
_context6.next = 26;
|
|
4159
|
-
break;
|
|
4160
|
-
}
|
|
4161
|
-
return _context6.abrupt("continue", 27);
|
|
4162
|
-
case 26:
|
|
4163
|
-
infos.push({
|
|
4164
|
-
token: getSymbol(tokenAddresses[i]),
|
|
4165
|
-
deposit: balR,
|
|
4166
|
-
borrow: borR
|
|
4189
|
+
case 2:
|
|
4190
|
+
result = _context6.sent;
|
|
4191
|
+
items = result.items.map(function (item, i) {
|
|
4192
|
+
return {
|
|
4193
|
+
campaign: campaign,
|
|
4194
|
+
userAddr: item.user,
|
|
4195
|
+
isReferrer: item.campaign.includes('referrer'),
|
|
4196
|
+
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
4197
|
+
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
4198
|
+
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
4199
|
+
transactionHash: null,
|
|
4200
|
+
refereeAddress: null
|
|
4201
|
+
};
|
|
4167
4202
|
});
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
_context6.next = 16;
|
|
4171
|
-
break;
|
|
4172
|
-
case 30:
|
|
4173
|
-
res.push({
|
|
4174
|
-
address: addr,
|
|
4175
|
-
tokens: infos
|
|
4203
|
+
items.sort(function (a, b) {
|
|
4204
|
+
return b.rewardTokenAmount.compare(a.rewardTokenAmount);
|
|
4176
4205
|
});
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
break;
|
|
4180
|
-
case 33:
|
|
4181
|
-
return _context6.abrupt("return", res);
|
|
4182
|
-
case 34:
|
|
4206
|
+
return _context6.abrupt("return", items);
|
|
4207
|
+
case 6:
|
|
4183
4208
|
case "end":
|
|
4184
4209
|
return _context6.stop();
|
|
4185
4210
|
}
|
|
4186
|
-
},
|
|
4211
|
+
}, _callee6);
|
|
4187
4212
|
}));
|
|
4188
|
-
function
|
|
4189
|
-
return
|
|
4213
|
+
function leaderboard(_x6) {
|
|
4214
|
+
return _leaderboard.apply(this, arguments);
|
|
4190
4215
|
}
|
|
4191
|
-
return
|
|
4192
|
-
}()
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
_context7.next = 6;
|
|
4205
|
-
return Promise.all(networkAddresses.auTokens.map(function (auToken) {
|
|
4206
|
-
var moneyMarket = new MoneyMarketRead(_this3._networkConnection, auToken.address, auToken.underlying);
|
|
4207
|
-
var apyWithoutIncentive = moneyMarket.getApyWithoutIncentive(userAddress);
|
|
4208
|
-
return apyWithoutIncentive;
|
|
4209
|
-
}));
|
|
4210
|
-
case 6:
|
|
4211
|
-
apys = _context7.sent;
|
|
4212
|
-
for (_iterator3 = _createForOfIteratorHelperLoose(apys); !(_step3 = _iterator3()).done;) {
|
|
4213
|
-
apy = _step3.value;
|
|
4214
|
-
sum = sum.plus(apy.sum);
|
|
4215
|
-
totalSuppliedValue = totalSuppliedValue.plus(apy.suppliedValue);
|
|
4216
|
-
totalBorrowedValue = totalBorrowedValue.plus(apy.borrowedValue);
|
|
4217
|
-
}
|
|
4218
|
-
if (sum.gt(0)) {
|
|
4219
|
-
netApy = sum.div(totalSuppliedValue);
|
|
4220
|
-
} else if (sum.lt(0)) {
|
|
4221
|
-
netApy = sum.div(totalBorrowedValue);
|
|
4222
|
-
}
|
|
4223
|
-
return _context7.abrupt("return", netApy);
|
|
4224
|
-
case 10:
|
|
4225
|
-
case "end":
|
|
4226
|
-
return _context7.stop();
|
|
4227
|
-
}
|
|
4228
|
-
}, _callee6);
|
|
4229
|
-
}));
|
|
4230
|
-
function getNetApyWithoutIncentive(_x7) {
|
|
4231
|
-
return _getNetApyWithoutIncentive.apply(this, arguments);
|
|
4232
|
-
}
|
|
4233
|
-
return getNetApyWithoutIncentive;
|
|
4234
|
-
}();
|
|
4235
|
-
_proto.getNetApyWithIncentive = /*#__PURE__*/function () {
|
|
4236
|
-
var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(userAddress) {
|
|
4237
|
-
var _this4 = this;
|
|
4238
|
-
var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator4, _step4, apy;
|
|
4239
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
4240
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
4216
|
+
return leaderboard;
|
|
4217
|
+
}()
|
|
4218
|
+
/**
|
|
4219
|
+
* current number of slots under a referral code being used that exceed minimum deposit amount
|
|
4220
|
+
*/
|
|
4221
|
+
;
|
|
4222
|
+
_proto.slotsInUse =
|
|
4223
|
+
/*#__PURE__*/
|
|
4224
|
+
function () {
|
|
4225
|
+
var _slotsInUse = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
4226
|
+
var result;
|
|
4227
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
4228
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
4241
4229
|
case 0:
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
var moneyMarket = new MoneyMarketRead(_this4._networkConnection, auToken.address, auToken.underlying);
|
|
4249
|
-
var apyWithIncentive = moneyMarket.getApyWithIncentive(userAddress);
|
|
4250
|
-
return apyWithIncentive;
|
|
4251
|
-
}));
|
|
4252
|
-
case 6:
|
|
4253
|
-
apys = _context8.sent;
|
|
4254
|
-
for (_iterator4 = _createForOfIteratorHelperLoose(apys); !(_step4 = _iterator4()).done;) {
|
|
4255
|
-
apy = _step4.value;
|
|
4256
|
-
sum = sum.plus(apy.sum);
|
|
4257
|
-
totalSuppliedValue = totalSuppliedValue.plus(apy.suppliedValue);
|
|
4258
|
-
totalBorrowedValue = totalBorrowedValue.plus(apy.borrowedValue);
|
|
4259
|
-
}
|
|
4260
|
-
if (sum.gt(0)) {
|
|
4261
|
-
netApy = sum.div(totalSuppliedValue);
|
|
4262
|
-
} else if (sum.lt(0)) {
|
|
4263
|
-
netApy = sum.div(totalBorrowedValue);
|
|
4264
|
-
}
|
|
4265
|
-
return _context8.abrupt("return", netApy);
|
|
4266
|
-
case 10:
|
|
4230
|
+
_context7.next = 2;
|
|
4231
|
+
return getApi('/referral/slotsInUse');
|
|
4232
|
+
case 2:
|
|
4233
|
+
result = _context7.sent;
|
|
4234
|
+
return _context7.abrupt("return", result);
|
|
4235
|
+
case 4:
|
|
4267
4236
|
case "end":
|
|
4268
|
-
return
|
|
4237
|
+
return _context7.stop();
|
|
4269
4238
|
}
|
|
4270
4239
|
}, _callee7);
|
|
4271
4240
|
}));
|
|
4272
|
-
function
|
|
4273
|
-
return
|
|
4241
|
+
function slotsInUse() {
|
|
4242
|
+
return _slotsInUse.apply(this, arguments);
|
|
4274
4243
|
}
|
|
4275
|
-
return
|
|
4244
|
+
return slotsInUse;
|
|
4276
4245
|
}();
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
4281
|
-
_inheritsLoose(PlyGameRead, _BlockchainEntityRead);
|
|
4282
|
-
function PlyGameRead(networkConnection) {
|
|
4283
|
-
var _this;
|
|
4284
|
-
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
4285
|
-
_this.env = new AuriEnv(networkConnection);
|
|
4286
|
-
var plyAddress = networkAddresses.tokens.PLY;
|
|
4287
|
-
var pulpAddress = networkAddresses.tokens.PULP;
|
|
4288
|
-
_this.plyToken = new Token(plyAddress, getDecimal(plyAddress));
|
|
4289
|
-
_this.pulpToken = new Token(pulpAddress, getDecimal(pulpAddress));
|
|
4290
|
-
return _this;
|
|
4291
|
-
}
|
|
4292
|
-
var _proto = PlyGameRead.prototype;
|
|
4293
|
-
_proto.parseBetMakeEvent = function parseBetMakeEvent(event) {
|
|
4294
|
-
var outcome = ['bigWin', 'win', 'lose', 'noImpact'][event.args.outcome];
|
|
4295
|
-
var betAmount = event.args.amount;
|
|
4296
|
-
// 0%, 0%, 100%, 2%
|
|
4297
|
-
// big win, win, lose, no impact
|
|
4298
|
-
var lostAmount = betAmount.mul([0, 0, 100, 2][event.args.outcome]).div(100);
|
|
4299
|
-
var unlock = betAmount.mul([10, 1, 0, 0][event.args.outcome]);
|
|
4300
|
-
return {
|
|
4301
|
-
player: event.args.player,
|
|
4302
|
-
lostAmount: new TokenAmount(this.plyToken, lostAmount.toString()),
|
|
4303
|
-
unlockedPulpAmount: new TokenAmount(this.pulpToken, unlock.toString()),
|
|
4304
|
-
outcome: outcome,
|
|
4305
|
-
transactionHash: event.transactionHash,
|
|
4306
|
-
block: event.blockNumber,
|
|
4307
|
-
timestamp: 0
|
|
4308
|
-
};
|
|
4246
|
+
_proto.totalReferralSlots = function totalReferralSlots() {
|
|
4247
|
+
return 500;
|
|
4309
4248
|
};
|
|
4310
|
-
_proto.
|
|
4311
|
-
var
|
|
4312
|
-
var
|
|
4313
|
-
return _regeneratorRuntime().wrap(function
|
|
4314
|
-
while (1) switch (
|
|
4249
|
+
_proto.queuePosition = /*#__PURE__*/function () {
|
|
4250
|
+
var _queuePosition = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address) {
|
|
4251
|
+
var result;
|
|
4252
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
4253
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
4315
4254
|
case 0:
|
|
4316
|
-
|
|
4317
|
-
|
|
4255
|
+
_context8.next = 2;
|
|
4256
|
+
return getApi('/referral/queuePosition', {
|
|
4257
|
+
address: address
|
|
4318
4258
|
});
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
return _context.abrupt("return", results.map(function (e, i) {
|
|
4324
|
-
return _extends({}, e, {
|
|
4325
|
-
timestamp: blockstimestamp[i]
|
|
4326
|
-
});
|
|
4327
|
-
}));
|
|
4328
|
-
case 5:
|
|
4259
|
+
case 2:
|
|
4260
|
+
result = _context8.sent;
|
|
4261
|
+
return _context8.abrupt("return", result);
|
|
4262
|
+
case 4:
|
|
4329
4263
|
case "end":
|
|
4330
|
-
return
|
|
4264
|
+
return _context8.stop();
|
|
4331
4265
|
}
|
|
4332
|
-
},
|
|
4266
|
+
}, _callee8);
|
|
4333
4267
|
}));
|
|
4334
|
-
function
|
|
4335
|
-
return
|
|
4268
|
+
function queuePosition(_x7) {
|
|
4269
|
+
return _queuePosition.apply(this, arguments);
|
|
4336
4270
|
}
|
|
4337
|
-
return
|
|
4271
|
+
return queuePosition;
|
|
4338
4272
|
}()
|
|
4339
4273
|
/**
|
|
4340
|
-
*
|
|
4274
|
+
* a way to determine qualification status of a user. null if not referred yet,
|
|
4275
|
+
* qualified if referred + min deposit, notQualified if referred + min deposit
|
|
4276
|
+
* not reached or withdrew too early
|
|
4341
4277
|
*/
|
|
4342
4278
|
;
|
|
4343
|
-
_proto.
|
|
4279
|
+
_proto.userReferralStatus =
|
|
4344
4280
|
/*#__PURE__*/
|
|
4345
4281
|
function () {
|
|
4346
|
-
var
|
|
4347
|
-
var
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
4282
|
+
var _userReferralStatus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(userAddr) {
|
|
4283
|
+
var result;
|
|
4284
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
4285
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
4351
4286
|
case 0:
|
|
4352
|
-
|
|
4353
|
-
return
|
|
4287
|
+
_context9.next = 2;
|
|
4288
|
+
return getApi('/referral/referralStatus', {
|
|
4289
|
+
address: userAddr
|
|
4290
|
+
});
|
|
4354
4291
|
case 2:
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
return
|
|
4361
|
-
case
|
|
4362
|
-
|
|
4363
|
-
_context2.next = 8;
|
|
4364
|
-
return this.env.plygame.queryFilter(filter, block100.toNumber());
|
|
4292
|
+
result = _context9.sent;
|
|
4293
|
+
_context9.t0 = result;
|
|
4294
|
+
_context9.next = _context9.t0 === -1 ? 6 : _context9.t0 === 0 ? 7 : _context9.t0 === 1 ? 8 : 9;
|
|
4295
|
+
break;
|
|
4296
|
+
case 6:
|
|
4297
|
+
return _context9.abrupt("return", 'notReferred');
|
|
4298
|
+
case 7:
|
|
4299
|
+
return _context9.abrupt("return", 'notQualified');
|
|
4365
4300
|
case 8:
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
return _this2.parseBetMakeEvent(event);
|
|
4371
|
-
})));
|
|
4372
|
-
case 11:
|
|
4301
|
+
return _context9.abrupt("return", 'Qualified');
|
|
4302
|
+
case 9:
|
|
4303
|
+
return _context9.abrupt("return", 'Withdrawn');
|
|
4304
|
+
case 10:
|
|
4373
4305
|
case "end":
|
|
4374
|
-
return
|
|
4306
|
+
return _context9.stop();
|
|
4375
4307
|
}
|
|
4376
|
-
},
|
|
4308
|
+
}, _callee9);
|
|
4377
4309
|
}));
|
|
4378
|
-
function
|
|
4379
|
-
return
|
|
4310
|
+
function userReferralStatus(_x8) {
|
|
4311
|
+
return _userReferralStatus.apply(this, arguments);
|
|
4380
4312
|
}
|
|
4381
|
-
return
|
|
4382
|
-
}()
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
/*#__PURE__*/
|
|
4389
|
-
function () {
|
|
4390
|
-
var _currentJackpotAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
4391
|
-
var jackpot;
|
|
4392
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4393
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
4313
|
+
return userReferralStatus;
|
|
4314
|
+
}();
|
|
4315
|
+
_proto.isWhitelistedAddress = /*#__PURE__*/function () {
|
|
4316
|
+
var _isWhitelistedAddress = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address) {
|
|
4317
|
+
var result;
|
|
4318
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
4319
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
4394
4320
|
case 0:
|
|
4395
|
-
|
|
4396
|
-
return this.env.
|
|
4321
|
+
_context10.next = 2;
|
|
4322
|
+
return this.env.referralDirectoryV2.isUserWhitelisted(address);
|
|
4397
4323
|
case 2:
|
|
4398
|
-
|
|
4399
|
-
return
|
|
4324
|
+
result = _context10.sent;
|
|
4325
|
+
return _context10.abrupt("return", result.eq(1));
|
|
4400
4326
|
case 4:
|
|
4401
4327
|
case "end":
|
|
4402
|
-
return
|
|
4328
|
+
return _context10.stop();
|
|
4403
4329
|
}
|
|
4404
|
-
},
|
|
4330
|
+
}, _callee10, this);
|
|
4405
4331
|
}));
|
|
4406
|
-
function
|
|
4407
|
-
return
|
|
4332
|
+
function isWhitelistedAddress(_x9) {
|
|
4333
|
+
return _isWhitelistedAddress.apply(this, arguments);
|
|
4408
4334
|
}
|
|
4409
|
-
return
|
|
4335
|
+
return isWhitelistedAddress;
|
|
4410
4336
|
}();
|
|
4411
|
-
_proto.
|
|
4412
|
-
var
|
|
4413
|
-
var
|
|
4414
|
-
return _regeneratorRuntime().wrap(function
|
|
4415
|
-
while (1) switch (
|
|
4337
|
+
_proto.isOnAuroraPlus = /*#__PURE__*/function () {
|
|
4338
|
+
var _isOnAuroraPlus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(address) {
|
|
4339
|
+
var resp;
|
|
4340
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
4341
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
4416
4342
|
case 0:
|
|
4417
|
-
|
|
4418
|
-
return
|
|
4343
|
+
_context11.next = 2;
|
|
4344
|
+
return axios.get(AURORA_PLUS_API_PREFIX + address);
|
|
4419
4345
|
case 2:
|
|
4420
|
-
|
|
4421
|
-
return
|
|
4346
|
+
resp = _context11.sent;
|
|
4347
|
+
return _context11.abrupt("return", resp.data.status == 'active');
|
|
4422
4348
|
case 4:
|
|
4423
4349
|
case "end":
|
|
4424
|
-
return
|
|
4350
|
+
return _context11.stop();
|
|
4425
4351
|
}
|
|
4426
|
-
},
|
|
4352
|
+
}, _callee11);
|
|
4427
4353
|
}));
|
|
4428
|
-
function
|
|
4429
|
-
return
|
|
4354
|
+
function isOnAuroraPlus(_x10) {
|
|
4355
|
+
return _isOnAuroraPlus.apply(this, arguments);
|
|
4430
4356
|
}
|
|
4431
|
-
return
|
|
4357
|
+
return isOnAuroraPlus;
|
|
4432
4358
|
}();
|
|
4433
|
-
_proto.
|
|
4434
|
-
var
|
|
4435
|
-
var _this3 = this;
|
|
4436
|
-
var tx, i, filter, betMadeEvents;
|
|
4437
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
4438
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
4439
|
-
case 0:
|
|
4440
|
-
_context5.next = 2;
|
|
4441
|
-
return this._networkConnection.provider.getTransactionReceipt(txHash);
|
|
4442
|
-
case 2:
|
|
4443
|
-
tx = _context5.sent;
|
|
4444
|
-
i = 0;
|
|
4445
|
-
case 4:
|
|
4446
|
-
if (!(i < 100 && !tx)) {
|
|
4447
|
-
_context5.next = 13;
|
|
4448
|
-
break;
|
|
4449
|
-
}
|
|
4450
|
-
_context5.next = 7;
|
|
4451
|
-
return sleep(1000);
|
|
4452
|
-
case 7:
|
|
4453
|
-
_context5.next = 9;
|
|
4454
|
-
return this._networkConnection.provider.getTransactionReceipt(txHash);
|
|
4455
|
-
case 9:
|
|
4456
|
-
tx = _context5.sent;
|
|
4457
|
-
case 10:
|
|
4458
|
-
i++;
|
|
4459
|
-
_context5.next = 4;
|
|
4460
|
-
break;
|
|
4461
|
-
case 13:
|
|
4462
|
-
if (tx) {
|
|
4463
|
-
_context5.next = 15;
|
|
4464
|
-
break;
|
|
4465
|
-
}
|
|
4466
|
-
throw new Error("Transaction " + txHash + " takes too long to be mined");
|
|
4467
|
-
case 15:
|
|
4468
|
-
filter = this.env.plygame.filters.BetMade();
|
|
4469
|
-
betMadeEvents = tx.logs.filter(function (log) {
|
|
4470
|
-
return isSameAddress(log.topics[0], filter.topics[0]);
|
|
4471
|
-
}).map(function (log) {
|
|
4472
|
-
return _extends({}, _this3.env.plygame["interface"].parseLog(log), {
|
|
4473
|
-
blockNumber: tx.blockNumber,
|
|
4474
|
-
transactionHash: txHash
|
|
4475
|
-
});
|
|
4476
|
-
});
|
|
4477
|
-
return _context5.abrupt("return", this.attachTimestamp(betMadeEvents.map(function (e) {
|
|
4478
|
-
return _this3.parseBetMakeEvent(e);
|
|
4479
|
-
})));
|
|
4480
|
-
case 18:
|
|
4481
|
-
case "end":
|
|
4482
|
-
return _context5.stop();
|
|
4483
|
-
}
|
|
4484
|
-
}, _callee5, this);
|
|
4485
|
-
}));
|
|
4486
|
-
function getPlyGameResultsInTransaction(_x4) {
|
|
4487
|
-
return _getPlyGameResultsInTransaction.apply(this, arguments);
|
|
4488
|
-
}
|
|
4489
|
-
return getPlyGameResultsInTransaction;
|
|
4490
|
-
}()
|
|
4491
|
-
/**
|
|
4492
|
-
* Top 100 users by amount of PULP unlocked
|
|
4493
|
-
*/
|
|
4494
|
-
;
|
|
4495
|
-
_proto.leaderboard =
|
|
4496
|
-
/*#__PURE__*/
|
|
4497
|
-
function () {
|
|
4498
|
-
var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
4499
|
-
var _this4 = this;
|
|
4359
|
+
_proto.isNewUserAtReferralTime = /*#__PURE__*/function () {
|
|
4360
|
+
var _isNewUserAtReferralTime = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address) {
|
|
4500
4361
|
var result;
|
|
4501
|
-
return _regeneratorRuntime().wrap(function
|
|
4502
|
-
while (1) switch (
|
|
4362
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
4363
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
4503
4364
|
case 0:
|
|
4504
|
-
|
|
4505
|
-
return
|
|
4365
|
+
_context12.next = 2;
|
|
4366
|
+
return getApi('/referral/isNewUser', {
|
|
4367
|
+
address: address
|
|
4368
|
+
});
|
|
4506
4369
|
case 2:
|
|
4507
|
-
result =
|
|
4508
|
-
return
|
|
4509
|
-
return {
|
|
4510
|
-
player: item.user,
|
|
4511
|
-
unlockedPulpAmount: new TokenAmount(_this4.pulpToken, item.unlockedAmount),
|
|
4512
|
-
gamesPlayed: item.count
|
|
4513
|
-
};
|
|
4514
|
-
}));
|
|
4370
|
+
result = _context12.sent;
|
|
4371
|
+
return _context12.abrupt("return", result);
|
|
4515
4372
|
case 4:
|
|
4516
4373
|
case "end":
|
|
4517
|
-
return
|
|
4518
|
-
}
|
|
4519
|
-
}, _callee6);
|
|
4520
|
-
}));
|
|
4521
|
-
function leaderboard() {
|
|
4522
|
-
return _leaderboard.apply(this, arguments);
|
|
4523
|
-
}
|
|
4524
|
-
return leaderboard;
|
|
4525
|
-
}();
|
|
4526
|
-
_proto.getLastJackpotResult = /*#__PURE__*/function () {
|
|
4527
|
-
var _getLastJackpotResult = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
4528
|
-
var round, result;
|
|
4529
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
4530
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
4531
|
-
case 0:
|
|
4532
|
-
_context7.t0 = BigNumber$1;
|
|
4533
|
-
_context7.next = 3;
|
|
4534
|
-
return this._networkConnection.provider.getStorageAt(this.env.plygame.address, 158);
|
|
4535
|
-
case 3:
|
|
4536
|
-
_context7.t1 = _context7.sent;
|
|
4537
|
-
round = _context7.t0.from.call(_context7.t0, _context7.t1);
|
|
4538
|
-
_context7.next = 7;
|
|
4539
|
-
return this.env.plygame.jackpotHistory(round.sub(1));
|
|
4540
|
-
case 7:
|
|
4541
|
-
result = _context7.sent;
|
|
4542
|
-
return _context7.abrupt("return", {
|
|
4543
|
-
winner: result.winner.slice(0, 5) + '...' + result.winner.slice(-3),
|
|
4544
|
-
amount: new TokenAmount(this.plyToken, result.amount.toString())
|
|
4545
|
-
});
|
|
4546
|
-
case 9:
|
|
4547
|
-
case "end":
|
|
4548
|
-
return _context7.stop();
|
|
4374
|
+
return _context12.stop();
|
|
4549
4375
|
}
|
|
4550
|
-
},
|
|
4376
|
+
}, _callee12);
|
|
4551
4377
|
}));
|
|
4552
|
-
function
|
|
4553
|
-
return
|
|
4378
|
+
function isNewUserAtReferralTime(_x11) {
|
|
4379
|
+
return _isNewUserAtReferralTime.apply(this, arguments);
|
|
4554
4380
|
}
|
|
4555
|
-
return
|
|
4381
|
+
return isNewUserAtReferralTime;
|
|
4556
4382
|
}();
|
|
4557
|
-
_proto.
|
|
4558
|
-
var
|
|
4559
|
-
var _this5 = this;
|
|
4383
|
+
_proto.depositedMoreThanMinimumAmount = /*#__PURE__*/function () {
|
|
4384
|
+
var _depositedMoreThanMinimumAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(address) {
|
|
4560
4385
|
var result;
|
|
4561
|
-
return _regeneratorRuntime().wrap(function
|
|
4562
|
-
while (1) switch (
|
|
4386
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
4387
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
4563
4388
|
case 0:
|
|
4564
|
-
|
|
4565
|
-
return
|
|
4389
|
+
_context13.next = 2;
|
|
4390
|
+
return getApi('/referral/depositedEnough', {
|
|
4391
|
+
address: address
|
|
4392
|
+
});
|
|
4566
4393
|
case 2:
|
|
4567
|
-
result =
|
|
4568
|
-
return
|
|
4569
|
-
return {
|
|
4570
|
-
player: item.user,
|
|
4571
|
-
unlockedPulpAmount: new TokenAmount(_this5.pulpToken, item.unlockedAmount),
|
|
4572
|
-
gamesPlayed: item.count
|
|
4573
|
-
};
|
|
4574
|
-
}));
|
|
4394
|
+
result = _context13.sent;
|
|
4395
|
+
return _context13.abrupt("return", result);
|
|
4575
4396
|
case 4:
|
|
4576
4397
|
case "end":
|
|
4577
|
-
return
|
|
4398
|
+
return _context13.stop();
|
|
4578
4399
|
}
|
|
4579
|
-
},
|
|
4400
|
+
}, _callee13);
|
|
4580
4401
|
}));
|
|
4581
|
-
function
|
|
4582
|
-
return
|
|
4402
|
+
function depositedMoreThanMinimumAmount(_x12) {
|
|
4403
|
+
return _depositedMoreThanMinimumAmount.apply(this, arguments);
|
|
4583
4404
|
}
|
|
4584
|
-
return
|
|
4405
|
+
return depositedMoreThanMinimumAmount;
|
|
4585
4406
|
}();
|
|
4586
|
-
return
|
|
4407
|
+
return ReferralRead;
|
|
4587
4408
|
}(BlockchainEntityRead);
|
|
4588
|
-
var
|
|
4589
|
-
_inheritsLoose(
|
|
4590
|
-
function
|
|
4591
|
-
return
|
|
4409
|
+
var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
4410
|
+
_inheritsLoose(ReferralReadWrite, _ReferralRead);
|
|
4411
|
+
function ReferralReadWrite() {
|
|
4412
|
+
return _ReferralRead.apply(this, arguments) || this;
|
|
4592
4413
|
}
|
|
4593
|
-
var _proto2 =
|
|
4414
|
+
var _proto2 = ReferralReadWrite.prototype;
|
|
4594
4415
|
/**
|
|
4595
|
-
*
|
|
4416
|
+
* Generate a referral code for a given address.
|
|
4417
|
+
*
|
|
4418
|
+
* Called when an user want to creates his own referral code
|
|
4596
4419
|
*/
|
|
4597
|
-
_proto2.
|
|
4420
|
+
_proto2.registerNewReferralCode =
|
|
4598
4421
|
/*#__PURE__*/
|
|
4599
4422
|
function () {
|
|
4600
|
-
var
|
|
4601
|
-
|
|
4602
|
-
|
|
4423
|
+
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
4424
|
+
var referralCode;
|
|
4425
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
4426
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
4603
4427
|
case 0:
|
|
4604
|
-
|
|
4605
|
-
|
|
4428
|
+
referralCode = ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
4429
|
+
return _context14.abrupt("return", this.env.referralDirectoryV2.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
|
|
4430
|
+
case 2:
|
|
4606
4431
|
case "end":
|
|
4607
|
-
return
|
|
4432
|
+
return _context14.stop();
|
|
4608
4433
|
}
|
|
4609
|
-
},
|
|
4434
|
+
}, _callee14, this);
|
|
4610
4435
|
}));
|
|
4611
|
-
function
|
|
4612
|
-
return
|
|
4436
|
+
function registerNewReferralCode() {
|
|
4437
|
+
return _registerNewReferralCode.apply(this, arguments);
|
|
4613
4438
|
}
|
|
4614
|
-
return
|
|
4615
|
-
}()
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4439
|
+
return registerNewReferralCode;
|
|
4440
|
+
}()
|
|
4441
|
+
/**
|
|
4442
|
+
* Called when an user confirms he is referred by a specified code
|
|
4443
|
+
*/
|
|
4444
|
+
;
|
|
4445
|
+
_proto2.useReferralCode =
|
|
4446
|
+
/*#__PURE__*/
|
|
4447
|
+
function () {
|
|
4448
|
+
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(code) {
|
|
4449
|
+
var referralCode;
|
|
4450
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
4451
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
4620
4452
|
case 0:
|
|
4621
|
-
|
|
4622
|
-
|
|
4453
|
+
referralCode = ethers.utils.formatBytes32String(code);
|
|
4454
|
+
return _context15.abrupt("return", this.env.referralDirectoryV2.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
|
|
4455
|
+
case 2:
|
|
4623
4456
|
case "end":
|
|
4624
|
-
return
|
|
4457
|
+
return _context15.stop();
|
|
4625
4458
|
}
|
|
4626
|
-
},
|
|
4459
|
+
}, _callee15, this);
|
|
4627
4460
|
}));
|
|
4628
|
-
function
|
|
4629
|
-
return
|
|
4461
|
+
function useReferralCode(_x13) {
|
|
4462
|
+
return _useReferralCode.apply(this, arguments);
|
|
4630
4463
|
}
|
|
4631
|
-
return
|
|
4464
|
+
return useReferralCode;
|
|
4465
|
+
}()
|
|
4466
|
+
/**
|
|
4467
|
+
* Claim all unclaimed rewards for a given user
|
|
4468
|
+
*/
|
|
4469
|
+
;
|
|
4470
|
+
_proto2.claimReferralRewards =
|
|
4471
|
+
/*#__PURE__*/
|
|
4472
|
+
function () {
|
|
4473
|
+
var _claimReferralRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
4474
|
+
var unclaimedRewards, campaigns, tokens;
|
|
4475
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
4476
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
4477
|
+
case 0:
|
|
4478
|
+
_context16.t0 = this;
|
|
4479
|
+
_context16.next = 3;
|
|
4480
|
+
return this._networkConnection.signer.getAddress();
|
|
4481
|
+
case 3:
|
|
4482
|
+
_context16.t1 = _context16.sent;
|
|
4483
|
+
_context16.next = 6;
|
|
4484
|
+
return _context16.t0.referralRewards.call(_context16.t0, _context16.t1);
|
|
4485
|
+
case 6:
|
|
4486
|
+
unclaimedRewards = _context16.sent.filter(function (reward) {
|
|
4487
|
+
return reward.transactionHash == null;
|
|
4488
|
+
});
|
|
4489
|
+
campaigns = unclaimedRewards.map(function (reward) {
|
|
4490
|
+
return reward.campaign;
|
|
4491
|
+
});
|
|
4492
|
+
tokens = unclaimedRewards.map(function (reward) {
|
|
4493
|
+
return reward.rewardTokenAmount.token.address;
|
|
4494
|
+
});
|
|
4495
|
+
return _context16.abrupt("return", new AirdropReadWrite(this._networkConnection).redeemMultiple(campaigns, tokens));
|
|
4496
|
+
case 10:
|
|
4497
|
+
case "end":
|
|
4498
|
+
return _context16.stop();
|
|
4499
|
+
}
|
|
4500
|
+
}, _callee16, this);
|
|
4501
|
+
}));
|
|
4502
|
+
function claimReferralRewards() {
|
|
4503
|
+
return _claimReferralRewards.apply(this, arguments);
|
|
4504
|
+
}
|
|
4505
|
+
return claimReferralRewards;
|
|
4632
4506
|
}();
|
|
4633
|
-
return
|
|
4634
|
-
}(
|
|
4635
|
-
var
|
|
4636
|
-
_inheritsLoose(
|
|
4637
|
-
function
|
|
4507
|
+
return ReferralReadWrite;
|
|
4508
|
+
}(ReferralRead);
|
|
4509
|
+
var Referral = /*#__PURE__*/function (_BlockchainEntity) {
|
|
4510
|
+
_inheritsLoose(Referral, _BlockchainEntity);
|
|
4511
|
+
function Referral() {
|
|
4638
4512
|
return _BlockchainEntity.call(this) || this;
|
|
4639
4513
|
}
|
|
4640
|
-
var _proto3 =
|
|
4514
|
+
var _proto3 = Referral.prototype;
|
|
4641
4515
|
_proto3.read = function read(networkConnection) {
|
|
4642
|
-
return new
|
|
4516
|
+
return new ReferralRead(networkConnection);
|
|
4643
4517
|
};
|
|
4644
4518
|
_proto3.readWrite = function readWrite(networkConnection) {
|
|
4645
|
-
return new
|
|
4519
|
+
return new ReferralReadWrite(networkConnection);
|
|
4646
4520
|
};
|
|
4647
|
-
return
|
|
4521
|
+
return Referral;
|
|
4648
4522
|
}(BlockchainEntity);
|
|
4649
4523
|
|
|
4650
|
-
var
|
|
4651
|
-
_inheritsLoose(
|
|
4652
|
-
function
|
|
4524
|
+
var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
4525
|
+
_inheritsLoose(StakingRead, _BlockchainEntityRead);
|
|
4526
|
+
function StakingRead(networkConnection) {
|
|
4653
4527
|
var _this;
|
|
4654
4528
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
4655
4529
|
_this.env = new AuriEnv(networkConnection);
|
|
4656
4530
|
return _this;
|
|
4657
4531
|
}
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
var _proto = ReferralRead.prototype;
|
|
4663
|
-
_proto.generateReferralCode = function generateReferralCode() {
|
|
4664
|
-
var letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
4665
|
-
var numbers = '1234567890';
|
|
4666
|
-
var charset = letters + letters.toUpperCase() + numbers;
|
|
4667
|
-
var R = '';
|
|
4668
|
-
for (var i = 0; i < 10; i++) R += charset[Math.floor(Math.random() * charset.length)];
|
|
4669
|
-
return R;
|
|
4670
|
-
}
|
|
4671
|
-
/**
|
|
4672
|
-
* Get the referral code for a given address, returns empty string if not found.
|
|
4673
|
-
*
|
|
4674
|
-
* Called to check if a user has a referral code.
|
|
4675
|
-
*/;
|
|
4676
|
-
_proto.getUserReferralCode =
|
|
4677
|
-
/*#__PURE__*/
|
|
4678
|
-
function () {
|
|
4679
|
-
var _getUserReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(userAddr) {
|
|
4680
|
-
var result;
|
|
4532
|
+
var _proto = StakingRead.prototype;
|
|
4533
|
+
_proto.getPLYWNEARPoolDetails = /*#__PURE__*/function () {
|
|
4534
|
+
var _getPLYWNEARPoolDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
4535
|
+
var stakedLiquidity, rewardPerSeconds, stakedLiquidityAmount, totalStakeValuation, promises, i, rewardTokenAddress, rewardToken, rewardPerSecond, APYs;
|
|
4681
4536
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4682
4537
|
while (1) switch (_context.prev = _context.next) {
|
|
4683
4538
|
case 0:
|
|
4684
4539
|
_context.next = 2;
|
|
4685
|
-
return this.env.
|
|
4540
|
+
return this.env.auriFairLaunch.getPoolInfo(PLYWNEAR_POOL_ID).then(function (res) {
|
|
4541
|
+
stakedLiquidity = res.totalStake;
|
|
4542
|
+
rewardPerSeconds = res.rewardPerSeconds;
|
|
4543
|
+
});
|
|
4686
4544
|
case 2:
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4545
|
+
stakedLiquidityAmount = new TokenAmount(PLYWNEARToken, stakedLiquidity.toString());
|
|
4546
|
+
_context.next = 5;
|
|
4547
|
+
return fetchValuation(stakedLiquidityAmount, this._networkConnection.provider);
|
|
4548
|
+
case 5:
|
|
4549
|
+
totalStakeValuation = _context.sent;
|
|
4550
|
+
promises = []; // Calculate the reward per second in USD
|
|
4551
|
+
for (i = 0; i < rewardPerSeconds.length; i++) {
|
|
4552
|
+
rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
|
|
4553
|
+
rewardToken = new Token(rewardTokenAddress, getDecimal(rewardTokenAddress));
|
|
4554
|
+
rewardPerSecond = rewardPerSeconds[i];
|
|
4555
|
+
promises.push(fetchValuation(new TokenAmount(rewardToken, rewardPerSecond.toString()), this._networkConnection.provider));
|
|
4556
|
+
}
|
|
4557
|
+
APYs = [];
|
|
4558
|
+
_context.next = 11;
|
|
4559
|
+
return Promise.all(promises);
|
|
4560
|
+
case 11:
|
|
4561
|
+
_context.sent.forEach(function (rewardPerSecondValuation, i) {
|
|
4562
|
+
var rewardTokenAddress = PLYWNEAR_REWARD_TOKENS[i];
|
|
4563
|
+
var apy = calcLMRewardApr(rewardPerSecondValuation, totalStakeValuation, ONE_DAY * 365).toFixed(DECIMAL_PRECISION);
|
|
4564
|
+
APYs.push({
|
|
4565
|
+
address: rewardTokenAddress,
|
|
4566
|
+
apy: apy
|
|
4567
|
+
});
|
|
4568
|
+
});
|
|
4569
|
+
return _context.abrupt("return", {
|
|
4570
|
+
totalStakedLiquidity: stakedLiquidityAmount,
|
|
4571
|
+
APYs: APYs
|
|
4572
|
+
});
|
|
4573
|
+
case 13:
|
|
4690
4574
|
case "end":
|
|
4691
4575
|
return _context.stop();
|
|
4692
4576
|
}
|
|
4693
4577
|
}, _callee, this);
|
|
4694
4578
|
}));
|
|
4695
|
-
function
|
|
4696
|
-
return
|
|
4579
|
+
function getPLYWNEARPoolDetails() {
|
|
4580
|
+
return _getPLYWNEARPoolDetails.apply(this, arguments);
|
|
4697
4581
|
}
|
|
4698
|
-
return
|
|
4582
|
+
return getPLYWNEARPoolDetails;
|
|
4699
4583
|
}()
|
|
4700
4584
|
/**
|
|
4701
|
-
* Get
|
|
4585
|
+
* Get amount of staked LP tokens
|
|
4702
4586
|
*/
|
|
4703
4587
|
;
|
|
4704
|
-
_proto.
|
|
4588
|
+
_proto.stakeBalanceOf =
|
|
4705
4589
|
/*#__PURE__*/
|
|
4706
4590
|
function () {
|
|
4707
|
-
var
|
|
4708
|
-
var
|
|
4591
|
+
var _stakeBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(user) {
|
|
4592
|
+
var userInfo;
|
|
4709
4593
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4710
4594
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4711
4595
|
case 0:
|
|
4712
4596
|
_context2.next = 2;
|
|
4713
|
-
return this.env.
|
|
4597
|
+
return this.env.auriFairLaunch.getUserInfo(PLYWNEAR_POOL_ID, user);
|
|
4714
4598
|
case 2:
|
|
4715
|
-
|
|
4716
|
-
return _context2.abrupt("return",
|
|
4599
|
+
userInfo = _context2.sent;
|
|
4600
|
+
return _context2.abrupt("return", new TokenAmount(PLYWNEARToken, userInfo.amount.toString()));
|
|
4717
4601
|
case 4:
|
|
4718
4602
|
case "end":
|
|
4719
4603
|
return _context2.stop();
|
|
4720
4604
|
}
|
|
4721
4605
|
}, _callee2, this);
|
|
4722
4606
|
}));
|
|
4723
|
-
function
|
|
4724
|
-
return
|
|
4607
|
+
function stakeBalanceOf(_x) {
|
|
4608
|
+
return _stakeBalanceOf.apply(this, arguments);
|
|
4725
4609
|
}
|
|
4726
|
-
return
|
|
4610
|
+
return stakeBalanceOf;
|
|
4727
4611
|
}()
|
|
4728
4612
|
/**
|
|
4729
|
-
* Get
|
|
4613
|
+
* Get amount of LP token in user wallet
|
|
4730
4614
|
*/
|
|
4731
4615
|
;
|
|
4732
|
-
_proto.
|
|
4616
|
+
_proto.LpBalanceOf =
|
|
4733
4617
|
/*#__PURE__*/
|
|
4734
4618
|
function () {
|
|
4735
|
-
var
|
|
4736
|
-
var
|
|
4619
|
+
var _LpBalanceOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(user) {
|
|
4620
|
+
var lpContract, balance;
|
|
4737
4621
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4738
4622
|
while (1) switch (_context3.prev = _context3.next) {
|
|
4739
4623
|
case 0:
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4624
|
+
lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$5.abi, this._networkConnection.provider);
|
|
4625
|
+
_context3.next = 3;
|
|
4626
|
+
return lpContract.balanceOf(user);
|
|
4627
|
+
case 3:
|
|
4628
|
+
balance = _context3.sent;
|
|
4629
|
+
return _context3.abrupt("return", new TokenAmount(PLYWNEARToken, balance.toString()));
|
|
4630
|
+
case 5:
|
|
4743
4631
|
case "end":
|
|
4744
4632
|
return _context3.stop();
|
|
4745
4633
|
}
|
|
4746
4634
|
}, _callee3, this);
|
|
4747
4635
|
}));
|
|
4748
|
-
function
|
|
4749
|
-
return
|
|
4636
|
+
function LpBalanceOf(_x2) {
|
|
4637
|
+
return _LpBalanceOf.apply(this, arguments);
|
|
4750
4638
|
}
|
|
4751
|
-
return
|
|
4752
|
-
}()
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
;
|
|
4757
|
-
_proto.getReferralsList =
|
|
4758
|
-
/*#__PURE__*/
|
|
4759
|
-
function () {
|
|
4760
|
-
var _getReferralsList = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(userAddr) {
|
|
4761
|
-
var result, blocks, blocksTimestamp, items;
|
|
4639
|
+
return LpBalanceOf;
|
|
4640
|
+
}();
|
|
4641
|
+
_proto.unclaimedRewardsOf = /*#__PURE__*/function () {
|
|
4642
|
+
var _unclaimedRewardsOf = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(user) {
|
|
4643
|
+
var userInfo, rewards;
|
|
4762
4644
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4763
4645
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4764
4646
|
case 0:
|
|
4765
4647
|
_context4.next = 2;
|
|
4766
|
-
return
|
|
4767
|
-
|
|
4648
|
+
return this.env.auriFairLaunch.callStatic.updateAndGetUserInfo(PLYWNEAR_POOL_ID, user, {
|
|
4649
|
+
from: user
|
|
4768
4650
|
});
|
|
4769
4651
|
case 2:
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
case 6:
|
|
4777
|
-
blocksTimestamp = _context4.sent;
|
|
4778
|
-
items = result.items.map(function (item, i) {
|
|
4779
|
-
return {
|
|
4780
|
-
user: item.user,
|
|
4781
|
-
timestamp: blocksTimestamp[i]
|
|
4782
|
-
};
|
|
4783
|
-
});
|
|
4784
|
-
return _context4.abrupt("return", items);
|
|
4785
|
-
case 9:
|
|
4652
|
+
userInfo = _context4.sent;
|
|
4653
|
+
rewards = userInfo.unclaimedRewards;
|
|
4654
|
+
return _context4.abrupt("return", rewards.map(function (reward, i) {
|
|
4655
|
+
return TokenAmount.fromAddressAndAmount(PLYWNEAR_REWARD_TOKENS[i], reward.toString());
|
|
4656
|
+
}));
|
|
4657
|
+
case 5:
|
|
4786
4658
|
case "end":
|
|
4787
4659
|
return _context4.stop();
|
|
4788
4660
|
}
|
|
4789
4661
|
}, _callee4, this);
|
|
4790
4662
|
}));
|
|
4791
|
-
function
|
|
4792
|
-
return
|
|
4663
|
+
function unclaimedRewardsOf(_x3) {
|
|
4664
|
+
return _unclaimedRewardsOf.apply(this, arguments);
|
|
4793
4665
|
}
|
|
4794
|
-
return
|
|
4795
|
-
}()
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
;
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4666
|
+
return unclaimedRewardsOf;
|
|
4667
|
+
}();
|
|
4668
|
+
return StakingRead;
|
|
4669
|
+
}(BlockchainEntityRead);
|
|
4670
|
+
var StakingReadWrite = /*#__PURE__*/function (_StakingRead) {
|
|
4671
|
+
_inheritsLoose(StakingReadWrite, _StakingRead);
|
|
4672
|
+
function StakingReadWrite() {
|
|
4673
|
+
return _StakingRead.apply(this, arguments) || this;
|
|
4674
|
+
}
|
|
4675
|
+
var _proto2 = StakingReadWrite.prototype;
|
|
4676
|
+
_proto2.stake = /*#__PURE__*/function () {
|
|
4677
|
+
var _stake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(amount) {
|
|
4805
4678
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
4806
4679
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4807
4680
|
case 0:
|
|
4808
|
-
_context5.
|
|
4809
|
-
|
|
4810
|
-
address: userAddr
|
|
4811
|
-
});
|
|
4812
|
-
case 2:
|
|
4813
|
-
result = _context5.sent;
|
|
4814
|
-
items = result.items.map(function (item, i) {
|
|
4815
|
-
var _item$transactionHash;
|
|
4816
|
-
return {
|
|
4817
|
-
campaign: item.campaign,
|
|
4818
|
-
userAddr: userAddr,
|
|
4819
|
-
isReferrer: item.campaign.includes('referrer'),
|
|
4820
|
-
rewardTokenAmount: TokenAmount.fromAddressAndAmount(item.token, item.amount),
|
|
4821
|
-
startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
|
|
4822
|
-
endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
|
|
4823
|
-
transactionHash: (_item$transactionHash = item.transactionHash) != null ? _item$transactionHash : null,
|
|
4824
|
-
refereeAddress: null
|
|
4825
|
-
};
|
|
4826
|
-
});
|
|
4827
|
-
return _context5.abrupt("return", items);
|
|
4828
|
-
case 5:
|
|
4681
|
+
return _context5.abrupt("return", this.env.auriFairLaunch.connect(this._networkConnection.signer).deposit(PLYWNEAR_POOL_ID, amount.rawAmount()));
|
|
4682
|
+
case 1:
|
|
4829
4683
|
case "end":
|
|
4830
4684
|
return _context5.stop();
|
|
4831
4685
|
}
|
|
4832
|
-
}, _callee5);
|
|
4686
|
+
}, _callee5, this);
|
|
4833
4687
|
}));
|
|
4834
|
-
function
|
|
4835
|
-
return
|
|
4688
|
+
function stake(_x4) {
|
|
4689
|
+
return _stake.apply(this, arguments);
|
|
4836
4690
|
}
|
|
4837
|
-
return
|
|
4838
|
-
}()
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
;
|
|
4843
|
-
_proto.leaderboard =
|
|
4844
|
-
/*#__PURE__*/
|
|
4845
|
-
function () {
|
|
4846
|
-
var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(campaign) {
|
|
4847
|
-
var result, items;
|
|
4691
|
+
return stake;
|
|
4692
|
+
}();
|
|
4693
|
+
_proto2.unstake = /*#__PURE__*/function () {
|
|
4694
|
+
var _unstake = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(amount) {
|
|
4695
|
+
var msgSender, amountInput, stakedAmount, unstakeAmount;
|
|
4848
4696
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
4849
4697
|
while (1) switch (_context6.prev = _context6.next) {
|
|
4850
4698
|
case 0:
|
|
4851
4699
|
_context6.next = 2;
|
|
4852
|
-
return
|
|
4853
|
-
campaign: campaign
|
|
4854
|
-
});
|
|
4700
|
+
return this._networkConnection.signer.getAddress();
|
|
4855
4701
|
case 2:
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
});
|
|
4869
|
-
items.sort(function (a, b) {
|
|
4870
|
-
return b.rewardTokenAmount.compare(a.rewardTokenAmount);
|
|
4871
|
-
});
|
|
4872
|
-
return _context6.abrupt("return", items);
|
|
4873
|
-
case 6:
|
|
4702
|
+
msgSender = _context6.sent;
|
|
4703
|
+
amountInput = BigNumber$1.from(amount.rawAmount());
|
|
4704
|
+
_context6.t0 = BigNumber$1;
|
|
4705
|
+
_context6.next = 7;
|
|
4706
|
+
return this.stakeBalanceOf(msgSender);
|
|
4707
|
+
case 7:
|
|
4708
|
+
_context6.t1 = _context6.sent.rawAmount();
|
|
4709
|
+
stakedAmount = _context6.t0.from.call(_context6.t0, _context6.t1);
|
|
4710
|
+
// unstakeAmount = min(amountInput, stakedAmount - 1)
|
|
4711
|
+
unstakeAmount = amountInput.lt(stakedAmount) ? amountInput : stakedAmount.sub(1);
|
|
4712
|
+
return _context6.abrupt("return", this.env.auriFairLaunch.connect(this._networkConnection.signer).withdraw(PLYWNEAR_POOL_ID, unstakeAmount));
|
|
4713
|
+
case 11:
|
|
4874
4714
|
case "end":
|
|
4875
4715
|
return _context6.stop();
|
|
4876
4716
|
}
|
|
4877
|
-
}, _callee6);
|
|
4717
|
+
}, _callee6, this);
|
|
4878
4718
|
}));
|
|
4879
|
-
function
|
|
4880
|
-
return
|
|
4719
|
+
function unstake(_x5) {
|
|
4720
|
+
return _unstake.apply(this, arguments);
|
|
4881
4721
|
}
|
|
4882
|
-
return
|
|
4883
|
-
}()
|
|
4722
|
+
return unstake;
|
|
4723
|
+
}();
|
|
4724
|
+
return StakingReadWrite;
|
|
4725
|
+
}(StakingRead);
|
|
4726
|
+
var Staking = /*#__PURE__*/function (_BlockchainEntity) {
|
|
4727
|
+
_inheritsLoose(Staking, _BlockchainEntity);
|
|
4728
|
+
function Staking() {
|
|
4729
|
+
return _BlockchainEntity.call(this) || this;
|
|
4730
|
+
}
|
|
4731
|
+
var _proto3 = Staking.prototype;
|
|
4732
|
+
_proto3.read = function read(networkConnection) {
|
|
4733
|
+
return new StakingRead(networkConnection);
|
|
4734
|
+
};
|
|
4735
|
+
_proto3.readWrite = function readWrite(networkConnection) {
|
|
4736
|
+
return new StakingReadWrite(networkConnection);
|
|
4737
|
+
};
|
|
4738
|
+
return Staking;
|
|
4739
|
+
}(BlockchainEntity);
|
|
4740
|
+
|
|
4741
|
+
var ComptrollerRewardType;
|
|
4742
|
+
(function (ComptrollerRewardType) {
|
|
4743
|
+
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
4744
|
+
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
4745
|
+
})(ComptrollerRewardType || (ComptrollerRewardType = {}));
|
|
4746
|
+
var MarketAction;
|
|
4747
|
+
(function (MarketAction) {
|
|
4748
|
+
MarketAction[MarketAction["Deposit"] = 0] = "Deposit";
|
|
4749
|
+
MarketAction[MarketAction["Borrow"] = 1] = "Borrow";
|
|
4750
|
+
MarketAction[MarketAction["Withdraw"] = 2] = "Withdraw";
|
|
4751
|
+
MarketAction[MarketAction["Repay"] = 3] = "Repay";
|
|
4752
|
+
MarketAction[MarketAction["EnableCollateral"] = 4] = "EnableCollateral";
|
|
4753
|
+
MarketAction[MarketAction["DisableCollateral"] = 5] = "DisableCollateral";
|
|
4754
|
+
})(MarketAction || (MarketAction = {}));
|
|
4755
|
+
|
|
4756
|
+
var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
4757
|
+
_inheritsLoose(MulticallRead, _BlockchainEntityRead);
|
|
4758
|
+
function MulticallRead(networkConnection) {
|
|
4759
|
+
var _this;
|
|
4760
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
4761
|
+
_this.multicall = new Contract(networkAddresses.misc.MULTICALL, abis$a.abi, networkConnection.provider);
|
|
4762
|
+
return _this;
|
|
4763
|
+
}
|
|
4884
4764
|
/**
|
|
4885
|
-
*
|
|
4765
|
+
* Run multiple calls via multicall contract
|
|
4886
4766
|
*/
|
|
4887
|
-
;
|
|
4888
|
-
_proto.
|
|
4767
|
+
var _proto = MulticallRead.prototype;
|
|
4768
|
+
_proto.aggregate =
|
|
4889
4769
|
/*#__PURE__*/
|
|
4890
4770
|
function () {
|
|
4891
|
-
var
|
|
4892
|
-
var
|
|
4893
|
-
return _regeneratorRuntime().wrap(function
|
|
4894
|
-
while (1) switch (
|
|
4771
|
+
var _aggregate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(calls) {
|
|
4772
|
+
var txns, i, _call$contract$popula, call, txn, response, decodedReturn, _i;
|
|
4773
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4774
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4895
4775
|
case 0:
|
|
4896
|
-
|
|
4897
|
-
|
|
4776
|
+
txns = []; // prepare transactions
|
|
4777
|
+
i = 0;
|
|
4898
4778
|
case 2:
|
|
4899
|
-
|
|
4900
|
-
|
|
4779
|
+
if (!(i < calls.length)) {
|
|
4780
|
+
_context.next = 11;
|
|
4781
|
+
break;
|
|
4782
|
+
}
|
|
4783
|
+
call = calls[i];
|
|
4784
|
+
_context.next = 6;
|
|
4785
|
+
return (_call$contract$popula = call.contract.populateTransaction)[call.method].apply(_call$contract$popula, call.args);
|
|
4786
|
+
case 6:
|
|
4787
|
+
txn = _context.sent;
|
|
4788
|
+
txns.push({
|
|
4789
|
+
target: txn.to,
|
|
4790
|
+
callData: txn.data
|
|
4791
|
+
});
|
|
4792
|
+
case 8:
|
|
4793
|
+
i++;
|
|
4794
|
+
_context.next = 2;
|
|
4795
|
+
break;
|
|
4796
|
+
case 11:
|
|
4797
|
+
_context.next = 13;
|
|
4798
|
+
return this.multicall.callStatic.aggregate(txns);
|
|
4799
|
+
case 13:
|
|
4800
|
+
response = _context.sent;
|
|
4801
|
+
// parse results
|
|
4802
|
+
decodedReturn = [];
|
|
4803
|
+
for (_i = 0; _i < calls.length; _i++) {
|
|
4804
|
+
decodedReturn.push(ethers.utils.defaultAbiCoder.decode(calls[_i].returnTypes, response.returnData[_i]));
|
|
4805
|
+
}
|
|
4806
|
+
return _context.abrupt("return", decodedReturn);
|
|
4807
|
+
case 17:
|
|
4808
|
+
case "end":
|
|
4809
|
+
return _context.stop();
|
|
4810
|
+
}
|
|
4811
|
+
}, _callee, this);
|
|
4812
|
+
}));
|
|
4813
|
+
function aggregate(_x) {
|
|
4814
|
+
return _aggregate.apply(this, arguments);
|
|
4815
|
+
}
|
|
4816
|
+
return aggregate;
|
|
4817
|
+
}();
|
|
4818
|
+
return MulticallRead;
|
|
4819
|
+
}(BlockchainEntityRead);
|
|
4820
|
+
|
|
4821
|
+
var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
4822
|
+
_inheritsLoose(MiscRead, _BlockchainEntityRead);
|
|
4823
|
+
function MiscRead(networkConnection) {
|
|
4824
|
+
var _this;
|
|
4825
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
4826
|
+
_this.stakingRead = new StakingRead(networkConnection);
|
|
4827
|
+
_this.env = new AuriEnv(networkConnection);
|
|
4828
|
+
return _this;
|
|
4829
|
+
}
|
|
4830
|
+
var _proto = MiscRead.prototype;
|
|
4831
|
+
_proto.getUserDetails = /*#__PURE__*/function () {
|
|
4832
|
+
var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(userAddress) {
|
|
4833
|
+
var marketCount, userMarketDetails, assetsIn, totalBorrowLimit, _iterator, _step, _auToken, userMarketDetail, _moneyMarket, _yield$Promise$all, depositBalance, borrowBalance, collateralRatio, underlyingPrice, depositValues, _loop, i, accountLiquidity, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
|
|
4834
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
4835
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4836
|
+
case 0:
|
|
4837
|
+
marketCount = networkAddresses.auTokens.length;
|
|
4838
|
+
userMarketDetails = [];
|
|
4839
|
+
totalBorrowLimit = new BigNumber(0);
|
|
4840
|
+
_iterator = _createForOfIteratorHelperLoose(networkAddresses.auTokens);
|
|
4901
4841
|
case 4:
|
|
4842
|
+
if ((_step = _iterator()).done) {
|
|
4843
|
+
_context2.next = 23;
|
|
4844
|
+
break;
|
|
4845
|
+
}
|
|
4846
|
+
_auToken = _step.value;
|
|
4847
|
+
userMarketDetail = {};
|
|
4848
|
+
userMarketDetails.push(userMarketDetail);
|
|
4849
|
+
userMarketDetail.market = _auToken.underlying;
|
|
4850
|
+
_moneyMarket = new MoneyMarketRead(this._networkConnection, _auToken.address, _auToken.underlying);
|
|
4851
|
+
_context2.next = 12;
|
|
4852
|
+
return Promise.all([_moneyMarket.getUserDepositBalance(userAddress), _moneyMarket.getUserBorrowBalance(userAddress), _moneyMarket.getCollateralRatio(), fetchPrice(_moneyMarket.underlying.address, this._networkConnection.provider)]);
|
|
4853
|
+
case 12:
|
|
4854
|
+
_yield$Promise$all = _context2.sent;
|
|
4855
|
+
depositBalance = _yield$Promise$all[0];
|
|
4856
|
+
borrowBalance = _yield$Promise$all[1];
|
|
4857
|
+
collateralRatio = _yield$Promise$all[2];
|
|
4858
|
+
underlyingPrice = _yield$Promise$all[3];
|
|
4859
|
+
userMarketDetail.depositBalance = depositBalance;
|
|
4860
|
+
userMarketDetail.borrowBalance = borrowBalance;
|
|
4861
|
+
userMarketDetail.collateralRatio = collateralRatio.toNumber();
|
|
4862
|
+
userMarketDetail.underlyingPrice = underlyingPrice.toString();
|
|
4863
|
+
case 21:
|
|
4864
|
+
_context2.next = 4;
|
|
4865
|
+
break;
|
|
4866
|
+
case 23:
|
|
4867
|
+
_context2.next = 25;
|
|
4868
|
+
return this.env.comptroller.getAssetsIn(userAddress);
|
|
4869
|
+
case 25:
|
|
4870
|
+
assetsIn = _context2.sent;
|
|
4871
|
+
depositValues = [];
|
|
4872
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
4873
|
+
var auToken;
|
|
4874
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
4875
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4876
|
+
case 0:
|
|
4877
|
+
auToken = networkAddresses.auTokens[i];
|
|
4878
|
+
if (assetsIn.find(function (auAddress) {
|
|
4879
|
+
return isSameAddress(auToken.address, auAddress);
|
|
4880
|
+
}) !== undefined) {
|
|
4881
|
+
userMarketDetails[i].isCollateral = true;
|
|
4882
|
+
} else {
|
|
4883
|
+
userMarketDetails[i].isCollateral = false;
|
|
4884
|
+
}
|
|
4885
|
+
depositValues.push(calcValuation(userMarketDetails[i].depositBalance, new BigNumber(userMarketDetails[i].underlyingPrice)));
|
|
4886
|
+
case 3:
|
|
4887
|
+
case "end":
|
|
4888
|
+
return _context.stop();
|
|
4889
|
+
}
|
|
4890
|
+
}, _loop);
|
|
4891
|
+
});
|
|
4892
|
+
i = 0;
|
|
4893
|
+
case 29:
|
|
4894
|
+
if (!(i < marketCount)) {
|
|
4895
|
+
_context2.next = 34;
|
|
4896
|
+
break;
|
|
4897
|
+
}
|
|
4898
|
+
return _context2.delegateYield(_loop(), "t0", 31);
|
|
4899
|
+
case 31:
|
|
4900
|
+
i++;
|
|
4901
|
+
_context2.next = 29;
|
|
4902
|
+
break;
|
|
4903
|
+
case 34:
|
|
4904
|
+
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
4905
|
+
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
4906
|
+
return p;
|
|
4907
|
+
}, new BigNumber(0));
|
|
4908
|
+
_context2.next = 37;
|
|
4909
|
+
return this.env.comptroller.getAccountLiquidity(userAddress);
|
|
4910
|
+
case 37:
|
|
4911
|
+
accountLiquidity = _context2.sent;
|
|
4912
|
+
borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
|
|
4913
|
+
if (borrowedvaluation.lt('0.00001')) {
|
|
4914
|
+
// Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
|
|
4915
|
+
borrowedvaluation = new BigNumber(0);
|
|
4916
|
+
}
|
|
4917
|
+
bufferedBorrowLimit = totalBorrowLimit.multipliedBy(BORROW_LIMIT_BUFFER);
|
|
4918
|
+
minimumBorrowLimitAllowed = borrowedvaluation.div(BORROW_LIMIT_BUFFER);
|
|
4919
|
+
if (bufferedBorrowLimit.lte(borrowedvaluation)) {
|
|
4920
|
+
borrowableAmount = new BigNumber(0);
|
|
4921
|
+
} else {
|
|
4922
|
+
borrowableAmount = bufferedBorrowLimit.minus(borrowedvaluation);
|
|
4923
|
+
}
|
|
4924
|
+
for (i = 0; i < marketCount; i++) {
|
|
4925
|
+
auToken = networkAddresses.auTokens[i];
|
|
4926
|
+
moneyMarket = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
|
|
4927
|
+
borrowLimitMargin = totalBorrowLimit.minus(minimumBorrowLimitAllowed).gt(0) ? totalBorrowLimit.minus(minimumBorrowLimitAllowed) : new BigNumber(0);
|
|
4928
|
+
maxWithdrawCap = borrowLimitMargin.div(userMarketDetails[i].collateralRatio).div(userMarketDetails[i].underlyingPrice);
|
|
4929
|
+
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());
|
|
4930
|
+
}
|
|
4931
|
+
_context2.t1 = userMarketDetails;
|
|
4932
|
+
_context2.t2 = {
|
|
4933
|
+
currency: 'USD',
|
|
4934
|
+
amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
|
|
4935
|
+
};
|
|
4936
|
+
_context2.next = 48;
|
|
4937
|
+
return new PapermillRead(this._networkConnection).getLockingDetails(userAddress);
|
|
4938
|
+
case 48:
|
|
4939
|
+
_context2.t3 = _context2.sent;
|
|
4940
|
+
_context2.t4 = {
|
|
4941
|
+
currency: 'USD',
|
|
4942
|
+
amount: borrowableAmount.toFixed(DECIMAL_PRECISION)
|
|
4943
|
+
};
|
|
4944
|
+
return _context2.abrupt("return", {
|
|
4945
|
+
markets: _context2.t1,
|
|
4946
|
+
borrowLimit: _context2.t2,
|
|
4947
|
+
userLockingDetails: _context2.t3,
|
|
4948
|
+
borrowableAmount: _context2.t4
|
|
4949
|
+
});
|
|
4950
|
+
case 51:
|
|
4902
4951
|
case "end":
|
|
4903
|
-
return
|
|
4952
|
+
return _context2.stop();
|
|
4904
4953
|
}
|
|
4905
|
-
},
|
|
4954
|
+
}, _callee, this);
|
|
4906
4955
|
}));
|
|
4907
|
-
function
|
|
4908
|
-
return
|
|
4956
|
+
function getUserDetails(_x) {
|
|
4957
|
+
return _getUserDetails.apply(this, arguments);
|
|
4909
4958
|
}
|
|
4910
|
-
return
|
|
4959
|
+
return getUserDetails;
|
|
4911
4960
|
}();
|
|
4912
|
-
_proto.
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
var result;
|
|
4918
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
4919
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
4961
|
+
_proto.getTokenPrice = /*#__PURE__*/function () {
|
|
4962
|
+
var _getTokenPrice = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(token) {
|
|
4963
|
+
var price;
|
|
4964
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
4965
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4920
4966
|
case 0:
|
|
4921
|
-
|
|
4922
|
-
return
|
|
4923
|
-
address: address
|
|
4924
|
-
});
|
|
4967
|
+
_context3.next = 2;
|
|
4968
|
+
return fetchPrice(token.address, this._networkConnection.provider);
|
|
4925
4969
|
case 2:
|
|
4926
|
-
|
|
4927
|
-
return
|
|
4970
|
+
price = _context3.sent;
|
|
4971
|
+
return _context3.abrupt("return", {
|
|
4972
|
+
currency: 'USD',
|
|
4973
|
+
amount: price.toFixed(DECIMAL_PRECISION)
|
|
4974
|
+
});
|
|
4928
4975
|
case 4:
|
|
4929
4976
|
case "end":
|
|
4930
|
-
return
|
|
4977
|
+
return _context3.stop();
|
|
4931
4978
|
}
|
|
4932
|
-
},
|
|
4979
|
+
}, _callee2, this);
|
|
4933
4980
|
}));
|
|
4934
|
-
function
|
|
4935
|
-
return
|
|
4981
|
+
function getTokenPrice(_x2) {
|
|
4982
|
+
return _getTokenPrice.apply(this, arguments);
|
|
4936
4983
|
}
|
|
4937
|
-
return
|
|
4938
|
-
}()
|
|
4984
|
+
return getTokenPrice;
|
|
4985
|
+
}();
|
|
4986
|
+
_proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
|
|
4987
|
+
var userMarketDetail = _ref.userMarketDetail,
|
|
4988
|
+
currentBorrowLimit = _ref.currentBorrowLimit,
|
|
4989
|
+
currentBorrowValuation = _ref.currentBorrowValuation,
|
|
4990
|
+
action = _ref.action,
|
|
4991
|
+
tokenAmount = _ref.tokenAmount;
|
|
4992
|
+
var newBorrowLimit = new BigNumber(currentBorrowLimit.amount),
|
|
4993
|
+
newBorrowValuation = new BigNumber(currentBorrowValuation.amount);
|
|
4994
|
+
switch (action) {
|
|
4995
|
+
case MarketAction.EnableCollateral:
|
|
4996
|
+
case MarketAction.DisableCollateral:
|
|
4997
|
+
var deltaBorrowLimit = calcValuation(userMarketDetail.depositBalance, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
4998
|
+
newBorrowLimit = action == MarketAction.EnableCollateral ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
4999
|
+
break;
|
|
5000
|
+
case MarketAction.Deposit:
|
|
5001
|
+
case MarketAction.Withdraw:
|
|
5002
|
+
deltaBorrowLimit = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
5003
|
+
newBorrowLimit = action == MarketAction.Deposit ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
5004
|
+
break;
|
|
5005
|
+
case MarketAction.Borrow:
|
|
5006
|
+
case MarketAction.Repay:
|
|
5007
|
+
var deltaBorrowValuation = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice));
|
|
5008
|
+
newBorrowValuation = action == MarketAction.Borrow ? newBorrowValuation.plus(deltaBorrowValuation) : newBorrowValuation.minus(deltaBorrowValuation);
|
|
5009
|
+
break;
|
|
5010
|
+
}
|
|
5011
|
+
return {
|
|
5012
|
+
newBorrowLimit: {
|
|
5013
|
+
amount: newBorrowLimit.toFixed(DECIMAL_PRECISION),
|
|
5014
|
+
currency: 'USD'
|
|
5015
|
+
},
|
|
5016
|
+
newBorrowUtilization: newBorrowLimit.eq(0) ? newBorrowValuation.eq(0) ? 0 : 9999.99 : newBorrowValuation.div(newBorrowLimit).toNumber()
|
|
5017
|
+
};
|
|
5018
|
+
}
|
|
4939
5019
|
/**
|
|
4940
|
-
*
|
|
4941
|
-
*
|
|
4942
|
-
*
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
5020
|
+
* Get ply circulating supply.
|
|
5021
|
+
* It is calculated by the total supply, minus:
|
|
5022
|
+
* - Ply in team multisig contract
|
|
5023
|
+
* - Ply in comptroller contract
|
|
5024
|
+
* - Ply in fairlaunch contract
|
|
5025
|
+
* - Ply in vesting contract
|
|
5026
|
+
*/;
|
|
5027
|
+
_proto.getPlyCirculatingSupply =
|
|
4946
5028
|
/*#__PURE__*/
|
|
4947
5029
|
function () {
|
|
4948
|
-
var
|
|
4949
|
-
var
|
|
4950
|
-
return _regeneratorRuntime().wrap(function
|
|
4951
|
-
while (1) switch (
|
|
5030
|
+
var _getPlyCirculatingSupply = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
5031
|
+
var multicallRead, baseBalanceOfCall, listAddrs, calls, callResults, circulatingSupply;
|
|
5032
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
5033
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4952
5034
|
case 0:
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
5035
|
+
multicallRead = new MulticallRead(this._networkConnection);
|
|
5036
|
+
baseBalanceOfCall = {
|
|
5037
|
+
contract: this.env.ply,
|
|
5038
|
+
method: 'balanceOf',
|
|
5039
|
+
returnTypes: ['uint256']
|
|
5040
|
+
};
|
|
5041
|
+
listAddrs = [networkAddresses.misc.TEAM_MULTISIG, networkAddresses.misc.COMPTROLLER, networkAddresses.misc.AURIFAIRLAUNCH, networkAddresses.misc.PLY_TOKEN_LOCK, networkAddresses.misc.TEAM_MULTISIG_AURORA_PLUS, networkAddresses.misc.AURORA_PLUS, networkAddresses.misc.PULP_CONTRACT];
|
|
5042
|
+
calls = listAddrs.map(function (addr) {
|
|
5043
|
+
return _extends({}, baseBalanceOfCall, {
|
|
5044
|
+
args: [addr]
|
|
5045
|
+
});
|
|
4956
5046
|
});
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
_context9.t0 = result;
|
|
4960
|
-
_context9.next = _context9.t0 === -1 ? 6 : _context9.t0 === 0 ? 7 : _context9.t0 === 1 ? 8 : 9;
|
|
4961
|
-
break;
|
|
5047
|
+
_context4.next = 6;
|
|
5048
|
+
return multicallRead.aggregate(calls);
|
|
4962
5049
|
case 6:
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
return _context9.abrupt("return", 'Qualified');
|
|
4968
|
-
case 9:
|
|
4969
|
-
return _context9.abrupt("return", 'Withdrawn');
|
|
4970
|
-
case 10:
|
|
4971
|
-
case "end":
|
|
4972
|
-
return _context9.stop();
|
|
4973
|
-
}
|
|
4974
|
-
}, _callee9);
|
|
4975
|
-
}));
|
|
4976
|
-
function userReferralStatus(_x8) {
|
|
4977
|
-
return _userReferralStatus.apply(this, arguments);
|
|
4978
|
-
}
|
|
4979
|
-
return userReferralStatus;
|
|
4980
|
-
}();
|
|
4981
|
-
_proto.isWhitelistedAddress = /*#__PURE__*/function () {
|
|
4982
|
-
var _isWhitelistedAddress = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address) {
|
|
4983
|
-
var result;
|
|
4984
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
4985
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
4986
|
-
case 0:
|
|
4987
|
-
_context10.next = 2;
|
|
4988
|
-
return this.env.referralDirectoryV2.isUserWhitelisted(address);
|
|
4989
|
-
case 2:
|
|
4990
|
-
result = _context10.sent;
|
|
4991
|
-
return _context10.abrupt("return", result.eq(1));
|
|
4992
|
-
case 4:
|
|
4993
|
-
case "end":
|
|
4994
|
-
return _context10.stop();
|
|
4995
|
-
}
|
|
4996
|
-
}, _callee10, this);
|
|
4997
|
-
}));
|
|
4998
|
-
function isWhitelistedAddress(_x9) {
|
|
4999
|
-
return _isWhitelistedAddress.apply(this, arguments);
|
|
5000
|
-
}
|
|
5001
|
-
return isWhitelistedAddress;
|
|
5002
|
-
}();
|
|
5003
|
-
_proto.isOnAuroraPlus = /*#__PURE__*/function () {
|
|
5004
|
-
var _isOnAuroraPlus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(address) {
|
|
5005
|
-
var resp;
|
|
5006
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
5007
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
5008
|
-
case 0:
|
|
5009
|
-
_context11.next = 2;
|
|
5010
|
-
return axios.get(AURORA_PLUS_API_PREFIX + address);
|
|
5011
|
-
case 2:
|
|
5012
|
-
resp = _context11.sent;
|
|
5013
|
-
return _context11.abrupt("return", resp.data.status == 'active');
|
|
5014
|
-
case 4:
|
|
5015
|
-
case "end":
|
|
5016
|
-
return _context11.stop();
|
|
5017
|
-
}
|
|
5018
|
-
}, _callee11);
|
|
5019
|
-
}));
|
|
5020
|
-
function isOnAuroraPlus(_x10) {
|
|
5021
|
-
return _isOnAuroraPlus.apply(this, arguments);
|
|
5022
|
-
}
|
|
5023
|
-
return isOnAuroraPlus;
|
|
5024
|
-
}();
|
|
5025
|
-
_proto.isNewUserAtReferralTime = /*#__PURE__*/function () {
|
|
5026
|
-
var _isNewUserAtReferralTime = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address) {
|
|
5027
|
-
var result;
|
|
5028
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
5029
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
5030
|
-
case 0:
|
|
5031
|
-
_context12.next = 2;
|
|
5032
|
-
return getApi('/referral/isNewUser', {
|
|
5033
|
-
address: address
|
|
5050
|
+
callResults = _context4.sent;
|
|
5051
|
+
circulatingSupply = BigNumber$1.from('1' + '0'.repeat(10) + '0'.repeat(getDecimal(this.env.ply.address)));
|
|
5052
|
+
callResults.forEach(function (result, i) {
|
|
5053
|
+
circulatingSupply = circulatingSupply.sub(result[0]);
|
|
5034
5054
|
});
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
return _context12.abrupt("return", result);
|
|
5038
|
-
case 4:
|
|
5055
|
+
return _context4.abrupt("return", new TokenAmount(PLYToken, circulatingSupply.toString()));
|
|
5056
|
+
case 10:
|
|
5039
5057
|
case "end":
|
|
5040
|
-
return
|
|
5058
|
+
return _context4.stop();
|
|
5041
5059
|
}
|
|
5042
|
-
},
|
|
5060
|
+
}, _callee3, this);
|
|
5043
5061
|
}));
|
|
5044
|
-
function
|
|
5045
|
-
return
|
|
5062
|
+
function getPlyCirculatingSupply() {
|
|
5063
|
+
return _getPlyCirculatingSupply.apply(this, arguments);
|
|
5046
5064
|
}
|
|
5047
|
-
return
|
|
5065
|
+
return getPlyCirculatingSupply;
|
|
5048
5066
|
}();
|
|
5049
|
-
_proto.
|
|
5050
|
-
var
|
|
5051
|
-
var
|
|
5052
|
-
return _regeneratorRuntime().wrap(function
|
|
5053
|
-
while (1) switch (
|
|
5067
|
+
_proto.getUtilisation = /*#__PURE__*/function () {
|
|
5068
|
+
var _getUtilisation = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(userAddr) {
|
|
5069
|
+
var accountDetail, sumBorrow, sumCol;
|
|
5070
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
5071
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
5054
5072
|
case 0:
|
|
5055
|
-
|
|
5056
|
-
return
|
|
5057
|
-
address: address
|
|
5058
|
-
});
|
|
5073
|
+
_context5.next = 2;
|
|
5074
|
+
return this.env.auriInternalLens.callStatic.getAccountLiquidityAccrueInterest(userAddr);
|
|
5059
5075
|
case 2:
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5076
|
+
accountDetail = _context5.sent;
|
|
5077
|
+
sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
|
|
5078
|
+
sumCol = new BigNumber(accountDetail.sumCollateral.toString());
|
|
5079
|
+
return _context5.abrupt("return", sumBorrow.dividedBy(sumCol));
|
|
5080
|
+
case 6:
|
|
5063
5081
|
case "end":
|
|
5064
|
-
return
|
|
5082
|
+
return _context5.stop();
|
|
5065
5083
|
}
|
|
5066
|
-
},
|
|
5084
|
+
}, _callee4, this);
|
|
5067
5085
|
}));
|
|
5068
|
-
function
|
|
5069
|
-
return
|
|
5086
|
+
function getUtilisation(_x3) {
|
|
5087
|
+
return _getUtilisation.apply(this, arguments);
|
|
5070
5088
|
}
|
|
5071
|
-
return
|
|
5089
|
+
return getUtilisation;
|
|
5072
5090
|
}();
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
var
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
}
|
|
5080
|
-
var _proto2 = ReferralReadWrite.prototype;
|
|
5081
|
-
/**
|
|
5082
|
-
* Generate a referral code for a given address.
|
|
5083
|
-
*
|
|
5084
|
-
* Called when an user want to creates his own referral code
|
|
5085
|
-
*/
|
|
5086
|
-
_proto2.registerNewReferralCode =
|
|
5087
|
-
/*#__PURE__*/
|
|
5088
|
-
function () {
|
|
5089
|
-
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
5090
|
-
var referralCode;
|
|
5091
|
-
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
5092
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
5091
|
+
_proto.sneakAccounts = /*#__PURE__*/function () {
|
|
5092
|
+
var _sneakAccounts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(accounts, tokenAddresses, dust) {
|
|
5093
|
+
var _this2 = this;
|
|
5094
|
+
var _1E18, oracle, tokens, prices, exrate, res, _iterator2, _step2, addr, infos, i, snapshot, bal, bor, balR, borR;
|
|
5095
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context6) {
|
|
5096
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
5093
5097
|
case 0:
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5098
|
+
if (dust === void 0) {
|
|
5099
|
+
dust = /*#__PURE__*/new BigNumber(0.1);
|
|
5100
|
+
}
|
|
5101
|
+
_1E18 = BigNumber$1.from(10).pow(18);
|
|
5102
|
+
oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
|
|
5103
|
+
tokens = tokenAddresses.map(function (addr) {
|
|
5104
|
+
return _this2.env.getContract(addr, abis.abi);
|
|
5105
|
+
});
|
|
5106
|
+
_context6.next = 6;
|
|
5107
|
+
return oracle.getUnderlyingPrices(tokenAddresses);
|
|
5108
|
+
case 6:
|
|
5109
|
+
prices = _context6.sent;
|
|
5110
|
+
_context6.next = 9;
|
|
5111
|
+
return this.env.auriInternalLens.callStatic.getExchangeRates(tokenAddresses);
|
|
5112
|
+
case 9:
|
|
5113
|
+
exrate = _context6.sent;
|
|
5114
|
+
res = [];
|
|
5115
|
+
_iterator2 = _createForOfIteratorHelperLoose(accounts);
|
|
5116
|
+
case 12:
|
|
5117
|
+
if ((_step2 = _iterator2()).done) {
|
|
5118
|
+
_context6.next = 33;
|
|
5119
|
+
break;
|
|
5120
|
+
}
|
|
5121
|
+
addr = _step2.value;
|
|
5122
|
+
infos = [];
|
|
5123
|
+
i = 0;
|
|
5124
|
+
case 16:
|
|
5125
|
+
if (!(i < tokens.length)) {
|
|
5126
|
+
_context6.next = 30;
|
|
5127
|
+
break;
|
|
5128
|
+
}
|
|
5129
|
+
_context6.next = 19;
|
|
5130
|
+
return tokens[i].getAccountSnapshot(addr);
|
|
5131
|
+
case 19:
|
|
5132
|
+
snapshot = _context6.sent;
|
|
5133
|
+
bal = snapshot[0].mul(exrate[i]).div(_1E18).mul(prices[i]).div(_1E18);
|
|
5134
|
+
bor = snapshot[1].mul(prices[i]).div(_1E18);
|
|
5135
|
+
balR = new BigNumber(bal.toString()).dividedBy(_1E18.toString());
|
|
5136
|
+
borR = new BigNumber(bor.toString()).dividedBy(_1E18.toString());
|
|
5137
|
+
if (!(balR.lte(dust) && borR.lte(dust))) {
|
|
5138
|
+
_context6.next = 26;
|
|
5139
|
+
break;
|
|
5140
|
+
}
|
|
5141
|
+
return _context6.abrupt("continue", 27);
|
|
5142
|
+
case 26:
|
|
5143
|
+
infos.push({
|
|
5144
|
+
token: getSymbol(tokenAddresses[i]),
|
|
5145
|
+
deposit: balR,
|
|
5146
|
+
borrow: borR
|
|
5147
|
+
});
|
|
5148
|
+
case 27:
|
|
5149
|
+
++i;
|
|
5150
|
+
_context6.next = 16;
|
|
5151
|
+
break;
|
|
5152
|
+
case 30:
|
|
5153
|
+
res.push({
|
|
5154
|
+
address: addr,
|
|
5155
|
+
tokens: infos
|
|
5156
|
+
});
|
|
5157
|
+
case 31:
|
|
5158
|
+
_context6.next = 12;
|
|
5159
|
+
break;
|
|
5160
|
+
case 33:
|
|
5161
|
+
return _context6.abrupt("return", res);
|
|
5162
|
+
case 34:
|
|
5097
5163
|
case "end":
|
|
5098
|
-
return
|
|
5164
|
+
return _context6.stop();
|
|
5099
5165
|
}
|
|
5100
|
-
},
|
|
5166
|
+
}, _callee5, this);
|
|
5101
5167
|
}));
|
|
5102
|
-
function
|
|
5103
|
-
return
|
|
5168
|
+
function sneakAccounts(_x4, _x5, _x6) {
|
|
5169
|
+
return _sneakAccounts.apply(this, arguments);
|
|
5104
5170
|
}
|
|
5105
|
-
return
|
|
5106
|
-
}()
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
function () {
|
|
5114
|
-
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(code) {
|
|
5115
|
-
var referralCode;
|
|
5116
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
5117
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
5171
|
+
return sneakAccounts;
|
|
5172
|
+
}();
|
|
5173
|
+
_proto.getNetApyWithoutIncentive = /*#__PURE__*/function () {
|
|
5174
|
+
var _getNetApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userAddress) {
|
|
5175
|
+
var _this3 = this;
|
|
5176
|
+
var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator3, _step3, apy;
|
|
5177
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
|
5178
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
5118
5179
|
case 0:
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5180
|
+
sum = new BigNumber(0);
|
|
5181
|
+
totalSuppliedValue = new BigNumber(0);
|
|
5182
|
+
totalBorrowedValue = new BigNumber(0);
|
|
5183
|
+
netApy = new BigNumber(0);
|
|
5184
|
+
_context7.next = 6;
|
|
5185
|
+
return Promise.all(networkAddresses.auTokens.map(function (auToken) {
|
|
5186
|
+
var moneyMarket = new MoneyMarketRead(_this3._networkConnection, auToken.address, auToken.underlying);
|
|
5187
|
+
var apyWithoutIncentive = moneyMarket.getApyWithoutIncentive(userAddress);
|
|
5188
|
+
return apyWithoutIncentive;
|
|
5189
|
+
}));
|
|
5190
|
+
case 6:
|
|
5191
|
+
apys = _context7.sent;
|
|
5192
|
+
for (_iterator3 = _createForOfIteratorHelperLoose(apys); !(_step3 = _iterator3()).done;) {
|
|
5193
|
+
apy = _step3.value;
|
|
5194
|
+
sum = sum.plus(apy.sum);
|
|
5195
|
+
totalSuppliedValue = totalSuppliedValue.plus(apy.suppliedValue);
|
|
5196
|
+
totalBorrowedValue = totalBorrowedValue.plus(apy.borrowedValue);
|
|
5197
|
+
}
|
|
5198
|
+
if (sum.gt(0)) {
|
|
5199
|
+
netApy = sum.div(totalSuppliedValue);
|
|
5200
|
+
} else if (sum.lt(0)) {
|
|
5201
|
+
netApy = sum.div(totalBorrowedValue);
|
|
5202
|
+
}
|
|
5203
|
+
return _context7.abrupt("return", netApy);
|
|
5204
|
+
case 10:
|
|
5122
5205
|
case "end":
|
|
5123
|
-
return
|
|
5206
|
+
return _context7.stop();
|
|
5124
5207
|
}
|
|
5125
|
-
},
|
|
5208
|
+
}, _callee6);
|
|
5126
5209
|
}));
|
|
5127
|
-
function
|
|
5128
|
-
return
|
|
5210
|
+
function getNetApyWithoutIncentive(_x7) {
|
|
5211
|
+
return _getNetApyWithoutIncentive.apply(this, arguments);
|
|
5129
5212
|
}
|
|
5130
|
-
return
|
|
5131
|
-
}()
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
function () {
|
|
5139
|
-
var _claimReferralRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
5140
|
-
var unclaimedRewards, campaigns, tokens;
|
|
5141
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
5142
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
5213
|
+
return getNetApyWithoutIncentive;
|
|
5214
|
+
}();
|
|
5215
|
+
_proto.getNetApyWithIncentive = /*#__PURE__*/function () {
|
|
5216
|
+
var _getNetApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(userAddress) {
|
|
5217
|
+
var _this4 = this;
|
|
5218
|
+
var sum, totalSuppliedValue, totalBorrowedValue, netApy, apys, _iterator4, _step4, apy;
|
|
5219
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
5220
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
5143
5221
|
case 0:
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5222
|
+
sum = new BigNumber(0);
|
|
5223
|
+
totalSuppliedValue = new BigNumber(0);
|
|
5224
|
+
totalBorrowedValue = new BigNumber(0);
|
|
5225
|
+
netApy = new BigNumber(0);
|
|
5226
|
+
_context8.next = 6;
|
|
5227
|
+
return Promise.all(networkAddresses.auTokens.map(function (auToken) {
|
|
5228
|
+
var moneyMarket = new MoneyMarketRead(_this4._networkConnection, auToken.address, auToken.underlying);
|
|
5229
|
+
var apyWithIncentive = moneyMarket.getApyWithIncentive(userAddress);
|
|
5230
|
+
return apyWithIncentive;
|
|
5231
|
+
}));
|
|
5151
5232
|
case 6:
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5233
|
+
apys = _context8.sent;
|
|
5234
|
+
for (_iterator4 = _createForOfIteratorHelperLoose(apys); !(_step4 = _iterator4()).done;) {
|
|
5235
|
+
apy = _step4.value;
|
|
5236
|
+
sum = sum.plus(apy.sum);
|
|
5237
|
+
totalSuppliedValue = totalSuppliedValue.plus(apy.suppliedValue);
|
|
5238
|
+
totalBorrowedValue = totalBorrowedValue.plus(apy.borrowedValue);
|
|
5239
|
+
}
|
|
5240
|
+
if (sum.gt(0)) {
|
|
5241
|
+
netApy = sum.div(totalSuppliedValue);
|
|
5242
|
+
} else if (sum.lt(0)) {
|
|
5243
|
+
netApy = sum.div(totalBorrowedValue);
|
|
5244
|
+
}
|
|
5245
|
+
return _context8.abrupt("return", netApy);
|
|
5162
5246
|
case 10:
|
|
5163
5247
|
case "end":
|
|
5164
|
-
return
|
|
5248
|
+
return _context8.stop();
|
|
5165
5249
|
}
|
|
5166
|
-
},
|
|
5250
|
+
}, _callee7);
|
|
5167
5251
|
}));
|
|
5168
|
-
function
|
|
5169
|
-
return
|
|
5252
|
+
function getNetApyWithIncentive(_x8) {
|
|
5253
|
+
return _getNetApyWithIncentive.apply(this, arguments);
|
|
5170
5254
|
}
|
|
5171
|
-
return
|
|
5255
|
+
return getNetApyWithIncentive;
|
|
5172
5256
|
}();
|
|
5173
|
-
return
|
|
5174
|
-
}(
|
|
5175
|
-
var Referral = /*#__PURE__*/function (_BlockchainEntity) {
|
|
5176
|
-
_inheritsLoose(Referral, _BlockchainEntity);
|
|
5177
|
-
function Referral() {
|
|
5178
|
-
return _BlockchainEntity.call(this) || this;
|
|
5179
|
-
}
|
|
5180
|
-
var _proto3 = Referral.prototype;
|
|
5181
|
-
_proto3.read = function read(networkConnection) {
|
|
5182
|
-
return new ReferralRead(networkConnection);
|
|
5183
|
-
};
|
|
5184
|
-
_proto3.readWrite = function readWrite(networkConnection) {
|
|
5185
|
-
return new ReferralReadWrite(networkConnection);
|
|
5186
|
-
};
|
|
5187
|
-
return Referral;
|
|
5188
|
-
}(BlockchainEntity);
|
|
5257
|
+
return MiscRead;
|
|
5258
|
+
}(BlockchainEntityRead);
|
|
5189
5259
|
|
|
5190
5260
|
var NOTIFICATION_API_END_POINT = 'https://api.aurigami.finance/notification/';
|
|
5191
5261
|
function postApi(_x3, _x4) {
|
|
@@ -5629,5 +5699,5 @@ BigNumber.config({
|
|
|
5629
5699
|
DECIMAL_PLACES: 50
|
|
5630
5700
|
});
|
|
5631
5701
|
|
|
5632
|
-
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, AURORA_PLUS_API_PREFIX, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, CACHE_TIMEOUT, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, PlyGame, PlyGameRead, PlyGameReadWrite, REFERRAL_CAMPAIGNS, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcNetApy, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchHistoricalLPPositions, fetchHistoricalLPPrice, fetchHistoricalPULPPrice, fetchHistoricalPrice, fetchHistoricalPriceByLP, fetchHistoricalPriceFromOracle, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromDefiLlama, fetchPriceFromDefiLlamaAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, referralRewardDummy1, referralRewardDummy2, sleep, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
|
|
5702
|
+
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, AURORA_PLUS_API_PREFIX, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, CACHE_TIMEOUT, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, PlyGame, PlyGameRead, PlyGameReadWrite, Pulp, PulpRead, PulpReadWrite, REFERRAL_CAMPAIGNS, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcNetApy, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchHistoricalLPPositions, fetchHistoricalLPPrice, fetchHistoricalPULPPrice, fetchHistoricalPrice, fetchHistoricalPriceByLP, fetchHistoricalPriceFromOracle, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromDefiLlama, fetchPriceFromDefiLlamaAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, referralRewardDummy1, referralRewardDummy2, sleep, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
|
|
5633
5703
|
//# sourceMappingURL=sdk.esm.js.map
|