Skip to content

Commit

Permalink
Merge pull request #173 from Se7en-Seas/feat/mainnet-btcn-minting-dec…
Browse files Browse the repository at this point in the history
…oder

BTCN Mainnet Decoder + tests
  • Loading branch information
mel0ndev authored Dec 18, 2024
2 parents 5104039 + 3cf25d5 commit 34afa7f
Show file tree
Hide file tree
Showing 37 changed files with 1,260 additions and 564 deletions.
135 changes: 135 additions & 0 deletions leafs/Mainnet/sBTCNStrategistLeafs.json

Large diffs are not rendered by default.

38 changes: 20 additions & 18 deletions script/DeployDecoderAndSanitizer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {MainnetAddresses} from "test/resources/MainnetAddresses.sol";
import {ContractNames} from "resources/ContractNames.sol";
import {PointFarmingDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/PointFarmingDecoderAndSanitizer.sol";
import {LombardBtcDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/LombardBtcDecoderAndSanitizer.sol";
import {AeraVaultFullDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/AeraVaultFullDecoderAndSanitizer.sol";

import {AeraVaultFullDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/AeraVaultFullDecoderAndSanitizer.sol";
import {sBTCNDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/sBTCNDecoderAndSanitizer.sol";

import {BoringDrone} from "src/base/Drones/BoringDrone.sol";

Expand All @@ -33,32 +33,31 @@ contract DeployDecoderAndSanitizerScript is Script, Test, ContractNames, Mainnet
uint256 public privateKey;
Deployer public deployer = Deployer(deployerAddress);


address boringVault = 0x5401b8620E5FB570064CA9114fd1e135fd77D57c;
//address boringVault = 0x5401b8620E5FB570064CA9114fd1e135fd77D57c;

//address boringVault = 0x5401b8620E5FB570064CA9114fd1e135fd77D57c;
//address boringVault = 0x1293b71644e7E55A692Cade85a0EDB381868AA7c;
address eEigen = 0xE77076518A813616315EaAba6cA8e595E845EeE9;
//address boringVault = 0x1293b71644e7E55A692Cade85a0EDB381868AA7c;
//address eEigen = 0xE77076518A813616315EaAba6cA8e595E845EeE9;

address liquidUsd = 0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C;
//address liquidUsd = 0x08c6F91e2B681FaF5e17227F2a44C307b3C1364C;

address boringVault = 0x5E272ca4bD94e57Ec5C51D26703621Ccac1A7089;

function setUp() external {
//privateKey = vm.envUint("ETHERFI_LIQUID_DEPLOYER");
vm.createSelectFork("base");
vm.createSelectFork("mainnet");
}

function run() external {
bytes memory creationCode;
bytes memory constructorArgs;
privateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(privateKey);
console.log(privateKey);

creationCode = type(AerodromeDecoderAndSanitizer).creationCode;
address aerodromeNonFungiblePositionManager = 0x827922686190790b37229fd06084350E74485b72;
constructorArgs = abi.encode(boringVault, aerodromeNonFungiblePositionManager);
deployer.deployContract(LombardBtcAerodromeDecoderAndSanitizerName, creationCode, constructorArgs, 0);
//creationCode = type(AerodromeDecoderAndSanitizer).creationCode;
//address aerodromeNonFungiblePositionManager = 0x827922686190790b37229fd06084350E74485b72;
//constructorArgs = abi.encode(boringVault, aerodromeNonFungiblePositionManager);
//deployer.deployContract(LombardBtcAerodromeDecoderAndSanitizerName, creationCode, constructorArgs, 0);

// creationCode = type(OnlyKarakDecoderAndSanitizer).creationCode;
// constructorArgs = abi.encode(boringVault);
Expand Down Expand Up @@ -88,11 +87,14 @@ contract DeployDecoderAndSanitizerScript is Script, Test, ContractNames, Mainnet

// new LombardBtcDecoderAndSanitizer(boringVault, baseUniswapV3NonFungiblePositionManager);

creationCode = type(AeraVaultFullDecoderAndSanitizer).creationCode;
constructorArgs = abi.encode(boringVault);
deployer.deployContract("Aera Vault Decoder and Santizier v0.0", creationCode, constructorArgs, 0);


//creationCode = type(AeraVaultFullDecoderAndSanitizer).creationCode;
//constructorArgs = abi.encode(boringVault);
//deployer.deployContract("Aera Vault Decoder and Santizier v0.0", creationCode, constructorArgs, 0);

creationCode = type(sBTCNDecoderAndSanitizer).creationCode;
constructorArgs = abi.encode(boringVault, uniswapV3NonFungiblePositionManager);
deployer.deployContract("Staked BTCN Decoder and Sanitizer V0.2", creationCode, constructorArgs, 0);

vm.stopBroadcast();
}
}
11 changes: 2 additions & 9 deletions script/MerkleRootCreation/Mainnet/CreateAeraTestMerkleRoot.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ import {ManagerWithMerkleVerification} from "src/base/Roles/ManagerWithMerkleVer
import {MerkleTreeHelper} from "test/resources/MerkleTreeHelper/MerkleTreeHelper.sol";
import "forge-std/Script.sol";


/**
* source .env && forge script script/MerkleRootCreation/Mainnet/CreateAeraTestMerkleRoot.s.sol:CreateAeraMerkleRoot --rpc-url $MAINNET_RPC_URL
*/


contract CreateAeraMerkleRoot is Script, MerkleTreeHelper {
using FixedPointMathLib for uint256;



/**
* @notice Uncomment which script you want to run.
*/
Expand All @@ -27,8 +23,5 @@ contract CreateAeraMerkleRoot is Script, MerkleTreeHelper {
generateAdminStrategistMerkleRoot();
}

function generateAdminStrategistMerkleRoot() public {

}

function generateAdminStrategistMerkleRoot() public {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract CreateEtherFiEigenMerkleRootScript is Script, MerkleTreeHelper {
*/
function run() external {
/// NOTE Only have 1 function run at a time, otherwise the merkle root created will be wrong.
generateAdminStrategistMerkleRoot();
generateAdminStrategistMerkleRoot();
//generateAdminMerkleRoot();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract CreateLoopBtcMerkleRootScript is Script, MerkleTreeHelper {
address public boringVault = 0xFE0C961A49E1aEe2AE2d842fE40157365C6d978f;
address public managerAddress = 0xaE4b4cfBB7A0B90e9455761ed6D93d6Dc1759710;
address public accountantAddress = 0xf1ecf4802C2b5Cf9c830A4AF297842Daa6D0f986;
address public rawDataDecoderAndSanitizer = 0x1bF0033c1F582ABFce07Dcb9b9020cB50416e20A;
address public rawDataDecoderAndSanitizer = 0x1bF0033c1F582ABFce07Dcb9b9020cB50416e20A;

function setUp() external {}

Expand All @@ -40,11 +40,11 @@ contract CreateLoopBtcMerkleRootScript is Script, MerkleTreeHelper {
ManageLeaf[] memory leafs = new ManageLeaf[](16);

// ========================== Aera ==========================
ERC20[] memory depositTokens = new ERC20[](3);
ERC20[] memory depositTokens = new ERC20[](3);
depositTokens[0] = ERC20(getAddress(sourceChain, "WBTC"));
depositTokens[1] = ERC20(getAddress(sourceChain, "LBTC"));
depositTokens[1] = ERC20(getAddress(sourceChain, "LBTC"));
depositTokens[2] = ERC20(getAddress(sourceChain, "cbBTC"));
_addAeraLeafs(leafs, getAddress(sourceChain, "aeraLoopBTCVault"), depositTokens);
_addAeraLeafs(leafs, getAddress(sourceChain, "aeraLoopBTCVault"), depositTokens);

//_verifyDecoderImplementsLeafsFunctionSelectors(leafs);

Expand Down
83 changes: 83 additions & 0 deletions script/MerkleRootCreation/Mainnet/CreateStakedBTCNMerkleRoot.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// 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/Mainnet/CreateStakedBTCNMerkleRoot.s.sol:CreateStakedBTCNMerkleRoot --rpc-url $MAINNET_RPC_URL */
contract CreateStakedBTCNMerkleRoot is Script, MerkleTreeHelper {
using FixedPointMathLib for uint256;

address boringVault = 0x5E272ca4bD94e57Ec5C51D26703621Ccac1A7089;
address managerAddress = 0x5239158272D1f626aF9ef3353489D3Cb68439D66;
address accountantAddress = 0x9A22F5dC4Ec86184D4771E620eb75D52E7b9E043;
address rawDataDecoderAndSanitizer = 0xCAc92301f96e3b6554EF11366482f464c6f87cFB;


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(mainnet);
setAddress(false, mainnet, "boringVault", boringVault);
setAddress(false, mainnet, "managerAddress", managerAddress);
setAddress(false, mainnet, "accountantAddress", accountantAddress);
setAddress(false, mainnet, "rawDataDecoderAndSanitizer", rawDataDecoderAndSanitizer);

ManageLeaf[] memory leafs = new ManageLeaf[](64);

// ========================== UniswapV3 ==========================
address[] memory token0 = new address[](3);
token0[0] = getAddress(sourceChain, "WBTC");
token0[1] = getAddress(sourceChain, "WBTC");
token0[2] = getAddress(sourceChain, "cbBTC");

address[] memory token1 = new address[](3);
token1[0] = getAddress(sourceChain, "cbBTC");
token1[1] = getAddress(sourceChain, "LBTC");
token1[2] = getAddress(sourceChain, "LBTC");

_addUniswapV3Leafs(leafs, token0, token1);

// ========================== 1inch ==========================
address[] memory assets = new address[](3);
SwapKind[] memory kind = new SwapKind[](3);
assets[0] = getAddress(sourceChain, "WBTC");
kind[0] = SwapKind.BuyAndSell;
assets[1] = getAddress(sourceChain, "LBTC");
kind[1] = SwapKind.BuyAndSell;
assets[2] = getAddress(sourceChain, "cbBTC");
kind[2] = SwapKind.BuyAndSell;
_addLeafsFor1InchGeneralSwapping(leafs, assets, kind);

// ========================== Corn BTCN ==========================
_addBTCNLeafs(leafs, getERC20(sourceChain, "WBTC"), getERC20(sourceChain, "BTCN"), getAddress(sourceChain, "cornSwapFacilityWBTC"));
_addBTCNLeafs(leafs, getERC20(sourceChain, "cbBTC"), getERC20(sourceChain, "BTCN"), getAddress(sourceChain, "cornSwapFacilitycbBTC"));

// ========================== LayerZero ==========================
_addLayerZeroLeafs(
leafs, getERC20(sourceChain, "BTCN"), getAddress(sourceChain, "BTCN"), layerZeroCornEndpointId
);
_addLayerZeroLeafs(
leafs, getERC20(sourceChain, "LBTC"), getAddress(sourceChain, "LBTCOFTAdapter"), layerZeroCornEndpointId
);

_verifyDecoderImplementsLeafsFunctionSelectors(leafs);

string memory filePath = "./leafs/Mainnet/sBTCNStrategistLeafs.json";

bytes32[][] memory manageTree = _generateMerkleTree(leafs);

_generateLeafs(filePath, leafs, manageTree[manageTree.length - 1][0], manageTree);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
pragma solidity 0.8.21;

import {BaseDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";
import {AeraVaultDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/AeraVaultDecoderAndSanitizer.sol";
import {AeraVaultDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/AeraVaultDecoderAndSanitizer.sol";

contract AeraVaultFullDecoderAndSanitizer is AeraVaultDecoderAndSanitizer {

constructor(address _boringVault) AeraVaultDecoderAndSanitizer(_boringVault) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;

import {BaseDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";
import {BTCNMinterDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/BTCNMinterDecoderAndSanitizer.sol";

contract BTCNFullMinterDecoderAndSanitizer is BTCNMinterDecoderAndSanitizer {
constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault) {}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;

import {FluidDexDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/FluidDexDecoderAndSanitizer.sol";
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){}
constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault) {}
}
10 changes: 3 additions & 7 deletions src/base/DecodersAndSanitizers/LombardBtcDecoderAndSanitizer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {StandardBridgeDecoderAndSanitizer} from
import {CompoundV3DecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/CompoundV3DecoderAndSanitizer.sol";
import {MerklDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/MerklDecoderAndSanitizer.sol";
import {LidoDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/LidoDecoderAndSanitizer.sol";
import {LombardBTCMinterDecoderAndSanitizer} from "src/base/DecodersAndSanitizers/Protocols/LombardBtcMinterDecoderAndSanitizer.sol";
import {LombardBTCMinterDecoderAndSanitizer} from
"src/base/DecodersAndSanitizers/Protocols/LombardBtcMinterDecoderAndSanitizer.sol";

contract LombardBtcDecoderAndSanitizer is
UniswapV3DecoderAndSanitizer,
Expand Down Expand Up @@ -173,12 +174,7 @@ contract LombardBtcDecoderAndSanitizer is
return addressesFound;
}

function burn(uint256)
external
pure
override(UniswapV3DecoderAndSanitizer)
returns (bytes memory addressesFound)
{
function burn(uint256) external pure override(UniswapV3DecoderAndSanitizer) returns (bytes memory addressesFound) {
// Nothing to sanitize or return
return addressesFound;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +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";
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) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ abstract contract AaveV3DecoderAndSanitizer is BaseDecoderAndSanitizer {
return addressesFound;
}

function claimRewards(address[] calldata /*assets*/, uint256 /*amount*/, address to, address /*reward*/)
function claimRewards(address[] calldata, /*assets*/ uint256, /*amount*/ address to, address /*reward*/ )
external
pure
virtual
returns (bytes memory addressesFound)
{
addressesFound = abi.encodePacked(to);
addressesFound = abi.encodePacked(to);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,35 @@ pragma solidity 0.8.21;
import {BaseDecoderAndSanitizer, DecoderCustomTypes} from "src/base/DecodersAndSanitizers/BaseDecoderAndSanitizer.sol";

abstract contract AeraVaultDecoderAndSanitizer is BaseDecoderAndSanitizer {

constructor(address _boringVault) BaseDecoderAndSanitizer(_boringVault) {}

function deposit(DecoderCustomTypes.AssetValue[] calldata amounts) external pure virtual returns (bytes memory addressesFound) {
function deposit(DecoderCustomTypes.AssetValue[] calldata amounts)
external
pure
virtual
returns (bytes memory addressesFound)
{
for (uint256 i = 0; i < amounts.length; i++) {
addressesFound = abi.encodePacked(amounts[i].asset);
addressesFound = abi.encodePacked(amounts[i].asset);
}
}

function withdraw(DecoderCustomTypes.AssetValue[] calldata amounts) external pure virtual returns (bytes memory addressesFound) {
function withdraw(DecoderCustomTypes.AssetValue[] calldata amounts)
external
pure
virtual
returns (bytes memory addressesFound)
{
for (uint256 i = 0; i < amounts.length; i++) {
addressesFound = abi.encodePacked(amounts[i].asset);
addressesFound = abi.encodePacked(amounts[i].asset);
}
}

function pause() external pure returns (bytes memory addressesFound) {
return addressesFound;
return addressesFound;
}

function resume() external pure returns (bytes memory addressesFound) {
return addressesFound;
return addressesFound;
}
}
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 BTCNMinterDecoderAndSanitizer is BaseDecoderAndSanitizer {
function swapExactCollateralForDebt(
uint256, /*collateralIn*/
uint256, /*debtOutMin*/
address to,
uint256 /*deadline*/
) external pure virtual returns (bytes memory addressesFound) {
return abi.encodePacked(to);
}

function swapExactDebtForCollateral(
uint256, /*debtIn*/
uint256, /*collateralOutMin*/
address to,
uint256 /*deadline*/
) external pure virtual returns (bytes memory addressesFound) {
return abi.encodePacked(to);
}
}
Loading

0 comments on commit 34afa7f

Please sign in to comment.