impermax-sdk 1.2.112 → 2.1.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/lib/abis/contracts/IAllowanceTransfer.json +3772 -0
- package/lib/abis/contracts/IERC721.json +3515 -0
- package/lib/abis/contracts/ITokenizedUniswapV2Position.json +4167 -0
- package/lib/abis/contracts/ITokenizedUniswapV3Position.json +5539 -0
- package/lib/abis/contracts/IUniswapV3Pool.json +6606 -0
- package/lib/abis/contracts/ImpermaxV3Borrowable.json +22131 -0
- package/lib/abis/contracts/ImpermaxV3Collateral.json +22988 -0
- package/lib/abis/contracts/ImpermaxV3Factory.json +17645 -0
- package/lib/abis/contracts/ImpermaxV3UniV2Router01.json +32488 -0
- package/lib/abis/contracts/ImpermaxV3UniV3Router01.json +37742 -0
- package/lib/abis/contracts/PoolTokenRouter01.json +9058 -0
- package/lib/config/amms.d.ts +0 -2
- package/lib/config/amms.js +0 -3
- package/lib/config/chainId.d.ts +2 -0
- package/lib/config/chainId.js +26 -0
- package/lib/config/contracts/routers.d.ts +3 -2
- package/lib/config/contracts/routers.js +46 -22
- package/lib/config/factories.js +1 -0
- package/lib/config/farms.d.ts +0 -2
- package/lib/config/farms.js +0 -3
- package/lib/config/types.d.ts +14 -1
- package/lib/config/types.js +15 -1
- package/lib/index.d.ts +6 -5
- package/lib/index.js +11 -4
- package/lib/offchain/account/index.d.ts +4 -2
- package/lib/offchain/account/index.js +7 -3
- package/lib/offchain/account/lendingPool/index.d.ts +2 -1
- package/lib/offchain/account/lendingPool/index.js +3 -1
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.d.ts +0 -3
- package/lib/offchain/account/lendingPool/offchainAccountBorrowable.js +1 -27
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.d.ts +0 -2
- package/lib/offchain/account/lendingPool/offchainAccountCollateral.js +2 -14
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.d.ts +11 -4
- package/lib/offchain/account/lendingPool/offchainAccountLendingPool.js +16 -15
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.d.ts +25 -0
- package/lib/offchain/account/lendingPool/offchainLeveragedPosition.js +116 -0
- package/lib/offchain/account/offchainAccount.d.ts +6 -6
- package/lib/offchain/account/offchainAccount.js +7 -7
- package/lib/offchain/account/offchainMultichainAccount.d.ts +34 -0
- package/lib/offchain/account/offchainMultichainAccount.js +66 -0
- package/lib/offchain/account/vault/index.d.ts +3 -0
- package/lib/offchain/account/vault/index.js +7 -0
- package/lib/offchain/account/vault/offchainAccountVault.d.ts +16 -0
- package/lib/offchain/account/{offchainAccountLendingVault.js → vault/offchainAccountVault.js} +14 -14
- package/lib/offchain/index.d.ts +3 -2
- package/lib/offchain/index.js +5 -3
- package/lib/offchain/lendingPool/offchainCollateral.d.ts +1 -0
- package/lib/offchain/lendingPool/offchainCollateral.js +6 -0
- package/lib/offchain/lendingPool/offchainLendingPool.d.ts +14 -1
- package/lib/offchain/lendingPool/offchainLendingPool.js +47 -0
- package/lib/offchain/offchain.d.ts +8 -15
- package/lib/offchain/offchain.js +16 -19
- package/lib/offchain/offchainAPRHelper.js +0 -1
- package/lib/offchain/offchainInitializer.d.ts +4 -4
- package/lib/offchain/offchainInitializer.js +4 -4
- package/lib/offchain/offchainMultichain.d.ts +50 -0
- package/lib/offchain/offchainMultichain.js +75 -0
- package/lib/offchain/offchainTypes.d.ts +1 -1
- package/lib/offchain/vault/index.d.ts +6 -0
- package/lib/offchain/vault/index.js +14 -0
- package/lib/offchain/vault/offchainHedgedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainHedgedVault.js +57 -0
- package/lib/offchain/vault/offchainLendingVault.d.ts +16 -0
- package/lib/offchain/vault/offchainLendingVault.js +73 -0
- package/lib/offchain/vault/offchainLeveragedVault.d.ts +9 -0
- package/lib/offchain/vault/offchainLeveragedVault.js +57 -0
- package/lib/offchain/{offchainLendingVault.d.ts → vault/offchainVault.d.ts} +16 -7
- package/lib/offchain/{offchainLendingVault.js → vault/offchainVault.js} +33 -17
- package/lib/onchain/account/lendingPool/index.d.ts +8 -1
- package/lib/onchain/account/lendingPool/index.js +38 -1
- package/lib/onchain/account/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.d.ts +7 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlp.js +12 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/account/lendingPool/nftlp/onchainAccountNftlpUniswapV3.js +13 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.d.ts +12 -7
- package/lib/onchain/account/lendingPool/onchainAccountBorrowable.js +5 -50
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV2.js +55 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.d.ts +10 -0
- package/lib/onchain/account/lendingPool/onchainAccountBorrowableV3.js +28 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.d.ts +6 -19
- package/lib/onchain/account/lendingPool/onchainAccountCollateral.js +7 -90
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +25 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.js +99 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.d.ts +18 -0
- package/lib/onchain/account/lendingPool/onchainAccountCollateralV3.js +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.d.ts +19 -34
- package/lib/onchain/account/lendingPool/onchainAccountLendingPool.js +17 -227
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.d.ts +44 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV2.js +285 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.d.ts +27 -0
- package/lib/onchain/account/lendingPool/onchainAccountLendingPoolV3.js +32 -0
- package/lib/onchain/account/onchainAccount.js +1 -2
- package/lib/onchain/account/onchainAccountLendingVault.d.ts +3 -3
- package/lib/onchain/impermaxFactory/index.d.ts +3 -1
- package/lib/onchain/impermaxFactory/index.js +5 -1
- package/lib/onchain/impermaxFactory/lendingPool/index.d.ts +8 -1
- package/lib/onchain/impermaxFactory/lendingPool/index.js +39 -1
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.d.ts +22 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlp.js +19 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.d.ts +24 -0
- package/lib/onchain/impermaxFactory/lendingPool/nftlp/onchainNftlpUniswapV3.js +90 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.d.ts +15 -11
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowable.js +5 -24
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.d.ts +9 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV2.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.d.ts +7 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainBorrowableV3.js +23 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.d.ts +5 -16
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateral.js +6 -43
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.d.ts +20 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV2.js +58 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.d.ts +13 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainCollateralV3.js +36 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.d.ts +32 -47
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +28 -314
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.d.ts +76 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV2.js +338 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.d.ts +42 -0
- package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPoolV3.js +39 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.d.ts +19 -9
- package/lib/onchain/impermaxFactory/onchainImpermaxFactory.js +16 -26
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV2.js +81 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.d.ts +16 -0
- package/lib/onchain/impermaxFactory/onchainImpermaxFactoryV3.js +88 -0
- package/lib/onchain/interactions/lendingPool/index.d.ts +8 -1
- package/lib/onchain/interactions/lendingPool/index.js +38 -1
- package/lib/onchain/interactions/lendingPool/nftlp/index.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/index.js +11 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.d.ts +7 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlp.js +12 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.d.ts +4 -0
- package/lib/onchain/interactions/lendingPool/nftlp/onchainInteractionsNftlpUniswapV3.js +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.d.ts +6 -10
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowable.js +5 -37
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.d.ts +15 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV2.js +63 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.d.ts +9 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsBorrowableV3.js +14 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.d.ts +3 -15
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateral.js +5 -37
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.d.ts +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV2.js +48 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.d.ts +13 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsCollateralV3.js +20 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.d.ts +16 -31
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPool.js +12 -94
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.d.ts +42 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV2.js +114 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.d.ts +27 -0
- package/lib/onchain/interactions/lendingPool/onchainInteractionsLendingPoolV3.js +32 -0
- package/lib/onchain/interactions/onchainInteractions.js +3 -4
- package/lib/onchain/interactions/onchainInteractionsLendingVault.d.ts +1 -1
- package/lib/onchain/interactions/onchainInteractionsLendingVault.js +1 -1
- package/lib/onchain/interactions/onchainInteractionsPoolToken.d.ts +13 -13
- package/lib/onchain/interactions/onchainInteractionsPoolToken.js +33 -85
- package/lib/onchain/onchain.d.ts +3 -0
- package/lib/onchain/onchain.js +11 -3
- package/lib/onchain/onchainContractsHelper.d.ts +19 -8
- package/lib/onchain/onchainContractsHelper.js +55 -21
- package/lib/onchain/onchainLendingVault.d.ts +3 -3
- package/lib/onchain/onchainPermitHelper.d.ts +21 -0
- package/lib/onchain/onchainPermitHelper.js +198 -0
- package/lib/onchain/onchainTypes.d.ts +6 -0
- package/package.json +1 -1
- package/lib/offchain/account/offchainAccountLendingVault.d.ts +0 -16
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import OffchainAccountLendingPool from "./index";
|
|
2
|
+
export default class OffchainLeveragedPosition {
|
|
3
|
+
private readonly lendingPool;
|
|
4
|
+
private readonly TOKEN_ID;
|
|
5
|
+
constructor(lendingPool: OffchainAccountLendingPool, TOKEN_ID: number);
|
|
6
|
+
isLiquidated(): Promise<boolean>;
|
|
7
|
+
getLeverage(): Promise<number>;
|
|
8
|
+
getAPR(): Promise<number>;
|
|
9
|
+
getDepositedA(): Promise<number>;
|
|
10
|
+
getDepositedB(): Promise<number>;
|
|
11
|
+
getDepositedAUSD(): Promise<number>;
|
|
12
|
+
getDepositedBUSD(): Promise<number>;
|
|
13
|
+
getBorrowedA(): Promise<number>;
|
|
14
|
+
getBorrowedB(): Promise<number>;
|
|
15
|
+
getBorrowedAUSD(): Promise<number>;
|
|
16
|
+
getBorrowedBUSD(): Promise<number>;
|
|
17
|
+
getExposureA(): Promise<number>;
|
|
18
|
+
getExposureB(): Promise<number>;
|
|
19
|
+
getExposureAUSD(): Promise<number>;
|
|
20
|
+
getExposureBUSD(): Promise<number>;
|
|
21
|
+
getValueUSD(): Promise<number>;
|
|
22
|
+
getLiquidationRange(): Promise<[number, number]>;
|
|
23
|
+
getFee(): Promise<number>;
|
|
24
|
+
getPriceRange(): Promise<[number, number]>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
class OffchainLeveragedPosition {
|
|
13
|
+
constructor(lendingPool, TOKEN_ID) {
|
|
14
|
+
this.lendingPool = lendingPool;
|
|
15
|
+
this.TOKEN_ID = TOKEN_ID;
|
|
16
|
+
}
|
|
17
|
+
// TODO
|
|
18
|
+
// Common properties
|
|
19
|
+
isLiquidated() {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return false;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
getLeverage() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return 1;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getAPR() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return 1;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
getDepositedA() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return 1;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getDepositedB() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return 1;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getDepositedAUSD() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return 1;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getDepositedBUSD() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return 1;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getBorrowedA() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return 1;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getBorrowedB() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return 1;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getBorrowedAUSD() {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return 1;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getBorrowedBUSD() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return 1;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getExposureA() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return (yield this.getDepositedA()) - (yield this.getBorrowedA());
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
getExposureB() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return (yield this.getDepositedB()) - (yield this.getBorrowedB());
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getExposureAUSD() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
return (yield this.getDepositedAUSD()) - (yield this.getBorrowedAUSD());
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getExposureBUSD() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return (yield this.getDepositedBUSD()) - (yield this.getBorrowedBUSD());
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
getValueUSD() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return (yield this.getExposureAUSD()) + (yield this.getExposureBUSD());
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
getLiquidationRange() {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
return [1, 10];
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// V3 properties
|
|
105
|
+
getFee() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
return 0.001;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getPriceRange() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
return [1, 10];
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.default = OffchainLeveragedPosition;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import Offchain from '../index';
|
|
2
2
|
import { Address, AddressIndex, Factory, FactoryIndex } from '../../config/types';
|
|
3
3
|
import OffchainAccountLendingPool from './lendingPool';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import OffchainAccountVault from './vault/offchainAccountVault';
|
|
5
|
+
import { VaultPosition, UserData } from '../offchainTypes';
|
|
6
6
|
export default class OffchainAccount {
|
|
7
7
|
private readonly offchain;
|
|
8
8
|
private readonly accountAddress;
|
|
9
9
|
private lendingPools;
|
|
10
|
-
private
|
|
10
|
+
private vaults;
|
|
11
11
|
constructor(offchain: Offchain, account: Address);
|
|
12
|
-
|
|
12
|
+
getOffchain: () => Offchain;
|
|
13
13
|
getAccountAddress: () => string;
|
|
14
14
|
private initializeLendingPool;
|
|
15
15
|
getLendingPool(factory: Factory, pair: Address): Promise<OffchainAccountLendingPool>;
|
|
16
16
|
private initializeLendingVault;
|
|
17
|
-
getLendingVault(vaultAddress: Address): Promise<
|
|
17
|
+
getLendingVault(vaultAddress: Address): Promise<OffchainAccountVault>;
|
|
18
18
|
getUserData(): Promise<FactoryIndex<UserData> | null>;
|
|
19
|
-
getLendingVaultsUserData(): Promise<AddressIndex<
|
|
19
|
+
getLendingVaultsUserData(): Promise<AddressIndex<VaultPosition> | null>;
|
|
20
20
|
getBorrowPositions(): Promise<FactoryIndex<Address[]>>;
|
|
21
21
|
getSupplyPositions(): Promise<FactoryIndex<Address[]>>;
|
|
22
22
|
getLendingVaultsSuppliedUSD(): Promise<number>;
|
|
@@ -13,15 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const lendingPool_1 = __importDefault(require("./lendingPool"));
|
|
16
|
-
const
|
|
16
|
+
const offchainAccountVault_1 = __importDefault(require("./vault/offchainAccountVault"));
|
|
17
17
|
class OffchainAccount {
|
|
18
18
|
constructor(offchain, account) {
|
|
19
|
-
this.
|
|
19
|
+
this.getOffchain = () => this.offchain;
|
|
20
20
|
this.getAccountAddress = () => this.accountAddress;
|
|
21
21
|
this.offchain = offchain;
|
|
22
22
|
this.accountAddress = account;
|
|
23
23
|
this.lendingPools = {};
|
|
24
|
-
this.
|
|
24
|
+
this.vaults = {};
|
|
25
25
|
}
|
|
26
26
|
initializeLendingPool(factory, pair) {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -42,14 +42,14 @@ class OffchainAccount {
|
|
|
42
42
|
initializeLendingVault(vaultAddress) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
44
|
const lendingVault = yield this.offchain.getLendingVault(vaultAddress);
|
|
45
|
-
return new
|
|
45
|
+
return new offchainAccountVault_1.default(this, lendingVault);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
getLendingVault(vaultAddress) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
if (!this.
|
|
51
|
-
this.
|
|
52
|
-
return this.
|
|
50
|
+
if (!this.vaults[vaultAddress])
|
|
51
|
+
this.vaults[vaultAddress] = this.initializeLendingVault(vaultAddress);
|
|
52
|
+
return this.vaults[vaultAddress];
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
getUserData() {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Address, Networks } from '../../config/types';
|
|
2
|
+
import { OffchainAccountBorrowable } from './lendingPool';
|
|
3
|
+
import OffchainAccountVault from './vault';
|
|
4
|
+
import OffchainMultichain from "../offchainMultichain";
|
|
5
|
+
import OffchainAccount from "./offchainAccount";
|
|
6
|
+
import OffchainLeveragedPosition from "./lendingPool/offchainLeveragedPosition";
|
|
7
|
+
export declare enum LeveragedPositionsOrderBy {
|
|
8
|
+
TVL = 0
|
|
9
|
+
}
|
|
10
|
+
export interface LeveragedPositionsParams {
|
|
11
|
+
}
|
|
12
|
+
export declare enum SupplyPositionsOrderBy {
|
|
13
|
+
TVL = 0
|
|
14
|
+
}
|
|
15
|
+
export interface SupplyPositionsParams {
|
|
16
|
+
}
|
|
17
|
+
export declare enum VaultPositionsOrderBy {
|
|
18
|
+
TVL = 0
|
|
19
|
+
}
|
|
20
|
+
export interface VaultPositionsParams {
|
|
21
|
+
}
|
|
22
|
+
export default class OffchainMultichainAccount {
|
|
23
|
+
readonly offchainMultichain: OffchainMultichain;
|
|
24
|
+
readonly accountAddress: Address;
|
|
25
|
+
constructor(offchainMultichain: OffchainMultichain, account: Address);
|
|
26
|
+
getOffchainMultichain: () => OffchainMultichain;
|
|
27
|
+
getAccountAddress: () => string;
|
|
28
|
+
getOffchainAccount(network: Networks): OffchainAccount;
|
|
29
|
+
getLeveragedPositions(params?: LeveragedPositionsParams, orderBy?: LeveragedPositionsOrderBy): Promise<Array<OffchainLeveragedPosition>>;
|
|
30
|
+
getSupplyPositions(params?: SupplyPositionsParams, orderBy?: SupplyPositionsOrderBy): Promise<Array<OffchainAccountBorrowable>>;
|
|
31
|
+
getVaultPositions(params?: VaultPositionsParams, orderBy?: VaultPositionsOrderBy): Promise<Array<OffchainAccountVault>>;
|
|
32
|
+
getTotalBalanceUSD(): Promise<number>;
|
|
33
|
+
getNetAPR(): Promise<number>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VaultPositionsOrderBy = exports.SupplyPositionsOrderBy = exports.LeveragedPositionsOrderBy = void 0;
|
|
13
|
+
var LeveragedPositionsOrderBy;
|
|
14
|
+
(function (LeveragedPositionsOrderBy) {
|
|
15
|
+
LeveragedPositionsOrderBy[LeveragedPositionsOrderBy["TVL"] = 0] = "TVL";
|
|
16
|
+
})(LeveragedPositionsOrderBy = exports.LeveragedPositionsOrderBy || (exports.LeveragedPositionsOrderBy = {}));
|
|
17
|
+
var SupplyPositionsOrderBy;
|
|
18
|
+
(function (SupplyPositionsOrderBy) {
|
|
19
|
+
SupplyPositionsOrderBy[SupplyPositionsOrderBy["TVL"] = 0] = "TVL";
|
|
20
|
+
})(SupplyPositionsOrderBy = exports.SupplyPositionsOrderBy || (exports.SupplyPositionsOrderBy = {}));
|
|
21
|
+
var VaultPositionsOrderBy;
|
|
22
|
+
(function (VaultPositionsOrderBy) {
|
|
23
|
+
VaultPositionsOrderBy[VaultPositionsOrderBy["TVL"] = 0] = "TVL";
|
|
24
|
+
})(VaultPositionsOrderBy = exports.VaultPositionsOrderBy || (exports.VaultPositionsOrderBy = {}));
|
|
25
|
+
class OffchainMultichainAccount {
|
|
26
|
+
constructor(offchainMultichain, account) {
|
|
27
|
+
this.getOffchainMultichain = () => this.offchainMultichain;
|
|
28
|
+
this.getAccountAddress = () => this.accountAddress;
|
|
29
|
+
this.offchainMultichain = offchainMultichain;
|
|
30
|
+
this.accountAddress = account;
|
|
31
|
+
}
|
|
32
|
+
getOffchainAccount(network) {
|
|
33
|
+
return this.offchainMultichain.getOffchain(network).getAccount(this.accountAddress);
|
|
34
|
+
}
|
|
35
|
+
// Positions
|
|
36
|
+
getLeveragedPositions(params = {}, orderBy = LeveragedPositionsOrderBy.TVL) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
// TODO FILL WITH FAKE DATA
|
|
39
|
+
return [];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
getSupplyPositions(params = {}, orderBy = SupplyPositionsOrderBy.TVL) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
// TODO FILL WITH FAKE DATA
|
|
45
|
+
return [];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getVaultPositions(params = {}, orderBy = VaultPositionsOrderBy.TVL) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
// TODO FILL WITH FAKE DATA
|
|
51
|
+
return [];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// Account stats
|
|
55
|
+
getTotalBalanceUSD() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return 10;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getNetAPR() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return 1;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = OffchainMultichainAccount;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const offchainAccountVault_1 = __importDefault(require("./offchainAccountVault"));
|
|
7
|
+
exports.default = offchainAccountVault_1.default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import OffchainAccount from '../index';
|
|
2
|
+
import OffchainAccountPoolToken from '../offchainAccountPoolToken';
|
|
3
|
+
import OffchainVault from '../../vault/offchainVault';
|
|
4
|
+
import { VaultPosition } from '../../offchainTypes';
|
|
5
|
+
export default class OffchainAccountVault extends OffchainAccountPoolToken {
|
|
6
|
+
private readonly account;
|
|
7
|
+
protected readonly poolToken: OffchainVault;
|
|
8
|
+
constructor(account: OffchainAccount, vault: OffchainVault);
|
|
9
|
+
getAccount: () => OffchainAccount;
|
|
10
|
+
getPoolToken: () => OffchainVault;
|
|
11
|
+
private getVaultAddress;
|
|
12
|
+
getVaultPosition(): Promise<VaultPosition | undefined>;
|
|
13
|
+
getAmount(): Promise<number>;
|
|
14
|
+
getEarnings(): Promise<number>;
|
|
15
|
+
getEarningsUSD(): Promise<number>;
|
|
16
|
+
}
|
package/lib/offchain/account/{offchainAccountLendingVault.js → vault/offchainAccountVault.js}
RENAMED
|
@@ -12,17 +12,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const offchainAccountPoolToken_1 = __importDefault(require("
|
|
16
|
-
class
|
|
17
|
-
constructor(account,
|
|
15
|
+
const offchainAccountPoolToken_1 = __importDefault(require("../offchainAccountPoolToken"));
|
|
16
|
+
class OffchainAccountVault extends offchainAccountPoolToken_1.default {
|
|
17
|
+
constructor(account, vault) {
|
|
18
18
|
super();
|
|
19
19
|
this.getAccount = () => this.account;
|
|
20
20
|
this.getPoolToken = () => this.poolToken;
|
|
21
21
|
this.getVaultAddress = () => this.poolToken.getVaultAddress();
|
|
22
22
|
this.account = account;
|
|
23
|
-
this.poolToken =
|
|
23
|
+
this.poolToken = vault;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
getVaultPosition() {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const lendingVaultsUserData = yield this.account.getLendingVaultsUserData();
|
|
28
28
|
if (!lendingVaultsUserData)
|
|
@@ -32,23 +32,23 @@ class OffchainAccountLendingVault extends offchainAccountPoolToken_1.default {
|
|
|
32
32
|
}
|
|
33
33
|
getAmount() {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
35
|
+
const vaultPosition = yield this.getVaultPosition();
|
|
36
|
+
if (!vaultPosition)
|
|
37
37
|
return 0;
|
|
38
38
|
const exchangeRate = yield this.poolToken.getCurrentExchangeRate();
|
|
39
|
-
const tokenBalance = parseFloat(
|
|
39
|
+
const tokenBalance = parseFloat(vaultPosition.tokenBalance);
|
|
40
40
|
return tokenBalance * exchangeRate;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
getEarnings() {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
45
|
+
const vaultPosition = yield this.getVaultPosition();
|
|
46
|
+
if (!vaultPosition)
|
|
47
47
|
return 0;
|
|
48
48
|
const exchangeRate = yield this.poolToken.getCurrentExchangeRate();
|
|
49
|
-
const tokenBalance = parseFloat(
|
|
50
|
-
const cumulativeEarnings = parseFloat(
|
|
51
|
-
const lastExchangeRate = parseFloat(
|
|
49
|
+
const tokenBalance = parseFloat(vaultPosition.tokenBalance);
|
|
50
|
+
const cumulativeEarnings = parseFloat(vaultPosition.cumulativeEarnings);
|
|
51
|
+
const lastExchangeRate = parseFloat(vaultPosition.lastExchangeRate);
|
|
52
52
|
const newEarnings = (exchangeRate - lastExchangeRate) * tokenBalance;
|
|
53
53
|
return cumulativeEarnings + newEarnings;
|
|
54
54
|
});
|
|
@@ -61,4 +61,4 @@ class OffchainAccountLendingVault extends offchainAccountPoolToken_1.default {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
exports.default =
|
|
64
|
+
exports.default = OffchainAccountVault;
|
package/lib/offchain/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import OffchainSolidexHelper from "./offchainSolidexHelper";
|
|
|
6
6
|
import OffchainAccount from "./account";
|
|
7
7
|
import * as account from "./account";
|
|
8
8
|
import * as configManager from "./configManager";
|
|
9
|
-
import
|
|
9
|
+
import * as vault from "./vault";
|
|
10
10
|
import OffchainPoolToken from "./offchainPoolToken";
|
|
11
11
|
import Offchain from './offchain';
|
|
12
12
|
import OffchainConfigManager from "./configManager";
|
|
13
|
-
|
|
13
|
+
import OffchainMultichain from "./offchainMultichain";
|
|
14
|
+
export { account, lendingPool, vault, configManager, OffchainMultichain, OffchainAccount, OffchainLendingPool, OffchainConfigManager, OffchainPoolToken, OffchainSolidexHelper, OffchainPriceHelper, OffchainAPRHelper };
|
|
14
15
|
export default Offchain;
|
package/lib/offchain/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.OffchainAPRHelper = exports.OffchainPriceHelper = exports.OffchainSolidexHelper = exports.
|
|
29
|
+
exports.OffchainAPRHelper = exports.OffchainPriceHelper = exports.OffchainSolidexHelper = exports.OffchainPoolToken = exports.OffchainConfigManager = exports.OffchainLendingPool = exports.OffchainAccount = exports.OffchainMultichain = exports.configManager = exports.vault = exports.lendingPool = exports.account = void 0;
|
|
30
30
|
const lendingPool_1 = __importDefault(require("./lendingPool"));
|
|
31
31
|
exports.OffchainLendingPool = lendingPool_1.default;
|
|
32
32
|
const lendingPool = __importStar(require("./lendingPool"));
|
|
@@ -43,11 +43,13 @@ const account = __importStar(require("./account"));
|
|
|
43
43
|
exports.account = account;
|
|
44
44
|
const configManager = __importStar(require("./configManager"));
|
|
45
45
|
exports.configManager = configManager;
|
|
46
|
-
const
|
|
47
|
-
exports.
|
|
46
|
+
const vault = __importStar(require("./vault"));
|
|
47
|
+
exports.vault = vault;
|
|
48
48
|
const offchainPoolToken_1 = __importDefault(require("./offchainPoolToken"));
|
|
49
49
|
exports.OffchainPoolToken = offchainPoolToken_1.default;
|
|
50
50
|
const offchain_1 = __importDefault(require("./offchain"));
|
|
51
51
|
const configManager_1 = __importDefault(require("./configManager"));
|
|
52
52
|
exports.OffchainConfigManager = configManager_1.default;
|
|
53
|
+
const offchainMultichain_1 = __importDefault(require("./offchainMultichain"));
|
|
54
|
+
exports.OffchainMultichain = offchainMultichain_1.default;
|
|
53
55
|
exports.default = offchain_1.default;
|
|
@@ -14,6 +14,7 @@ export default class OffchainCollateral extends OffchainPoolToken {
|
|
|
14
14
|
getSymbol(): Promise<string>;
|
|
15
15
|
getDecimals(): Promise<number>;
|
|
16
16
|
getUnderlyingAddress(): Promise<Address>;
|
|
17
|
+
getTWAP(): Promise<number>;
|
|
17
18
|
getTokenPriceFast(fallback?: boolean): Promise<number>;
|
|
18
19
|
getTokenPriceAccurate(): Promise<number>;
|
|
19
20
|
}
|
|
@@ -54,6 +54,12 @@ class OffchainCollateral extends offchainPoolToken_1.default {
|
|
|
54
54
|
return this.lendingPool.getPairAddress();
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
getTWAP() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
// TODO
|
|
60
|
+
return 1;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
57
63
|
// Token price getters
|
|
58
64
|
getTokenPriceFast(fallback = true) {
|
|
59
65
|
const _super = Object.create(null, {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import Offchain from '../index';
|
|
2
|
-
import { Address, Factory, PoolTokenType, WhitelistState } from '../../config/types';
|
|
2
|
+
import { Address, Borrowable, Factory, PoolTokenType, WhitelistState } from '../../config/types';
|
|
3
3
|
import OffchainCollateral from './offchainCollateral';
|
|
4
4
|
import OffchainBorrowable from './offchainBorrowable';
|
|
5
5
|
import OffchainPoolToken from '../offchainPoolToken';
|
|
6
6
|
import { LendingPoolData, LendingPoolPastData } from '../offchainTypes';
|
|
7
7
|
import { Farms } from '../../config/farms';
|
|
8
8
|
import { Amms } from '../../config/amms';
|
|
9
|
+
export declare enum LendingPoolVersion {
|
|
10
|
+
V1 = 0,
|
|
11
|
+
V2 = 1,
|
|
12
|
+
V3 = 2
|
|
13
|
+
}
|
|
9
14
|
export default class OffchainLendingPool {
|
|
10
15
|
private readonly offchain;
|
|
11
16
|
private readonly factory;
|
|
@@ -16,6 +21,7 @@ export default class OffchainLendingPool {
|
|
|
16
21
|
getFactory: () => Factory;
|
|
17
22
|
getPairAddress: () => string;
|
|
18
23
|
getPoolToken(poolTokenType: PoolTokenType): OffchainPoolToken;
|
|
24
|
+
getBorrowable: (borrowable: Borrowable) => OffchainBorrowable;
|
|
19
25
|
getBorrowableA: () => OffchainBorrowable;
|
|
20
26
|
getBorrowableB: () => OffchainBorrowable;
|
|
21
27
|
getCollateral: () => OffchainCollateral;
|
|
@@ -44,4 +50,11 @@ export default class OffchainLendingPool {
|
|
|
44
50
|
getKinkMultiplier(): 2 | 5;
|
|
45
51
|
getTotalBorrowsUSD(): Promise<number>;
|
|
46
52
|
getTotalAPR(): Promise<number>;
|
|
53
|
+
getTVL(): Promise<number>;
|
|
54
|
+
isDeprecated(): Promise<boolean>;
|
|
55
|
+
isBlacklisted(): Promise<boolean>;
|
|
56
|
+
isStable(): Promise<boolean>;
|
|
57
|
+
isLowTVL(): Promise<boolean>;
|
|
58
|
+
isHighTVL(): Promise<boolean>;
|
|
59
|
+
getLendingPoolVersion(): Promise<LendingPoolVersion>;
|
|
47
60
|
}
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LendingPoolVersion = void 0;
|
|
15
16
|
const types_1 = require("../../config/types");
|
|
16
17
|
const offchainCollateral_1 = __importDefault(require("./offchainCollateral"));
|
|
17
18
|
const offchainBorrowable_1 = __importDefault(require("./offchainBorrowable"));
|
|
@@ -19,11 +20,18 @@ const farms_1 = require("../../config/farms");
|
|
|
19
20
|
const utils_1 = require("../../utils");
|
|
20
21
|
const amms_1 = require("../../config/amms");
|
|
21
22
|
const factories_1 = require("../../config/factories");
|
|
23
|
+
var LendingPoolVersion;
|
|
24
|
+
(function (LendingPoolVersion) {
|
|
25
|
+
LendingPoolVersion[LendingPoolVersion["V1"] = 0] = "V1";
|
|
26
|
+
LendingPoolVersion[LendingPoolVersion["V2"] = 1] = "V2";
|
|
27
|
+
LendingPoolVersion[LendingPoolVersion["V3"] = 2] = "V3";
|
|
28
|
+
})(LendingPoolVersion = exports.LendingPoolVersion || (exports.LendingPoolVersion = {}));
|
|
22
29
|
class OffchainLendingPool {
|
|
23
30
|
constructor(offchain, factory, pairAddress) {
|
|
24
31
|
this.getOffchain = () => this.offchain;
|
|
25
32
|
this.getFactory = () => this.factory;
|
|
26
33
|
this.getPairAddress = () => this.pairAddress;
|
|
34
|
+
this.getBorrowable = (borrowable) => borrowable == types_1.Borrowable.A ? this.getBorrowableA() : this.getBorrowableB();
|
|
27
35
|
// Shortcuts
|
|
28
36
|
this.getBorrowableA = () => this.poolTokens[types_1.PoolTokenType.BorrowableA];
|
|
29
37
|
this.getBorrowableB = () => this.poolTokens[types_1.PoolTokenType.BorrowableB];
|
|
@@ -226,5 +234,44 @@ class OffchainLendingPool {
|
|
|
226
234
|
return uniswapAPR + stakingAPR;
|
|
227
235
|
});
|
|
228
236
|
}
|
|
237
|
+
getTVL() {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
// TODO
|
|
240
|
+
return 1;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
// Flags
|
|
244
|
+
isDeprecated() {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
return false;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
isBlacklisted() {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
return false;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
isStable() {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
return false;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
isLowTVL() {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
return false;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
isHighTVL() {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
return false;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// Versions Specfics
|
|
270
|
+
getLendingPoolVersion() {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
// TODO
|
|
273
|
+
return LendingPoolVersion.V2;
|
|
274
|
+
});
|
|
275
|
+
}
|
|
229
276
|
}
|
|
230
277
|
exports.default = OffchainLendingPool;
|
|
@@ -6,8 +6,8 @@ import OffchainSolidexHelper from "./offchainSolidexHelper";
|
|
|
6
6
|
import OffchainAccount from "./account";
|
|
7
7
|
import OffchainEndpointManager from './offchainEndpointManager';
|
|
8
8
|
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, Networks, WhitelistState } from '../config/types';
|
|
9
|
-
import { LendingPoolData, LendingVaultData,
|
|
10
|
-
import
|
|
9
|
+
import { LendingPoolData, LendingVaultData, VaultPosition, TvlData, UserData, XimxData } from './offchainTypes';
|
|
10
|
+
import OffchainVault from './vault/offchainVault';
|
|
11
11
|
import OffchainConfigManager from './configManager';
|
|
12
12
|
import { LlamaTvlChart } from './offchainAPRHelper';
|
|
13
13
|
export interface OffchainCfg {
|
|
@@ -15,12 +15,14 @@ export interface OffchainCfg {
|
|
|
15
15
|
chainId: number;
|
|
16
16
|
whitelistedPairs?: FactoryIndex<Address[]>;
|
|
17
17
|
}
|
|
18
|
+
import OffchainMultichain from "./offchainMultichain";
|
|
18
19
|
export default class Offchain {
|
|
20
|
+
readonly offchainMultichain: OffchainMultichain;
|
|
19
21
|
readonly network: Networks;
|
|
20
22
|
readonly chainId: number;
|
|
21
23
|
readonly whitelistedPairs: FactoryIndex<Address[]>;
|
|
22
24
|
protected lendingPools: LendingPoolIndex<OffchainLendingPool>;
|
|
23
|
-
protected
|
|
25
|
+
protected vaults: AddressIndex<OffchainVault>;
|
|
24
26
|
protected accounts: AddressIndex<OffchainAccount>;
|
|
25
27
|
protected priceHelper: OffchainPriceHelper;
|
|
26
28
|
protected aprHelper: OffchainAPRHelper;
|
|
@@ -32,30 +34,21 @@ export default class Offchain {
|
|
|
32
34
|
};
|
|
33
35
|
protected lendingVaultsData: Promise<AddressIndex<LendingVaultData>> | null;
|
|
34
36
|
protected lendingVaultsUsersData: {
|
|
35
|
-
[key in Address]?: Promise<AddressIndex<
|
|
37
|
+
[key in Address]?: Promise<AddressIndex<VaultPosition> | null>;
|
|
36
38
|
};
|
|
37
39
|
protected tvlData: Promise<TvlData> | null;
|
|
38
40
|
protected ximxData: Promise<XimxData> | null;
|
|
39
41
|
protected whitelistData: Promise<LendingPoolIndex<WhitelistState>> | null;
|
|
40
42
|
protected endpointManager: OffchainEndpointManager;
|
|
41
|
-
constructor(
|
|
43
|
+
constructor(offchainMultichain: OffchainMultichain, network: Networks);
|
|
42
44
|
cleanCache(): void;
|
|
43
45
|
getLendingPool(factory: Factory, pairAddress: Address): Promise<OffchainLendingPool>;
|
|
44
|
-
getLendingVault(vaultAddress: Address): Promise<
|
|
46
|
+
getLendingVault(vaultAddress: Address): Promise<OffchainVault>;
|
|
45
47
|
getAccount(accountAddress: Address): OffchainAccount;
|
|
46
48
|
getPriceHelper: () => OffchainPriceHelper;
|
|
47
49
|
getSolidexHelper: () => OffchainSolidexHelper;
|
|
48
50
|
getConfigManager: () => OffchainConfigManager;
|
|
49
51
|
getAPRHelper: () => OffchainAPRHelper;
|
|
50
|
-
/**
|
|
51
|
-
* TODO
|
|
52
|
-
* Potrei organizzare in:
|
|
53
|
-
* - lendingPoolData
|
|
54
|
-
* - usersData
|
|
55
|
-
* - tvlData
|
|
56
|
-
* - ximxData
|
|
57
|
-
* - lendingVaultData
|
|
58
|
-
*/
|
|
59
52
|
apolloFetcher: typeof initializer.apolloFetcher;
|
|
60
53
|
protected fetchLendingPools: typeof initializer.fetchLendingPools;
|
|
61
54
|
protected fetchLendingPoolsPast: typeof initializer.fetchLendingPoolsPast;
|