-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from Se7en-Seas/feat/add-lbtc-base
Feat/add lbtc base
- Loading branch information
Showing
17 changed files
with
3,173 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
script/MerkleRootCreation/Base/CreateLBTCMerkleRoot.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.21; | ||
|
||
import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol"; | ||
import {ERC20} from "@solmate/tokens/ERC20.sol"; | ||
import {Strings} from "lib/openzeppelin-contracts/contracts/utils/Strings.sol"; | ||
import {ERC4626} from "@solmate/tokens/ERC4626.sol"; | ||
import {ManagerWithMerkleVerification} from "src/base/Roles/ManagerWithMerkleVerification.sol"; | ||
import {MerkleTreeHelper} from "test/resources/MerkleTreeHelper/MerkleTreeHelper.sol"; | ||
import "forge-std/Script.sol"; | ||
|
||
/** | ||
* source .env && forge script script/MerkleRootCreation/Base/CreateLBTCMerkleRoot.s.sol:CreateLBTCMerkleRootScript --rpc-url $BASE_RPC_URL | ||
*/ | ||
contract CreateLBTCMerkleRootScript is Script, MerkleTreeHelper { | ||
using FixedPointMathLib for uint256; | ||
|
||
address public boringVault = 0x5401b8620E5FB570064CA9114fd1e135fd77D57c; | ||
address public managerAddress = 0xcf38e37872748E3b66741A42560672A6cef75e9B; | ||
address public accountantAddress = 0x28634D0c5edC67CF2450E74deA49B90a4FF93dCE; | ||
address public rawDataDecoderAndSanitizer = 0xAae1c7546a8CCa32C0B02d8f4aB3A8a3d6E18070; | ||
address public aerodromeDecoderAndSanitizer = 0xD657c2A871C467871b59d5992CD3bAb1634dd457; | ||
|
||
function setUp() external {} | ||
|
||
/** | ||
* @notice Uncomment which script you want to run. | ||
*/ | ||
function run() external { | ||
/// NOTE Only have 1 function run at a time, otherwise the merkle root created will be wrong. | ||
generateAdminStrategistMerkleRoot(); | ||
} | ||
|
||
function generateAdminStrategistMerkleRoot() public { | ||
setSourceChainName(base); | ||
setAddress(false, base, "boringVault", boringVault); | ||
setAddress(false, base, "managerAddress", managerAddress); | ||
setAddress(false, base, "accountantAddress", accountantAddress); | ||
setAddress(false, base, "rawDataDecoderAndSanitizer", rawDataDecoderAndSanitizer); | ||
|
||
ManageLeaf[] memory leafs = new ManageLeaf[](128); | ||
|
||
// ========================== UniswapV3 ========================== | ||
address[] memory token0 = new address[](3); | ||
token0[0] = getAddress(sourceChain, "cbBTC"); | ||
token0[1] = getAddress(sourceChain, "cbBTC"); | ||
token0[2] = getAddress(sourceChain, "LBTC"); | ||
|
||
address[] memory token1 = new address[](3); | ||
token1[0] = getAddress(sourceChain, "LBTC"); | ||
token1[1] = getAddress(sourceChain, "WBTC"); | ||
token1[2] = getAddress(sourceChain, "WBTC"); | ||
|
||
_addUniswapV3Leafs(leafs, token0, token1); | ||
|
||
// ========================== 1inch ========================== | ||
address[] memory assets = new address[](4); | ||
SwapKind[] memory kind = new SwapKind[](4); | ||
assets[0] = getAddress(sourceChain, "cbBTC"); | ||
kind[0] = SwapKind.BuyAndSell; | ||
assets[1] = getAddress(sourceChain, "LBTC"); | ||
kind[1] = SwapKind.BuyAndSell; | ||
assets[2] = getAddress(sourceChain, "WBTC"); | ||
kind[2] = SwapKind.BuyAndSell; | ||
assets[3] = getAddress(sourceChain, "AERO"); | ||
kind[3] = SwapKind.Sell; | ||
//assets[3] = getAddress(sourceChain, "PENDLE"); | ||
//kind[3] = SwapKind.Sell; | ||
_addLeafsFor1InchGeneralSwapping(leafs, assets, kind); | ||
|
||
// ========================== Pendle ========================== | ||
_addPendleMarketLeafs(leafs, getAddress(sourceChain, "pendle_LBTC_market_05_29_25"), true); | ||
|
||
// ========================== Morpho ========================== | ||
_addERC4626Leafs(leafs, ERC4626(getAddress(sourceChain, "gauntletCbBTCcore"))); | ||
|
||
// ========================= Aerodrome ======================== | ||
setAddress(true, sourceChain, "rawDataDecoderAndSanitizer", aerodromeDecoderAndSanitizer); | ||
address[] memory _token0 = new address[](1); | ||
_token0[0] = getAddress(sourceChain, "LBTC"); | ||
address[] memory _token1 = new address[](1); | ||
_token1[0] = getAddress(sourceChain, "cbBTC"); | ||
|
||
address[] memory gauges = new address[](1); | ||
gauges[0] = address(0); | ||
|
||
_addVelodromeV3Leafs( | ||
leafs, _token0, _token1, getAddress(sourceChain, "aerodromeNonFungiblePositionManager"), gauges | ||
); | ||
|
||
// ========================== Lombard ======================== | ||
// setAddress(true, sourceChain, "rawDataDecoderAndSanitizer", rawDataDecoderAndSanitizer); | ||
// _addLombardBTCLeafs(leafs, getERC20(sourceChain, "cbBTC"), getERC20(sourceChain, "LBTC")); | ||
|
||
string memory filePath = "./leafs/Base/LombardBTCStrategistLeafs.json"; | ||
|
||
bytes32[][] memory manageTree = _generateMerkleTree(leafs); | ||
|
||
_generateLeafs(filePath, leafs, manageTree[manageTree.length - 1][0], manageTree); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/base/DecodersAndSanitizers/FluidDexFullDecoderAndSanitizer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.21; | ||
|
||
import {FluidDexDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/FluidDexDecoderAndSanitizer.sol"; | ||
import {BaseDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol"; | ||
|
||
contract FluidDexFullDecoderAndSanitizer is FluidDexDecoderAndSanitizer { | ||
|
||
constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault){} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/base/DecodersAndSanitizers/LombardBtcFullMinterDecoderAndSanitizer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.21; | ||
|
||
import {BaseDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol"; | ||
import {LombardBTCMinterDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/LombardBtcMinterDecoderAndSanitizer.sol"; | ||
|
||
contract LombardBTCFullMinterDecoderAndSanitizer is LombardBTCMinterDecoderAndSanitizer { | ||
|
||
constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/base/DecodersAndSanitizers/Protocols/FluidDexDecoderAndSanitizer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.21; | ||
|
||
import {BaseDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol"; | ||
|
||
|
||
abstract contract FluidDexDecoderAndSanitizer is BaseDecoderAndSanitizer { | ||
|
||
/// @notice T2 and T3 | ||
|
||
/* | ||
* @notice Vault T2 and T3 ((smart collateral, normal debt) / (normal collateral, smart debt)) | ||
* @notice T2 params on LHS, T3 on RHS -> T2ParamName/T3ParamName | ||
* @dev These use the same function sig, so I'm just grouping them together | ||
* @param nftId The ID of the NFT representing the vault position, use 0 for a new position | ||
* @param newColToken0/newCol The change in collateral amount (positive for deposit, negative for withdrawal) * @param newColtoken1/newDebtToken0 The change in debt amount for token0 (positive for borrowing, negative for repayment) | ||
* @param colSharesMinMax/newDebtToken1 The change in debt amount for token1 (positive for borrowing, negative for repayment) | ||
* @param newDebt/debtSharesMinMax Min or max debt shares to mint or burn (positive for borrowing, negative for repayment) | ||
* @param to The address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender) | ||
*/ | ||
function operate( | ||
uint256 /*nftId*/, | ||
int256 /*newColToken0 / newCol*/, | ||
int256 /*newColToken1 / newDebtToken0*/, | ||
int256 /*colSharesMinMax / newDebtToken1*/, | ||
int256 /*newDebt / debtSharesMinMax*/, | ||
address to | ||
) external pure virtual returns (bytes memory addressesFound) { | ||
addressesFound = abi.encodePacked(to); | ||
} | ||
|
||
/* | ||
* @param nftId The ID of the NFT representing the vault position, use 0 for a new position | ||
* @param perfectColShares The change in collateral shares (positive for deposit, negative for withdrawal) | ||
* @param colToken0MinMax_ min or max collateral amount of token0 to withdraw or deposit (positive for deposit, negative for withdrawal) | ||
* @param colToken1MinMax_ min or max collateral amount of token1 to withdraw or deposit (positive for deposit, negative for withdrawal) | ||
* @param newDebt_ The change in debt amount (positive for borrowing, negative for repayment) | ||
* @param to_ The address to receive withdrawn collateral or borrowed tokens (if address(0), defaults to msg.sender) | ||
*/ | ||
function operatePerfect( | ||
uint256 /*nftId*/, | ||
int256 /*perfectColShares*/, | ||
int256 /*colToken0MinMax*/, | ||
int256 /*colToken1MinMax*/, | ||
int256 /*newDebt*/, | ||
address to | ||
) external pure virtual returns (bytes memory addressesFound) { | ||
addressesFound = abi.encodePacked(to); | ||
} | ||
|
||
|
||
/// @notice T4 (smart collateral, smart debt) | ||
|
||
/* | ||
* @param nftId The ID of the NFT representing the vault position | ||
* @param newColToken0 The change in collateral amount for token0 (positive for deposit, negative for withdrawal) | ||
* @param newColToken1 The change in collateral amount for token1 (positive for deposit, negative for withdrawal) | ||
* @param colSharesMinMax Min or max collateral shares to mint or burn (positive for deposit, negative for withdrawal) | ||
* @param newDebtToken0 The change in debt amount for token0 (positive for borrowing, negative for repayment) | ||
* @param newDebtToken1 The change in debt amount for token1 (positive for borrowing, negative for repayment) | ||
* @param debtSharesMinMax Min or max debt shares to burn or mint (positive for borrowing, negative for repayment) | ||
* @param to The address to receive funds (if address(0), defaults to msg.sender) | ||
*/ | ||
function operate( | ||
uint256 /*nftId*/, | ||
int256 /*newColToken0*/, | ||
int256 /*newColToken1*/, | ||
int256 /*colSharesMinMax*/, | ||
int256 /*newDebtToken0*/, | ||
int256 /*newDebtToken1*/, | ||
int256 /*debtSharesMinMax*/, | ||
address to | ||
) external pure virtual returns (bytes memory addressesFound) { | ||
addressesFound = abi.encodePacked(to); | ||
} | ||
|
||
/* | ||
* @param nftId_ The ID of the NFT representing the vault position | ||
* @param perfectColShares_ The change in collateral shares (positive for deposit, negative for withdrawal) | ||
* @param colToken0MinMax_ Min or max collateral amount of token0 to withdraw or deposit (positive for deposit, negative for withdrawal) | ||
* @param colToken1MinMax_ Min or max collateral amount of token1 to withdraw or deposit (positive for deposit, negative for withdrawal) | ||
* @param perfectDebtShares_ The change in debt shares (positive for borrowing, negative for repayment) | ||
* @param debtToken0MinMax_ Min or max debt amount for token0 to borrow or payback (positive for borrowing, negative for repayment) | ||
* @param debtToken1MinMax_ Min or max debt amount for token1 to borrow or payback (positive for borrowing, negative for repayment) | ||
* @param to_ The address to receive funds (if address(0), defaults to msg.sender) | ||
*/ | ||
function operatePerfect( | ||
uint256 /*nftId*/, | ||
int256 /*perfectColShares*/, | ||
int256 /*colToken0MinMax*/, | ||
int256 /*colToken1MinMax*/, | ||
int256 /*perfectDebtShares*/, | ||
int256 /*debtToken0MinMax*/, | ||
int256 /*debtToken1MinMax*/, | ||
address to | ||
) external pure virtual returns (bytes memory addressesFound) { | ||
addressesFound = abi.encodePacked(to); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/base/DecodersAndSanitizers/Protocols/LombardBtcMinterDecoderAndSanitizer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.21; | ||
|
||
import {BaseDecoderAndSanitizer, DecoderCustomTypes} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol"; | ||
|
||
abstract contract LombardBTCMinterDecoderAndSanitizer is BaseDecoderAndSanitizer { | ||
|
||
/// @notice for permissioned users | ||
function mint(address to, uint256 /*amount*/) external pure virtual returns (bytes memory addressesFound) { | ||
addressesFound = abi.encodePacked(to); | ||
} | ||
|
||
/// @notice minting directly via LTBC contract | ||
function mint(bytes calldata data, bytes calldata /*proofSignature*/) external pure virtual returns (bytes memory addressesFound) { | ||
(, address to, , ,) = abi.decode(data, (uint256, address, uint64, bytes32, uint32)); | ||
addressesFound = abi.encodePacked(to); | ||
} | ||
|
||
/// @notice for minting using cbBTCPPM contract | ||
function swapCBBTCToLBTC(uint256 /*amount*/) external pure virtual returns (bytes memory addressesFound) { | ||
return addressesFound; | ||
} | ||
|
||
} |
Oops, something went wrong.