Skip to content

Commit 95f4a3b

Browse files
committed
Add Hub config
1 parent 827765a commit 95f4a3b

File tree

5 files changed

+93
-161
lines changed

5 files changed

+93
-161
lines changed

.env.example

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,3 @@
1-
# Contracts admin.
2-
ADMIN=
3-
4-
# Address that can increase/decerease LP conversion rate.
5-
ADJUSTER=
6-
7-
# Deposits to Liquidity Hub are only allowed till this limit is reached.
8-
ASSETS_LIMIT=
9-
10-
# Liquidity mining tiers. Multiplier will be divided by 1000,000,000. So 1750000000 will result in 1.75x.
11-
# There is no limit to the number of tiers, but has to be atleast one.
12-
TIER_1_SECONDS=7776000
13-
TIER_1_MULTIPLIER=300000000
14-
TIER_2_SECONDS=15552000
15-
TIER_2_MULTIPLIER=800000000
16-
TIER_3_SECONDS=31104000
17-
TIER_3_MULTIPLIER=1666666667
18-
19-
# Rebalance caller.
20-
REBALANCE_CALLER=
21-
22-
# Liquidity Pool parameters.
23-
# Value 500 will result in health factor 5.
24-
MIN_HEALTH_FACTOR=500
25-
26-
# Value 20 will result in LTV 20%.
27-
DEFAULT_LTV=20
28-
MPC_ADDRESS=
29-
WITHDRAW_PROFIT=
30-
PAUSER=
31-
321
# General deployment parameters.
332
# Deploy id + the deployer address acts as a key to determine deployed contract addresses.
343
# It should only be set once and never change, unless you are planning to redeploy everything.

contracts/LiquidityPoolAave.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ contract LiquidityPoolAave is LiquidityPool {
3333
uint256 public minHealthFactor;
3434
uint256 public defaultLTV;
3535

36-
mapping(address token => uint256 ltv) public _borrowTokenLTV;
36+
mapping(address token => uint256 ltv) public borrowTokenLTV;
3737

3838
error TokenLtvExceeded();
3939
error NoCollateral();
@@ -92,8 +92,8 @@ contract LiquidityPoolAave is LiquidityPool {
9292
for (uint256 i = 0; i < tokens.length; ++i) {
9393
address token = tokens[i];
9494
uint256 ltv = ltvs[i];
95-
uint256 oldLTV = _borrowTokenLTV[token];
96-
_borrowTokenLTV[token] = ltv;
95+
uint256 oldLTV = borrowTokenLTV[token];
96+
borrowTokenLTV[token] = ltv;
9797
emit BorrowTokenLTVSet(token, oldLTV, ltv);
9898
}
9999
}
@@ -113,7 +113,7 @@ contract LiquidityPoolAave is LiquidityPool {
113113
// Internal functions
114114

115115
function _checkTokenLTV(address borrowToken) private view {
116-
uint256 ltv = _borrowTokenLTV[borrowToken];
116+
uint256 ltv = borrowTokenLTV[borrowToken];
117117
if (ltv == 0) ltv = defaultLTV;
118118

119119
uint256 totalCollateral = ATOKEN.balanceOf(address(this));

network.config.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,47 @@ interface RoutesConfig {
3232
Pools: string[];
3333
Domains: Network[];
3434
Providers: Provider[];
35-
}
35+
};
3636

3737
interface TokenLtvConfig {
3838
Tokens: string[];
3939
LTVs: number[];
40-
}
40+
};
4141

4242
interface AavePoolConfig {
4343
AaveAddressesProvider: string;
44-
minHealthFactor: number;
45-
defaultLTV: number;
44+
minHealthFactor: number; // Value 500 will result in health factor 5.
45+
defaultLTV: number; // Value 20 will result in LTV 20%.
4646
tokenLTVs?: TokenLtvConfig;
47-
}
47+
};
48+
49+
// Liquidity mining tiers.
50+
// Period is in seconds.
51+
// Multiplier will be divided by 1000,000,000. So 1750000000 will result in 1.75x.
52+
// There is no limit to the number of tiers, but has to be atleast one.
53+
interface Tier {
54+
period: bigint;
55+
multiplier: bigint;
56+
};
57+
58+
interface HubConfig {
59+
AssetsAdjuster: string; // Address that can increase/decerease LP conversion rate.
60+
AssetsLimit: number; // Deposits to Liquidity Hub are only allowed till this limit is reached.
61+
Tiers: Tier[];
62+
};
4863

