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