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
package/lib/offchain/offchain.js
CHANGED
|
@@ -41,23 +41,16 @@ const offchainAPRHelper_1 = __importDefault(require("./offchainAPRHelper"));
|
|
|
41
41
|
const offchainSolidexHelper_1 = __importDefault(require("./offchainSolidexHelper"));
|
|
42
42
|
const account_1 = __importDefault(require("./account"));
|
|
43
43
|
const offchainEndpointManager_1 = __importDefault(require("./offchainEndpointManager"));
|
|
44
|
-
const
|
|
44
|
+
const offchainVault_1 = __importDefault(require("./vault/offchainVault"));
|
|
45
45
|
const configManager_1 = __importDefault(require("./configManager"));
|
|
46
|
+
const chainId_1 = require("../config/chainId");
|
|
46
47
|
class Offchain {
|
|
47
|
-
constructor(
|
|
48
|
+
constructor(offchainMultichain, network) {
|
|
49
|
+
this.whitelistedPairs = {};
|
|
48
50
|
this.getPriceHelper = () => this.priceHelper;
|
|
49
51
|
this.getSolidexHelper = () => this.solidexHelper;
|
|
50
52
|
this.getConfigManager = () => this.configManager;
|
|
51
53
|
this.getAPRHelper = () => this.aprHelper;
|
|
52
|
-
/**
|
|
53
|
-
* TODO
|
|
54
|
-
* Potrei organizzare in:
|
|
55
|
-
* - lendingPoolData
|
|
56
|
-
* - usersData
|
|
57
|
-
* - tvlData
|
|
58
|
-
* - ximxData
|
|
59
|
-
* - lendingVaultData
|
|
60
|
-
*/
|
|
61
54
|
// TODO make everything protected
|
|
62
55
|
// Fetchers
|
|
63
56
|
this.apolloFetcher = initializer.apolloFetcher;
|
|
@@ -89,9 +82,13 @@ class Offchain {
|
|
|
89
82
|
this.initializeWhitelistData = initializer.initializeWhitelistData;
|
|
90
83
|
this.getWhitelistData = initializer.getWhitelistData;
|
|
91
84
|
this.getWhitelistState = initializer.getWhitelistState;
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
85
|
+
// TODO fix conflicting lines (commented)
|
|
86
|
+
//this.network = cfg.network;
|
|
87
|
+
//this.chainId = cfg.chainId;
|
|
88
|
+
//this.whitelistedPairs = cfg.whitelistedPairs ? cfg.whitelistedPairs : {};
|
|
89
|
+
this.offchainMultichain = offchainMultichain;
|
|
90
|
+
this.network = network;
|
|
91
|
+
this.chainId = chainId_1.CHAIN_IDS[network];
|
|
95
92
|
this.priceHelper = new offchainPriceHelper_1.default(this);
|
|
96
93
|
this.solidexHelper = new offchainSolidexHelper_1.default(this);
|
|
97
94
|
this.configManager = new configManager_1.default(this);
|
|
@@ -123,11 +120,11 @@ class Offchain {
|
|
|
123
120
|
getLendingVault(vaultAddress) {
|
|
124
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
122
|
yield this.getLendingVaultsData(); // make sure that lending vaults are initialized
|
|
126
|
-
if (!this.
|
|
127
|
-
this.
|
|
128
|
-
if (!this.
|
|
129
|
-
this.
|
|
130
|
-
return this.
|
|
123
|
+
if (!this.vaults)
|
|
124
|
+
this.vaults = {};
|
|
125
|
+
if (!this.vaults[vaultAddress])
|
|
126
|
+
this.vaults[vaultAddress] = new offchainVault_1.default(this, vaultAddress);
|
|
127
|
+
return this.vaults[vaultAddress];
|
|
131
128
|
});
|
|
132
129
|
}
|
|
133
130
|
getAccount(accountAddress) {
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const types_1 = require("../config/types");
|
|
13
|
-
// Map of OUR chains to the chain names used by llama in their `poolsOld`
|
|
14
13
|
const LlamaChains = {
|
|
15
14
|
[types_1.Networks.Ropsten]: "ropsten",
|
|
16
15
|
[types_1.Networks.Mainnet]: "ethereum",
|
|
@@ -2,7 +2,7 @@ import { ApolloQueryResult } from "apollo-client";
|
|
|
2
2
|
import { DocumentNode } from "graphql";
|
|
3
3
|
import { Address, AddressIndex, Factory, FactoryIndex, LendingPoolIndex, WhitelistState } from '../config/types';
|
|
4
4
|
import { Amms } from '../config/amms';
|
|
5
|
-
import { LendingPoolData, LendingVaultData,
|
|
5
|
+
import { LendingPoolData, LendingVaultData, VaultPosition, RawUserData, TvlData, UserData, WhitelistData, XimxData } from './offchainTypes';
|
|
6
6
|
import Offchain from './offchain';
|
|
7
7
|
export declare function apolloFetcher(subgraphUrl: string, query: DocumentNode): Promise<ApolloQueryResult<any>>;
|
|
8
8
|
export declare function fetchBlockByTimestamp(this: Offchain, timestamp: number): Promise<number | null>;
|
|
@@ -47,6 +47,6 @@ export declare function getWhitelistState(this: Offchain, factory: Factory, pair
|
|
|
47
47
|
/**
|
|
48
48
|
* User Data
|
|
49
49
|
*/
|
|
50
|
-
export declare function fetchLendingVaultsUserData(this: Offchain, account: Address): Promise<
|
|
51
|
-
export declare function initializeLendingVaultsUserData(this: Offchain, account: Address): Promise<AddressIndex<
|
|
52
|
-
export declare function getLendingVaultsUserData(this: Offchain, account: Address): Promise<AddressIndex<
|
|
50
|
+
export declare function fetchLendingVaultsUserData(this: Offchain, account: Address): Promise<VaultPosition[] | null>;
|
|
51
|
+
export declare function initializeLendingVaultsUserData(this: Offchain, account: Address): Promise<AddressIndex<VaultPosition> | null>;
|
|
52
|
+
export declare function getLendingVaultsUserData(this: Offchain, account: Address): Promise<AddressIndex<VaultPosition> | null>;
|
|
@@ -21,7 +21,7 @@ const lendingPool_1 = __importDefault(require("./lendingPool"));
|
|
|
21
21
|
const subgraphs_1 = require("../config/subgraphs");
|
|
22
22
|
const types_1 = require("../config/types");
|
|
23
23
|
const amms_1 = require("../config/amms");
|
|
24
|
-
const
|
|
24
|
+
const offchainVault_1 = __importDefault(require("./vault/offchainVault"));
|
|
25
25
|
const impermax_factories_1 = require("../config/contracts/impermax-factories");
|
|
26
26
|
const SECONDS_IN_YEAR = 60 * 60 * 24 * 365;
|
|
27
27
|
function apolloFetcher(subgraphUrl, query) {
|
|
@@ -674,10 +674,10 @@ function initializeLendingVaultsData() {
|
|
|
674
674
|
lendingVaultsData[lendingVault.id] = lendingVault;
|
|
675
675
|
}
|
|
676
676
|
// Initialize OffchainLendingVault objects
|
|
677
|
-
this.
|
|
677
|
+
this.vaults = {};
|
|
678
678
|
for (const lendingVault of lendingVaults) {
|
|
679
|
-
this.
|
|
680
|
-
new
|
|
679
|
+
this.vaults[lendingVault.id] =
|
|
680
|
+
new offchainVault_1.default(this, lendingVault.id);
|
|
681
681
|
}
|
|
682
682
|
return lendingVaultsData;
|
|
683
683
|
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NetworkIndex, Networks } from '../config/types';
|
|
2
|
+
import Offchain from "./offchain";
|
|
3
|
+
import OffchainVault, { VaultType } from "./vault/offchainVault";
|
|
4
|
+
import { Amms } from "../config/amms";
|
|
5
|
+
import { Farms } from "../config/farms";
|
|
6
|
+
import { RiskLevel } from "./vault/offchainLendingVault";
|
|
7
|
+
import OffchainLendingPool from "./lendingPool";
|
|
8
|
+
import { LendingPoolVersion } from "./lendingPool/offchainLendingPool";
|
|
9
|
+
export declare enum VaultOrderBy {
|
|
10
|
+
TVL = 0,
|
|
11
|
+
APR = 1,
|
|
12
|
+
DEPOSITED = 2
|
|
13
|
+
}
|
|
14
|
+
export interface VaultListParams {
|
|
15
|
+
networks?: Array<Networks>;
|
|
16
|
+
type?: VaultType;
|
|
17
|
+
searchInput?: string;
|
|
18
|
+
riskLevel?: RiskLevel;
|
|
19
|
+
amm?: Array<Amms>;
|
|
20
|
+
farm?: Array<Farms>;
|
|
21
|
+
deprecated?: boolean;
|
|
22
|
+
stable?: boolean;
|
|
23
|
+
highTvl?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare enum LendingPoolListOrderBy {
|
|
26
|
+
TVL = 0,
|
|
27
|
+
TOTAL_SUPPLY = 1,
|
|
28
|
+
TOTAL_BORROW = 2,
|
|
29
|
+
SUPPLY_APR = 3,
|
|
30
|
+
LEVERAGED_APR = 4
|
|
31
|
+
}
|
|
32
|
+
export interface LendingPoolListParams {
|
|
33
|
+
networks?: Array<Networks>;
|
|
34
|
+
version?: LendingPoolVersion;
|
|
35
|
+
searchInput?: string;
|
|
36
|
+
amm?: Array<Amms>;
|
|
37
|
+
farm?: Array<Farms>;
|
|
38
|
+
deprecated?: boolean;
|
|
39
|
+
stable?: boolean;
|
|
40
|
+
highTvl?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export default class OffchainMultichain {
|
|
43
|
+
#private;
|
|
44
|
+
protected offchains: NetworkIndex<Offchain>;
|
|
45
|
+
private constructor();
|
|
46
|
+
static get instance(): OffchainMultichain;
|
|
47
|
+
getOffchain(network: Networks): Offchain;
|
|
48
|
+
getVaultList(params?: VaultListParams, orderBy?: VaultOrderBy): Promise<Array<OffchainVault>>;
|
|
49
|
+
getLendingPoolList(params?: LendingPoolListParams, orderBy?: LendingPoolListOrderBy): Promise<Array<OffchainLendingPool>>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
17
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
20
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
var _a, _OffchainMultichain_instance;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.LendingPoolListOrderBy = exports.VaultOrderBy = void 0;
|
|
28
|
+
const offchain_1 = __importDefault(require("./offchain"));
|
|
29
|
+
var VaultOrderBy;
|
|
30
|
+
(function (VaultOrderBy) {
|
|
31
|
+
VaultOrderBy[VaultOrderBy["TVL"] = 0] = "TVL";
|
|
32
|
+
VaultOrderBy[VaultOrderBy["APR"] = 1] = "APR";
|
|
33
|
+
VaultOrderBy[VaultOrderBy["DEPOSITED"] = 2] = "DEPOSITED";
|
|
34
|
+
})(VaultOrderBy = exports.VaultOrderBy || (exports.VaultOrderBy = {}));
|
|
35
|
+
var LendingPoolListOrderBy;
|
|
36
|
+
(function (LendingPoolListOrderBy) {
|
|
37
|
+
LendingPoolListOrderBy[LendingPoolListOrderBy["TVL"] = 0] = "TVL";
|
|
38
|
+
LendingPoolListOrderBy[LendingPoolListOrderBy["TOTAL_SUPPLY"] = 1] = "TOTAL_SUPPLY";
|
|
39
|
+
LendingPoolListOrderBy[LendingPoolListOrderBy["TOTAL_BORROW"] = 2] = "TOTAL_BORROW";
|
|
40
|
+
LendingPoolListOrderBy[LendingPoolListOrderBy["SUPPLY_APR"] = 3] = "SUPPLY_APR";
|
|
41
|
+
LendingPoolListOrderBy[LendingPoolListOrderBy["LEVERAGED_APR"] = 4] = "LEVERAGED_APR";
|
|
42
|
+
})(LendingPoolListOrderBy = exports.LendingPoolListOrderBy || (exports.LendingPoolListOrderBy = {}));
|
|
43
|
+
// singleton class
|
|
44
|
+
class OffchainMultichain {
|
|
45
|
+
constructor() {
|
|
46
|
+
// Initialize empty
|
|
47
|
+
this.offchains = {};
|
|
48
|
+
}
|
|
49
|
+
static get instance() {
|
|
50
|
+
if (!__classPrivateFieldGet(OffchainMultichain, _a, "f", _OffchainMultichain_instance)) {
|
|
51
|
+
__classPrivateFieldSet(OffchainMultichain, _a, new OffchainMultichain(), "f", _OffchainMultichain_instance);
|
|
52
|
+
}
|
|
53
|
+
return __classPrivateFieldGet(OffchainMultichain, _a, "f", _OffchainMultichain_instance);
|
|
54
|
+
}
|
|
55
|
+
getOffchain(network) {
|
|
56
|
+
if (!this.offchains[network])
|
|
57
|
+
this.offchains[network] = new offchain_1.default(this, network);
|
|
58
|
+
return this.offchains[network];
|
|
59
|
+
}
|
|
60
|
+
getVaultList(params = {}, orderBy = VaultOrderBy.TVL) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
// TODO FILL WITH FAKE DATA
|
|
63
|
+
return [];
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getLendingPoolList(params = {}, orderBy = LendingPoolListOrderBy.TVL) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
// TODO FILL WITH FAKE DATA
|
|
69
|
+
return [];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = OffchainMultichain;
|
|
74
|
+
_a = OffchainMultichain;
|
|
75
|
+
_OffchainMultichain_instance = { value: void 0 };
|
|
@@ -166,7 +166,7 @@ export interface LendingVaultData extends PoolTokenData {
|
|
|
166
166
|
availableLiquidity: string;
|
|
167
167
|
lastUpdate: string;
|
|
168
168
|
}
|
|
169
|
-
export interface
|
|
169
|
+
export interface VaultPosition {
|
|
170
170
|
tokenBalance: string;
|
|
171
171
|
lastExchangeRate: string;
|
|
172
172
|
cumulativeEarnings: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import OffchainLeveragedVault from './offchainLeveragedVault';
|
|
2
|
+
import OffchainLendingVault from './offchainLendingVault';
|
|
3
|
+
import OffchainHedgedVault from './offchainHedgedVault';
|
|
4
|
+
import OffchainVault from './offchainVault';
|
|
5
|
+
export { OffchainLeveragedVault, OffchainLendingVault, OffchainHedgedVault, };
|
|
6
|
+
export default OffchainVault;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
exports.OffchainHedgedVault = exports.OffchainLendingVault = exports.OffchainLeveragedVault = void 0;
|
|
7
|
+
const offchainLeveragedVault_1 = __importDefault(require("./offchainLeveragedVault"));
|
|
8
|
+
exports.OffchainLeveragedVault = offchainLeveragedVault_1.default;
|
|
9
|
+
const offchainLendingVault_1 = __importDefault(require("./offchainLendingVault"));
|
|
10
|
+
exports.OffchainLendingVault = offchainLendingVault_1.default;
|
|
11
|
+
const offchainHedgedVault_1 = __importDefault(require("./offchainHedgedVault"));
|
|
12
|
+
exports.OffchainHedgedVault = offchainHedgedVault_1.default;
|
|
13
|
+
const offchainVault_1 = __importDefault(require("./offchainVault"));
|
|
14
|
+
exports.default = offchainVault_1.default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Offchain from "../index";
|
|
2
|
+
import { Address } from '../../config/types';
|
|
3
|
+
import OffchainVault from "./offchainVault";
|
|
4
|
+
import OffchainLendingPool from "../lendingPool";
|
|
5
|
+
export default class OffchainHedgedVaultVault extends OffchainVault {
|
|
6
|
+
constructor(offchain: Offchain, vaultAddress: Address);
|
|
7
|
+
getLeverage(): Promise<number>;
|
|
8
|
+
getPair(): Promise<OffchainLendingPool>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const types_1 = require("../../config/types");
|
|
39
|
+
const offchainVault_1 = __importStar(require("./offchainVault"));
|
|
40
|
+
const lendingPool_1 = __importDefault(require("../lendingPool"));
|
|
41
|
+
class OffchainHedgedVaultVault extends offchainVault_1.default {
|
|
42
|
+
constructor(offchain, vaultAddress) {
|
|
43
|
+
super(offchain, vaultAddress);
|
|
44
|
+
this.vaultType = offchainVault_1.VaultType.HEDGED;
|
|
45
|
+
}
|
|
46
|
+
getLeverage() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return 1;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getPair() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return new lendingPool_1.default(this.getOffchain(), types_1.Factory.V2V2, "0x");
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = OffchainHedgedVaultVault;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Offchain from "../index";
|
|
2
|
+
import { Address } from '../../config/types';
|
|
3
|
+
import OffchainVault from "./offchainVault";
|
|
4
|
+
import { OffchainBorrowable } from "../lendingPool";
|
|
5
|
+
export declare enum RiskLevel {
|
|
6
|
+
LOW = 0,
|
|
7
|
+
MEDIUM = 1,
|
|
8
|
+
HIGH = 2
|
|
9
|
+
}
|
|
10
|
+
export default class OffchainLendingVault extends OffchainVault {
|
|
11
|
+
constructor(offchain: Offchain, vaultAddress: Address);
|
|
12
|
+
getRiskLevel(): Promise<RiskLevel>;
|
|
13
|
+
getAvailableLiquidity(): Promise<number>;
|
|
14
|
+
getAvailableLiquidityUSD(): Promise<number>;
|
|
15
|
+
getBorrowables(): Promise<Array<OffchainBorrowable>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.RiskLevel = void 0;
|
|
36
|
+
const offchainVault_1 = __importStar(require("./offchainVault"));
|
|
37
|
+
var RiskLevel;
|
|
38
|
+
(function (RiskLevel) {
|
|
39
|
+
RiskLevel[RiskLevel["LOW"] = 0] = "LOW";
|
|
40
|
+
RiskLevel[RiskLevel["MEDIUM"] = 1] = "MEDIUM";
|
|
41
|
+
RiskLevel[RiskLevel["HIGH"] = 2] = "HIGH";
|
|
42
|
+
})(RiskLevel = exports.RiskLevel || (exports.RiskLevel = {}));
|
|
43
|
+
class OffchainLendingVault extends offchainVault_1.default {
|
|
44
|
+
constructor(offchain, vaultAddress) {
|
|
45
|
+
super(offchain, vaultAddress);
|
|
46
|
+
this.vaultType = offchainVault_1.VaultType.LENDING;
|
|
47
|
+
}
|
|
48
|
+
getRiskLevel() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return RiskLevel.MEDIUM;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Available Liquidity
|
|
54
|
+
getAvailableLiquidity() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return Math.min(yield this.getPoolTokenParamFloat("availableLiquidity"), yield this.getVaultSupply());
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getAvailableLiquidityUSD() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const availableLiquidity = yield this.getAvailableLiquidity();
|
|
62
|
+
const tokenPrice = yield this.getTokenPriceFast();
|
|
63
|
+
return availableLiquidity * tokenPrice;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Borrowables
|
|
67
|
+
getBorrowables() {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return [];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = OffchainLendingVault;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Offchain from "../index";
|
|
2
|
+
import { Address } from '../../config/types';
|
|
3
|
+
import OffchainVault from "./offchainVault";
|
|
4
|
+
import OffchainLendingPool from "../lendingPool";
|
|
5
|
+
export default class OffchainLeveragedVault extends OffchainVault {
|
|
6
|
+
constructor(offchain: Offchain, vaultAddress: Address);
|
|
7
|
+
getLeverage(): Promise<number>;
|
|
8
|
+
getPair(): Promise<OffchainLendingPool>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const types_1 = require("../../config/types");
|
|
39
|
+
const offchainVault_1 = __importStar(require("./offchainVault"));
|
|
40
|
+
const lendingPool_1 = __importDefault(require("../lendingPool"));
|
|
41
|
+
class OffchainLeveragedVault extends offchainVault_1.default {
|
|
42
|
+
constructor(offchain, vaultAddress) {
|
|
43
|
+
super(offchain, vaultAddress);
|
|
44
|
+
this.vaultType = offchainVault_1.VaultType.LEVERAGED;
|
|
45
|
+
}
|
|
46
|
+
getLeverage() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return 1;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getPair() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return new lendingPool_1.default(this.getOffchain(), types_1.Factory.V2V2, "0x");
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = OffchainLeveragedVault;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import Offchain from "
|
|
2
|
-
import { Address } from '
|
|
3
|
-
import OffchainPoolToken from '
|
|
4
|
-
import { PoolTokenData } from '
|
|
5
|
-
export
|
|
1
|
+
import Offchain from "../index";
|
|
2
|
+
import { Address } from '../../config/types';
|
|
3
|
+
import OffchainPoolToken from '../offchainPoolToken';
|
|
4
|
+
import { PoolTokenData } from '../offchainTypes';
|
|
5
|
+
export declare enum VaultType {
|
|
6
|
+
LENDING = 0,
|
|
7
|
+
HEDGED = 1,
|
|
8
|
+
LEVERAGED = 2
|
|
9
|
+
}
|
|
10
|
+
export default class OffchainVault extends OffchainPoolToken {
|
|
6
11
|
private readonly offchain;
|
|
7
12
|
private readonly vaultAddress;
|
|
13
|
+
protected vaultType: VaultType;
|
|
8
14
|
constructor(offchain: Offchain, vaultAddress: Address);
|
|
9
15
|
getOffchain: () => Offchain;
|
|
10
16
|
getVaultAddress: () => string;
|
|
17
|
+
getVaultType: () => VaultType;
|
|
11
18
|
getPoolTokenData(): Promise<PoolTokenData>;
|
|
12
19
|
private getTotalSupply;
|
|
13
20
|
private getLastUpdate;
|
|
@@ -18,8 +25,10 @@ export default class OffchainLendingVault extends OffchainPoolToken {
|
|
|
18
25
|
getReserveFactor(): Promise<number>;
|
|
19
26
|
getSupplyRate(): Promise<number>;
|
|
20
27
|
getSupplyAPR(): Promise<number>;
|
|
21
|
-
getAvailableLiquidity(): Promise<number>;
|
|
22
|
-
getAvailableLiquidityUSD(): Promise<number>;
|
|
23
28
|
getTokenPriceFast(fallback?: boolean): Promise<number>;
|
|
24
29
|
getTokenPriceAccurate(): Promise<number>;
|
|
30
|
+
isDeprecated(): Promise<boolean>;
|
|
31
|
+
isBlacklisted(): Promise<boolean>;
|
|
32
|
+
isStable(): Promise<boolean>;
|
|
33
|
+
isHighTVL(): Promise<boolean>;
|
|
25
34
|
}
|
|
@@ -12,13 +12,21 @@ 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
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
15
|
+
exports.VaultType = void 0;
|
|
16
|
+
const offchainPoolToken_1 = __importDefault(require("../offchainPoolToken"));
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
18
|
+
var VaultType;
|
|
19
|
+
(function (VaultType) {
|
|
20
|
+
VaultType[VaultType["LENDING"] = 0] = "LENDING";
|
|
21
|
+
VaultType[VaultType["HEDGED"] = 1] = "HEDGED";
|
|
22
|
+
VaultType[VaultType["LEVERAGED"] = 2] = "LEVERAGED";
|
|
23
|
+
})(VaultType = exports.VaultType || (exports.VaultType = {}));
|
|
24
|
+
class OffchainVault extends offchainPoolToken_1.default {
|
|
18
25
|
constructor(offchain, vaultAddress) {
|
|
19
26
|
super();
|
|
20
27
|
this.getOffchain = () => this.offchain;
|
|
21
28
|
this.getVaultAddress = () => this.vaultAddress;
|
|
29
|
+
this.getVaultType = () => this.vaultType;
|
|
22
30
|
this.offchain = offchain;
|
|
23
31
|
this.vaultAddress = vaultAddress;
|
|
24
32
|
}
|
|
@@ -85,19 +93,6 @@ class OffchainLendingVault extends offchainPoolToken_1.default {
|
|
|
85
93
|
return (0, utils_1.toAPR)(supplyRate);
|
|
86
94
|
});
|
|
87
95
|
}
|
|
88
|
-
// Available Liquidity
|
|
89
|
-
getAvailableLiquidity() {
|
|
90
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
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;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
96
|
// Token price getters
|
|
102
97
|
getTokenPriceFast(fallback = true) {
|
|
103
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -110,5 +105,26 @@ class OffchainLendingVault extends offchainPoolToken_1.default {
|
|
|
110
105
|
return this.getOffchain().getPriceHelper().getDebankTokenPrice(tokenAddress);
|
|
111
106
|
});
|
|
112
107
|
}
|
|
108
|
+
// Flags
|
|
109
|
+
isDeprecated() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
return false;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
isBlacklisted() {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
isStable() {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
return false;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
isHighTVL() {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
return false;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
113
129
|
}
|
|
114
|
-
exports.default =
|
|
130
|
+
exports.default = OffchainVault;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import * as nftlp from './nftlp';
|
|
1
2
|
import OnchainAccountBorrowable from "./onchainAccountBorrowable";
|
|
3
|
+
import OnchainAccountBorrowableV2 from "./onchainAccountBorrowableV2";
|
|
4
|
+
import OnchainAccountBorrowableV3 from "./onchainAccountBorrowableV3";
|
|
2
5
|
import OnchainAccountCollateral from "./onchainAccountCollateral";
|
|
6
|
+
import OnchainAccountCollateralV2 from "./onchainAccountCollateralV2";
|
|
7
|
+
import OnchainAccountCollateralV3 from "./onchainAccountCollateralV3";
|
|
3
8
|
import OnchainAccountLendingPool from './onchainAccountLendingPool';
|
|
4
|
-
|
|
9
|
+
import OnchainAccountLendingPoolV2 from "./onchainAccountLendingPoolV2";
|
|
10
|
+
import OnchainAccountLendingPoolV3 from "./onchainAccountLendingPoolV3";
|
|
11
|
+
export { nftlp, OnchainAccountBorrowable, OnchainAccountCollateral, OnchainAccountLendingPoolV2, OnchainAccountBorrowableV2, OnchainAccountCollateralV2, OnchainAccountLendingPoolV3, OnchainAccountBorrowableV3, OnchainAccountCollateralV3, };
|
|
5
12
|
export default OnchainAccountLendingPool;
|