4964
export interface NetworkConfig {
5065
chainId?: number;
5166
CCTP: CCTPConfig;
5267
USDC: string;
5368
Routes?: RoutesConfig;
5469
IsTest: boolean;
55-
IsHub: boolean;
56-
AssetsLimit?: number;
57-
Admin: string;
58-
AssetsAdjuster: string;
70+
Admin: string; // Every contracts admin/owner.
5971
WithdrawProfit: string;
6072
Pauser: string;
61-
RebalanceCaller: string;
73+
RebalanceCaller: string; // Address that can trigger funds movement between pools.
6274
MpcAddress: string;
75+
Hub?: HubConfig;
6376
AavePool?: AavePoolConfig;
6477
USDCPool?: boolean;
6578
};
@@ -77,9 +90,7 @@ export const networkConfig: NetworksConfig = {
7790
},
7891
USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
7992
IsTest: false,
80-
IsHub: false,
8193
Admin: "",
82-
AssetsAdjuster: "",
8394
WithdrawProfit: "",
8495
Pauser: "",
8596
RebalanceCaller: "",
@@ -103,9 +114,7 @@ export const networkConfig: NetworksConfig = {
103114
},
104115
USDC: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
105116
IsTest: false,
106-
IsHub: false,
107117
Admin: "",
108-
AssetsAdjuster: "",
109118
WithdrawProfit: "",
110119
Pauser: "",
111120
RebalanceCaller: "",
@@ -124,9 +133,7 @@ export const networkConfig: NetworksConfig = {
124133
},
125134
USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
126135
IsTest: false,
127-
IsHub: false,
128136
Admin: "",
129-
AssetsAdjuster: "",
130137
WithdrawProfit: "",
131138
Pauser: "",
132139
RebalanceCaller: "",
@@ -145,9 +152,7 @@ export const networkConfig: NetworksConfig = {
145152
},
146153
USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
147154
IsTest: false,
148-
IsHub: false,
149155
Admin: "",
150-
AssetsAdjuster: "",
151156
WithdrawProfit: "",
152157
Pauser: "",
153158
RebalanceCaller: "",
@@ -166,13 +171,20 @@ export const networkConfig: NetworksConfig = {
166171
},
167172
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
168173
IsTest: false,
169-
IsHub: true,
170174
Admin: "",
171-
AssetsAdjuster: "",
172175
WithdrawProfit: "",
173176
Pauser: "",
174177
RebalanceCaller: "",
175178
MpcAddress: "",
179+
Hub: {
180+
AssetsAdjuster: "",
181+
AssetsLimit: 10_000_000,
182+
Tiers: [
183+
{period: 7776000n, multiplier: 300000000n},
184+
{period: 15552000n, multiplier: 800000000n},
185+
{period: 31104000n, multiplier: 1666666667n},
186+
]
187+
},
176188
Routes: {
177189
Pools: [LiquidityPoolAaveUSDC],
178190
Domains: [Network.ETHEREUM],
@@ -192,9 +204,7 @@ export const networkConfig: NetworksConfig = {
192204
},
193205
USDC: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
194206
IsTest: false,
195-
IsHub: false,
196207
Admin: "",
197-
AssetsAdjuster: "",
198208
WithdrawProfit: "",
199209
Pauser: "",
200210
RebalanceCaller: "",
@@ -213,9 +223,7 @@ export const networkConfig: NetworksConfig = {
213223
},
214224
USDC: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
215225
IsTest: true,
216-
IsHub: false,
217226
Admin: "0xcf2d403c75ba3481ae7b190b1cd3246b5afe9120",
218-
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
219227
WithdrawProfit: "0xed24c1ca7c8d01c4ba862c6792ad6144f01566f2",
220228
Pauser: "0xcc5dd1eec29dbe028e61e91db5da4d453be48d90",
221229
RebalanceCaller: "0x20ad9b208767e98dba19346f88b2686f00dbcf58",
@@ -235,9 +243,7 @@ export const networkConfig: NetworksConfig = {
235243
},
236244
USDC: "0x5425890298aed601595a70ab815c96711a31bc65",
237245
IsTest: true,
238-
IsHub: false,
239246
Admin: "0xcf2d403c75ba3481ae7b190b1cd3246b5afe9120",
240-
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
241247
WithdrawProfit: "0xed24c1ca7c8d01c4ba862c6792ad6144f01566f2",
242248
Pauser: "0xcc5dd1eec29dbe028e61e91db5da4d453be48d90",
243249
RebalanceCaller: "0x20ad9b208767e98dba19346f88b2686f00dbcf58",
@@ -256,9 +262,7 @@ export const networkConfig: NetworksConfig = {
256262
},
257263
USDC: "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
258264
IsTest: true,
259-
IsHub: false,
260265
Admin: "0xcf2d403c75ba3481ae7b190b1cd3246b5afe9120",
261-
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
262266
WithdrawProfit: "0xed24c1ca7c8d01c4ba862c6792ad6144f01566f2",
263267
Pauser: "0xcc5dd1eec29dbe028e61e91db5da4d453be48d90",
264268
RebalanceCaller: "0x20ad9b208767e98dba19346f88b2686f00dbcf58",
@@ -277,9 +281,7 @@ export const networkConfig: NetworksConfig = {
277281
},
278282
USDC: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
279283
IsTest: true,
280-
IsHub: false,
281284
Admin: "0xcf2d403c75ba3481ae7b190b1cd3246b5afe9120",
282-
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
283285
WithdrawProfit: "0xed24c1ca7c8d01c4ba862c6792ad6144f01566f2",
284286
Pauser: "0xcc5dd1eec29dbe028e61e91db5da4d453be48d90",
285287
RebalanceCaller: "0x20ad9b208767e98dba19346f88b2686f00dbcf58",
@@ -303,13 +305,20 @@ export const networkConfig: NetworksConfig = {
303305
},
304306
USDC: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
305307
IsTest: true,
306-
IsHub: true,
307308
Admin: "0xcf2d403c75ba3481ae7b190b1cd3246b5afe9120",
308-
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
309309
WithdrawProfit: "0xed24c1ca7c8d01c4ba862c6792ad6144f01566f2",
310310
Pauser: "0xcc5dd1eec29dbe028e61e91db5da4d453be48d90",
311311
RebalanceCaller: "0x20ad9b208767e98dba19346f88b2686f00dbcf58",
312312
MpcAddress: "0xc731bac6c62ecb49dba1393700218d03beaa0359",
313+
Hub: {
314+
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
315+
AssetsLimit: 1000,
316+
Tiers: [
317+
{period: 600n, multiplier: 300000000n},
318+
{period: 1200n, multiplier: 800000000n},
319+
{period: 2400n, multiplier: 1666666667n},
320+
]
321+
},
313322
Routes: {
314323
Pools: [LiquidityPoolUSDC, LiquidityPoolAaveUSDC],
315324
Domains: [Network.ETHEREUM_SEPOLIA, Network.ARBITRUM_SEPOLIA],
@@ -330,9 +339,7 @@ export const networkConfig: NetworksConfig = {
330339
},
331340
USDC: "0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",
332341
IsTest: true,
333-
IsHub: false,
334342
Admin: "0xcf2d403c75ba3481ae7b190b1cd3246b5afe9120",
335-
AssetsAdjuster: "0x6c663396827e68d10c58691f9c4bb58ae9ec85e3",
336343
WithdrawProfit: "0xed24c1ca7c8d01c4ba862c6792ad6144f01566f2",
337344
Pauser: "0xcc5dd1eec29dbe028e61e91db5da4d453be48d90",
338345
RebalanceCaller: "0x20ad9b208767e98dba19346f88b2686f00dbcf58",

0 commit comments

Comments
 (0)