@aurigami/sdk 1.15.3 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consts/constants.d.ts +84 -9
- package/dist/interactors/MoneyMarket.d.ts +1 -0
- package/dist/sdk.cjs.development.js +210 -141
- 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 +210 -141
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +70 -71
- package/src/consts/constants.ts +8 -11
- package/src/consts/decimals.ts +3 -2
- package/src/interactors/MoneyMarket.ts +46 -15
- package/src/types/index.ts +2 -1
- package/src/.DS_Store +0 -0
|
@@ -102,6 +102,10 @@ var networkAddresses = {
|
|
|
102
102
|
name: 'auUSN',
|
|
103
103
|
address: /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
|
|
104
104
|
underlying: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
|
|
105
|
+
}, {
|
|
106
|
+
name: 'auNEARX',
|
|
107
|
+
address: /*#__PURE__*/MAINNET_ADDRESSES.auTokens.NEARX.toLowerCase(),
|
|
108
|
+
underlying: /*#__PURE__*/'0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase()
|
|
105
109
|
}],
|
|
106
110
|
misc: {
|
|
107
111
|
COMPTROLLER: /*#__PURE__*/MAINNET_ADDRESSES.comptroller.toLowerCase(),
|
|
@@ -134,7 +138,8 @@ var networkAddresses = {
|
|
|
134
138
|
USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
|
|
135
139
|
PLY_WNEAR: /*#__PURE__*/'0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
|
|
136
140
|
WNEAR_TRI: /*#__PURE__*/'0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
|
|
137
|
-
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase()
|
|
141
|
+
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase(),
|
|
142
|
+
NEARX: /*#__PURE__*/'0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase()
|
|
138
143
|
}
|
|
139
144
|
};
|
|
140
145
|
var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase()]; // All token that we can calculate the price via oracle + coingecko
|
|
@@ -225,7 +230,8 @@ var decimalRecords = {
|
|
|
225
230
|
'0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18,
|
|
226
231
|
'0x5183e1b1091804bc2602586919e6880ac1cf2896': 18,
|
|
227
232
|
'0x84b123875f0f36b966d0b6ca14b31121bd9676ad': 18,
|
|
228
|
-
'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18
|
|
233
|
+
'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18,
|
|
234
|
+
'0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375': 24
|
|
229
235
|
};
|
|
230
236
|
|
|
231
237
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -3727,36 +3733,88 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3727
3733
|
return getDepositMetaAPY;
|
|
3728
3734
|
}();
|
|
3729
3735
|
|
|
3730
|
-
_proto.
|
|
3731
|
-
var
|
|
3732
|
-
var
|
|
3736
|
+
_proto.getDepositStaderAPY = /*#__PURE__*/function () {
|
|
3737
|
+
var _getDepositStaderAPY = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14() {
|
|
3738
|
+
var rewardStartTime, currentTime, _yield$Promise$all7, totalDeposited, underlyingPrice, depositStaderApy;
|
|
3733
3739
|
|
|
3734
3740
|
return runtime_1.wrap(function _callee14$(_context14) {
|
|
3735
3741
|
while (1) {
|
|
3736
3742
|
switch (_context14.prev = _context14.next) {
|
|
3737
3743
|
case 0:
|
|
3738
|
-
|
|
3739
|
-
|
|
3744
|
+
rewardStartTime = 1675371600;
|
|
3745
|
+
currentTime = getCurrentTimestamp();
|
|
3740
3746
|
|
|
3741
|
-
|
|
3747
|
+
if (!(currentTime < rewardStartTime)) {
|
|
3748
|
+
_context14.next = 4;
|
|
3749
|
+
break;
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3752
|
+
return _context14.abrupt("return", new BigNumber(0));
|
|
3753
|
+
|
|
3754
|
+
case 4:
|
|
3755
|
+
_context14.next = 6;
|
|
3756
|
+
return Promise.all([this.getTotalTokenDeposited(), fetchPrice(this.underlying.address, this._networkConnection.provider)]);
|
|
3757
|
+
|
|
3758
|
+
case 6:
|
|
3742
3759
|
_yield$Promise$all7 = _context14.sent;
|
|
3743
3760
|
totalDeposited = _yield$Promise$all7[0];
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3761
|
+
underlyingPrice = _yield$Promise$all7[1];
|
|
3762
|
+
|
|
3763
|
+
if (isSameAddress(this.underlying.address, networkAddresses.tokens.NEARX)) {
|
|
3764
|
+
// 100$ a day
|
|
3765
|
+
depositStaderApy = calcLMRewardApr(new BigNumber(100), underlyingPrice.multipliedBy(totalDeposited.formattedAmount()), 365);
|
|
3766
|
+
} else {
|
|
3767
|
+
depositStaderApy = new BigNumber(0);
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
return _context14.abrupt("return", depositStaderApy);
|
|
3771
|
+
|
|
3772
|
+
case 11:
|
|
3773
|
+
case "end":
|
|
3774
|
+
return _context14.stop();
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
}, _callee14, this);
|
|
3778
|
+
}));
|
|
3779
|
+
|
|
3780
|
+
function getDepositStaderAPY() {
|
|
3781
|
+
return _getDepositStaderAPY.apply(this, arguments);
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
return getDepositStaderAPY;
|
|
3785
|
+
}();
|
|
3786
|
+
|
|
3787
|
+
_proto.getDetails = /*#__PURE__*/function () {
|
|
3788
|
+
var _getDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
|
|
3789
|
+
var _yield$Promise$all8, totalDeposited, totalBorrowed, depositAPY, borrowAPY, collateralRatio, rewardSpeeds, _yield$Promise$all9, depositPlyAPY, borrowPlyAPY, depositNearAPY, borrowNearAPY, depositMetaAPY, staderDepositApy;
|
|
3790
|
+
|
|
3791
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
3792
|
+
while (1) {
|
|
3793
|
+
switch (_context15.prev = _context15.next) {
|
|
3794
|
+
case 0:
|
|
3795
|
+
_context15.next = 2;
|
|
3796
|
+
return Promise.all([this.getTotalTokenDeposited(), this.getTotalTokenBorrowed(), this.getDepositAPY(), this.getBorrowAPY(), this.getCollateralRatio(), this.getRewardSpeeds()]);
|
|
3797
|
+
|
|
3798
|
+
case 2:
|
|
3799
|
+
_yield$Promise$all8 = _context15.sent;
|
|
3800
|
+
totalDeposited = _yield$Promise$all8[0];
|
|
3801
|
+
totalBorrowed = _yield$Promise$all8[1];
|
|
3802
|
+
depositAPY = _yield$Promise$all8[2];
|
|
3803
|
+
borrowAPY = _yield$Promise$all8[3];
|
|
3804
|
+
collateralRatio = _yield$Promise$all8[4];
|
|
3805
|
+
rewardSpeeds = _yield$Promise$all8[5];
|
|
3806
|
+
_context15.next = 11;
|
|
3807
|
+
return Promise.all([this.getDepositPlyAPY(), this.getBorrowPlyAPY(), this.getDepositNearAPY(), this.getBorrowNearAPY(), this.getDepositMetaAPY(), this.getDepositStaderAPY()]);
|
|
3751
3808
|
|
|
3752
3809
|
case 11:
|
|
3753
|
-
_yield$Promise$
|
|
3754
|
-
depositPlyAPY = _yield$Promise$
|
|
3755
|
-
borrowPlyAPY = _yield$Promise$
|
|
3756
|
-
depositNearAPY = _yield$Promise$
|
|
3757
|
-
borrowNearAPY = _yield$Promise$
|
|
3758
|
-
depositMetaAPY = _yield$Promise$
|
|
3759
|
-
|
|
3810
|
+
_yield$Promise$all9 = _context15.sent;
|
|
3811
|
+
depositPlyAPY = _yield$Promise$all9[0];
|
|
3812
|
+
borrowPlyAPY = _yield$Promise$all9[1];
|
|
3813
|
+
depositNearAPY = _yield$Promise$all9[2];
|
|
3814
|
+
borrowNearAPY = _yield$Promise$all9[3];
|
|
3815
|
+
depositMetaAPY = _yield$Promise$all9[4];
|
|
3816
|
+
staderDepositApy = _yield$Promise$all9[5];
|
|
3817
|
+
return _context15.abrupt("return", {
|
|
3760
3818
|
auTokenAddress: this.auToken.address,
|
|
3761
3819
|
totalTokenDeposited: totalDeposited,
|
|
3762
3820
|
totalTokenBorrowed: totalBorrowed,
|
|
@@ -3769,15 +3827,16 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3769
3827
|
borrowPlyPerWeek: new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.mul(ONE_DAY).mul(7).toString()),
|
|
3770
3828
|
depositNEARApy: depositNearAPY.toNumber(),
|
|
3771
3829
|
borrowNEARApy: borrowNearAPY.toNumber() * -1,
|
|
3772
|
-
depositMETAApy: depositMetaAPY.toNumber()
|
|
3830
|
+
depositMETAApy: depositMetaAPY.toNumber(),
|
|
3831
|
+
staderDepositApy: staderDepositApy.toNumber()
|
|
3773
3832
|
});
|
|
3774
3833
|
|
|
3775
|
-
case
|
|
3834
|
+
case 19:
|
|
3776
3835
|
case "end":
|
|
3777
|
-
return
|
|
3836
|
+
return _context15.stop();
|
|
3778
3837
|
}
|
|
3779
3838
|
}
|
|
3780
|
-
},
|
|
3839
|
+
}, _callee15, this);
|
|
3781
3840
|
}));
|
|
3782
3841
|
|
|
3783
3842
|
function getDetails() {
|
|
@@ -3788,25 +3847,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3788
3847
|
}();
|
|
3789
3848
|
|
|
3790
3849
|
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
3791
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3850
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(userAddress) {
|
|
3792
3851
|
var totalBorrow;
|
|
3793
|
-
return runtime_1.wrap(function
|
|
3852
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
3794
3853
|
while (1) {
|
|
3795
|
-
switch (
|
|
3854
|
+
switch (_context16.prev = _context16.next) {
|
|
3796
3855
|
case 0:
|
|
3797
|
-
|
|
3856
|
+
_context16.next = 2;
|
|
3798
3857
|
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
3799
3858
|
|
|
3800
3859
|
case 2:
|
|
3801
|
-
totalBorrow =
|
|
3802
|
-
return
|
|
3860
|
+
totalBorrow = _context16.sent;
|
|
3861
|
+
return _context16.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
3803
3862
|
|
|
3804
3863
|
case 4:
|
|
3805
3864
|
case "end":
|
|
3806
|
-
return
|
|
3865
|
+
return _context16.stop();
|
|
3807
3866
|
}
|
|
3808
3867
|
}
|
|
3809
|
-
},
|
|
3868
|
+
}, _callee16, this);
|
|
3810
3869
|
}));
|
|
3811
3870
|
|
|
3812
3871
|
function getUserBorrowBalance(_x) {
|
|
@@ -3817,25 +3876,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3817
3876
|
}();
|
|
3818
3877
|
|
|
3819
3878
|
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
3820
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3879
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(userAddress) {
|
|
3821
3880
|
var totalDeposit;
|
|
3822
|
-
return runtime_1.wrap(function
|
|
3881
|
+
return runtime_1.wrap(function _callee17$(_context17) {
|
|
3823
3882
|
while (1) {
|
|
3824
|
-
switch (
|
|
3883
|
+
switch (_context17.prev = _context17.next) {
|
|
3825
3884
|
case 0:
|
|
3826
|
-
|
|
3885
|
+
_context17.next = 2;
|
|
3827
3886
|
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
3828
3887
|
|
|
3829
3888
|
case 2:
|
|
3830
|
-
totalDeposit =
|
|
3831
|
-
return
|
|
3889
|
+
totalDeposit = _context17.sent;
|
|
3890
|
+
return _context17.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
3832
3891
|
|
|
3833
3892
|
case 4:
|
|
3834
3893
|
case "end":
|
|
3835
|
-
return
|
|
3894
|
+
return _context17.stop();
|
|
3836
3895
|
}
|
|
3837
3896
|
}
|
|
3838
|
-
},
|
|
3897
|
+
}, _callee17, this);
|
|
3839
3898
|
}));
|
|
3840
3899
|
|
|
3841
3900
|
function getUserDepositBalance(_x2) {
|
|
@@ -3880,26 +3939,26 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3880
3939
|
};
|
|
3881
3940
|
|
|
3882
3941
|
_proto.mintCap = /*#__PURE__*/function () {
|
|
3883
|
-
var _mintCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3884
|
-
return runtime_1.wrap(function
|
|
3942
|
+
var _mintCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee18() {
|
|
3943
|
+
return runtime_1.wrap(function _callee18$(_context18) {
|
|
3885
3944
|
while (1) {
|
|
3886
|
-
switch (
|
|
3945
|
+
switch (_context18.prev = _context18.next) {
|
|
3887
3946
|
case 0:
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3947
|
+
_context18.t0 = TokenAmount;
|
|
3948
|
+
_context18.t1 = this.underlying;
|
|
3949
|
+
_context18.next = 4;
|
|
3891
3950
|
return this.env.comptroller.mintCaps(this.auToken.address);
|
|
3892
3951
|
|
|
3893
3952
|
case 4:
|
|
3894
|
-
|
|
3895
|
-
return
|
|
3953
|
+
_context18.t2 = _context18.sent.toString();
|
|
3954
|
+
return _context18.abrupt("return", new _context18.t0(_context18.t1, _context18.t2));
|
|
3896
3955
|
|
|
3897
3956
|
case 6:
|
|
3898
3957
|
case "end":
|
|
3899
|
-
return
|
|
3958
|
+
return _context18.stop();
|
|
3900
3959
|
}
|
|
3901
3960
|
}
|
|
3902
|
-
},
|
|
3961
|
+
}, _callee18, this);
|
|
3903
3962
|
}));
|
|
3904
3963
|
|
|
3905
3964
|
function mintCap() {
|
|
@@ -3910,26 +3969,26 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3910
3969
|
}();
|
|
3911
3970
|
|
|
3912
3971
|
_proto.borrowCap = /*#__PURE__*/function () {
|
|
3913
|
-
var _borrowCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3914
|
-
return runtime_1.wrap(function
|
|
3972
|
+
var _borrowCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19() {
|
|
3973
|
+
return runtime_1.wrap(function _callee19$(_context19) {
|
|
3915
3974
|
while (1) {
|
|
3916
|
-
switch (
|
|
3975
|
+
switch (_context19.prev = _context19.next) {
|
|
3917
3976
|
case 0:
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3977
|
+
_context19.t0 = TokenAmount;
|
|
3978
|
+
_context19.t1 = this.underlying;
|
|
3979
|
+
_context19.next = 4;
|
|
3921
3980
|
return this.env.comptroller.borrowCaps(this.auToken.address);
|
|
3922
3981
|
|
|
3923
3982
|
case 4:
|
|
3924
|
-
|
|
3925
|
-
return
|
|
3983
|
+
_context19.t2 = _context19.sent.toString();
|
|
3984
|
+
return _context19.abrupt("return", new _context19.t0(_context19.t1, _context19.t2));
|
|
3926
3985
|
|
|
3927
3986
|
case 6:
|
|
3928
3987
|
case "end":
|
|
3929
|
-
return
|
|
3988
|
+
return _context19.stop();
|
|
3930
3989
|
}
|
|
3931
3990
|
}
|
|
3932
|
-
},
|
|
3991
|
+
}, _callee19, this);
|
|
3933
3992
|
}));
|
|
3934
3993
|
|
|
3935
3994
|
function borrowCap() {
|
|
@@ -3940,27 +3999,27 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3940
3999
|
}();
|
|
3941
4000
|
|
|
3942
4001
|
_proto.getApyWithoutIncentive = /*#__PURE__*/function () {
|
|
3943
|
-
var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3944
|
-
var _yield$Promise$
|
|
4002
|
+
var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee20(userAddress) {
|
|
4003
|
+
var _yield$Promise$all10, price, depositApy, borrowApy, depositBalance, borrowBalance, suppliedValue, borrowedValue, sum;
|
|
3945
4004
|
|
|
3946
|
-
return runtime_1.wrap(function
|
|
4005
|
+
return runtime_1.wrap(function _callee20$(_context20) {
|
|
3947
4006
|
while (1) {
|
|
3948
|
-
switch (
|
|
4007
|
+
switch (_context20.prev = _context20.next) {
|
|
3949
4008
|
case 0:
|
|
3950
|
-
|
|
4009
|
+
_context20.next = 2;
|
|
3951
4010
|
return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
|
|
3952
4011
|
|
|
3953
4012
|
case 2:
|
|
3954
|
-
_yield$Promise$
|
|
3955
|
-
price = _yield$Promise$
|
|
3956
|
-
depositApy = _yield$Promise$
|
|
3957
|
-
borrowApy = _yield$Promise$
|
|
3958
|
-
depositBalance = _yield$Promise$
|
|
3959
|
-
borrowBalance = _yield$Promise$
|
|
4013
|
+
_yield$Promise$all10 = _context20.sent;
|
|
4014
|
+
price = _yield$Promise$all10[0];
|
|
4015
|
+
depositApy = _yield$Promise$all10[1];
|
|
4016
|
+
borrowApy = _yield$Promise$all10[2];
|
|
4017
|
+
depositBalance = _yield$Promise$all10[3];
|
|
4018
|
+
borrowBalance = _yield$Promise$all10[4];
|
|
3960
4019
|
suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
3961
4020
|
borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
3962
4021
|
sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
|
|
3963
|
-
return
|
|
4022
|
+
return _context20.abrupt("return", {
|
|
3964
4023
|
sum: sum,
|
|
3965
4024
|
suppliedValue: suppliedValue,
|
|
3966
4025
|
borrowedValue: borrowedValue
|
|
@@ -3968,10 +4027,10 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3968
4027
|
|
|
3969
4028
|
case 12:
|
|
3970
4029
|
case "end":
|
|
3971
|
-
return
|
|
4030
|
+
return _context20.stop();
|
|
3972
4031
|
}
|
|
3973
4032
|
}
|
|
3974
|
-
},
|
|
4033
|
+
}, _callee20, this);
|
|
3975
4034
|
}));
|
|
3976
4035
|
|
|
3977
4036
|
function getApyWithoutIncentive(_x3) {
|
|
@@ -3982,45 +4041,50 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3982
4041
|
}();
|
|
3983
4042
|
|
|
3984
4043
|
_proto.getApyWithIncentive = /*#__PURE__*/function () {
|
|
3985
|
-
var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3986
|
-
var _yield$Promise$
|
|
4044
|
+
var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee21(userAddress) {
|
|
4045
|
+
var _yield$Promise$all11, price, depositApy, borrowApy, depositBalance, borrowBalance, nearDepositApy, plyDepositApy, metaDepositApy, nearBorrowApy, plyBorrowApy, staderDepositApy, suppliedValue, borrowedValue, totalDepositApy, totalBorrowApy, sum;
|
|
3987
4046
|
|
|
3988
|
-
return runtime_1.wrap(function
|
|
4047
|
+
return runtime_1.wrap(function _callee21$(_context21) {
|
|
3989
4048
|
while (1) {
|
|
3990
|
-
switch (
|
|
4049
|
+
switch (_context21.prev = _context21.next) {
|
|
3991
4050
|
case 0:
|
|
3992
|
-
|
|
4051
|
+
_context21.next = 2;
|
|
3993
4052
|
return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress), this.getDepositNearAPY(), this.getDepositPlyAPY(), this.getDepositMetaAPY(), this.getBorrowNearAPY(), this.getBorrowPlyAPY()]);
|
|
3994
4053
|
|
|
3995
4054
|
case 2:
|
|
3996
|
-
_yield$Promise$
|
|
3997
|
-
price = _yield$Promise$
|
|
3998
|
-
depositApy = _yield$Promise$
|
|
3999
|
-
borrowApy = _yield$Promise$
|
|
4000
|
-
depositBalance = _yield$Promise$
|
|
4001
|
-
borrowBalance = _yield$Promise$
|
|
4002
|
-
nearDepositApy = _yield$Promise$
|
|
4003
|
-
plyDepositApy = _yield$Promise$
|
|
4004
|
-
metaDepositApy = _yield$Promise$
|
|
4005
|
-
nearBorrowApy = _yield$Promise$
|
|
4006
|
-
plyBorrowApy = _yield$Promise$
|
|
4055
|
+
_yield$Promise$all11 = _context21.sent;
|
|
4056
|
+
price = _yield$Promise$all11[0];
|
|
4057
|
+
depositApy = _yield$Promise$all11[1];
|
|
4058
|
+
borrowApy = _yield$Promise$all11[2];
|
|
4059
|
+
depositBalance = _yield$Promise$all11[3];
|
|
4060
|
+
borrowBalance = _yield$Promise$all11[4];
|
|
4061
|
+
nearDepositApy = _yield$Promise$all11[5];
|
|
4062
|
+
plyDepositApy = _yield$Promise$all11[6];
|
|
4063
|
+
metaDepositApy = _yield$Promise$all11[7];
|
|
4064
|
+
nearBorrowApy = _yield$Promise$all11[8];
|
|
4065
|
+
plyBorrowApy = _yield$Promise$all11[9];
|
|
4066
|
+
_context21.next = 15;
|
|
4067
|
+
return this.getDepositStaderAPY();
|
|
4068
|
+
|
|
4069
|
+
case 15:
|
|
4070
|
+
staderDepositApy = _context21.sent;
|
|
4007
4071
|
suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
4008
4072
|
borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
4009
|
-
totalDepositApy = depositApy.plus(nearDepositApy).plus(plyDepositApy).plus(metaDepositApy);
|
|
4073
|
+
totalDepositApy = depositApy.plus(nearDepositApy).plus(plyDepositApy).plus(metaDepositApy).plus(staderDepositApy);
|
|
4010
4074
|
totalBorrowApy = borrowApy.plus(nearBorrowApy).plus(plyBorrowApy);
|
|
4011
4075
|
sum = calcNetApy(suppliedValue, totalDepositApy, borrowedValue, totalBorrowApy);
|
|
4012
|
-
return
|
|
4076
|
+
return _context21.abrupt("return", {
|
|
4013
4077
|
sum: sum,
|
|
4014
4078
|
suppliedValue: suppliedValue,
|
|
4015
4079
|
borrowedValue: borrowedValue
|
|
4016
4080
|
});
|
|
4017
4081
|
|
|
4018
|
-
case
|
|
4082
|
+
case 22:
|
|
4019
4083
|
case "end":
|
|
4020
|
-
return
|
|
4084
|
+
return _context21.stop();
|
|
4021
4085
|
}
|
|
4022
4086
|
}
|
|
4023
|
-
},
|
|
4087
|
+
}, _callee21, this);
|
|
4024
4088
|
}));
|
|
4025
4089
|
|
|
4026
4090
|
function getApyWithIncentive(_x4) {
|
|
@@ -4098,6 +4162,11 @@ tslib.__decorate([cacheDecorator.cache({
|
|
|
4098
4162
|
type: cacheDecorator.CacheType.MEMO
|
|
4099
4163
|
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositMetaAPY", null);
|
|
4100
4164
|
|
|
4165
|
+
tslib.__decorate([cacheDecorator.cache({
|
|
4166
|
+
ttl: CACHE_TIMEOUT,
|
|
4167
|
+
type: cacheDecorator.CacheType.MEMO
|
|
4168
|
+
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositStaderAPY", null);
|
|
4169
|
+
|
|
4101
4170
|
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
4102
4171
|
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
4103
4172
|
|
|
@@ -4112,29 +4181,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4112
4181
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
4113
4182
|
|
|
4114
4183
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
4115
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4116
|
-
return runtime_1.wrap(function
|
|
4184
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee22(amount) {
|
|
4185
|
+
return runtime_1.wrap(function _callee22$(_context22) {
|
|
4117
4186
|
while (1) {
|
|
4118
|
-
switch (
|
|
4187
|
+
switch (_context22.prev = _context22.next) {
|
|
4119
4188
|
case 0:
|
|
4120
4189
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
4121
|
-
|
|
4190
|
+
_context22.next = 4;
|
|
4122
4191
|
break;
|
|
4123
4192
|
}
|
|
4124
4193
|
|
|
4125
|
-
return
|
|
4194
|
+
return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
4126
4195
|
value: amount.rawAmount()
|
|
4127
4196
|
}));
|
|
4128
4197
|
|
|
4129
4198
|
case 4:
|
|
4130
|
-
return
|
|
4199
|
+
return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
4131
4200
|
|
|
4132
4201
|
case 5:
|
|
4133
4202
|
case "end":
|
|
4134
|
-
return
|
|
4203
|
+
return _context22.stop();
|
|
4135
4204
|
}
|
|
4136
4205
|
}
|
|
4137
|
-
},
|
|
4206
|
+
}, _callee22, this);
|
|
4138
4207
|
}));
|
|
4139
4208
|
|
|
4140
4209
|
function deposit(_x5) {
|
|
@@ -4145,19 +4214,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4145
4214
|
}();
|
|
4146
4215
|
|
|
4147
4216
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
4148
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4149
|
-
return runtime_1.wrap(function
|
|
4217
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee23(amount) {
|
|
4218
|
+
return runtime_1.wrap(function _callee23$(_context23) {
|
|
4150
4219
|
while (1) {
|
|
4151
|
-
switch (
|
|
4220
|
+
switch (_context23.prev = _context23.next) {
|
|
4152
4221
|
case 0:
|
|
4153
|
-
return
|
|
4222
|
+
return _context23.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
4154
4223
|
|
|
4155
4224
|
case 1:
|
|
4156
4225
|
case "end":
|
|
4157
|
-
return
|
|
4226
|
+
return _context23.stop();
|
|
4158
4227
|
}
|
|
4159
4228
|
}
|
|
4160
|
-
},
|
|
4229
|
+
}, _callee23, this);
|
|
4161
4230
|
}));
|
|
4162
4231
|
|
|
4163
4232
|
function borrow(_x6) {
|
|
@@ -4168,27 +4237,27 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4168
4237
|
}();
|
|
4169
4238
|
|
|
4170
4239
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
4171
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4172
|
-
return runtime_1.wrap(function
|
|
4240
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee24(amount) {
|
|
4241
|
+
return runtime_1.wrap(function _callee24$(_context24) {
|
|
4173
4242
|
while (1) {
|
|
4174
|
-
switch (
|
|
4243
|
+
switch (_context24.prev = _context24.next) {
|
|
4175
4244
|
case 0:
|
|
4176
4245
|
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
4177
|
-
|
|
4246
|
+
_context24.next = 2;
|
|
4178
4247
|
break;
|
|
4179
4248
|
}
|
|
4180
4249
|
|
|
4181
|
-
return
|
|
4250
|
+
return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
|
|
4182
4251
|
|
|
4183
4252
|
case 2:
|
|
4184
|
-
return
|
|
4253
|
+
return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
4185
4254
|
|
|
4186
4255
|
case 3:
|
|
4187
4256
|
case "end":
|
|
4188
|
-
return
|
|
4257
|
+
return _context24.stop();
|
|
4189
4258
|
}
|
|
4190
4259
|
}
|
|
4191
|
-
},
|
|
4260
|
+
}, _callee24, this);
|
|
4192
4261
|
}));
|
|
4193
4262
|
|
|
4194
4263
|
function withdraw(_x7) {
|
|
@@ -4199,37 +4268,37 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4199
4268
|
}();
|
|
4200
4269
|
|
|
4201
4270
|
_proto2.repay = /*#__PURE__*/function () {
|
|
4202
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4203
|
-
return runtime_1.wrap(function
|
|
4271
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee25(amount) {
|
|
4272
|
+
return runtime_1.wrap(function _callee25$(_context25) {
|
|
4204
4273
|
while (1) {
|
|
4205
|
-
switch (
|
|
4274
|
+
switch (_context25.prev = _context25.next) {
|
|
4206
4275
|
case 0:
|
|
4207
4276
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
4208
|
-
|
|
4277
|
+
_context25.next = 4;
|
|
4209
4278
|
break;
|
|
4210
4279
|
}
|
|
4211
4280
|
|
|
4212
|
-
return
|
|
4281
|
+
return _context25.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
|
|
4213
4282
|
value: amount.rawAmount()
|
|
4214
4283
|
}));
|
|
4215
4284
|
|
|
4216
4285
|
case 4:
|
|
4217
4286
|
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
4218
|
-
|
|
4287
|
+
_context25.next = 8;
|
|
4219
4288
|
break;
|
|
4220
4289
|
}
|
|
4221
4290
|
|
|
4222
|
-
return
|
|
4291
|
+
return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
|
|
4223
4292
|
|
|
4224
4293
|
case 8:
|
|
4225
|
-
return
|
|
4294
|
+
return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
4226
4295
|
|
|
4227
4296
|
case 9:
|
|
4228
4297
|
case "end":
|
|
4229
|
-
return
|
|
4298
|
+
return _context25.stop();
|
|
4230
4299
|
}
|
|
4231
4300
|
}
|
|
4232
|
-
},
|
|
4301
|
+
}, _callee25, this);
|
|
4233
4302
|
}));
|
|
4234
4303
|
|
|
4235
4304
|
function repay(_x8) {
|
|
@@ -4240,19 +4309,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4240
4309
|
}();
|
|
4241
4310
|
|
|
4242
4311
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
4243
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4244
|
-
return runtime_1.wrap(function
|
|
4312
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee26() {
|
|
4313
|
+
return runtime_1.wrap(function _callee26$(_context26) {
|
|
4245
4314
|
while (1) {
|
|
4246
|
-
switch (
|
|
4315
|
+
switch (_context26.prev = _context26.next) {
|
|
4247
4316
|
case 0:
|
|
4248
|
-
return
|
|
4317
|
+
return _context26.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
4249
4318
|
|
|
4250
4319
|
case 1:
|
|
4251
4320
|
case "end":
|
|
4252
|
-
return
|
|
4321
|
+
return _context26.stop();
|
|
4253
4322
|
}
|
|
4254
4323
|
}
|
|
4255
|
-
},
|
|
4324
|
+
}, _callee26, this);
|
|
4256
4325
|
}));
|
|
4257
4326
|
|
|
4258
4327
|
function enableCollateral() {
|
|
@@ -4263,19 +4332,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4263
4332
|
}();
|
|
4264
4333
|
|
|
4265
4334
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
4266
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4267
|
-
return runtime_1.wrap(function
|
|
4335
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee27() {
|
|
4336
|
+
return runtime_1.wrap(function _callee27$(_context27) {
|
|
4268
4337
|
while (1) {
|
|
4269
|
-
switch (
|
|
4338
|
+
switch (_context27.prev = _context27.next) {
|
|
4270
4339
|
case 0:
|
|
4271
|
-
return
|
|
4340
|
+
return _context27.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
4272
4341
|
|
|
4273
4342
|
case 1:
|
|
4274
4343
|
case "end":
|
|
4275
|
-
return
|
|
4344
|
+
return _context27.stop();
|
|
4276
4345
|
}
|
|
4277
4346
|
}
|
|
4278
|
-
},
|
|
4347
|
+
}, _callee27, this);
|
|
4279
4348
|
}));
|
|
4280
4349
|
|
|
4281
4350
|
function disableCollateral() {
|