forked from LayerZero-Labs/mainnet-testnet-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to set min amount for OFT and NativeOFT
- Loading branch information
0xIryna
committed
Dec 23, 2022
1 parent
5d11c0f
commit 0d9c77c
Showing
24 changed files
with
576 additions
and
291 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"goerli": { | ||
"name": "Native OFT", | ||
"symbol": "NOFT", | ||
"minAmount": "0.001", | ||
"useMinAmount": true, | ||
"contractName": "MinSendAmountNativeOFT" | ||
}, | ||
"bsc-testnet": { | ||
"name": "Native OFT", | ||
"symbol": "NOFT", | ||
"useMinAmount": false, | ||
"contractName": "NativeOFT" | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"goerli": { | ||
"name": "OFT", | ||
"symbol": "OFT", | ||
"minAmount": "0.001", | ||
"useMinAmount": true, | ||
"contractName": "MinSendAmountOFT" | ||
}, | ||
"bsc-testnet": { | ||
"name": "OFT", | ||
"symbol": "OFT", | ||
"useMinAmount": false, | ||
"contractName": "OFT" | ||
} | ||
} |
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,4 +1,4 @@ | ||
{ | ||
"goerli": "0xeBBEa1682C59D9cfBd0142783B47AA934cB3137d", | ||
"bsc-testnet": "0xd336c031701debb988f9780c7b5c606b9348504d" | ||
"goerli": "0x1D146E9f8b3196e207F8e9f052e1C12B4a02716F", | ||
"bsc-testnet": "0x14f20d80cfe1c1334e4abcb07c0f9c7a95232159" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "@layerzerolabs/solidity-examples/contracts/token/oft/extension/NativeOFT.sol"; | ||
|
||
contract MinSendAmountNativeOFT is NativeOFT { | ||
uint public minSendAmount; | ||
|
||
constructor(string memory _name, string memory _symbol, address _lzEndpoint, uint _minSendAmount) NativeOFT(_name, _symbol, _lzEndpoint) { | ||
minSendAmount = _minSendAmount; | ||
} | ||
|
||
function setMinSendAmount(uint _minSendAmount) external onlyOwner { | ||
minSendAmount = _minSendAmount; | ||
} | ||
|
||
function _send(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual override { | ||
require(_amount >= minSendAmount, "MinSendAmountNativeOFT: amount is less than minimum"); | ||
super._send(_from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); | ||
} | ||
} |
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,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "@layerzerolabs/solidity-examples/contracts/token/oft/OFT.sol"; | ||
|
||
contract MinSendAmountOFT is OFT { | ||
uint public minSendAmount; | ||
|
||
constructor(string memory _name, string memory _symbol, address _lzEndpoint, uint _minSendAmount) OFT(_name, _symbol, _lzEndpoint) { | ||
minSendAmount = _minSendAmount; | ||
} | ||
|
||
function setMinSendAmount(uint _minSendAmount) external onlyOwner { | ||
minSendAmount = _minSendAmount; | ||
} | ||
|
||
function _send(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual override { | ||
require(_amount >= minSendAmount, "MinSendAmountOFT: amount is less than minimum"); | ||
super._send(_from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../MinSendAmountOFT.sol"; | ||
|
||
contract MintableMinSendAmountOFTMock is MinSendAmountOFT { | ||
constructor(string memory _name, string memory _symbol, address _layerZeroEndpoint, uint _minSendAmount) MinSendAmountOFT(_name, _symbol, _layerZeroEndpoint, _minSendAmount) {} | ||
|
||
function mint(address _to, uint _amount) public { | ||
_mint(_to, _amount); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
const LZ_ENDPOINTS = require("../constants/layerzeroEndpoints.json") | ||
const NATIVE_OFT_ARGS = require("../constants/nativeOftArgs.json") | ||
|
||
module.exports = async function ({ deployments, getNamedAccounts }) { | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
console.log(`>>> your address: ${deployer}`) | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
console.log(`>>> your address: ${deployer}`) | ||
|
||
const lzEndpointAddress = LZ_ENDPOINTS[hre.network.name] | ||
console.log(`[${hre.network.name}] Endpoint Address: ${lzEndpointAddress}`) | ||
const lzEndpointAddress = LZ_ENDPOINTS[hre.network.name] | ||
console.log(`[${hre.network.name}] Endpoint Address: ${lzEndpointAddress}`) | ||
const nativeOftArgs = NATIVE_OFT_ARGS[hre.network.name] | ||
const constructorArgs = nativeOftArgs.useMinAmount | ||
? [nativeOftArgs.name, nativeOftArgs.symbol, lzEndpointAddress, ethers.utils.parseEther(nativeOftArgs.minAmount)] | ||
: [nativeOftArgs.name, nativeOftArgs.symbol, lzEndpointAddress] | ||
|
||
await deploy("NativeOFT", { | ||
from: deployer, | ||
args: ["Native OFT", "NOFT", lzEndpointAddress], | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
await deploy(nativeOftArgs.contractName, { | ||
from: deployer, | ||
args: constructorArgs, | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
} | ||
|
||
module.exports.tags = ["NativeOFT"] |
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,19 +1,24 @@ | ||
const LZ_ENDPOINTS = require("../constants/layerzeroEndpoints.json") | ||
const OFT_ARGS = require("../constants/oftArgs.json") | ||
|
||
module.exports = async function ({ deployments, getNamedAccounts }) { | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
console.log(`>>> your address: ${deployer}`) | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
console.log(`>>> your address: ${deployer}`) | ||
|
||
const lzEndpointAddress = LZ_ENDPOINTS[hre.network.name] | ||
console.log(`[${hre.network.name}] Endpoint Address: ${lzEndpointAddress}`) | ||
const lzEndpointAddress = LZ_ENDPOINTS[hre.network.name] | ||
console.log(`[${hre.network.name}] Endpoint Address: ${lzEndpointAddress}`) | ||
const oftArgs = OFT_ARGS[hre.network.name] | ||
const constructorArgs = oftArgs.useMinAmount | ||
? [oftArgs.name, oftArgs.symbol, lzEndpointAddress, ethers.utils.parseEther(oftArgs.minAmount)] | ||
: [oftArgs.name, oftArgs.symbol, lzEndpointAddress] | ||
|
||
await deploy("OFT", { | ||
from: deployer, | ||
args: ["OFT", "OFT", lzEndpointAddress], | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
await deploy(oftArgs.contractName, { | ||
from: deployer, | ||
args: constructorArgs, | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
} | ||
|
||
module.exports.tags = ["OFT"] |
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,25 +1,27 @@ | ||
const ROUTERS = require("../constants/uniswapRoutes.json") | ||
const OFT_ARGS = require("../constants/oftArgs.json") | ||
const NATIVE_OFT_ARGS = require("../constants/nativeOftArgs.json") | ||
|
||
module.exports = async function ({ deployments, getNamedAccounts }) { | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
console.log(`>>> your address: ${deployer}`) | ||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
console.log(`>>> your address: ${deployer}`) | ||
|
||
const routerAddress = ROUTERS[hre.network.name] | ||
console.log(`[${hre.network.name}] Uniswap Router Address: ${routerAddress}`) | ||
const routerAddress = ROUTERS[hre.network.name] | ||
console.log(`[${hre.network.name}] Uniswap Router Address: ${routerAddress}`) | ||
|
||
const oft = await ethers.getContract("OFT"); | ||
console.log(`[${hre.network.name}] OFT Address: ${oft.address}`) | ||
const oft = await ethers.getContract(OFT_ARGS[hre.network.name].contractName) | ||
console.log(`[${hre.network.name}] OFT Address: ${oft.address}`) | ||
|
||
const nativeOft = await ethers.getContract("NativeOFT"); | ||
console.log(`[${hre.network.name}] OFT Address: ${nativeOft.address}`) | ||
const nativeOft = await ethers.getContract(NATIVE_OFT_ARGS[hre.network.name].contractName) | ||
console.log(`[${hre.network.name}] Native OFT Address: ${nativeOft.address}`) | ||
|
||
await deploy("SwappableBridge", { | ||
from: deployer, | ||
args: [oft.address, nativeOft.address, routerAddress], | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
await deploy("SwappableBridge", { | ||
from: deployer, | ||
args: [oft.address, nativeOft.address, routerAddress], | ||
log: true, | ||
waitConfirmations: 1, | ||
}) | ||
} | ||
|
||
module.exports.tags = ["SwappableBridge"] |
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
Oops, something went wrong.