@aurigami/sdk 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SDK.d.ts +4 -3
- package/dist/constants.d.ts +3 -1
- package/dist/priceFetcher.d.ts +2 -1
- package/dist/sdk.cjs.development.js +104 -72
- 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 +106 -75
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
- package/src/MoneyMarket.ts +7 -6
- package/src/SDK.ts +46 -12
- package/src/constants.ts +17 -27
- package/src/decimals.ts +10 -14
- package/src/dummy.ts +2 -1
- package/src/priceFetcher.ts +7 -5
- package/src/types.ts +8 -0
package/dist/SDK.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
|
|
2
|
-
import { LockingDetails, PlyAuroraPoolDetails, NetworkConnection, UserDetails, UserMarketDetails, CurrencyAmount, HypotheticalStats } from './types';
|
|
2
|
+
import { LockingDetails, PlyAuroraPoolDetails, NetworkConnection, UserDetails, UserMarketDetails, CurrencyAmount, HypotheticalStats, MarketAction } from './types';
|
|
3
3
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
4
4
|
import { Contract } from 'ethers';
|
|
5
5
|
import { AuriFairLaunch, Comptroller, TokenLock } from '@aurigami/contracts/typechain';
|
|
@@ -16,11 +16,12 @@ export declare class SdkRead extends BlockchainEntityRead {
|
|
|
16
16
|
getPlyAuroraPoolDetails(): Promise<PlyAuroraPoolDetails>;
|
|
17
17
|
getTokenPrice(token: Token): Promise<CurrencyAmount>;
|
|
18
18
|
stakeBalanceOf(user: string): Promise<TokenAmount>;
|
|
19
|
-
calcHypotheticalStats(
|
|
19
|
+
calcHypotheticalStats({ userMarketDetail, currentBorrowLimit, currentBorrowValuation, action, tokenAmount }: {
|
|
20
20
|
userMarketDetail: UserMarketDetails;
|
|
21
21
|
currentBorrowLimit: CurrencyAmount;
|
|
22
22
|
currentBorrowValuation: CurrencyAmount;
|
|
23
|
-
|
|
23
|
+
action: MarketAction;
|
|
24
|
+
tokenAmount?: TokenAmount;
|
|
24
25
|
}): HypotheticalStats;
|
|
25
26
|
}
|
|
26
27
|
export declare class SdkReadWrite extends SdkRead {
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
2
3
|
export declare const dummyAddress: string;
|
|
3
4
|
export declare const ETHAddress: string;
|
|
4
5
|
export declare const AURORA_CHAINID = 1313161554;
|
|
5
|
-
export declare const DECIMAL_PRECISION =
|
|
6
|
+
export declare const DECIMAL_PRECISION = 10;
|
|
6
7
|
export declare type NetworkAddresses = {
|
|
7
8
|
auTokens: {
|
|
8
9
|
address: string;
|
|
@@ -17,3 +18,4 @@ export declare const REWARDCLAIMSTART = 1640995200;
|
|
|
17
18
|
export declare const ONE_DAY = 86400;
|
|
18
19
|
export declare const ONE_YEAR: number;
|
|
19
20
|
export declare const AurPlyPid = 0;
|
|
21
|
+
export declare const INF: ethers.BigNumber;
|
package/dist/priceFetcher.d.ts
CHANGED
|
@@ -18,4 +18,5 @@ export declare function fetchUnderlyingTokensPrices(provider: providers.Provider
|
|
|
18
18
|
underlyingPrice: BigNumber;
|
|
19
19
|
}[]>;
|
|
20
20
|
export declare function fetchPrice(address: Address, provider: providers.Provider): Promise<BigNumber>;
|
|
21
|
-
export declare function fetchValuation(tokenAmount: TokenAmount, provider: providers.Provider
|
|
21
|
+
export declare function fetchValuation(tokenAmount: TokenAmount, provider: providers.Provider): Promise<BigNumber>;
|
|
22
|
+
export declare function calcValuation(tokenAmount: TokenAmount, price: BigNumber): BigNumber;
|
|
@@ -897,47 +897,52 @@ var BlockchainEntity = /*#__PURE__*/function () {
|
|
|
897
897
|
return BlockchainEntity;
|
|
898
898
|
}();
|
|
899
899
|
|
|
900
|
+
(function (ComptrollerRewardType) {
|
|
901
|
+
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
902
|
+
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
903
|
+
})(exports.ComptrollerRewardType || (exports.ComptrollerRewardType = {}));
|
|
904
|
+
|
|
905
|
+
(function (MarketAction) {
|
|
906
|
+
MarketAction[MarketAction["Deposit"] = 0] = "Deposit";
|
|
907
|
+
MarketAction[MarketAction["Borrow"] = 1] = "Borrow";
|
|
908
|
+
MarketAction[MarketAction["Withdraw"] = 2] = "Withdraw";
|
|
909
|
+
MarketAction[MarketAction["Repay"] = 3] = "Repay";
|
|
910
|
+
MarketAction[MarketAction["EnableCollateral"] = 4] = "EnableCollateral";
|
|
911
|
+
MarketAction[MarketAction["DisableCollateral"] = 5] = "DisableCollateral";
|
|
912
|
+
})(exports.MarketAction || (exports.MarketAction = {}));
|
|
913
|
+
|
|
900
914
|
var dummyAddress = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
|
|
901
915
|
var ETHAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
902
916
|
var AURORA_CHAINID = 1313161554;
|
|
903
|
-
var DECIMAL_PRECISION =
|
|
917
|
+
var DECIMAL_PRECISION = 10;
|
|
904
918
|
var networkAddresses = {
|
|
905
919
|
auTokens: [{
|
|
906
|
-
address: /*#__PURE__*/'
|
|
920
|
+
address: /*#__PURE__*/'0x8bA0b797F3A965C12EF49d924d154B71d63316b5'.toLowerCase(),
|
|
907
921
|
underlying: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
|
|
908
922
|
}, {
|
|
909
|
-
address: /*#__PURE__*/'
|
|
923
|
+
address: /*#__PURE__*/'0xA2926acb1BEdBC827000FCA08D4279aC3Bb6a443'.toLowerCase(),
|
|
910
924
|
underlying: /*#__PURE__*/ETHAddress.toLowerCase()
|
|
911
925
|
}, {
|
|
912
|
-
address: /*#__PURE__*/'
|
|
926
|
+
address: /*#__PURE__*/'0x4176c37161E1873FA08C8301c45D4cC02293AF44'.toLowerCase(),
|
|
913
927
|
underlying: /*#__PURE__*/'0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
|
|
914
928
|
}, {
|
|
915
|
-
address: /*#__PURE__*/'
|
|
929
|
+
address: /*#__PURE__*/'0xaE1B4372e6881f69Caeb44D0793ed710bb345278'.toLowerCase(),
|
|
916
930
|
underlying: /*#__PURE__*/'0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
|
|
917
931
|
}, {
|
|
918
|
-
address: /*#__PURE__*/'
|
|
932
|
+
address: /*#__PURE__*/'0x3d3b76B7E62a1f1bB08684933F63215e0582a149'.toLowerCase(),
|
|
919
933
|
underlying: /*#__PURE__*/'0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
|
|
920
|
-
}, {
|
|
921
|
-
address: /*#__PURE__*/'0x83Ae17f197C1F1260543d4D5A710772761535066'.toLowerCase(),
|
|
922
|
-
underlying: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase()
|
|
923
|
-
}, {
|
|
924
|
-
address: /*#__PURE__*/'0xcC5CA0156317C1FF2A96E0f45659625081352071'.toLowerCase(),
|
|
925
|
-
underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
|
|
926
|
-
}, {
|
|
927
|
-
address: /*#__PURE__*/'0x173Bf18675D52B4887C5d40E935C3ab1192aFb4C'.toLowerCase(),
|
|
928
|
-
underlying: /*#__PURE__*/'0xb9b8d9e5557381BF025f1A59B602ad3F19A4e4Be'.toLowerCase()
|
|
929
934
|
}],
|
|
930
935
|
misc: {
|
|
931
|
-
COMPTROLLER: /*#__PURE__*/"
|
|
932
|
-
oracle: /*#__PURE__*/"
|
|
933
|
-
AURIFAIRLAUNCH: /*#__PURE__*/"
|
|
934
|
-
AURILENS: /*#__PURE__*/'
|
|
935
|
-
TOKENLOCK: /*#__PURE__*/'
|
|
936
|
+
COMPTROLLER: /*#__PURE__*/"0x448717B7Be11C3fb7AA7f0284f28B399D0004fE1".toLowerCase(),
|
|
937
|
+
oracle: /*#__PURE__*/"0xfD47837a18ad6a72F564903a7E5162286E059224".toLowerCase(),
|
|
938
|
+
AURIFAIRLAUNCH: /*#__PURE__*/"0x986e3ac1bC3C02714C9Bfd73Cd6a206F10600b4c".toLowerCase(),
|
|
939
|
+
AURILENS: /*#__PURE__*/'0xE770e5f08251622F368Bf1a449E072627Ff6cB62'.toLowerCase(),
|
|
940
|
+
TOKENLOCK: /*#__PURE__*/'0xE130E307eF5b5c157FB233320b7ebD08f2fD320A'.toLowerCase()
|
|
936
941
|
},
|
|
937
942
|
tokens: {
|
|
938
|
-
AURORA: /*#__PURE__*/"
|
|
939
|
-
PLY: /*#__PURE__*/"
|
|
940
|
-
AURPLY: /*#__PURE__*/"
|
|
943
|
+
AURORA: /*#__PURE__*/"0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79".toLowerCase(),
|
|
944
|
+
PLY: /*#__PURE__*/"0x706bd3b9473126D2E7dCA097d7AAc5dB74918E6c".toLowerCase(),
|
|
945
|
+
AURPLY: /*#__PURE__*/"0x95890d73F2995E621F6A66EF9b71413926845542".toLowerCase()
|
|
941
946
|
}
|
|
942
947
|
};
|
|
943
948
|
var BORROW_LIMIT_BUFFER = /*#__PURE__*/new BigNumber(0.95);
|
|
@@ -945,25 +950,22 @@ var REWARDCLAIMSTART = 1640995200;
|
|
|
945
950
|
var ONE_DAY = 86400;
|
|
946
951
|
var ONE_YEAR = ONE_DAY * 365;
|
|
947
952
|
var AurPlyPid = 0;
|
|
953
|
+
var INF = /*#__PURE__*/ethers.BigNumber.from(2).pow(256).sub(1);
|
|
948
954
|
|
|
949
955
|
var decimalRecords = {
|
|
950
956
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
951
|
-
'
|
|
952
|
-
'
|
|
957
|
+
'0x4176c37161e1873fa08c8301c45d4cc02293af44': 8,
|
|
958
|
+
'0x95890d73f2995e621f6a66ef9b71413926845542': 18,
|
|
959
|
+
'0x3d3b76b7e62a1f1bb08684933f63215e0582a149': 8,
|
|
953
960
|
'0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
|
|
954
|
-
'
|
|
955
|
-
'0xfb0e4680b8b1c7b69fb6a3988029c74fea871dd9': 8,
|
|
961
|
+
'0x8ba0b797f3a965c12ef49d924d154b71d63316b5': 8,
|
|
956
962
|
'0xb12bfca5a55806aaf64e99521918a4bf0fc40802': 6,
|
|
957
|
-
'
|
|
958
|
-
'0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24,
|
|
959
|
-
'0x7b47690b04494a628151dbb86b4cc95cf2629b14': 8,
|
|
960
|
-
'0x822e871518c22e8570cfbea43fddbbff963d4bde': 18,
|
|
961
|
-
'0x2def6eb801757655ad227110d65c80db595bbc60': 8,
|
|
962
|
-
'0x6bb82009b316a9098c23e3962b4371e879c8d23d': 8,
|
|
963
|
+
'0x706bd3b9473126d2e7dca097d7aac5db74918e6c': 18,
|
|
963
964
|
'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
|
|
964
|
-
'
|
|
965
|
-
'
|
|
966
|
-
'
|
|
965
|
+
'0xae1b4372e6881f69caeb44d0793ed710bb345278': 8,
|
|
966
|
+
'0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
|
|
967
|
+
'0xa2926acb1bedbc827000fca08d4279ac3bb6a443': 8,
|
|
968
|
+
'0xe3520349f477a5f6eb06107066048508498a291b': 18
|
|
967
969
|
};
|
|
968
970
|
|
|
969
971
|
function formatObject(object) {
|
|
@@ -1013,11 +1015,6 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1013
1015
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
1014
1016
|
}
|
|
1015
1017
|
|
|
1016
|
-
(function (ComptrollerRewardType) {
|
|
1017
|
-
ComptrollerRewardType[ComptrollerRewardType["PLY"] = 0] = "PLY";
|
|
1018
|
-
ComptrollerRewardType[ComptrollerRewardType["AURORA"] = 1] = "AURORA";
|
|
1019
|
-
})(exports.ComptrollerRewardType || (exports.ComptrollerRewardType = {}));
|
|
1020
|
-
|
|
1021
1018
|
var Token = function Token(address, decimals) {
|
|
1022
1019
|
this.address = address.toLowerCase();
|
|
1023
1020
|
this.decimals = decimals;
|
|
@@ -2271,31 +2268,25 @@ function _fetchPrice() {
|
|
|
2271
2268
|
return _fetchPrice.apply(this, arguments);
|
|
2272
2269
|
}
|
|
2273
2270
|
|
|
2274
|
-
function fetchValuation(_x13, _x14
|
|
2271
|
+
function fetchValuation(_x13, _x14) {
|
|
2275
2272
|
return _fetchValuation.apply(this, arguments);
|
|
2276
2273
|
}
|
|
2277
2274
|
|
|
2278
2275
|
function _fetchValuation() {
|
|
2279
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider
|
|
2276
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider) {
|
|
2277
|
+
var price;
|
|
2280
2278
|
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2281
2279
|
while (1) {
|
|
2282
2280
|
switch (_context8.prev = _context8.next) {
|
|
2283
2281
|
case 0:
|
|
2284
|
-
|
|
2285
|
-
_context8.next = 4;
|
|
2286
|
-
break;
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2289
|
-
_context8.next = 3;
|
|
2282
|
+
_context8.next = 2;
|
|
2290
2283
|
return fetchPrice(tokenAmount.token.address, provider);
|
|
2291
2284
|
|
|
2292
|
-
case
|
|
2285
|
+
case 2:
|
|
2293
2286
|
price = _context8.sent;
|
|
2287
|
+
return _context8.abrupt("return", calcValuation(tokenAmount, price));
|
|
2294
2288
|
|
|
2295
2289
|
case 4:
|
|
2296
|
-
return _context8.abrupt("return", new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price));
|
|
2297
|
-
|
|
2298
|
-
case 5:
|
|
2299
2290
|
case "end":
|
|
2300
2291
|
return _context8.stop();
|
|
2301
2292
|
}
|
|
@@ -2305,6 +2296,10 @@ function _fetchValuation() {
|
|
|
2305
2296
|
return _fetchValuation.apply(this, arguments);
|
|
2306
2297
|
}
|
|
2307
2298
|
|
|
2299
|
+
function calcValuation(tokenAmount, price) {
|
|
2300
|
+
return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price);
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2308
2303
|
var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
2309
2304
|
_inheritsLoose(MoneyMarketRead, _BlockchainEntityRead);
|
|
2310
2305
|
|
|
@@ -2626,7 +2621,7 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2626
2621
|
case 11:
|
|
2627
2622
|
_context9.t0 = calcLMRewardApr;
|
|
2628
2623
|
_context9.next = 14;
|
|
2629
|
-
return
|
|
2624
|
+
return calcValuation(new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.toString()), plyPrice);
|
|
2630
2625
|
|
|
2631
2626
|
case 14:
|
|
2632
2627
|
_context9.t1 = _context9.sent;
|
|
@@ -2635,7 +2630,7 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2635
2630
|
borrowPlyApy = (0, _context9.t0)(_context9.t1, _context9.t2, _context9.t3);
|
|
2636
2631
|
_context9.t4 = calcLMRewardApr;
|
|
2637
2632
|
_context9.next = 21;
|
|
2638
|
-
return
|
|
2633
|
+
return calcValuation(new TokenAmount(PLYToken, rewardSpeeds.plyRewardSupplySpeed.toString()), plyPrice);
|
|
2639
2634
|
|
|
2640
2635
|
case 21:
|
|
2641
2636
|
_context9.t5 = _context9.sent;
|
|
@@ -2799,9 +2794,17 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
2799
2794
|
while (1) {
|
|
2800
2795
|
switch (_context14.prev = _context14.next) {
|
|
2801
2796
|
case 0:
|
|
2797
|
+
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
2798
|
+
_context14.next = 2;
|
|
2799
|
+
break;
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
|
|
2803
|
+
|
|
2804
|
+
case 2:
|
|
2802
2805
|
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
2803
2806
|
|
|
2804
|
-
case
|
|
2807
|
+
case 3:
|
|
2805
2808
|
case "end":
|
|
2806
2809
|
return _context14.stop();
|
|
2807
2810
|
}
|
|
@@ -2987,7 +2990,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2987
2990
|
var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
|
|
2988
2991
|
var _this2 = this;
|
|
2989
2992
|
|
|
2990
|
-
var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices,
|
|
2993
|
+
var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, rewardBalancesMetadata, lockedAmount, values, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, maxWithdrawCap;
|
|
2991
2994
|
|
|
2992
2995
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2993
2996
|
while (1) {
|
|
@@ -3036,7 +3039,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3036
3039
|
|
|
3037
3040
|
case 12:
|
|
3038
3041
|
underlyingPrices = _context2.sent;
|
|
3039
|
-
|
|
3042
|
+
depositValues = [];
|
|
3040
3043
|
|
|
3041
3044
|
_loop = function _loop() {
|
|
3042
3045
|
var auToken = networkAddresses.auTokens[i];
|
|
@@ -3049,18 +3052,13 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3049
3052
|
userMarketDetails[i].isCollateral = false;
|
|
3050
3053
|
}
|
|
3051
3054
|
|
|
3052
|
-
|
|
3055
|
+
depositValues.push(calcValuation(userMarketDetails[i].depositBalance, underlyingPrices[i]));
|
|
3053
3056
|
};
|
|
3054
3057
|
|
|
3055
3058
|
for (i = 0; i < marketCount; i++) {
|
|
3056
3059
|
_loop();
|
|
3057
3060
|
}
|
|
3058
3061
|
|
|
3059
|
-
_context2.next = 18;
|
|
3060
|
-
return Promise.all(depositValuationPromises);
|
|
3061
|
-
|
|
3062
|
-
case 18:
|
|
3063
|
-
depositValues = _context2.sent;
|
|
3064
3062
|
totalBorrowLimit = depositValues.reduce(function (p, v, index) {
|
|
3065
3063
|
if (userMarketDetails[index].isCollateral) return p.plus(v.multipliedBy(userMarketDetails[index].collateralRatio));
|
|
3066
3064
|
return p;
|
|
@@ -3069,15 +3067,20 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3069
3067
|
promises.push(this._comptroller.getAccountLiquidity(userAddress));
|
|
3070
3068
|
promises.push(this._auriLens.callStatic.getRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, userAddress, [AurPlyPid]));
|
|
3071
3069
|
promises.push(this._tokenLock.lockedAmounts(userAddress));
|
|
3072
|
-
_context2.next =
|
|
3070
|
+
_context2.next = 23;
|
|
3073
3071
|
return Promise.all(promises);
|
|
3074
3072
|
|
|
3075
|
-
case
|
|
3073
|
+
case 23:
|
|
3076
3074
|
values = _context2.sent;
|
|
3077
3075
|
accountLiquidity = values[0];
|
|
3078
3076
|
rewardBalancesMetadata = values[1];
|
|
3079
3077
|
lockedAmount = values[2];
|
|
3080
3078
|
borrowedvaluation = totalBorrowLimit.minus(new BigNumber(accountLiquidity[1].toString()).div(decimalFactor(18)));
|
|
3079
|
+
|
|
3080
|
+
if (borrowedvaluation.lt("0.00001")) {
|
|
3081
|
+
borrowedvaluation = new BigNumber(0);
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3081
3084
|
bufferedBorrowLimit = totalBorrowLimit.multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3082
3085
|
minimumBorrowLimitAllowed = borrowedvaluation.div(BORROW_LIMIT_BUFFER);
|
|
3083
3086
|
|
|
@@ -3108,7 +3111,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3108
3111
|
}
|
|
3109
3112
|
});
|
|
3110
3113
|
|
|
3111
|
-
case
|
|
3114
|
+
case 34:
|
|
3112
3115
|
case "end":
|
|
3113
3116
|
return _context2.stop();
|
|
3114
3117
|
}
|
|
@@ -3231,15 +3234,41 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3231
3234
|
return stakeBalanceOf;
|
|
3232
3235
|
}();
|
|
3233
3236
|
|
|
3234
|
-
_proto.calcHypotheticalStats = function calcHypotheticalStats(
|
|
3235
|
-
var
|
|
3236
|
-
|
|
3237
|
+
_proto.calcHypotheticalStats = function calcHypotheticalStats(_ref) {
|
|
3238
|
+
var userMarketDetail = _ref.userMarketDetail,
|
|
3239
|
+
currentBorrowLimit = _ref.currentBorrowLimit,
|
|
3240
|
+
currentBorrowValuation = _ref.currentBorrowValuation,
|
|
3241
|
+
action = _ref.action,
|
|
3242
|
+
tokenAmount = _ref.tokenAmount;
|
|
3243
|
+
var newBorrowLimit = new BigNumber(currentBorrowLimit.amount),
|
|
3244
|
+
newBorrowValuation = new BigNumber(currentBorrowValuation.amount);
|
|
3245
|
+
|
|
3246
|
+
switch (action) {
|
|
3247
|
+
case exports.MarketAction.EnableCollateral:
|
|
3248
|
+
case exports.MarketAction.DisableCollateral:
|
|
3249
|
+
var deltaBorrowLimit = calcValuation(userMarketDetail.depositBalance, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3250
|
+
newBorrowLimit = action == exports.MarketAction.EnableCollateral ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
3251
|
+
break;
|
|
3252
|
+
|
|
3253
|
+
case exports.MarketAction.Deposit:
|
|
3254
|
+
case exports.MarketAction.Withdraw:
|
|
3255
|
+
deltaBorrowLimit = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice)).multipliedBy(userMarketDetail.collateralRatio).multipliedBy(BORROW_LIMIT_BUFFER);
|
|
3256
|
+
newBorrowLimit = action == exports.MarketAction.Deposit ? newBorrowLimit.plus(deltaBorrowLimit) : newBorrowLimit.minus(deltaBorrowLimit);
|
|
3257
|
+
break;
|
|
3258
|
+
|
|
3259
|
+
case exports.MarketAction.Borrow:
|
|
3260
|
+
case exports.MarketAction.Repay:
|
|
3261
|
+
var deltaBorrowValuation = calcValuation(tokenAmount, new BigNumber(userMarketDetail.underlyingPrice));
|
|
3262
|
+
newBorrowValuation = action == exports.MarketAction.Borrow ? newBorrowValuation.plus(deltaBorrowValuation) : newBorrowValuation.minus(deltaBorrowValuation);
|
|
3263
|
+
break;
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3237
3266
|
return {
|
|
3238
3267
|
newBorrowLimit: {
|
|
3239
3268
|
amount: newBorrowLimit.toFixed(DECIMAL_PRECISION),
|
|
3240
3269
|
currency: "USD"
|
|
3241
3270
|
},
|
|
3242
|
-
newBorrowUtilization:
|
|
3271
|
+
newBorrowUtilization: newBorrowValuation.div(newBorrowLimit).toNumber()
|
|
3243
3272
|
};
|
|
3244
3273
|
};
|
|
3245
3274
|
|
|
@@ -3359,7 +3388,8 @@ var dummyUserMarketDetails = {
|
|
|
3359
3388
|
borrowBalance: dummyZeroTokenAmount,
|
|
3360
3389
|
isCollateral: true,
|
|
3361
3390
|
maxWithdrawableAmount: dummyTokenAmount,
|
|
3362
|
-
collateralRatio: 0.5
|
|
3391
|
+
collateralRatio: 0.5,
|
|
3392
|
+
underlyingPrice: "1"
|
|
3363
3393
|
};
|
|
3364
3394
|
|
|
3365
3395
|
exports.AURORA_CHAINID = AURORA_CHAINID;
|
|
@@ -3371,6 +3401,7 @@ exports.BlockchainEntityRead = BlockchainEntityRead;
|
|
|
3371
3401
|
exports.BlockchainEntityReadWrite = BlockchainEntityReadWrite;
|
|
3372
3402
|
exports.DECIMAL_PRECISION = DECIMAL_PRECISION;
|
|
3373
3403
|
exports.ETHAddress = ETHAddress;
|
|
3404
|
+
exports.INF = INF;
|
|
3374
3405
|
exports.MoneyMarket = MoneyMarket;
|
|
3375
3406
|
exports.MoneyMarketRead = MoneyMarketRead;
|
|
3376
3407
|
exports.MoneyMarketReadWrite = MoneyMarketReadWrite;
|
|
@@ -3384,6 +3415,7 @@ exports.SdkReadWrite = SdkReadWrite;
|
|
|
3384
3415
|
exports.Token = Token;
|
|
3385
3416
|
exports.TokenAmount = TokenAmount;
|
|
3386
3417
|
exports.calcLMRewardApr = calcLMRewardApr;
|
|
3418
|
+
exports.calcValuation = calcValuation;
|
|
3387
3419
|
exports.decimalFactor = decimalFactor;
|
|
3388
3420
|
exports.dummyAddress = dummyAddress;
|
|
3389
3421
|
exports.dummyMarketAddress = dummyMarketAddress;
|