-
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 #173 from Se7en-Seas/feat/mainnet-btcn-minting-dec…
…oder BTCN Mainnet Decoder + tests
- Loading branch information
Showing
37 changed files
with
1,260 additions
and
564 deletions.
There are no files selected for viewing
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
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
83 changes: 83 additions & 0 deletions
83
script/MerkleRootCreation/Mainnet/CreateStakedBTCNMerkleRoot.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,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); | ||
|
||
} | ||
|
||
} |
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
9 changes: 9 additions & 0 deletions
9
src/base/DecodersAndSanitizers/BTCNFullMinterDecoderAndSanitizer.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,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) {} | ||
} |
5 changes: 2 additions & 3 deletions
5
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 |
---|---|---|
@@ -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) {} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
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 |
---|---|---|
@@ -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) {} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/base/DecodersAndSanitizers/Protocols/BTCNMinterDecoderAndSanitizer.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 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); | ||
} | ||
} |
Oops, something went wrong.