Skip to content

Commit

Permalink
Feat: deploy Frax Ecosystem OFTs (#1)
Browse files Browse the repository at this point in the history
* build: fraxfinance/layerzero-v2-upgradeable

* feat: FraxOFTUpgradeable

* build: fix

* fix(deploy): deployment addr/order

* refactor: deployFraxOFTUpgradeablesAndProxies

* feat: setPeers

* feat: admin role setup

* refactor: bytes conversion, initial state check

* feat: ProxyAdmin

* feat: setEnforcedOptions

* feat: set DVNs

* fix: build

* pass until setDVNs()

* feat: setSendReceiveLibraries()

* feat: deploy local passes

* docs: notice on resolving failed `setSendAndReceiveLibrary()`

* fix: use default send/receive lib

* fix: blast EID

* build: deploy addrs

* deploy: final script for Mode

* ops: deploy v1.0.0

* fix: deterministic ProxyAdmin

* feat: deterministic proxy addr

* feat: ImplementationMock

* ops: deploy v0.1.0
  • Loading branch information
pegahcarter authored Jun 12, 2024
1 parent 3697ff1 commit f8cdb55
Show file tree
Hide file tree
Showing 13 changed files with 8,126 additions and 4,495 deletions.
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@
#
# You don't need to set both of these values, just pick the one that you prefer and set that one
MNEMONIC=
PRIVATE_KEY=
PRIVATE_KEY=

OFT_DEPLOYER=0x2b4309B7cd184C7E3e7BA3bf6CA938c6A37FDCC4
PK_OFT_DEPLOYER=
CONFIG_DEPLOYER=0x19D0467ab629f9Ef1cD51732dacF6dA74cE9CFF6
PK_CONFIG_DEPLOYER=
DELEGATE=

MODE_RPC_URL=https://mainnet.mode.network/
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@

<p align="center">Template project for getting started with LayerZero's <code>OFT</code> contract development.</p>

```
carter@laptop:~/Documents/frax/frax-oft-upgradeable$ forge verify-contract --rpc-url $MODE_RPC_URL --constructor-args $(cast abi-encode "constructor(address)" 0x1a44076050125825900e736c501f859c50fE728c) --verifier-url 'https://api.routescan.io/v2/network/mainnet/evm/34443/etherscan' --etherscan-api-key "verifyContract" --chain-id 34443 0x90a706775489D190256D0C721fC6eA3Df64904d0 contracts/FraxOFTUpgradeable.sol:FraxOFTUpgradeable --watch
Start verifying contract `0x90a706775489D190256D0C721fC6eA3Df64904d0` deployed on mode
Submitting verification for [contracts/FraxOFTUpgradeable.sol:FraxOFTUpgradeable] 0x90a706775489D190256D0C721fC6eA3Df64904d0.
Submitted contract for verification:
Response: `OK`
GUID: `fdbc2830-068c-5ab7-8814-76ed815b7cdc`
URL: https://explorer.mode.network/address/0x90a706775489d190256d0c721fc6ea3df64904d0
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `NOTOK`
Details: `Error: contract does not exist`
carter@laptop:~/Documents/frax/frax-oft-upgradeable$ forge verify-contract --rpc-url $MODE_RPC_URL --constructor-args 0x0000000000000000000000006336CFA6eDBeC2A459d869031DB77fC2770Eaa66 --verifier-url 'https://api.routescan.io/v2/network/mainnet/evm/34443/etherscan' --etherscan-api-key "verifyContract" --chain-id 34443 0xb65c2079dfed58b7a6e472c0d6971605023ec6a9 node_modules/@fraxfinance/layerzero-v2-upgradeable/messagelib/contracts/upgradeable/proxy/ProxyAdmin.sol:ProxyAdmin
Start verifying contract `0xb65c2079dfed58B7a6E472c0d6971605023ec6A9` deployed on mode
Error:
Failed to get standard json input
Context:
- cannot resolve file at "/home/carter/Documents/frax/frax-oft-upgradeable/node_modules/@fraxfinance/layerzero-v2-upgradeable/messagelib/contracts/upgradeable/proxy/ProxyAdmin.sol"
```

## 1) Developing Contracts

#### Installing dependencies
Expand Down
3,495 changes: 3,495 additions & 0 deletions broadcast/DeployFraxOFTProtocol.s.sol/34443/run-1718039607.json

Large diffs are not rendered by default.

3,495 changes: 3,495 additions & 0 deletions broadcast/DeployFraxOFTProtocol.s.sol/34443/run-latest.json

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions contracts/FraxOFTUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import { OFTUpgradeable } from "@fraxfinance/layerzero-v2-upgradeable/oapp/contracts/oft/OFTUpgradeable.sol";
import { SendParam } from "@fraxfinance/layerzero-v2-upgradeable/oapp/contracts/oft/interfaces/IOFT.sol";

contract FraxOFTUpgradeable is OFTUpgradeable {
constructor(address _lzEndpoint) OFTUpgradeable(_lzEndpoint) {}

function version() external pure returns (uint256 major, uint256 minor, uint256 patch) {
major = 1;
minor = 0;
patch = 0;
}

// Admin

function initialize(string memory _name, string memory _symbol, address _delegate) external initializer {
__OFT_init(_name, _symbol, _delegate);
__Ownable_init();
_transferOwnership(_delegate);
}

// Helper views

function toLD(uint64 _amountSD) external view returns (uint256 amountLD) {
return _toLD(_amountSD);
}

function toSD(uint256 _amountLD) external view returns (uint64 amountSD) {
return _toSD(_amountLD);
}

function removeDust(uint256 _amountLD) public view returns (uint256 amountLD) {
return _removeDust(_amountLD);
}

function debitView(uint256 _amountLD, uint256 _minAmountLD, uint32 _dstEid) external view returns (uint256 amountSentLD, uint256 amountReceivedLD) {
/// @dev: _dstEid is unused in _debitView
return _debitView(_amountLD, _minAmountLD, _dstEid);
}

function buildMsgAndOptions(
SendParam calldata _sendParam,
uint256 _amountLD
) external view returns (bytes memory message, bytes memory options) {
return _buildMsgAndOptions(_sendParam, _amountLD);
}

}
2 changes: 1 addition & 1 deletion contracts/MyOFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ contract MyOFT is OFT {
string memory _symbol,
address _lzEndpoint,
address _delegate
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {}
) OFT(_name, _symbol, _lzEndpoint, _delegate) {}
}
12 changes: 12 additions & 0 deletions contracts/mocks/ImplementationMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

