impermax-sdk 1.2.8 → 1.2.10
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.
|
@@ -5,10 +5,12 @@ import OffchainAccountLendingVault from './offchainAccountLendingVault';
|
|
|
5
5
|
import { LendingVaultPosition, UserData } from '../offchainTypes';
|
|
6
6
|
export default class OffchainAccount {
|
|
7
7
|
private readonly offchain;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly accountAddress;
|
|
9
9
|
private lendingPools;
|
|
10
10
|
private lendingVaults;
|
|
11
11
|
constructor(offchain: Offchain, account: Address);
|
|
12
|
+
getOnchain: () => Offchain;
|
|
13
|
+
getAccountAddress: () => string;
|
|
12
14
|
private initializeLendingPool;
|
|
13
15
|
getLendingPool(factory: Factory, pair: Address): Promise<OffchainAccountLendingPool>;
|
|
14
16
|
private initializeLendingVault;
|
|
@@ -16,8 +16,10 @@ const lendingPool_1 = __importDefault(require("./lendingPool"));
|
|
|
16
16
|
const offchainAccountLendingVault_1 = __importDefault(require("./offchainAccountLendingVault"));
|
|
17
17
|
class OffchainAccount {
|
|
18
18
|
constructor(offchain, account) {
|
|
19
|
+
this.getOnchain = () => this.offchain;
|
|
20
|
+
this.getAccountAddress = () => this.accountAddress;
|
|
19
21
|
this.offchain = offchain;
|
|
20
|
-
this.
|
|
22
|
+
this.accountAddress = account;
|
|
21
23
|
this.lendingPools = {};
|
|
22
24
|
this.lendingVaults = {};
|
|
23
25
|
}
|
|
@@ -52,12 +54,12 @@ class OffchainAccount {
|
|
|
52
54
|
}
|
|
53
55
|
getUserData() {
|
|
54
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return this.offchain.getUserData(this.
|
|
57
|
+
return this.offchain.getUserData(this.accountAddress);
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
getLendingVaultsUserData() {
|
|
59
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return this.offchain.getLendingVaultsUserData(this.
|
|
62
|
+
return this.offchain.getLendingVaultsUserData(this.accountAddress);
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
getBorrowPositions() {
|
|
@@ -19,6 +19,7 @@ export default class OffchainLendingVault extends OffchainPoolToken {
|
|
|
19
19
|
getSupplyRate(): Promise<number>;
|
|
20
20
|
getSupplyAPR(): Promise<number>;
|
|
21
21
|
getAvailableLiquidity(): Promise<number>;
|
|
22
|
+
getAvailableLiquidityUSD(): Promise<number>;
|
|
22
23
|
getTokenPriceFast(fallback?: boolean): Promise<number>;
|
|
23
24
|
getTokenPriceAccurate(): Promise<number>;
|
|
24
25
|
}
|
|
@@ -88,7 +88,14 @@ class OffchainLendingVault extends offchainPoolToken_1.default {
|
|
|
88
88
|
// Available Liquidity
|
|
89
89
|
getAvailableLiquidity() {
|
|
90
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
return this.getPoolTokenParamFloat("availableLiquidity");
|
|
91
|
+
return Math.min(yield this.getPoolTokenParamFloat("availableLiquidity"), yield this.getVaultSupply());
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
getAvailableLiquidityUSD() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const availableLiquidity = yield this.getAvailableLiquidity();
|
|
97
|
+
const tokenPrice = yield this.getTokenPriceFast();
|
|
98
|
+
return availableLiquidity * tokenPrice;
|
|
92
99
|
});
|
|
93
100
|
}
|
|
94
101
|
// Token price getters
|