@defisaver/positions-sdk 0.0.28 → 0.0.29
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/cjs/config/contracts.d.ts +18 -1
- package/cjs/config/contracts.js +4 -1
- package/cjs/contracts.d.ts +1 -1
- package/cjs/contracts.js +27 -4
- package/cjs/markets/aave/marketAssets.d.ts +1 -1
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/morphoAaveV3/index.js +0 -2
- package/esm/config/contracts.d.ts +18 -1
- package/esm/config/contracts.js +4 -1
- package/esm/contracts.d.ts +1 -1
- package/esm/contracts.js +27 -4
- package/esm/markets/aave/marketAssets.d.ts +1 -1
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/morphoAaveV3/index.js +0 -2
- package/package.json +1 -1
|
@@ -3037,7 +3037,24 @@ export namespace LiquityView {
|
|
|
3037
3037
|
"12549073": string;
|
|
3038
3038
|
"12567960": string;
|
|
3039
3039
|
"12638758": string;
|
|
3040
|
-
"12746821":
|
|
3040
|
+
"12746821": {
|
|
3041
|
+
abi: {
|
|
3042
|
+
inputs: {
|
|
3043
|
+
internalType: string;
|
|
3044
|
+
name: string;
|
|
3045
|
+
type: string;
|
|
3046
|
+
}[];
|
|
3047
|
+
name: string;
|
|
3048
|
+
outputs: {
|
|
3049
|
+
internalType: string;
|
|
3050
|
+
name: string;
|
|
3051
|
+
type: string;
|
|
3052
|
+
}[];
|
|
3053
|
+
stateMutability: string;
|
|
3054
|
+
type: string;
|
|
3055
|
+
}[];
|
|
3056
|
+
address: string;
|
|
3057
|
+
};
|
|
3041
3058
|
};
|
|
3042
3059
|
};
|
|
3043
3060
|
};
|
package/cjs/config/contracts.js
CHANGED
|
@@ -557,7 +557,10 @@ module.exports = {
|
|
|
557
557
|
"12549073": "0xFCDd12C6317adbd033B93486d176f99441344A0f",
|
|
558
558
|
"12567960": "0x0bE59e4804d957026a0E31B5d0BEA0fbaE262ba7",
|
|
559
559
|
"12638758": "0x30EFEF27A6919d927E4c684E373198F671c686Dc",
|
|
560
|
-
"12746821":
|
|
560
|
+
"12746821": {
|
|
561
|
+
"abi": [{ "inputs": [{ "internalType": "address", "name": "_troveOwner", "type": "address" }], "name": "getTroveInfo", "outputs": [{ "internalType": "uint256", "name": "troveStatus", "type": "uint256" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "uint256", "name": "TCRatio", "type": "uint256" }, { "internalType": "bool", "name": "recoveryMode", "type": "bool" }], "stateMutability": "view", "type": "function" }],
|
|
562
|
+
"address": "0xD1913B977737c9505B8EcFEDB8121546096d3393"
|
|
563
|
+
},
|
|
561
564
|
}
|
|
562
565
|
}
|
|
563
566
|
}
|
package/cjs/contracts.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as ContractTypes from './types/contracts/generated';
|
|
|
5
5
|
import { Blockish, NetworkNumber } from './types/common';
|
|
6
6
|
export type ConfigKey = keyof typeof configRaw;
|
|
7
7
|
export declare const getConfigContractAddress: (name: ConfigKey, network: NetworkNumber, block?: Blockish) => string;
|
|
8
|
-
export declare const getConfigContractAbi: (name: ConfigKey) => any[];
|
|
8
|
+
export declare const getConfigContractAbi: (name: ConfigKey, network?: NetworkNumber, block?: Blockish) => any[];
|
|
9
9
|
export declare const getErc20Contract: (address: string, web3: Web3) => import("web3-eth-contract").Contract;
|
|
10
10
|
export declare const createContractWrapper: (web3: Web3, network: NetworkNumber, name: ConfigKey, _address?: string, block?: Blockish) => BaseContract;
|
|
11
11
|
export declare const UniMulticallContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.UniMulticall;
|
package/cjs/contracts.js
CHANGED
|
@@ -14,20 +14,43 @@ const getConfigContractAddress = (name, network, block) => {
|
|
|
14
14
|
return latestAddress;
|
|
15
15
|
}
|
|
16
16
|
const oldVersions = (networkData === null || networkData === void 0 ? void 0 : networkData.oldVersions) || {};
|
|
17
|
-
|
|
17
|
+
// Versions are ordered from oldest to the newest
|
|
18
|
+
for (const [createdBlock, addressOrObject] of Object.entries(oldVersions).reverse()) {
|
|
18
19
|
if (block >= Number(createdBlock)) {
|
|
19
|
-
|
|
20
|
+
if (typeof addressOrObject !== 'string') {
|
|
21
|
+
return addressOrObject.address;
|
|
22
|
+
}
|
|
23
|
+
return addressOrObject;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
return latestAddress;
|
|
24
28
|
};
|
|
25
29
|
exports.getConfigContractAddress = getConfigContractAddress;
|
|
26
|
-
const getConfigContractAbi = (name) =>
|
|
30
|
+
const getConfigContractAbi = (name, network, block) => {
|
|
31
|
+
const networkData = network ? contractConfig[name].networks[network] : null;
|
|
32
|
+
const latestAbi = contractConfig[name].abi;
|
|
33
|
+
if (block && block !== 'latest' && networkData) {
|
|
34
|
+
if (block >= ((networkData === null || networkData === void 0 ? void 0 : networkData.createdBlock) || 0)) {
|
|
35
|
+
return latestAbi;
|
|
36
|
+
}
|
|
37
|
+
const oldVersions = (networkData === null || networkData === void 0 ? void 0 : networkData.oldVersions) || {};
|
|
38
|
+
// Versions are ordered from oldest to the newest
|
|
39
|
+
for (const [createdBlock, addressOrObject] of Object.entries(oldVersions).reverse()) {
|
|
40
|
+
if (block >= Number(createdBlock)) {
|
|
41
|
+
if (typeof addressOrObject !== 'string') {
|
|
42
|
+
return addressOrObject.abi;
|
|
43
|
+
}
|
|
44
|
+
return latestAbi;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return latestAbi;
|
|
49
|
+
};
|
|
27
50
|
exports.getConfigContractAbi = getConfigContractAbi;
|
|
28
51
|
const createContractFromConfigFunc = (name, _address) => (web3, network, block) => {
|
|
29
52
|
const address = _address || (0, exports.getConfigContractAddress)(name, network, block);
|
|
30
|
-
return new web3.eth.Contract(
|
|
53
|
+
return new web3.eth.Contract((0, exports.getConfigContractAbi)(name, network, block), address);
|
|
31
54
|
};
|
|
32
55
|
const getErc20Contract = (address, web3) => (new web3.eth.Contract((0, exports.getConfigContractAbi)('Erc20'), address));
|
|
33
56
|
exports.getErc20Contract = getErc20Contract;
|
|
@@ -5,5 +5,5 @@ export declare const aaveV3AssetsDefaultMarket: {
|
|
|
5
5
|
readonly 1: readonly ["WBTC", "ETH", "wstETH", "USDC", "DAI", "LINK", "AAVE", "cbETH", "USDT", "rETH", "LUSD", "UNI", "MKR", "SNX", "BAL", "LDO", "CRV", "ENS", "1INCH", "GHO", "FRAX", "RPL", "sDAI"];
|
|
6
6
|
readonly 10: readonly ["DAI", "USDC.e", "USDT", "SUSD", "AAVE", "LINK", "WBTC", "ETH", "OP", "wstETH", "LUSD", "MAI", "rETH"];
|
|
7
7
|
readonly 42161: readonly ["ETH", "DAI", "EURS", "USDC", "USDT", "AAVE", "LINK", "WBTC", "wstETH", "MAI", "rETH", "LUSD", "USDC.e", "FRAX", "ARB"];
|
|
8
|
-
readonly 8453: readonly ["ETH", "USDbC", "cbETH"];
|
|
8
|
+
readonly 8453: readonly ["ETH", "USDbC", "cbETH", "wstETH"];
|
|
9
9
|
};
|
|
@@ -26,6 +26,6 @@ exports.aaveV3AssetsDefaultMarket = {
|
|
|
26
26
|
'ETH', 'DAI', 'EURS', 'USDC', 'USDT', 'AAVE', 'LINK', 'WBTC', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC.e', 'FRAX', 'ARB',
|
|
27
27
|
],
|
|
28
28
|
[common_1.NetworkNumber.Base]: [
|
|
29
|
-
'ETH', 'USDbC', 'cbETH',
|
|
29
|
+
'ETH', 'USDbC', 'cbETH', 'wstETH',
|
|
30
30
|
],
|
|
31
31
|
};
|
|
@@ -139,8 +139,6 @@ const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3)
|
|
|
139
139
|
const morphoMarketData = Object.assign(Object.assign({}, multicallResponse[(2 * i) + loanInfoCallsToSkip][0]), { scaledMorphoBorrowOnPool: scaledBalanceResponse.value[2 * i][0], scaledMorphoSupplyOnPool: scaledBalanceResponse.value[(2 * i) + 1][0] });
|
|
140
140
|
const marketData = computeMorphoMarketData(info, morphoMarketData, multicallResponse[(2 * i) + (loanInfoCallsToSkip + 1)]);
|
|
141
141
|
const { symbol, address } = (0, tokens_1.getAssetInfoByAddress)((0, utils_1.wethToEthByAddress)(marketData.underlyingTokenAddress));
|
|
142
|
-
if (symbol === 'ETH')
|
|
143
|
-
console.log(marketData);
|
|
144
142
|
const data = {
|
|
145
143
|
symbol,
|
|
146
144
|
morphoMarketData,
|
|
@@ -3037,7 +3037,24 @@ export namespace LiquityView {
|
|
|
3037
3037
|
"12549073": string;
|
|
3038
3038
|
"12567960": string;
|
|
3039
3039
|
"12638758": string;
|
|
3040
|
-
"12746821":
|
|
3040
|
+
"12746821": {
|
|
3041
|
+
abi: {
|
|
3042
|
+
inputs: {
|
|
3043
|
+
internalType: string;
|
|
3044
|
+
name: string;
|
|
3045
|
+
type: string;
|
|
3046
|
+
}[];
|
|
3047
|
+
name: string;
|
|
3048
|
+
outputs: {
|
|
3049
|
+
internalType: string;
|
|
3050
|
+
name: string;
|
|
3051
|
+
type: string;
|
|
3052
|
+
}[];
|
|
3053
|
+
stateMutability: string;
|
|
3054
|
+
type: string;
|
|
3055
|
+
}[];
|
|
3056
|
+
address: string;
|
|
3057
|
+
};
|
|
3041
3058
|
};
|
|
3042
3059
|
};
|
|
3043
3060
|
};
|
package/esm/config/contracts.js
CHANGED
|
@@ -556,7 +556,10 @@ module.exports = {
|
|
|
556
556
|
"12549073": "0xFCDd12C6317adbd033B93486d176f99441344A0f",
|
|
557
557
|
"12567960": "0x0bE59e4804d957026a0E31B5d0BEA0fbaE262ba7",
|
|
558
558
|
"12638758": "0x30EFEF27A6919d927E4c684E373198F671c686Dc",
|
|
559
|
-
"12746821":
|
|
559
|
+
"12746821": {
|
|
560
|
+
"abi": [{ "inputs": [{ "internalType": "address", "name": "_troveOwner", "type": "address" }], "name": "getTroveInfo", "outputs": [{ "internalType": "uint256", "name": "troveStatus", "type": "uint256" }, { "internalType": "uint256", "name": "collAmount", "type": "uint256" }, { "internalType": "uint256", "name": "debtAmount", "type": "uint256" }, { "internalType": "uint256", "name": "collPrice", "type": "uint256" }, { "internalType": "uint256", "name": "TCRatio", "type": "uint256" }, { "internalType": "bool", "name": "recoveryMode", "type": "bool" }], "stateMutability": "view", "type": "function" }],
|
|
561
|
+
"address": "0xD1913B977737c9505B8EcFEDB8121546096d3393"
|
|
562
|
+
},
|
|
560
563
|
}
|
|
561
564
|
}
|
|
562
565
|
}
|
package/esm/contracts.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as ContractTypes from './types/contracts/generated';
|
|
|
5
5
|
import { Blockish, NetworkNumber } from './types/common';
|
|
6
6
|
export type ConfigKey = keyof typeof configRaw;
|
|
7
7
|
export declare const getConfigContractAddress: (name: ConfigKey, network: NetworkNumber, block?: Blockish) => string;
|
|
8
|
-
export declare const getConfigContractAbi: (name: ConfigKey) => any[];
|
|
8
|
+
export declare const getConfigContractAbi: (name: ConfigKey, network?: NetworkNumber, block?: Blockish) => any[];
|
|
9
9
|
export declare const getErc20Contract: (address: string, web3: Web3) => import("web3-eth-contract").Contract;
|
|
10
10
|
export declare const createContractWrapper: (web3: Web3, network: NetworkNumber, name: ConfigKey, _address?: string, block?: Blockish) => BaseContract;
|
|
11
11
|
export declare const UniMulticallContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.UniMulticall;
|
package/esm/contracts.js
CHANGED
|
@@ -8,18 +8,41 @@ export const getConfigContractAddress = (name, network, block) => {
|
|
|
8
8
|
return latestAddress;
|
|
9
9
|
}
|
|
10
10
|
const oldVersions = (networkData === null || networkData === void 0 ? void 0 : networkData.oldVersions) || {};
|
|
11
|
-
|
|
11
|
+
// Versions are ordered from oldest to the newest
|
|
12
|
+
for (const [createdBlock, addressOrObject] of Object.entries(oldVersions).reverse()) {
|
|
12
13
|
if (block >= Number(createdBlock)) {
|
|
13
|
-
|
|
14
|
+
if (typeof addressOrObject !== 'string') {
|
|
15
|
+
return addressOrObject.address;
|
|
16
|
+
}
|
|
17
|
+
return addressOrObject;
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
return latestAddress;
|
|
18
22
|
};
|
|
19
|
-
export const getConfigContractAbi = (name) =>
|
|
23
|
+
export const getConfigContractAbi = (name, network, block) => {
|
|
24
|
+
const networkData = network ? contractConfig[name].networks[network] : null;
|
|
25
|
+
const latestAbi = contractConfig[name].abi;
|
|
26
|
+
if (block && block !== 'latest' && networkData) {
|
|
27
|
+
if (block >= ((networkData === null || networkData === void 0 ? void 0 : networkData.createdBlock) || 0)) {
|
|
28
|
+
return latestAbi;
|
|
29
|
+
}
|
|
30
|
+
const oldVersions = (networkData === null || networkData === void 0 ? void 0 : networkData.oldVersions) || {};
|
|
31
|
+
// Versions are ordered from oldest to the newest
|
|
32
|
+
for (const [createdBlock, addressOrObject] of Object.entries(oldVersions).reverse()) {
|
|
33
|
+
if (block >= Number(createdBlock)) {
|
|
34
|
+
if (typeof addressOrObject !== 'string') {
|
|
35
|
+
return addressOrObject.abi;
|
|
36
|
+
}
|
|
37
|
+
return latestAbi;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return latestAbi;
|
|
42
|
+
};
|
|
20
43
|
const createContractFromConfigFunc = (name, _address) => (web3, network, block) => {
|
|
21
44
|
const address = _address || getConfigContractAddress(name, network, block);
|
|
22
|
-
return new web3.eth.Contract(
|
|
45
|
+
return new web3.eth.Contract(getConfigContractAbi(name, network, block), address);
|
|
23
46
|
};
|
|
24
47
|
export const getErc20Contract = (address, web3) => (new web3.eth.Contract(getConfigContractAbi('Erc20'), address));
|
|
25
48
|
export const createContractWrapper = (web3, network, name, _address, block) => (createContractFromConfigFunc(name, _address)(web3, network, block));
|
|
@@ -5,5 +5,5 @@ export declare const aaveV3AssetsDefaultMarket: {
|
|
|
5
5
|
readonly 1: readonly ["WBTC", "ETH", "wstETH", "USDC", "DAI", "LINK", "AAVE", "cbETH", "USDT", "rETH", "LUSD", "UNI", "MKR", "SNX", "BAL", "LDO", "CRV", "ENS", "1INCH", "GHO", "FRAX", "RPL", "sDAI"];
|
|
6
6
|
readonly 10: readonly ["DAI", "USDC.e", "USDT", "SUSD", "AAVE", "LINK", "WBTC", "ETH", "OP", "wstETH", "LUSD", "MAI", "rETH"];
|
|
7
7
|
readonly 42161: readonly ["ETH", "DAI", "EURS", "USDC", "USDT", "AAVE", "LINK", "WBTC", "wstETH", "MAI", "rETH", "LUSD", "USDC.e", "FRAX", "ARB"];
|
|
8
|
-
readonly 8453: readonly ["ETH", "USDbC", "cbETH"];
|
|
8
|
+
readonly 8453: readonly ["ETH", "USDbC", "cbETH", "wstETH"];
|
|
9
9
|
};
|
|
@@ -23,6 +23,6 @@ export const aaveV3AssetsDefaultMarket = {
|
|
|
23
23
|
'ETH', 'DAI', 'EURS', 'USDC', 'USDT', 'AAVE', 'LINK', 'WBTC', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC.e', 'FRAX', 'ARB',
|
|
24
24
|
],
|
|
25
25
|
[NetworkNumber.Base]: [
|
|
26
|
-
'ETH', 'USDbC', 'cbETH',
|
|
26
|
+
'ETH', 'USDbC', 'cbETH', 'wstETH',
|
|
27
27
|
],
|
|
28
28
|
};
|
|
@@ -133,8 +133,6 @@ export const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainne
|
|
|
133
133
|
const morphoMarketData = Object.assign(Object.assign({}, multicallResponse[(2 * i) + loanInfoCallsToSkip][0]), { scaledMorphoBorrowOnPool: scaledBalanceResponse.value[2 * i][0], scaledMorphoSupplyOnPool: scaledBalanceResponse.value[(2 * i) + 1][0] });
|
|
134
134
|
const marketData = computeMorphoMarketData(info, morphoMarketData, multicallResponse[(2 * i) + (loanInfoCallsToSkip + 1)]);
|
|
135
135
|
const { symbol, address } = getAssetInfoByAddress(wethToEthByAddress(marketData.underlyingTokenAddress));
|
|
136
|
-
if (symbol === 'ETH')
|
|
137
|
-
console.log(marketData);
|
|
138
136
|
const data = {
|
|
139
137
|
symbol,
|
|
140
138
|
morphoMarketData,
|