contract ImplementationMock {

uint256 public foo;
constructor() {}

function bar() external {
foo++;
}
}
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ remappings = [
'forge-std/=node_modules/@layerzerolabs/toolbox-foundry/lib/forge-std',
'@layerzerolabs/=node_modules/@layerzerolabs/',
'@openzeppelin/=node_modules/@openzeppelin/',
'frax-std/=node_modules/frax-standard-solidity/src/',
]
26 changes: 11 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,11 @@
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@layerzerolabs/eslint-config-next": "~2.3.3",
"@layerzerolabs/lz-definitions": "~2.3.3",
"@layerzerolabs/lz-evm-messagelib-v2": "~2.3.3",
"@layerzerolabs/lz-evm-oapp-v2": "~2.3.3",
"@fraxfinance/layerzero-v2-upgradeable": "github:fraxfinance/LayerZero-v2-upgradeable",
"@layerzerolabs/lz-evm-oapp-v2": "~2.3.19",
"@layerzerolabs/lz-evm-protocol-v2": "~2.3.3",
"@layerzerolabs/lz-evm-v1-0.7": "~2.3.3",
"@layerzerolabs/lz-v2-utilities": "~2.3.3",
"@layerzerolabs/prettier-config-next": "^2.3.3",
"@layerzerolabs/solhint-config": "^2.3.3",
"@layerzerolabs/test-devtools-evm-foundry": "~0.2.3",
"@layerzerolabs/toolbox-foundry": "~0.1.5",
"@layerzerolabs/toolbox-hardhat": "~0.2.21",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@openzeppelin/contracts": "^5.0.1",
"@openzeppelin/contracts-upgradeable": "^5.0.1",
"@openzeppelin/contracts": "^4.8.1",
"@openzeppelin/contracts-upgradeable": "^4.8.1",
"@rushstack/eslint-patch": "^1.7.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
Expand All @@ -47,6 +36,8 @@
"dotenv": "^16.4.1",
"eslint-plugin-jest-extended": "~2.0.0",
"ethers": "^5.7.2",
"frax-standard-solidity": "github:FraxFinance/frax-standard-solidity",
"frax-template": "github:FraxFinance/frax-template",
"hardhat": "^2.22.3",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.12.1",
Expand All @@ -71,5 +62,10 @@
"@nomicfoundation/edr": "0.3.5",
"ethers": "^5.7.2",
"hardhat-deploy": "^0.12.1"
},
"dependencies": {
"@layerzerolabs/lz-evm-messagelib-v2": "^2.3.21",
"@layerzerolabs/toolbox-foundry": "^0.1.5",
"frax-template": "github:fraxfinance/frax-template"
}
}
Loading

0 comments on commit f8cdb55

Please sign in to comment.