Skip to content

Commit 7f7b5cc

Browse files
viatrixlastperson
andauthored
Feature: Liquidity Pool (#19)
* Add liquidity pool * Fix lint * Cleanup * Fix typo * Fix typo * Fix test * Refactor deployment * Remove withdrawAll * Add nonce and deadline to MPC signature * Make deployable to testnets * Borrow and repay collateral * Try to repay before deposit * Fix typo in _checkTokenLTV * Remove unnecessary condition * Fix ltv calculation * Add sign-borrow task * Add set default LTV task * Set default ltv in task to 20% * Fix default borrow task * Cleanup * Fix warnings * Add upgrade liquidity pool script * Update withdrawProfit * Fix lint * Cleanup, refactor, fix solhint, add tasks * Fix withdrawProfit, cleanup * Fix lint * Check that collateral is supported * Add set-routes tasks and deploy arbitrum sepolia commands --------- Co-authored-by: Oleksii Matiiasevych <oleksii@chainsafe.io>
1 parent a7b0c26 commit 7f7b5cc

28 files changed

+2416
-177
lines changed

.env.example

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,41 @@
11
# Contracts admin.
22
ADMIN=
3-
# Rebalance caller.
4-
REBALANCE_CALLER=
3+
# Address that can increase/decerease LP conversion rate.
4+
ADJUSTER=
55
# Deposits to Liquidity Hub are only allowed till this limit is reached.
66
ASSETS_LIMIT=
77
# Liquidity mining tiers. Multiplier will be divided by 100. So 175 will result in 1.75x.
88
# There is no limit to the number of tiers, but has to be atleast one.
9-
TIER_1_DAYS=90
10-
TIER_1_MULTIPLIER=100
11-
TIER_2_DAYS=180
12-
TIER_2_MULTIPLIER=150
13-
TIER_3_DAYS=360
14-
TIER_3_MULTIPLIER=200
15-
BASE_SEPOLIA_PRIVATE_KEY=
9+
TIER_1_SECONDS=7776000
10+
TIER_1_MULTIPLIER=30
11+
TIER_2_SECONDS=15552000
12+
TIER_2_MULTIPLIER=80
13+
TIER_3_SECONDS=31104000
14+
TIER_3_MULTIPLIER=170
15+
# Rebalance caller.
16+
REBALANCE_CALLER=
17+
# Liquidity Pool parameters.
18+
# Value 500 will result in health factor 5.
19+
MIN_HEALTH_FACTOR=500
20+
# Value 20 will result in LTV 20%.
21+
DEFAULT_LTV=20
22+
MPC_ADDRESS=
23+
WITHDRAW_PROFIT=
24+
# General deployment parameters.
25+
DEPLOYER_PRIVATE_KEY=
1626
VERIFY=false
27+
BASE_SEPOLIA_RPC=
28+
ETHEREUM_SEPOLIA_RPC=
29+
ARBITRUM_SEPOLIA_RPC=
30+
ETHERSCAN_BASE_SEPOLIA=
31+
ETHERSCAN_ETHEREUM_SEPOLIA=
32+
ETHERSCAN_ARBITRUM_SEPOLIA=
33+
# Upgrade and configuration update parameters.
34+
LIQUIDITY_POOL=
35+
REBALANCER=
36+
# Testing parameters.
37+
FORK_PROVIDER=https://eth-mainnet.public.blastapi.io
38+
USDC_OWNER_ADDRESS=0x7713974908Be4BEd47172370115e8b1219F4A5f0
39+
RPL_OWNER_ADDRESS=0xdC7b28976d6eb13082a5Be7C66f9dCFE0115738f
40+
UNI_OWNER_ADDRESS=0x46f34C24A7bA7a2Ac6DD76c3F09B32D41C144d08
41+
PRIME_OWNER_ADDRESS=0x1D0065D367DA1919cD597d25F91a97B6039428C5

.solhint.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"extends": "solhint:recommended",
33
"rules": {
4-
"max-line-length": ["off", 120],
4+
"max-line-length": ["warn", 120],
55
"func-visibility": ["warn", {"ignoreConstructors": true}],
66
"func-name-mixedcase": ["off"],
7-
"one-contract-per-file": ["off"]
7+
"one-contract-per-file": ["off"],
8+
"no-inline-assembly": ["off"],
9+
"avoid-low-level-calls": ["off"]
810
}
911
}

contracts/Deps.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: LGPL-3.0-only
22
pragma solidity 0.8.28;
33

4-
import { TransparentUpgradeableProxy } from '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';
4+
/* solhint-disable no-unused-import */
5+
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contracts/LiquidityHub.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import {
1010
Math
1111
} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol";
1212
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
13-
import {AccessControlUpgradeable} from '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
14-
import {ERC7201Helper} from './utils/ERC7201Helper.sol';
15-
import {IManagedToken} from './interfaces/IManagedToken.sol';
16-
import {ILiquidityPool} from './interfaces/ILiquidityPool.sol';
17-
import {ILiquidityHub} from './interfaces/ILiquidityHub.sol';
13+
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
14+
import {ERC7201Helper} from "./utils/ERC7201Helper.sol";
15+
import {IManagedToken} from "./interfaces/IManagedToken.sol";
16+
import {ILiquidityPool} from "./interfaces/ILiquidityPool.sol";
17+
import {ILiquidityHub} from "./interfaces/ILiquidityHub.sol";
1818

1919
contract LiquidityHub is ILiquidityHub, ERC4626Upgradeable, AccessControlUpgradeable {
2020
using Math for uint256;
@@ -37,12 +37,12 @@ contract LiquidityHub is ILiquidityHub, ERC4626Upgradeable, AccessControlUpgrade
3737
uint256 assetsLimit;
3838
}
3939

40-
bytes32 private constant StorageLocation = 0xb877bfaae1674461dd1960c90f24075e3de3265a91f6906fe128ab8da6ba1700;
40+
bytes32 private constant STORAGE_LOCATION = 0xb877bfaae1674461dd1960c90f24075e3de3265a91f6906fe128ab8da6ba1700;
4141

4242
constructor(address shares, address liquidityPool) {
4343
ERC7201Helper.validateStorageLocation(
44-
StorageLocation,
45-
'sprinter.storage.LiquidityHub'
44+
STORAGE_LOCATION,
45+
"sprinter.storage.LiquidityHub"
4646
);
4747
if (shares == address(0)) revert ZeroAddress();
4848
if (liquidityPool == address(0)) revert ZeroAddress();
@@ -251,7 +251,7 @@ contract LiquidityHub is ILiquidityHub, ERC4626Upgradeable, AccessControlUpgrade
251251

252252
function _getStorage() private pure returns (LiquidityHubStorage storage $) {
253253
assembly {
254-
$.slot := StorageLocation
254+
$.slot := STORAGE_LOCATION
255255
}
256256
}
257257
}

contracts/LiquidityMining.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pragma solidity 0.8.28;
44
import {ERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
55
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
66
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
7-
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
87
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
98

109
contract LiquidityMining is ERC20, Ownable {

0 commit comments

Comments
 (0)