@aurigami/sdk 1.16.0 → 1.16.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/consts/constants.d.ts +1 -0
- package/dist/interactors/MoneyMarket.d.ts +1 -0
- package/dist/sdk.cjs.development.js +204 -140
- 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 +204 -140
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +70 -71
- package/src/consts/constants.ts +1 -0
- package/src/interactors/MoneyMarket.ts +45 -9
- package/src/types/index.ts +1 -0
- package/src/.DS_Store +0 -0
|
@@ -28,6 +28,7 @@ export declare class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
28
28
|
getDepositNearAPY(): Promise<BigNumber>;
|
|
29
29
|
getBorrowNearAPY(): Promise<BigNumber>;
|
|
30
30
|
getDepositMetaAPY(): Promise<BigNumber>;
|
|
31
|
+
getDepositStaderAPY(): Promise<BigNumber>;
|
|
31
32
|
getDetails(): Promise<MoneyMarketDetails>;
|
|
32
33
|
getUserBorrowBalance(userAddress: string): Promise<TokenAmount>;
|
|
33
34
|
getUserDepositBalance(userAddress: string): Promise<TokenAmount>;
|
|
@@ -138,7 +138,8 @@ var networkAddresses = {
|
|
|
138
138
|
USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
|
|
139
139
|
PLY_WNEAR: /*#__PURE__*/'0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
|
|
140
140
|
WNEAR_TRI: /*#__PURE__*/'0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
|
|
141
|
-
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase()
|
|
141
|
+
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase(),
|
|
142
|
+
NEARX: /*#__PURE__*/'0xb39eeb9e168ef6c639f5e282fef1f6bc4dcae375'.toLowerCase()
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
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
|
|
@@ -3732,36 +3733,88 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3732
3733
|
return getDepositMetaAPY;
|
|
3733
3734
|
}();
|
|
3734
3735
|
|
|
3735
|
-
_proto.
|
|
3736
|
-
var
|
|
3737
|
-
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;
|
|
3738
3739
|
|
|
3739
3740
|
return runtime_1.wrap(function _callee14$(_context14) {
|
|
3740
3741
|
while (1) {
|
|
3741
3742
|
switch (_context14.prev = _context14.next) {
|
|
3742
3743
|
case 0:
|
|
3743
|
-
|
|
3744
|
-
|
|
3744
|
+
rewardStartTime = 1675346400;
|
|
3745
|
+
currentTime = getCurrentTimestamp();
|
|
3745
3746
|
|
|
3746
|
-
|
|
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:
|
|
3747
3759
|
_yield$Promise$all7 = _context14.sent;
|
|
3748
3760
|
totalDeposited = _yield$Promise$all7[0];
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
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);
|
|
3756
3771
|
|
|
3757
3772
|
case 11:
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
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()]);
|
|
3808
|
+
|
|
3809
|
+
case 11:
|
|
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", {
|
|
3765
3818
|
auTokenAddress: this.auToken.address,
|
|
3766
3819
|
totalTokenDeposited: totalDeposited,
|
|
3767
3820
|
totalTokenBorrowed: totalBorrowed,
|
|
@@ -3774,15 +3827,16 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3774
3827
|
borrowPlyPerWeek: new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.mul(ONE_DAY).mul(7).toString()),
|
|
3775
3828
|
depositNEARApy: depositNearAPY.toNumber(),
|
|
3776
3829
|
borrowNEARApy: borrowNearAPY.toNumber() * -1,
|
|
3777
|
-
depositMETAApy: depositMetaAPY.toNumber()
|
|
3830
|
+
depositMETAApy: depositMetaAPY.toNumber(),
|
|
3831
|
+
staderDepositApy: staderDepositApy.toNumber()
|
|
3778
3832
|
});
|
|
3779
3833
|
|
|
3780
|
-
case
|
|
3834
|
+
case 19:
|
|
3781
3835
|
case "end":
|
|
3782
|
-
return
|
|
3836
|
+
return _context15.stop();
|
|
3783
3837
|
}
|
|
3784
3838
|
}
|
|
3785
|
-
},
|
|
3839
|
+
}, _callee15, this);
|
|
3786
3840
|
}));
|
|
3787
3841
|
|
|
3788
3842
|
function getDetails() {
|
|
@@ -3793,25 +3847,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3793
3847
|
}();
|
|
3794
3848
|
|
|
3795
3849
|
_proto.getUserBorrowBalance = /*#__PURE__*/function () {
|
|
3796
|
-
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3850
|
+
var _getUserBorrowBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(userAddress) {
|
|
3797
3851
|
var totalBorrow;
|
|
3798
|
-
return runtime_1.wrap(function
|
|
3852
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
3799
3853
|
while (1) {
|
|
3800
|
-
switch (
|
|
3854
|
+
switch (_context16.prev = _context16.next) {
|
|
3801
3855
|
case 0:
|
|
3802
|
-
|
|
3856
|
+
_context16.next = 2;
|
|
3803
3857
|
return this.auToken.callStatic.borrowBalanceCurrent(userAddress);
|
|
3804
3858
|
|
|
3805
3859
|
case 2:
|
|
3806
|
-
totalBorrow =
|
|
3807
|
-
return
|
|
3860
|
+
totalBorrow = _context16.sent;
|
|
3861
|
+
return _context16.abrupt("return", new TokenAmount(this.underlying, totalBorrow.toString()));
|
|
3808
3862
|
|
|
3809
3863
|
case 4:
|
|
3810
3864
|
case "end":
|
|
3811
|
-
return
|
|
3865
|
+
return _context16.stop();
|
|
3812
3866
|
}
|
|
3813
3867
|
}
|
|
3814
|
-
},
|
|
3868
|
+
}, _callee16, this);
|
|
3815
3869
|
}));
|
|
3816
3870
|
|
|
3817
3871
|
function getUserBorrowBalance(_x) {
|
|
@@ -3822,25 +3876,25 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3822
3876
|
}();
|
|
3823
3877
|
|
|
3824
3878
|
_proto.getUserDepositBalance = /*#__PURE__*/function () {
|
|
3825
|
-
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3879
|
+
var _getUserDepositBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(userAddress) {
|
|
3826
3880
|
var totalDeposit;
|
|
3827
|
-
return runtime_1.wrap(function
|
|
3881
|
+
return runtime_1.wrap(function _callee17$(_context17) {
|
|
3828
3882
|
while (1) {
|
|
3829
|
-
switch (
|
|
3883
|
+
switch (_context17.prev = _context17.next) {
|
|
3830
3884
|
case 0:
|
|
3831
|
-
|
|
3885
|
+
_context17.next = 2;
|
|
3832
3886
|
return this.auToken.callStatic.balanceOfUnderlying(userAddress);
|
|
3833
3887
|
|
|
3834
3888
|
case 2:
|
|
3835
|
-
totalDeposit =
|
|
3836
|
-
return
|
|
3889
|
+
totalDeposit = _context17.sent;
|
|
3890
|
+
return _context17.abrupt("return", new TokenAmount(this.underlying, totalDeposit.toString()));
|
|
3837
3891
|
|
|
3838
3892
|
case 4:
|
|
3839
3893
|
case "end":
|
|
3840
|
-
return
|
|
3894
|
+
return _context17.stop();
|
|
3841
3895
|
}
|
|
3842
3896
|
}
|
|
3843
|
-
},
|
|
3897
|
+
}, _callee17, this);
|
|
3844
3898
|
}));
|
|
3845
3899
|
|
|
3846
3900
|
function getUserDepositBalance(_x2) {
|
|
@@ -3885,26 +3939,26 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3885
3939
|
};
|
|
3886
3940
|
|
|
3887
3941
|
_proto.mintCap = /*#__PURE__*/function () {
|
|
3888
|
-
var _mintCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3889
|
-
return runtime_1.wrap(function
|
|
3942
|
+
var _mintCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee18() {
|
|
3943
|
+
return runtime_1.wrap(function _callee18$(_context18) {
|
|
3890
3944
|
while (1) {
|
|
3891
|
-
switch (
|
|
3945
|
+
switch (_context18.prev = _context18.next) {
|
|
3892
3946
|
case 0:
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3947
|
+
_context18.t0 = TokenAmount;
|
|
3948
|
+
_context18.t1 = this.underlying;
|
|
3949
|
+
_context18.next = 4;
|
|
3896
3950
|
return this.env.comptroller.mintCaps(this.auToken.address);
|
|
3897
3951
|
|
|
3898
3952
|
case 4:
|
|
3899
|
-
|
|
3900
|
-
return
|
|
3953
|
+
_context18.t2 = _context18.sent.toString();
|
|
3954
|
+
return _context18.abrupt("return", new _context18.t0(_context18.t1, _context18.t2));
|
|
3901
3955
|
|
|
3902
3956
|
case 6:
|
|
3903
3957
|
case "end":
|
|
3904
|
-
return
|
|
3958
|
+
return _context18.stop();
|
|
3905
3959
|
}
|
|
3906
3960
|
}
|
|
3907
|
-
},
|
|
3961
|
+
}, _callee18, this);
|
|
3908
3962
|
}));
|
|
3909
3963
|
|
|
3910
3964
|
function mintCap() {
|
|
@@ -3915,26 +3969,26 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3915
3969
|
}();
|
|
3916
3970
|
|
|
3917
3971
|
_proto.borrowCap = /*#__PURE__*/function () {
|
|
3918
|
-
var _borrowCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3919
|
-
return runtime_1.wrap(function
|
|
3972
|
+
var _borrowCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19() {
|
|
3973
|
+
return runtime_1.wrap(function _callee19$(_context19) {
|
|
3920
3974
|
while (1) {
|
|
3921
|
-
switch (
|
|
3975
|
+
switch (_context19.prev = _context19.next) {
|
|
3922
3976
|
case 0:
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3977
|
+
_context19.t0 = TokenAmount;
|
|
3978
|
+
_context19.t1 = this.underlying;
|
|
3979
|
+
_context19.next = 4;
|
|
3926
3980
|
return this.env.comptroller.borrowCaps(this.auToken.address);
|
|
3927
3981
|
|
|
3928
3982
|
case 4:
|
|
3929
|
-
|
|
3930
|
-
return
|
|
3983
|
+
_context19.t2 = _context19.sent.toString();
|
|
3984
|
+
return _context19.abrupt("return", new _context19.t0(_context19.t1, _context19.t2));
|
|
3931
3985
|
|
|
3932
3986
|
case 6:
|
|
3933
3987
|
case "end":
|
|
3934
|
-
return
|
|
3988
|
+
return _context19.stop();
|
|
3935
3989
|
}
|
|
3936
3990
|
}
|
|
3937
|
-
},
|
|
3991
|
+
}, _callee19, this);
|
|
3938
3992
|
}));
|
|
3939
3993
|
|
|
3940
3994
|
function borrowCap() {
|
|
@@ -3945,27 +3999,27 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3945
3999
|
}();
|
|
3946
4000
|
|
|
3947
4001
|
_proto.getApyWithoutIncentive = /*#__PURE__*/function () {
|
|
3948
|
-
var _getApyWithoutIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3949
|
-
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;
|
|
3950
4004
|
|
|
3951
|
-
return runtime_1.wrap(function
|
|
4005
|
+
return runtime_1.wrap(function _callee20$(_context20) {
|
|
3952
4006
|
while (1) {
|
|
3953
|
-
switch (
|
|
4007
|
+
switch (_context20.prev = _context20.next) {
|
|
3954
4008
|
case 0:
|
|
3955
|
-
|
|
4009
|
+
_context20.next = 2;
|
|
3956
4010
|
return Promise.all([this.getUnderlyingPrice(), this.getDepositAPY(), this.getBorrowAPY(), this.getUserDepositBalance(userAddress), this.getUserBorrowBalance(userAddress)]);
|
|
3957
4011
|
|
|
3958
4012
|
case 2:
|
|
3959
|
-
_yield$Promise$
|
|
3960
|
-
price = _yield$Promise$
|
|
3961
|
-
depositApy = _yield$Promise$
|
|
3962
|
-
borrowApy = _yield$Promise$
|
|
3963
|
-
depositBalance = _yield$Promise$
|
|
3964
|
-
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];
|
|
3965
4019
|
suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
3966
4020
|
borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
3967
4021
|
sum = calcNetApy(suppliedValue, depositApy, borrowedValue, borrowApy);
|
|
3968
|
-
return
|
|
4022
|
+
return _context20.abrupt("return", {
|
|
3969
4023
|
sum: sum,
|
|
3970
4024
|
suppliedValue: suppliedValue,
|
|
3971
4025
|
borrowedValue: borrowedValue
|
|
@@ -3973,10 +4027,10 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3973
4027
|
|
|
3974
4028
|
case 12:
|
|
3975
4029
|
case "end":
|
|
3976
|
-
return
|
|
4030
|
+
return _context20.stop();
|
|
3977
4031
|
}
|
|
3978
4032
|
}
|
|
3979
|
-
},
|
|
4033
|
+
}, _callee20, this);
|
|
3980
4034
|
}));
|
|
3981
4035
|
|
|
3982
4036
|
function getApyWithoutIncentive(_x3) {
|
|
@@ -3987,45 +4041,50 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3987
4041
|
}();
|
|
3988
4042
|
|
|
3989
4043
|
_proto.getApyWithIncentive = /*#__PURE__*/function () {
|
|
3990
|
-
var _getApyWithIncentive = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3991
|
-
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;
|
|
3992
4046
|
|
|
3993
|
-
return runtime_1.wrap(function
|
|
4047
|
+
return runtime_1.wrap(function _callee21$(_context21) {
|
|
3994
4048
|
while (1) {
|
|
3995
|
-
switch (
|
|
4049
|
+
switch (_context21.prev = _context21.next) {
|
|
3996
4050
|
case 0:
|
|
3997
|
-
|
|
4051
|
+
_context21.next = 2;
|
|
3998
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()]);
|
|
3999
4053
|
|
|
4000
4054
|
case 2:
|
|
4001
|
-
_yield$Promise$
|
|
4002
|
-
price = _yield$Promise$
|
|
4003
|
-
depositApy = _yield$Promise$
|
|
4004
|
-
borrowApy = _yield$Promise$
|
|
4005
|
-
depositBalance = _yield$Promise$
|
|
4006
|
-
borrowBalance = _yield$Promise$
|
|
4007
|
-
nearDepositApy = _yield$Promise$
|
|
4008
|
-
plyDepositApy = _yield$Promise$
|
|
4009
|
-
metaDepositApy = _yield$Promise$
|
|
4010
|
-
nearBorrowApy = _yield$Promise$
|
|
4011
|
-
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;
|
|
4012
4071
|
suppliedValue = price.multipliedBy(depositBalance.formattedAmount());
|
|
4013
4072
|
borrowedValue = price.multipliedBy(borrowBalance.formattedAmount());
|
|
4014
|
-
totalDepositApy = depositApy.plus(nearDepositApy).plus(plyDepositApy).plus(metaDepositApy);
|
|
4073
|
+
totalDepositApy = depositApy.plus(nearDepositApy).plus(plyDepositApy).plus(metaDepositApy).plus(staderDepositApy);
|
|
4015
4074
|
totalBorrowApy = borrowApy.plus(nearBorrowApy).plus(plyBorrowApy);
|
|
4016
4075
|
sum = calcNetApy(suppliedValue, totalDepositApy, borrowedValue, totalBorrowApy);
|
|
4017
|
-
return
|
|
4076
|
+
return _context21.abrupt("return", {
|
|
4018
4077
|
sum: sum,
|
|
4019
4078
|
suppliedValue: suppliedValue,
|
|
4020
4079
|
borrowedValue: borrowedValue
|
|
4021
4080
|
});
|
|
4022
4081
|
|
|
4023
|
-
case
|
|
4082
|
+
case 22:
|
|
4024
4083
|
case "end":
|
|
4025
|
-
return
|
|
4084
|
+
return _context21.stop();
|
|
4026
4085
|
}
|
|
4027
4086
|
}
|
|
4028
|
-
},
|
|
4087
|
+
}, _callee21, this);
|
|
4029
4088
|
}));
|
|
4030
4089
|
|
|
4031
4090
|
function getApyWithIncentive(_x4) {
|
|
@@ -4103,6 +4162,11 @@ tslib.__decorate([cacheDecorator.cache({
|
|
|
4103
4162
|
type: cacheDecorator.CacheType.MEMO
|
|
4104
4163
|
}), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositMetaAPY", null);
|
|
4105
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
|
+
|
|
4106
4170
|
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
4107
4171
|
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
4108
4172
|
|
|
@@ -4117,29 +4181,29 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4117
4181
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
4118
4182
|
|
|
4119
4183
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
4120
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4121
|
-
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) {
|
|
4122
4186
|
while (1) {
|
|
4123
|
-
switch (
|
|
4187
|
+
switch (_context22.prev = _context22.next) {
|
|
4124
4188
|
case 0:
|
|
4125
4189
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
4126
|
-
|
|
4190
|
+
_context22.next = 4;
|
|
4127
4191
|
break;
|
|
4128
4192
|
}
|
|
4129
4193
|
|
|
4130
|
-
return
|
|
4194
|
+
return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
4131
4195
|
value: amount.rawAmount()
|
|
4132
4196
|
}));
|
|
4133
4197
|
|
|
4134
4198
|
case 4:
|
|
4135
|
-
return
|
|
4199
|
+
return _context22.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
4136
4200
|
|
|
4137
4201
|
case 5:
|
|
4138
4202
|
case "end":
|
|
4139
|
-
return
|
|
4203
|
+
return _context22.stop();
|
|
4140
4204
|
}
|
|
4141
4205
|
}
|
|
4142
|
-
},
|
|
4206
|
+
}, _callee22, this);
|
|
4143
4207
|
}));
|
|
4144
4208
|
|
|
4145
4209
|
function deposit(_x5) {
|
|
@@ -4150,19 +4214,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4150
4214
|
}();
|
|
4151
4215
|
|
|
4152
4216
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
4153
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4154
|
-
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) {
|
|
4155
4219
|
while (1) {
|
|
4156
|
-
switch (
|
|
4220
|
+
switch (_context23.prev = _context23.next) {
|
|
4157
4221
|
case 0:
|
|
4158
|
-
return
|
|
4222
|
+
return _context23.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
4159
4223
|
|
|
4160
4224
|
case 1:
|
|
4161
4225
|
case "end":
|
|
4162
|
-
return
|
|
4226
|
+
return _context23.stop();
|
|
4163
4227
|
}
|
|
4164
4228
|
}
|
|
4165
|
-
},
|
|
4229
|
+
}, _callee23, this);
|
|
4166
4230
|
}));
|
|
4167
4231
|
|
|
4168
4232
|
function borrow(_x6) {
|
|
@@ -4173,27 +4237,27 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4173
4237
|
}();
|
|
4174
4238
|
|
|
4175
4239
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
4176
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4177
|
-
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) {
|
|
4178
4242
|
while (1) {
|
|
4179
|
-
switch (
|
|
4243
|
+
switch (_context24.prev = _context24.next) {
|
|
4180
4244
|
case 0:
|
|
4181
4245
|
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
4182
|
-
|
|
4246
|
+
_context24.next = 2;
|
|
4183
4247
|
break;
|
|
4184
4248
|
}
|
|
4185
4249
|
|
|
4186
|
-
return
|
|
4250
|
+
return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
|
|
4187
4251
|
|
|
4188
4252
|
case 2:
|
|
4189
|
-
return
|
|
4253
|
+
return _context24.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
4190
4254
|
|
|
4191
4255
|
case 3:
|
|
4192
4256
|
case "end":
|
|
4193
|
-
return
|
|
4257
|
+
return _context24.stop();
|
|
4194
4258
|
}
|
|
4195
4259
|
}
|
|
4196
|
-
},
|
|
4260
|
+
}, _callee24, this);
|
|
4197
4261
|
}));
|
|
4198
4262
|
|
|
4199
4263
|
function withdraw(_x7) {
|
|
@@ -4204,37 +4268,37 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4204
4268
|
}();
|
|
4205
4269
|
|
|
4206
4270
|
_proto2.repay = /*#__PURE__*/function () {
|
|
4207
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4208
|
-
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) {
|
|
4209
4273
|
while (1) {
|
|
4210
|
-
switch (
|
|
4274
|
+
switch (_context25.prev = _context25.next) {
|
|
4211
4275
|
case 0:
|
|
4212
4276
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
4213
|
-
|
|
4277
|
+
_context25.next = 4;
|
|
4214
4278
|
break;
|
|
4215
4279
|
}
|
|
4216
4280
|
|
|
4217
|
-
return
|
|
4281
|
+
return _context25.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
|
|
4218
4282
|
value: amount.rawAmount()
|
|
4219
4283
|
}));
|
|
4220
4284
|
|
|
4221
4285
|
case 4:
|
|
4222
4286
|
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
4223
|
-
|
|
4287
|
+
_context25.next = 8;
|
|
4224
4288
|
break;
|
|
4225
4289
|
}
|
|
4226
4290
|
|
|
4227
|
-
return
|
|
4291
|
+
return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
|
|
4228
4292
|
|
|
4229
4293
|
case 8:
|
|
4230
|
-
return
|
|
4294
|
+
return _context25.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
4231
4295
|
|
|
4232
4296
|
case 9:
|
|
4233
4297
|
case "end":
|
|
4234
|
-
return
|
|
4298
|
+
return _context25.stop();
|
|
4235
4299
|
}
|
|
4236
4300
|
}
|
|
4237
|
-
},
|
|
4301
|
+
}, _callee25, this);
|
|
4238
4302
|
}));
|
|
4239
4303
|
|
|
4240
4304
|
function repay(_x8) {
|
|
@@ -4245,19 +4309,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4245
4309
|
}();
|
|
4246
4310
|
|
|
4247
4311
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
4248
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4249
|
-
return runtime_1.wrap(function
|
|
4312
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee26() {
|
|
4313
|
+
return runtime_1.wrap(function _callee26$(_context26) {
|
|
4250
4314
|
while (1) {
|
|
4251
|
-
switch (
|
|
4315
|
+
switch (_context26.prev = _context26.next) {
|
|
4252
4316
|
case 0:
|
|
4253
|
-
return
|
|
4317
|
+
return _context26.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
4254
4318
|
|
|
4255
4319
|
case 1:
|
|
4256
4320
|
case "end":
|
|
4257
|
-
return
|
|
4321
|
+
return _context26.stop();
|
|
4258
4322
|
}
|
|
4259
4323
|
}
|
|
4260
|
-
},
|
|
4324
|
+
}, _callee26, this);
|
|
4261
4325
|
}));
|
|
4262
4326
|
|
|
4263
4327
|
function enableCollateral() {
|
|
@@ -4268,19 +4332,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
4268
4332
|
}();
|
|
4269
4333
|
|
|
4270
4334
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
4271
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4272
|
-
return runtime_1.wrap(function
|
|
4335
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee27() {
|
|
4336
|
+
return runtime_1.wrap(function _callee27$(_context27) {
|
|
4273
4337
|
while (1) {
|
|
4274
|
-
switch (
|
|
4338
|
+
switch (_context27.prev = _context27.next) {
|
|
4275
4339
|
case 0:
|
|
4276
|
-
return
|
|
4340
|
+
return _context27.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
4277
4341
|
|
|
4278
4342
|
case 1:
|
|
4279
4343
|
case "end":
|
|
4280
|
-
return
|
|
4344
|
+
return _context27.stop();
|
|
4281
4345
|
}
|
|
4282
4346
|
}
|
|
4283
|
-
},
|
|
4347
|
+
}, _callee27, this);
|
|
4284
4348
|
}));
|
|
4285
4349
|
|
|
4286
4350
|
function disableCollateral() {
|