-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
* feat: deployAgTokenSideChain script * feat: DeployChain script * feat: deployTokenSideChain script * feat: remove BasicScript * chore: update fs_permissions in foundry.toml * refactor: rename angleImpl to agTokenImpl * feat: deploy proxy with create2 * feat: rename to new A naming * chore: add optimizer in ci profile * feat: hardcode symbol for ANGLE * feat: check expectedAddress before create2 * refactor: rename script to deploy angle on sidechain * feat: in case of a mock coreborrow, initialize contracts * chore: update utils dependency * feat: immutable proxy first to deployer hen real implementation * feat: env vvariable for governor / guardian * feat: remove guardian proxyAdmin from DeployCHain script * feat: store addresses in a json * feat: LayerZeroBridgeTokenERC20 * feat: remove mock governor when using scripts as mock * feat: treasury write to addresses json * feat: add back require to check preocmputed address * feat: vanity now loads everything from multiple files * feat: create2 deploy for veANGLE * fix: vanity address script returns salt * feat: expected address is env or chain to contract on mainnet * chore: remove via_ir in foundry.toml * chore: update forge-std to add envExists * feat: ir-minmum in coverage * chore: remappings for slither * chore: add back foundry compile before * chore: ignore script and test for slither * chore: specify version for slither in ci * chore: remove wrong src * chore: tmate * chore: try to run slither manually * chore: set sarif file * chore: debug ci * chore: use new version of slither ci * feat: scripts works even if addresses.json doesn't exists * chore: update utils dependency * fix: compile DeployAgTokenSideChain * chore: manual ci for slither * chore: try to set output to a constant * chore: try to rename sarif file * chore: add an && in stead of | in ci * chore: try to redirect output to stdout * chore: results.sarif file * chore: upgrade utils dependency * feat: change governor optional * feat: governor and guardian inside addresses.json * chore: loads slither errors * chore: update utils dependency * feat: update vanity of EURA * feat: new salt for EUR * chore: update foundry.toml to add base and linea etherscan api keys * feat: expected addresses for EURA and ANGLE * chore: remove base from etherscan keys * feat: mantle * feat: update name of AngleSideChain to ANGLE * feat: setuseCustomAdapterParams * feat: useCustomAdapaters good interface * feat: all steps to deploy a new chain * feat: transfer ownership of ProxyAdmin * feat: add governor when deploying a new chain * feat: remove useless line * feat: finalize is optional * feat: deploy savings * fix: savings now compile * feat: change address for savings to arbitrum * fix: correct epxectedAddress * fix: write savings address in json * feat: deduce stableType from STABLE_NAME * feat: add blast config * fix: forwardUtils * fix: deployChain works without sdk * feat: governor and guardian addresses
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,20 +221,20 @@ jobs: | |
version: nightly | ||
|
||
- name: Compile foundry | ||
run: forge clean && forge build --build-info --force | ||
run: forge clean && forge build --build-info --force --skip "*/test/**" "*/scripts/**" | ||
|
||
- name: "Install Slither" | ||
run: "python3 -m pip install slither-analyzer" | ||
|
||
- name: "Run Slither analysis" | ||
uses: "crytic/[email protected]" | ||
id: "slither" | ||
with: | ||
ignore-compile: true | ||
fail-on: "none" | ||
sarif: "results.sarif" | ||
id: slither | ||
run: | ||
slither . --ignore-compile --sarif results.sarif --fail-none | ||
|
||
- name: "Upload SARIF file to GitHub code scanning" | ||
uses: "github/codeql-action/upload-sarif@v2" | ||
with: | ||
sarif_file: ${{ steps.slither.outputs.sarif }} | ||
sarif_file: results.sarif | ||
|
||
- name: "Add Slither summary" | ||
run: | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
pragma solidity ^0.8.12; | ||
|
||
import "./utils/OFTCore.sol"; | ||
import "../../interfaces/IAgTokenSideChainMultiBridge.sol"; | ||
import "oz-upgradeable/security/PausableUpgradeable.sol"; | ||
import "oz-upgradeable/token/ERC20/ERC20Upgradeable.sol"; | ||
|
||
/// @title LayerZeroBridgeTokenERC20 | ||
/// @author Angle Core Team, forked from https://github.com/LayerZero-Labs/solidity-examples/blob/main/contracts/token/oft/OFT.sol | ||
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
Check warning on line 11 in contracts/agToken/layerZero/LayerZeroBridgeTokenERC20.sol GitHub Actions / lint
|
||
/// @notice Contract to be deployed on a L2/sidechain for bridging a token (ANGLE for instance) using | ||
/// a bridge intermediate token and LayerZero | ||
contract LayerZeroBridgeTokenERC20 is OFTCore, ERC20Upgradeable, PausableUpgradeable { | ||
/// @notice Address of the bridgeable token | ||
IAgTokenSideChainMultiBridge public canonicalToken; | ||
|
||
// =================================== ERRORS ================================== | ||
|
||
error InvalidAllowance(); | ||
|
||
// ================================ CONSTRUCTOR ================================ | ||
|
||
/// @notice Initializes the contract | ||
/// @param _name Name of the token corresponding to this contract | ||
/// @param _symbol Symbol of the token corresponding to this contract | ||
/// @param _lzEndpoint Layer zero endpoint to pass messages | ||
/// @param _coreBorrow Address of the `CoreBorrow` contract used for access control | ||
/// @param _canonicalToken Address of the bridgeable token | ||
function initialize( | ||
string memory _name, | ||
string memory _symbol, | ||
address _lzEndpoint, | ||
address _coreBorrow, | ||
address _canonicalToken | ||
) external initializer { | ||
if (_canonicalToken == address(0)) revert ZeroAddress(); | ||
__ERC20_init_unchained(_name, _symbol); | ||
__LzAppUpgradeable_init(_lzEndpoint, _coreBorrow); | ||
|
||
canonicalToken = IAgTokenSideChainMultiBridge(_canonicalToken); | ||
_approve(address(this), _canonicalToken, type(uint256).max); | ||
} | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() initializer {} | ||
|
||
// ===================== EXTERNAL PERMISSIONLESS FUNCTIONS ===================== | ||
|
||
/// @inheritdoc OFTCore | ||
function sendWithPermit( | ||
uint16 _dstChainId, | ||
bytes memory _toAddress, | ||
uint256 _amount, | ||
address payable _refundAddress, | ||
address _zroPaymentAddress, | ||
bytes memory _adapterParams, | ||
uint256 deadline, | ||
uint8 v, | ||
bytes32 r, | ||
bytes32 s | ||
) public payable override { | ||
canonicalToken.permit(msg.sender, address(this), _amount, deadline, v, r, s); | ||
send(_dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); | ||
} | ||
|
||
/// @inheritdoc OFTCore | ||
function withdraw(uint256 amount, address recipient) external override returns (uint256 amountMinted) { | ||
// Does not check allowances as transfers from `msg.sender` | ||
_transfer(msg.sender, address(this), amount); | ||
amountMinted = canonicalToken.swapIn(address(this), amount, recipient); | ||
uint256 leftover = balanceOf(address(this)); | ||
if (leftover > 0) { | ||
_transfer(address(this), msg.sender, leftover); | ||
} | ||
} | ||
|
||
// ============================= INTERNAL FUNCTIONS ============================ | ||
|
||
/// @inheritdoc OFTCore | ||
function _debitFrom( | ||
uint16, | ||
bytes memory, | ||
uint256 _amount | ||
) internal override whenNotPaused returns (uint256 amountSwapped) { | ||
// No need to use safeTransferFrom as we know this implementation reverts on failure | ||
canonicalToken.transferFrom(msg.sender, address(this), _amount); | ||
|
||
// Swap canonical for this bridge token. There may be some fees | ||
amountSwapped = canonicalToken.swapOut(address(this), _amount, address(this)); | ||
_burn(address(this), amountSwapped); | ||
} | ||
|
||
/// @inheritdoc OFTCore | ||
function _debitCreditFrom(uint16, bytes memory, uint256 _amount) internal override whenNotPaused returns (uint256) { | ||
_burn(msg.sender, _amount); | ||
return _amount; | ||
} | ||
|
||
/// @inheritdoc OFTCore | ||
function _creditTo( | ||
uint16, | ||
address _toAddress, | ||
uint256 _amount | ||
) internal override whenNotPaused returns (uint256 amountMinted) { | ||
_mint(address(this), _amount); | ||
amountMinted = canonicalToken.swapIn(address(this), _amount, _toAddress); | ||
uint256 leftover = balanceOf(address(this)); | ||
if (leftover > 0) { | ||
_transfer(address(this), _toAddress, leftover); | ||
} | ||
} | ||
|
||
// =============================== VIEW FUNCTIONS ============================== | ||
|
||
/// @inheritdoc ERC165Upgradeable | ||
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { | ||
return | ||
interfaceId == type(IOFT).interfaceId || | ||
interfaceId == type(IERC20).interfaceId || | ||
super.supportsInterface(interfaceId); | ||
} | ||
|
||
// ============================ GOVERNANCE FUNCTIONS =========================== | ||
|
||
/// @notice Mints the intermediate contract to the `canonicalToken` | ||
/// @dev Used to increase the bridging capacity | ||
function mint(uint256 amount) external onlyGovernorOrGuardian { | ||
_mint(address(canonicalToken), amount); | ||
} | ||
|
||
/// @notice Burns the intermediate contract from the `canonicalToken` | ||
/// @dev Used to decrease the bridging capacity | ||
function burn(uint256 amount) external onlyGovernorOrGuardian { | ||
_burn(address(canonicalToken), amount); | ||
} | ||
|
||
/// @notice Increases allowance of the `canonicalToken` | ||
function setupAllowance() public onlyGovernorOrGuardian { | ||
_approve(address(this), address(canonicalToken), type(uint256).max); | ||
} | ||
|
||
/// @notice Pauses bridging through the contract | ||
/// @param pause Future pause status | ||
function pauseSendTokens(bool pause) external onlyGovernorOrGuardian { | ||
pause ? _pause() : _unpause(); | ||
} | ||
|
||
uint256[49] private __gap; | ||
} |
+6 −12 | .github/workflows/ci.yml | |
+3 −1 | .github/workflows/sync.yml | |
+2 −2 | foundry.toml | |
+1 −1 | src/StdAssertions.sol | |
+7 −7 | src/StdChains.sol | |
+1 −1 | src/StdUtils.sol | |
+116 −6 | src/Vm.sol | |
+7 −7 | test/StdChains.t.sol | |
+1 −1 | test/StdCheats.t.sol | |
+2 −2 | test/Vm.t.sol |
+0 −1 | .npmrc | |
+12 −0 | helpers/common.sh | |
+1 −1 | lib/forge-std | |
+326 −236 | src/CommonUtils.sol | |
+8 −1 | src/Constants.sol | |
+37 −0 | utils/getConnectedChains.js |
This file was deleted.