@defisaver/positions-sdk 0.0.60 → 0.0.61-dev
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 +11 -189
- package/cjs/config/contracts.js +6 -25
- package/cjs/llamaLend/index.js +28 -29
- package/cjs/markets/llamaLend/contractAddresses.d.ts +9 -0
- package/cjs/markets/llamaLend/contractAddresses.js +88 -0
- package/cjs/markets/llamaLend/index.d.ts +12 -10
- package/cjs/markets/llamaLend/index.js +41 -57
- package/cjs/types/contracts/generated/{LlamaLendCRVCrvUSDController.d.ts → LlamaLendControllerAbi.d.ts} +3 -3
- package/cjs/types/contracts/generated/LlamaLendView.d.ts +5 -0
- package/cjs/types/contracts/generated/index.d.ts +1 -4
- package/cjs/types/llamaLend.d.ts +35 -9
- package/cjs/types/llamaLend.js +26 -8
- package/esm/config/contracts.d.ts +11 -189
- package/esm/config/contracts.js +6 -25
- package/esm/llamaLend/index.js +31 -32
- package/esm/markets/llamaLend/contractAddresses.d.ts +9 -0
- package/esm/markets/llamaLend/contractAddresses.js +84 -0
- package/esm/markets/llamaLend/index.d.ts +12 -10
- package/esm/markets/llamaLend/index.js +31 -55
- package/esm/types/contracts/generated/{LlamaLendCrvUSDCRVController.d.ts → LlamaLendControllerAbi.d.ts} +3 -3
- package/esm/types/contracts/generated/LlamaLendView.d.ts +5 -0
- package/esm/types/contracts/generated/index.d.ts +1 -4
- package/esm/types/llamaLend.d.ts +35 -9
- package/esm/types/llamaLend.js +25 -7
- package/package.json +2 -2
- package/src/config/contracts.js +6 -25
- package/src/contracts.ts +2 -1
- package/src/llamaLend/index.ts +20 -28
- package/src/markets/llamaLend/contractAddresses.ts +93 -0
- package/src/markets/llamaLend/index.ts +122 -37
- package/src/types/common.ts +1 -1
- package/src/types/contracts/generated/{LlamaLendCRVCrvUSDController.ts → LlamaLendControllerAbi.ts} +3 -3
- package/src/types/contracts/generated/LlamaLendView.ts +9 -0
- package/src/types/contracts/generated/index.ts +1 -4
- package/src/types/llamaLend.ts +34 -10
- package/cjs/types/contracts/generated/LlamaLendCrvUSDCRVController.d.ts +0 -209
- package/cjs/types/contracts/generated/LlamaLendCrvUSDCRVController.js +0 -5
- package/cjs/types/contracts/generated/LlamaLendTBTCCrvUSDController.d.ts +0 -209
- package/cjs/types/contracts/generated/LlamaLendTBTCCrvUSDController.js +0 -5
- package/cjs/types/contracts/generated/LlamaLendWstETHCrvUSDController.d.ts +0 -209
- package/cjs/types/contracts/generated/LlamaLendWstETHCrvUSDController.js +0 -5
- package/esm/types/contracts/generated/LlamaLendCRVCrvUSDController.d.ts +0 -209
- package/esm/types/contracts/generated/LlamaLendCrvUSDCRVController.js +0 -4
- package/esm/types/contracts/generated/LlamaLendTBTCCrvUSDController.d.ts +0 -209
- package/esm/types/contracts/generated/LlamaLendTBTCCrvUSDController.js +0 -4
- package/esm/types/contracts/generated/LlamaLendWstETHCrvUSDController.d.ts +0 -209
- package/esm/types/contracts/generated/LlamaLendWstETHCrvUSDController.js +0 -4
- package/src/types/contracts/generated/LlamaLendCrvUSDCRVController.ts +0 -416
- package/src/types/contracts/generated/LlamaLendTBTCCrvUSDController.ts +0 -416
- package/src/types/contracts/generated/LlamaLendWstETHCrvUSDController.ts +0 -416
- /package/cjs/types/contracts/generated/{LlamaLendCRVCrvUSDController.js → LlamaLendControllerAbi.js} +0 -0
- /package/esm/types/contracts/generated/{LlamaLendCRVCrvUSDController.js → LlamaLendControllerAbi.js} +0 -0
package/esm/llamaLend/index.js
CHANGED
|
@@ -10,13 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
12
12
|
import { LlamaLendStatus, } from '../types';
|
|
13
|
-
import { multicall } from '../multicall';
|
|
14
13
|
import { NetworkNumber, } from '../types/common';
|
|
15
|
-
import {
|
|
14
|
+
import { LlamaLendViewContract } from '../contracts';
|
|
16
15
|
import { getLlamaLendAggregatedData } from '../helpers/llamaLendHelpers';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { USD_QUOTE } from '../constants';
|
|
16
|
+
import { getEthAmountForDecimals, wethToEth } from '../services/utils';
|
|
17
|
+
import { getLlamaLendMarketFromControllerAddress } from "../markets/llamaLend";
|
|
20
18
|
const getAndFormatBands = (web3, network, selectedMarket, _minBand, _maxBand) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
19
|
const contract = LlamaLendViewContract(web3, network);
|
|
22
20
|
const minBand = parseInt(_minBand, 10);
|
|
@@ -55,34 +53,19 @@ const getAndFormatBands = (web3, network, selectedMarket, _minBand, _maxBand) =>
|
|
|
55
53
|
});
|
|
56
54
|
export const getLlamaLendGlobalData = (web3, network, selectedMarket) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
55
|
const contract = LlamaLendViewContract(web3, network);
|
|
58
|
-
const FeedRegistryAddress = getConfigContractAddress('FeedRegistry', network);
|
|
59
|
-
const FeedRegistryAbi = getConfigContractAbi('FeedRegistry');
|
|
60
56
|
const collAsset = selectedMarket.collAsset;
|
|
61
57
|
const debtAsset = selectedMarket.baseAsset;
|
|
62
|
-
|
|
63
|
-
const multicallData = [
|
|
64
|
-
{
|
|
65
|
-
target: FeedRegistryAddress,
|
|
66
|
-
abiItem: getAbiItem(FeedRegistryAbi, 'latestAnswer'),
|
|
67
|
-
params: [getAssetInfo(debtAsset).address, USD_QUOTE],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
target: contract.options.address,
|
|
71
|
-
abiItem: contract.options.jsonInterface.find(({ name }) => name === 'globalData'),
|
|
72
|
-
params: [selectedMarket.controllerAddress],
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
const multiRes = yield multicall(multicallData, web3, network);
|
|
76
|
-
const data = multiRes[1][0];
|
|
77
|
-
const debtUsdPrice = getEthAmountForDecimals(multiRes[0][0], 8);
|
|
58
|
+
const data = yield contract.methods.globalData(selectedMarket.controllerAddress).call();
|
|
78
59
|
// all prices are in 18 decimals
|
|
60
|
+
const oraclePrice = getEthAmountForDecimals(data.oraclePrice, 18);
|
|
61
|
+
const collPriceUsd = collAsset === 'crvUSD' ? '1' : new Dec(1).mul(oraclePrice).toDP(18).toString();
|
|
62
|
+
const debtPriceUsd = debtAsset === 'crvUSD' ? '1' : new Dec(1).div(oraclePrice).toDP(18).toString();
|
|
79
63
|
const totalDebt = assetAmountInEth(data.totalDebt, debtAsset);
|
|
80
64
|
const totalDebtSupplied = assetAmountInEth(data.debtTokenTotalSupply, debtAsset);
|
|
81
65
|
const utilization = new Dec(totalDebtSupplied).gt(0)
|
|
82
|
-
? new Dec(totalDebt).div(totalDebtSupplied).mul(100)
|
|
83
|
-
: 0;
|
|
66
|
+
? new Dec(totalDebt).div(totalDebtSupplied).mul(100).toString()
|
|
67
|
+
: '0';
|
|
84
68
|
const ammPrice = assetAmountInEth(data.ammPrice, debtAsset);
|
|
85
|
-
const oraclePrice = getEthAmountForDecimals(data.oraclePrice, 18);
|
|
86
69
|
const rate = assetAmountInEth(data.ammRate);
|
|
87
70
|
const futureRate = assetAmountInEth(data.monetaryPolicyRate);
|
|
88
71
|
const exponentRate = new Dec(rate).mul(365).mul(86400);
|
|
@@ -100,7 +83,7 @@ export const getLlamaLendGlobalData = (web3, network, selectedMarket) => __await
|
|
|
100
83
|
assetsData[debtAsset] = {
|
|
101
84
|
symbol: debtAsset,
|
|
102
85
|
address: data.debtToken,
|
|
103
|
-
price:
|
|
86
|
+
price: debtPriceUsd,
|
|
104
87
|
supplyRate: lendRate,
|
|
105
88
|
borrowRate,
|
|
106
89
|
canBeSupplied: true,
|
|
@@ -109,19 +92,35 @@ export const getLlamaLendGlobalData = (web3, network, selectedMarket) => __await
|
|
|
109
92
|
assetsData[collAsset] = {
|
|
110
93
|
symbol: collAsset,
|
|
111
94
|
address: data.collateralToken,
|
|
112
|
-
price:
|
|
95
|
+
price: collPriceUsd,
|
|
113
96
|
supplyRate: '0',
|
|
114
97
|
borrowRate: '0',
|
|
115
98
|
canBeSupplied: true,
|
|
116
99
|
canBeBorrowed: false,
|
|
117
100
|
};
|
|
118
|
-
return
|
|
101
|
+
return {
|
|
102
|
+
A: data.A,
|
|
103
|
+
loanDiscount: data.loanDiscount,
|
|
104
|
+
activeBand: data.activeBand,
|
|
105
|
+
monetaryPolicyRate: data.monetaryPolicyRate,
|
|
106
|
+
ammRate: data.ammRate,
|
|
107
|
+
minBand: data.minBand,
|
|
108
|
+
maxBand: data.maxBand,
|
|
109
|
+
assetsData,
|
|
119
110
|
totalDebt,
|
|
120
111
|
totalDebtSupplied,
|
|
121
112
|
utilization,
|
|
122
|
-
ammPrice,
|
|
113
|
+
ammPrice,
|
|
114
|
+
oraclePrice: assetAmountInEth(data.oraclePrice, debtAsset),
|
|
115
|
+
basePrice: assetAmountInEth(data.basePrice, debtAsset),
|
|
116
|
+
minted: assetAmountInEth(data.minted, debtAsset),
|
|
117
|
+
redeemed: assetAmountInEth(data.redeemed, debtAsset),
|
|
118
|
+
borrowRate,
|
|
123
119
|
lendRate,
|
|
124
|
-
futureBorrowRate,
|
|
120
|
+
futureBorrowRate,
|
|
121
|
+
bands: bandsData,
|
|
122
|
+
leftToBorrow,
|
|
123
|
+
};
|
|
125
124
|
});
|
|
126
125
|
const getStatusForUser = (bandRange, activeBand, debtSupplied, collSupplied, healthPercent) => {
|
|
127
126
|
// if bands are equal, that can only be [0,0] which means user doesn't have loan (min number of bands is 4)
|
|
@@ -149,7 +148,7 @@ export const getLlamaLendAccountBalances = (web3, network, block, addressMapping
|
|
|
149
148
|
return balances;
|
|
150
149
|
}
|
|
151
150
|
const contract = LlamaLendViewContract(web3, network, block);
|
|
152
|
-
const selectedMarket =
|
|
151
|
+
const selectedMarket = getLlamaLendMarketFromControllerAddress(controllerAddress, network);
|
|
153
152
|
const data = yield contract.methods.userData(selectedMarket.controllerAddress, address).call({}, block);
|
|
154
153
|
balances = {
|
|
155
154
|
collateral: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LlamaLendVersionsType } from "../../types";
|
|
2
|
+
import { NetworkNumber } from "../../types/common";
|
|
3
|
+
type LLAddresses = {
|
|
4
|
+
controllerAddress: string;
|
|
5
|
+
vaultAddress: string;
|
|
6
|
+
controllerId: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getLLamaLendAddresses: (networkId: NetworkNumber, version: LlamaLendVersionsType) => LLAddresses;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { LlamaLendVersions } from "../../types";
|
|
2
|
+
import { NetworkNumber } from "../../types/common";
|
|
3
|
+
const ethAddresses = {
|
|
4
|
+
[LlamaLendVersions.LLWstethCrvusd]: {
|
|
5
|
+
controllerId: 0,
|
|
6
|
+
controllerAddress: '0x1E0165DbD2019441aB7927C018701f3138114D71',
|
|
7
|
+
vaultAddress: '0x8cf1DE26729cfB7137AF1A6B2a665e099EC319b5',
|
|
8
|
+
},
|
|
9
|
+
[LlamaLendVersions.LLSusdeCrvusd]: {
|
|
10
|
+
controllerId: 7,
|
|
11
|
+
controllerAddress: '0x98fc283d6636f6dcff5a817a00ac69a3add96907',
|
|
12
|
+
vaultAddress: '0x52096539ed1391CB50C6b9e4Fd18aFd2438ED23b',
|
|
13
|
+
},
|
|
14
|
+
[LlamaLendVersions.LLCrvCrvusd]: {
|
|
15
|
+
controllerId: 3,
|
|
16
|
+
controllerAddress: '0xEdA215b7666936DEd834f76f3fBC6F323295110A',
|
|
17
|
+
vaultAddress: '0xCeA18a8752bb7e7817F9AE7565328FE415C0f2cA',
|
|
18
|
+
},
|
|
19
|
+
[LlamaLendVersions.LLCrvusdCrv]: {
|
|
20
|
+
controllerId: 4,
|
|
21
|
+
controllerAddress: '0xC510d73Ad34BeDECa8978B6914461aA7b50CF3Fc',
|
|
22
|
+
vaultAddress: '0x4D2f44B0369f3C20c3d670D2C26b048985598450',
|
|
23
|
+
},
|
|
24
|
+
[LlamaLendVersions.LLTbtcCrvusd]: {
|
|
25
|
+
controllerId: 2,
|
|
26
|
+
controllerAddress: '0x413FD2511BAD510947a91f5c6c79EBD8138C29Fc',
|
|
27
|
+
vaultAddress: '0xb2b23C87a4B6d1b03Ba603F7C3EB9A81fDC0AAC9',
|
|
28
|
+
},
|
|
29
|
+
[LlamaLendVersions.LLCrvusdTbtc]: {
|
|
30
|
+
controllerId: 6,
|
|
31
|
+
controllerAddress: '0xe438658874b0acf4d81c24172e137f0ee00621b8',
|
|
32
|
+
vaultAddress: '0x99Cff9Dc26A44dc2496B4448ebE415b5E894bd30',
|
|
33
|
+
},
|
|
34
|
+
[LlamaLendVersions.LLWethCrvusd]: {
|
|
35
|
+
controllerId: 1,
|
|
36
|
+
controllerAddress: '0xaade9230aa9161880e13a38c83400d3d1995267b',
|
|
37
|
+
vaultAddress: '0x5AE28c9197a4a6570216fC7e53E7e0221D7A0FEF',
|
|
38
|
+
},
|
|
39
|
+
[LlamaLendVersions.LLCrvusdWeth]: {
|
|
40
|
+
controllerId: 5,
|
|
41
|
+
controllerAddress: '0xa5d9137d2a1ee912469d911a8e74b6c77503bac8',
|
|
42
|
+
vaultAddress: '0x46196C004de85c7a75C8b1bB9d54Afb0f8654A45',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
const arbAddresses = {
|
|
46
|
+
[LlamaLendVersions.LLArbCrvusd]: {
|
|
47
|
+
controllerId: 5,
|
|
48
|
+
controllerAddress: '0x76709bc0da299ab0234eec51385e900922ae98f5',
|
|
49
|
+
vaultAddress: '0x65592b1F12c07D434e95c7BF87F4f2f464e950e4',
|
|
50
|
+
},
|
|
51
|
+
[LlamaLendVersions.LLFxnCrvusd]: {
|
|
52
|
+
controllerId: 7,
|
|
53
|
+
controllerAddress: '0x7adcc491f0b7f9bc12837b8f5edf0e580d176f1f',
|
|
54
|
+
vaultAddress: '0xebA51f6472F4cE1C47668c2474ab8f84B32E1ae7',
|
|
55
|
+
},
|
|
56
|
+
[LlamaLendVersions.LLWbtcCrvusd]: {
|
|
57
|
+
controllerId: 1,
|
|
58
|
+
controllerAddress: '0x013be86e1cdb0f384daf24bd974fe75edffe6b68',
|
|
59
|
+
vaultAddress: '0x60D38b12d22BF423F28082bf396ff8F28cC506B1',
|
|
60
|
+
},
|
|
61
|
+
[LlamaLendVersions.LLCrvCrvusd]: {
|
|
62
|
+
controllerId: 4,
|
|
63
|
+
controllerAddress: '0x88f88e937db48bbfe8e3091718576430704e47ab',
|
|
64
|
+
vaultAddress: '0xeEaF2ccB73A01deb38Eca2947d963D64CfDe6A32',
|
|
65
|
+
},
|
|
66
|
+
[LlamaLendVersions.LLWethCrvusd]: {
|
|
67
|
+
controllerId: 0,
|
|
68
|
+
controllerAddress: '0xb5b6f0e69c283aa32425fa18220e64283b51f0a4',
|
|
69
|
+
vaultAddress: '0x49014A8eB1585cBee6A7a9A50C3b81017BF6Cc4d',
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const getLLamaLendAddresses = (networkId, version) => {
|
|
73
|
+
let addresses;
|
|
74
|
+
if (networkId === NetworkNumber.Eth) {
|
|
75
|
+
addresses = ethAddresses[version];
|
|
76
|
+
}
|
|
77
|
+
else if (networkId === NetworkNumber.Arb) {
|
|
78
|
+
addresses = arbAddresses[version];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error(`Invalid LlamaLend network ${networkId} for version ${version}`);
|
|
82
|
+
}
|
|
83
|
+
return addresses;
|
|
84
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { LlamaLendMarketData,
|
|
1
|
+
import { LlamaLendMarketData, LlamaLendVersionsType } from '../../types';
|
|
2
2
|
import { NetworkNumber } from '../../types/common';
|
|
3
3
|
export declare const LLAMALEND_WSTETH_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const LLAMALEND_SUSDE_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
5
5
|
export declare const LLAMALEND_CRV_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
6
|
+
export declare const LLAMALEND_CRVUSD_CRV_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
6
7
|
export declare const LLAMALEND_TBTC_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
7
|
-
export declare const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const getLlamaLendMarketData: (market:
|
|
8
|
+
export declare const LLAMALEND_CRVUSD_TBTC_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
9
|
+
export declare const LLAMALEND_WETH_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
10
|
+
export declare const LLAMALEND_CRVUSD_WETH_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
11
|
+
export declare const LLAMALEND_ARB_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
12
|
+
export declare const LLAMALEND_FXN_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
13
|
+
export declare const LLAMALEND_WBTC_CRVUSD_MARKET: (networkId: NetworkNumber) => LlamaLendMarketData;
|
|
14
|
+
export declare const LlamaLendMarkets: (networkId: NetworkNumber) => Record<LlamaLendVersionsType, LlamaLendMarketData>;
|
|
15
|
+
export declare const getLlamaLendMarketData: (market: LlamaLendVersionsType, network?: NetworkNumber) => LlamaLendMarketData;
|
|
16
|
+
export declare const getLlamaLendMarketFromControllerAddress: (controllerAddress: string, network: NetworkNumber) => LlamaLendMarketData;
|
|
@@ -1,59 +1,35 @@
|
|
|
1
|
-
import { getConfigContractAddress } from '../../contracts';
|
|
2
1
|
import { LlamaLendVersions } from '../../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
label: 'LlamaLend - crvUSD/CRV',
|
|
17
|
-
shortLabel: 'crvUSD/CRV',
|
|
18
|
-
value: LlamaLendVersions.LlamaLendcrvUSDCRV,
|
|
19
|
-
collAsset: 'crvUSD',
|
|
20
|
-
baseAsset: 'CRV',
|
|
21
|
-
controllerAddress: getConfigContractAddress('LlamaLendCrvUSDCRVController', networkId),
|
|
22
|
-
vaultAddress: '0x4D2f44B0369f3C20c3d670D2C26b048985598450',
|
|
23
|
-
url: 'crvusdcrv',
|
|
24
|
-
});
|
|
25
|
-
export const LLAMALEND_CRV_CRVUSD_MARKET = (networkId) => ({
|
|
26
|
-
chainIds: [1],
|
|
27
|
-
label: 'LlamaLend - CRV/crvUSD',
|
|
28
|
-
shortLabel: 'CRV/crvUSD',
|
|
29
|
-
value: LlamaLendVersions.LlamaLendCRVcrvUSD,
|
|
30
|
-
collAsset: 'CRV',
|
|
31
|
-
baseAsset: 'crvUSD',
|
|
32
|
-
controllerAddress: getConfigContractAddress('LlamaLendCRVCrvUSDController', networkId),
|
|
33
|
-
vaultAddress: '0xCeA18a8752bb7e7817F9AE7565328FE415C0f2cA',
|
|
34
|
-
url: 'crvcrvusd',
|
|
35
|
-
});
|
|
36
|
-
export const LLAMALEND_TBTC_CRVUSD_MARKET = (networkId) => ({
|
|
37
|
-
chainIds: [1],
|
|
38
|
-
label: 'LlamaLend - TBTC/crvUSD',
|
|
39
|
-
shortLabel: 'TBTC/crvUSD',
|
|
40
|
-
value: LlamaLendVersions.LlamaLendTBTCcrvUSD,
|
|
41
|
-
collAsset: 'tBTC',
|
|
42
|
-
baseAsset: 'crvUSD',
|
|
43
|
-
controllerAddress: getConfigContractAddress('LlamaLendTBTCCrvUSDController', networkId),
|
|
44
|
-
vaultAddress: '0xb2b23C87a4B6d1b03Ba603F7C3EB9A81fDC0AAC9',
|
|
45
|
-
url: 'tbtccrvusd',
|
|
46
|
-
});
|
|
2
|
+
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
import { getLLamaLendAddresses } from "./contractAddresses";
|
|
4
|
+
export const LLAMALEND_WSTETH_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth], label: 'LlamaLend - wstETH/crvUSD', shortLabel: 'wstETH/crvUSD', value: LlamaLendVersions.LLWstethCrvusd, collAsset: 'wstETH', baseAsset: 'crvUSD', url: 'wstethcrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLWstethCrvusd)));
|
|
5
|
+
export const LLAMALEND_SUSDE_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth], label: 'LlamaLend - sUSDe/crvUSD', shortLabel: 'sUSDe/crvUSD', value: LlamaLendVersions.LLSusdeCrvusd, collAsset: 'sUSDe', baseAsset: 'crvUSD', url: 'susdecrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLSusdeCrvusd)));
|
|
6
|
+
export const LLAMALEND_CRV_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth, NetworkNumber.Arb], label: 'LlamaLend - CRV/crvUSD', shortLabel: 'CRV/crvUSD', value: LlamaLendVersions.LLCrvCrvusd, collAsset: 'CRV', baseAsset: 'crvUSD', url: 'crvcrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLCrvCrvusd)));
|
|
7
|
+
export const LLAMALEND_CRVUSD_CRV_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth], label: 'LlamaLend - crvUSD/CRV', shortLabel: 'crvUSD/CRV', value: LlamaLendVersions.LLCrvusdCrv, collAsset: 'crvUSD', baseAsset: 'CRV', url: 'crvusdcrv' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLCrvusdCrv)));
|
|
8
|
+
export const LLAMALEND_TBTC_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth], label: 'LlamaLend - TBTC/crvUSD', shortLabel: 'TBTC/crvUSD', value: LlamaLendVersions.LLTbtcCrvusd, collAsset: 'tBTC', baseAsset: 'crvUSD', url: 'tbtccrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLTbtcCrvusd)));
|
|
9
|
+
export const LLAMALEND_CRVUSD_TBTC_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth], label: 'LlamaLend - crvUSD/TBTC', shortLabel: 'crvUSD/TBTC', value: LlamaLendVersions.LLCrvusdTbtc, collAsset: 'crvUSD', baseAsset: 'tBTC', url: 'crvusdtbtc' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLCrvusdTbtc)));
|
|
10
|
+
export const LLAMALEND_WETH_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth, NetworkNumber.Arb], label: 'LlamaLend - ETH/crvUSD', shortLabel: 'ETH/crvUSD', value: LlamaLendVersions.LLWethCrvusd, collAsset: 'ETH', baseAsset: 'crvUSD', url: 'wethcrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLWethCrvusd)));
|
|
11
|
+
export const LLAMALEND_CRVUSD_WETH_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Eth], label: 'LlamaLend - crvUSD/WETH', shortLabel: 'crvUSD/WETH', value: LlamaLendVersions.LLCrvusdWeth, collAsset: 'crvUSD', baseAsset: 'WETH', url: 'crvusdweth' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLCrvusdWeth)));
|
|
12
|
+
export const LLAMALEND_ARB_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Arb], label: 'LlamaLend - ARB/crvUSD', shortLabel: 'ARB/crvUSD', value: LlamaLendVersions.LLArbCrvusd, collAsset: 'ARB', baseAsset: 'crvUSD', url: 'arbcrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLArbCrvusd)));
|
|
13
|
+
export const LLAMALEND_FXN_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Arb], label: 'LlamaLend - FXN/crvUSD', shortLabel: 'FXN/crvUSD', value: LlamaLendVersions.LLFxnCrvusd, collAsset: 'FXN', baseAsset: 'crvUSD', url: 'fxncrvusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLFxnCrvusd)));
|
|
14
|
+
export const LLAMALEND_WBTC_CRVUSD_MARKET = (networkId) => (Object.assign({ chainIds: [NetworkNumber.Arb], label: 'LlamaLend - WBTC/crvUSD', shortLabel: 'WBTC/crvUSD', value: LlamaLendVersions.LLWbtcCrvusd, collAsset: 'WBTC', baseAsset: 'crvUSD', url: 'wbtcusd' }, getLLamaLendAddresses(networkId, LlamaLendVersions.LLWbtcCrvusd)));
|
|
47
15
|
export const LlamaLendMarkets = (networkId) => ({
|
|
48
|
-
[LlamaLendVersions.
|
|
49
|
-
[LlamaLendVersions.
|
|
50
|
-
[LlamaLendVersions.
|
|
51
|
-
[LlamaLendVersions.
|
|
16
|
+
[LlamaLendVersions.LLWstethCrvusd]: LLAMALEND_WSTETH_CRVUSD_MARKET(networkId),
|
|
17
|
+
[LlamaLendVersions.LLCrvusdCrv]: LLAMALEND_CRVUSD_CRV_MARKET(networkId),
|
|
18
|
+
[LlamaLendVersions.LLCrvCrvusd]: LLAMALEND_CRV_CRVUSD_MARKET(networkId),
|
|
19
|
+
[LlamaLendVersions.LLTbtcCrvusd]: LLAMALEND_TBTC_CRVUSD_MARKET(networkId),
|
|
20
|
+
[LlamaLendVersions.LLCrvusdTbtc]: LLAMALEND_CRVUSD_TBTC_MARKET(networkId),
|
|
21
|
+
[LlamaLendVersions.LLWethCrvusd]: LLAMALEND_WETH_CRVUSD_MARKET(networkId),
|
|
22
|
+
[LlamaLendVersions.LLCrvusdWeth]: LLAMALEND_CRVUSD_WETH_MARKET(networkId),
|
|
23
|
+
[LlamaLendVersions.LLArbCrvusd]: LLAMALEND_ARB_CRVUSD_MARKET(networkId),
|
|
24
|
+
[LlamaLendVersions.LLFxnCrvusd]: LLAMALEND_FXN_CRVUSD_MARKET(networkId),
|
|
25
|
+
[LlamaLendVersions.LLWbtcCrvusd]: LLAMALEND_WBTC_CRVUSD_MARKET(networkId),
|
|
26
|
+
[LlamaLendVersions.LLSusdeCrvusd]: LLAMALEND_SUSDE_CRVUSD_MARKET(networkId),
|
|
52
27
|
});
|
|
53
|
-
export const LLAMALEND_ALL_VERSIONS = [
|
|
54
|
-
LlamaLendVersions.LlamaLendwstETHcrvUSD,
|
|
55
|
-
LlamaLendVersions.LlamaLendcrvUSDCRV,
|
|
56
|
-
LlamaLendVersions.LlamaLendCRVcrvUSD,
|
|
57
|
-
LlamaLendVersions.LlamaLendTBTCcrvUSD,
|
|
58
|
-
];
|
|
59
28
|
export const getLlamaLendMarketData = (market, network = 1) => LlamaLendMarkets(network)[market];
|
|
29
|
+
export const getLlamaLendMarketFromControllerAddress = (controllerAddress, network) => {
|
|
30
|
+
const markets = LlamaLendMarkets(network);
|
|
31
|
+
const market = Object.values(markets).find((market) => market.controllerAddress === controllerAddress);
|
|
32
|
+
if (!market)
|
|
33
|
+
throw new Error('Market not found');
|
|
34
|
+
return market;
|
|
35
|
+
};
|
|
@@ -73,9 +73,9 @@ export type CollectFees = ContractEventLog<{
|
|
|
73
73
|
0: string;
|
|
74
74
|
1: string;
|
|
75
75
|
}>;
|
|
76
|
-
export interface
|
|
77
|
-
constructor(jsonInterface: any[], address?: string, options?: ContractOptions):
|
|
78
|
-
clone():
|
|
76
|
+
export interface LlamaLendControllerAbi extends BaseContract {
|
|
77
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): LlamaLendControllerAbi;
|
|
78
|
+
clone(): LlamaLendControllerAbi;
|
|
79
79
|
methods: {
|
|
80
80
|
factory(): NonPayableTransactionObject<string>;
|
|
81
81
|
amm(): NonPayableTransactionObject<string>;
|
|
@@ -75,6 +75,7 @@ export declare namespace LlamaLendView {
|
|
|
75
75
|
number | string | BN,
|
|
76
76
|
number | string | BN,
|
|
77
77
|
number | string | BN,
|
|
78
|
+
number | string | BN,
|
|
78
79
|
number | string | BN
|
|
79
80
|
] | {
|
|
80
81
|
collateralToken: string;
|
|
@@ -96,6 +97,7 @@ export declare namespace LlamaLendView {
|
|
|
96
97
|
lendApr: number | string | BN;
|
|
97
98
|
debtTokenTotalSupply: number | string | BN;
|
|
98
99
|
debtTokenLeftToBorrow: number | string | BN;
|
|
100
|
+
loanDiscount: number | string | BN;
|
|
99
101
|
};
|
|
100
102
|
type GlobalDataStructOutputArray = [
|
|
101
103
|
string,
|
|
@@ -116,6 +118,7 @@ export declare namespace LlamaLendView {
|
|
|
116
118
|
string,
|
|
117
119
|
string,
|
|
118
120
|
string,
|
|
121
|
+
string,
|
|
119
122
|
string
|
|
120
123
|
];
|
|
121
124
|
type GlobalDataStructOutputStruct = {
|
|
@@ -138,6 +141,7 @@ export declare namespace LlamaLendView {
|
|
|
138
141
|
lendApr: string;
|
|
139
142
|
debtTokenTotalSupply: string;
|
|
140
143
|
debtTokenLeftToBorrow: string;
|
|
144
|
+
loanDiscount: string;
|
|
141
145
|
};
|
|
142
146
|
type GlobalDataStructOutput = GlobalDataStructOutputArray & GlobalDataStructOutputStruct;
|
|
143
147
|
type UserDataStruct = [
|
|
@@ -249,6 +253,7 @@ export interface LlamaLendView extends BaseContract {
|
|
|
249
253
|
}>;
|
|
250
254
|
globalData(market: string): NonPayableTransactionObject<LlamaLendView.GlobalDataStructOutput>;
|
|
251
255
|
healthCalculator(market: string, user: string, collChange: number | string | BN, debtChange: number | string | BN, isFull: boolean, numBands: number | string | BN): NonPayableTransactionObject<string>;
|
|
256
|
+
isControllerValid(_controllerAddr: string, _controllerId: number | string | BN): NonPayableTransactionObject<boolean>;
|
|
252
257
|
maxBorrow(market: string, collateral: number | string | BN, N: number | string | BN): NonPayableTransactionObject<string>;
|
|
253
258
|
minCollateral(market: string, debt: number | string | BN, N: number | string | BN): NonPayableTransactionObject<string>;
|
|
254
259
|
userData(market: string, user: string): NonPayableTransactionObject<LlamaLendView.UserDataStructOutput>;
|
|
@@ -30,11 +30,8 @@ export type { LendingPoolAddressesProvider } from "./LendingPoolAddressesProvide
|
|
|
30
30
|
export type { Lido } from "./Lido";
|
|
31
31
|
export type { LiquityActivePool } from "./LiquityActivePool";
|
|
32
32
|
export type { LiquityView } from "./LiquityView";
|
|
33
|
-
export type {
|
|
34
|
-
export type { LlamaLendCrvUSDCRVController } from "./LlamaLendCrvUSDCRVController";
|
|
35
|
-
export type { LlamaLendTBTCCrvUSDController } from "./LlamaLendTBTCCrvUSDController";
|
|
33
|
+
export type { LlamaLendControllerAbi } from "./LlamaLendControllerAbi";
|
|
36
34
|
export type { LlamaLendView } from "./LlamaLendView";
|
|
37
|
-
export type { LlamaLendWstETHCrvUSDController } from "./LlamaLendWstETHCrvUSDController";
|
|
38
35
|
export type { McdDog } from "./McdDog";
|
|
39
36
|
export type { McdJug } from "./McdJug";
|
|
40
37
|
export type { McdSpotter } from "./McdSpotter";
|
package/esm/types/llamaLend.d.ts
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import { EthAddress, NetworkNumber } from './common';
|
|
2
2
|
import { BandData, UserBandData } from './curveUsd';
|
|
3
|
-
export declare enum
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export declare enum LLVersionsEth {
|
|
4
|
+
LLWstethCrvusd = "llamaLendwstETHcrvUSD",
|
|
5
|
+
LLSusdeCrvusd = "llamaLendsUSDecrvUSD",
|
|
6
|
+
LLCrvCrvusd = "llamaLendCRVcrvUSD",
|
|
7
|
+
LLCrvusdCrv = "llamaLendcrvUSDCRV",
|
|
8
|
+
LLTbtcCrvusd = "llamaLendTBTCcrvUSD",
|
|
9
|
+
LLCrvusdTbtc = "llamaLendcrvUSDTBTC",
|
|
10
|
+
LLWethCrvusd = "llamaLendWETHcrvUSD",
|
|
11
|
+
LLCrvusdWeth = "llamaLendcrvUSDWETH"
|
|
8
12
|
}
|
|
13
|
+
export declare enum LLVersionsArb {
|
|
14
|
+
LLArbCrvusd = "llamaLendArbcrvUSD",
|
|
15
|
+
LLFxnCrvusd = "llamaLendFXNcrvUSD",
|
|
16
|
+
LLWbtcCrvusd = "llamaLendWBTCcrvUSD",
|
|
17
|
+
LLCrvCrvusd = "llamaLendCRVcrvUSD",
|
|
18
|
+
LLWethCrvusd = "llamaLendWETHcrvUSD"
|
|
19
|
+
}
|
|
20
|
+
export declare const LlamaLendVersions: {
|
|
21
|
+
readonly LLArbCrvusd: LLVersionsArb.LLArbCrvusd;
|
|
22
|
+
readonly LLFxnCrvusd: LLVersionsArb.LLFxnCrvusd;
|
|
23
|
+
readonly LLWbtcCrvusd: LLVersionsArb.LLWbtcCrvusd;
|
|
24
|
+
readonly LLCrvCrvusd: LLVersionsArb.LLCrvCrvusd;
|
|
25
|
+
readonly LLWethCrvusd: LLVersionsArb.LLWethCrvusd;
|
|
26
|
+
readonly LLWstethCrvusd: LLVersionsEth.LLWstethCrvusd;
|
|
27
|
+
readonly LLSusdeCrvusd: LLVersionsEth.LLSusdeCrvusd;
|
|
28
|
+
readonly LLCrvusdCrv: LLVersionsEth.LLCrvusdCrv;
|
|
29
|
+
readonly LLTbtcCrvusd: LLVersionsEth.LLTbtcCrvusd;
|
|
30
|
+
readonly LLCrvusdTbtc: LLVersionsEth.LLCrvusdTbtc;
|
|
31
|
+
readonly LLCrvusdWeth: LLVersionsEth.LLCrvusdWeth;
|
|
32
|
+
};
|
|
33
|
+
export type LlamaLendVersionsType = typeof LlamaLendVersions[keyof typeof LlamaLendVersions];
|
|
9
34
|
export declare enum LlamaLendStatus {
|
|
10
35
|
Nonexistant = "Nonexistant",
|
|
11
36
|
Safe = "Safe",
|
|
@@ -17,7 +42,7 @@ export interface LlamaLendMarketData {
|
|
|
17
42
|
chainIds: NetworkNumber[];
|
|
18
43
|
label: string;
|
|
19
44
|
shortLabel: string;
|
|
20
|
-
value:
|
|
45
|
+
value: LlamaLendVersionsType;
|
|
21
46
|
collAsset: string;
|
|
22
47
|
baseAsset: string;
|
|
23
48
|
controllerAddress: string;
|
|
@@ -40,10 +65,12 @@ export type LlamaLendAssetsData = {
|
|
|
40
65
|
[key: string]: LlamaLendAssetData;
|
|
41
66
|
};
|
|
42
67
|
export interface LlamaLendGlobalMarketData {
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
A: string;
|
|
69
|
+
loanDiscount: string;
|
|
45
70
|
activeBand: string;
|
|
46
71
|
totalDebt: string;
|
|
72
|
+
totalDebtSupplied: string;
|
|
73
|
+
utilization: string;
|
|
47
74
|
ammPrice: string;
|
|
48
75
|
basePrice: string;
|
|
49
76
|
oraclePrice: string;
|
|
@@ -53,7 +80,6 @@ export interface LlamaLendGlobalMarketData {
|
|
|
53
80
|
ammRate: string;
|
|
54
81
|
minBand: string;
|
|
55
82
|
maxBand: string;
|
|
56
|
-
debtCeiling: string;
|
|
57
83
|
borrowRate: string;
|
|
58
84
|
lendRate: string;
|
|
59
85
|
futureBorrowRate: string;
|
package/esm/types/llamaLend.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export var LLVersionsEth;
|
|
2
|
+
(function (LLVersionsEth) {
|
|
3
|
+
//long only
|
|
4
|
+
LLVersionsEth["LLWstethCrvusd"] = "llamaLendwstETHcrvUSD";
|
|
5
|
+
LLVersionsEth["LLSusdeCrvusd"] = "llamaLendsUSDecrvUSD";
|
|
6
|
+
// long and short crv
|
|
7
|
+
LLVersionsEth["LLCrvCrvusd"] = "llamaLendCRVcrvUSD";
|
|
8
|
+
LLVersionsEth["LLCrvusdCrv"] = "llamaLendcrvUSDCRV";
|
|
9
|
+
// long and short tbtc
|
|
10
|
+
LLVersionsEth["LLTbtcCrvusd"] = "llamaLendTBTCcrvUSD";
|
|
11
|
+
LLVersionsEth["LLCrvusdTbtc"] = "llamaLendcrvUSDTBTC";
|
|
12
|
+
// long and short weth
|
|
13
|
+
LLVersionsEth["LLWethCrvusd"] = "llamaLendWETHcrvUSD";
|
|
14
|
+
LLVersionsEth["LLCrvusdWeth"] = "llamaLendcrvUSDWETH";
|
|
15
|
+
})(LLVersionsEth || (LLVersionsEth = {}));
|
|
16
|
+
export var LLVersionsArb;
|
|
17
|
+
(function (LLVersionsArb) {
|
|
18
|
+
//long only
|
|
19
|
+
LLVersionsArb["LLArbCrvusd"] = "llamaLendArbcrvUSD";
|
|
20
|
+
LLVersionsArb["LLFxnCrvusd"] = "llamaLendFXNcrvUSD";
|
|
21
|
+
LLVersionsArb["LLWbtcCrvusd"] = "llamaLendWBTCcrvUSD";
|
|
22
|
+
LLVersionsArb["LLCrvCrvusd"] = "llamaLendCRVcrvUSD";
|
|
23
|
+
LLVersionsArb["LLWethCrvusd"] = "llamaLendWETHcrvUSD";
|
|
24
|
+
})(LLVersionsArb || (LLVersionsArb = {}));
|
|
25
|
+
export const LlamaLendVersions = Object.assign(Object.assign({}, LLVersionsEth), LLVersionsArb);
|
|
8
26
|
export var LlamaLendStatus;
|
|
9
27
|
(function (LlamaLendStatus) {
|
|
10
28
|
LlamaLendStatus["Nonexistant"] = "Nonexistant";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.61-dev",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@defisaver/tokens": "^1.5.
|
|
22
|
+
"@defisaver/tokens": "^1.5.11",
|
|
23
23
|
"@ethersproject/bignumber": "^5.7.0",
|
|
24
24
|
"@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
|
|
25
25
|
"decimal.js": "^10.4.3"
|