diff --git a/examples/nft/contracts/Universal.sol b/examples/nft/contracts/Universal.sol index 8e4e9530..f270f338 100644 --- a/examples/nft/contracts/Universal.sol +++ b/examples/nft/contracts/Universal.sol @@ -23,7 +23,7 @@ contract Universal is Events { GatewayZEVM public immutable gateway; - SystemContract public immutable systemContract; + address public immutable uniswapRouter; uint256 private _nextTokenId; bool public isUniversal = true; uint256 public gasLimit; @@ -46,16 +46,16 @@ contract Universal is string memory name, string memory symbol, uint256 gas, - address systemContractAddress + address uniswapRouterAddress ) ERC721(name, symbol) Ownable(owner) { if ( gatewayAddress == address(0) || owner == address(0) || - systemContractAddress == address(0) + uniswapRouterAddress == address(0) ) revert InvalidAddress(); if (gas == 0) revert InvalidGasLimit(); gateway = GatewayZEVM(gatewayAddress); - systemContract = SystemContract(systemContractAddress); + uniswapRouter = uniswapRouterAddress; gasLimit = gas; } @@ -144,7 +144,7 @@ contract Universal is ); SwapHelperLib.swapExactTokensForTokens( - systemContract, + uniswapRouter, zrc20, amount, destination, diff --git a/examples/nft/package.json b/examples/nft/package.json index 3230694a..84fec511 100644 --- a/examples/nft/package.json +++ b/examples/nft/package.json @@ -28,7 +28,7 @@ "@typescript-eslint/eslint-plugin": "^5.59.9", "@typescript-eslint/parser": "^5.59.9", "@zetachain/localnet": "4.0.0-rc6", - "@zetachain/toolkit": "13.0.0-rc7", + "@zetachain/toolkit": "13.0.0-rc8", "axios": "^1.3.6", "chai": "^4.2.0", "dotenv": "^16.0.3", diff --git a/examples/nft/scripts/localnet.sh b/examples/nft/scripts/localnet.sh index c9d03935..4aa09719 100755 --- a/examples/nft/scripts/localnet.sh +++ b/examples/nft/scripts/localnet.sh @@ -24,10 +24,10 @@ ZRC20_BNB=$(jq -r '.addresses[] | select(.type=="ZRC-20 BNB on 97") | .address' GATEWAY_ZETACHAIN=$(jq -r '.addresses[] | select(.type=="gatewayZEVM" and .chain=="zetachain") | .address' localnet.json) GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json) GATEWAY_BNB=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="bnb") | .address' localnet.json) -SYSTEM_CONTRACT=$(jq -r '.addresses[] | select(.type=="systemContract" and .chain=="zetachain") | .address' localnet.json) +UNISWAP_ROUTER=$(jq -r '.addresses[] | select(.type=="uniswapRouterInstance" and .chain=="zetachain") | .address' localnet.json) SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --gateway "$GATEWAY_ZETACHAIN" --system-contract "$SYSTEM_CONTRACT" --json | jq -r '.contractAddress') +CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --gateway "$GATEWAY_ZETACHAIN" --uniswap-router "$UNISWAP_ROUTER" --json | jq -r '.contractAddress') echo -e "\nšŸš€ Deployed NFT contract on ZetaChain: $CONTRACT_ZETACHAIN" CONTRACT_ETHEREUM=$(npx hardhat deploy --name Connected --json --network localhost --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress') diff --git a/examples/nft/tasks/deploy.ts b/examples/nft/tasks/deploy.ts index e8835d3c..c4be2622 100644 --- a/examples/nft/tasks/deploy.ts +++ b/examples/nft/tasks/deploy.ts @@ -19,7 +19,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { args.tokenName, args.tokenSymbol, args.gasLimit, - ...(args.systemContract ? [args.systemContract] : []), + ...(args.uniswapRouter ? [args.uniswapRouter] : []), { gasPrice: args.deployGasPrice, } @@ -64,4 +64,4 @@ task("deploy", "Deploy the NFT contract", main) "Gas price for deploy transaction", "10000000000" ) - .addOptionalParam("systemContract", "System contract address"); + .addOptionalParam("uniswapRouter", "Uniswap v2 router address on ZetaChain"); diff --git a/examples/nft/yarn.lock b/examples/nft/yarn.lock index 65dd7967..14f87151 100644 --- a/examples/nft/yarn.lock +++ b/examples/nft/yarn.lock @@ -2780,10 +2780,10 @@ resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-9.0.0.tgz#c20ad5da43f6f3676f31556b303d1cb4ea17357e" integrity sha512-L4A8bddlyhjaBAsIv/x1Bvxc38RJz8U8rbbBtxK5oVyOAd5Zz04ZiT3HqzO4FuKq6RGGM1uiA8jvUfmRkKchXw== -"@zetachain/toolkit@13.0.0-rc7": - version "13.0.0-rc7" - resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc7.tgz#d8710dfeed6c84d7d5808de253887da3e67bf050" - integrity sha512-rh9q66iipRF3XJ4jlkawYqc10eA2mYgIS2rl1PiWvcqi39R1PgUzperKVwwoVmRuJi0FxE5fetP4SmqzfkfBXw== +"@zetachain/toolkit@13.0.0-rc8": + version "13.0.0-rc8" + resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc8.tgz#1f8b975428f6f1b7bdef4ccc0a1312de81f90e7d" + integrity sha512-lXAyyMpgN/dsGIUTR/hi5M+6/tsnzONLAaisAnJzsrEUB4nYkoZtQCR4lwP4oWhNl4i3SK5k+bFjAfBo1DU3iw== dependencies: "@coral-xyz/anchor" "^0.30.1" "@inquirer/prompts" "^2.1.1" diff --git a/examples/swap/contracts/Swap.sol b/examples/swap/contracts/Swap.sol index 5ae0f482..ffe9cecd 100644 --- a/examples/swap/contracts/Swap.sol +++ b/examples/swap/contracts/Swap.sol @@ -12,7 +12,7 @@ import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol import {GatewayZEVM} from "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol"; contract Swap is UniversalContract { - SystemContract public systemContract; + address public immutable uniswapRouter; GatewayZEVM public gateway; uint256 constant BITCOIN = 18332; @@ -21,8 +21,8 @@ contract Swap is UniversalContract { _; } - constructor(address systemContractAddress, address payable gatewayAddress) { - systemContract = SystemContract(systemContractAddress); + constructor(address payable gatewayAddress, address uniswapRouterAddress) { + uniswapRouter = uniswapRouterAddress; gateway = GatewayZEVM(gatewayAddress); } @@ -74,7 +74,7 @@ contract Swap is UniversalContract { swapAmount = amount - gasFee; } else { inputForGas = SwapHelperLib.swapTokensForExactTokens( - systemContract, + uniswapRouter, inputToken, gasFee, gasZRC20, @@ -84,7 +84,7 @@ contract Swap is UniversalContract { } uint256 outputAmount = SwapHelperLib.swapExactTokensForTokens( - systemContract, + uniswapRouter, inputToken, swapAmount, targetToken, diff --git a/examples/swap/contracts/SwapToAnyToken.sol b/examples/swap/contracts/SwapToAnyToken.sol index 30feec5e..db503db6 100644 --- a/examples/swap/contracts/SwapToAnyToken.sol +++ b/examples/swap/contracts/SwapToAnyToken.sol @@ -13,7 +13,7 @@ import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IWZETA.sol"; import {GatewayZEVM} from "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol"; contract SwapToAnyToken is UniversalContract { - SystemContract public systemContract; + address public immutable uniswapRouter; GatewayZEVM public gateway; uint256 constant BITCOIN = 18332; @@ -22,8 +22,8 @@ contract SwapToAnyToken is UniversalContract { _; } - constructor(address systemContractAddress, address payable gatewayAddress) { - systemContract = SystemContract(systemContractAddress); + constructor(address payable gatewayAddress, address uniswapRouterAddress) { + uniswapRouter = uniswapRouterAddress; gateway = GatewayZEVM(gatewayAddress); } @@ -92,7 +92,7 @@ contract SwapToAnyToken is UniversalContract { swapAmount = amount - gasFee; } else { inputForGas = SwapHelperLib.swapTokensForExactTokens( - systemContract, + uniswapRouter, inputToken, gasFee, gasZRC20, @@ -103,7 +103,7 @@ contract SwapToAnyToken is UniversalContract { } uint256 outputAmount = SwapHelperLib.swapExactTokensForTokens( - systemContract, + uniswapRouter, inputToken, swapAmount, targetToken, diff --git a/examples/swap/package.json b/examples/swap/package.json index d7477480..221f9067 100644 --- a/examples/swap/package.json +++ b/examples/swap/package.json @@ -58,6 +58,6 @@ "@solana/spl-memo": "^0.2.5", "@solana/web3.js": "^1.95.2", "@zetachain/protocol-contracts": "11.0.0-rc3", - "@zetachain/toolkit": "13.0.0-rc7" + "@zetachain/toolkit": "13.0.0-rc8" } } diff --git a/examples/swap/scripts/localnet.sh b/examples/swap/scripts/localnet.sh index 9aeacca0..9867ddef 100755 --- a/examples/swap/scripts/localnet.sh +++ b/examples/swap/scripts/localnet.sh @@ -11,9 +11,10 @@ ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .addre ZRC20_USDC=$(jq -r '.addresses[] | select(.type=="ZRC-20 USDC on 97") | .address' localnet.json) GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json) GATEWAY_ZETACHAIN=$(jq -r '.addresses[] | select(.type=="gatewayZEVM" and .chain=="zetachain") | .address' localnet.json) +UNISWAP_ROUTER=$(jq -r '.addresses[] | select(.type=="uniswapRouterInstance" and .chain=="zetachain") | .address' localnet.json) SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -CONTRACT_ZETACHAIN=$(npx hardhat deploy --name Swap --network localhost --gateway "$GATEWAY_ZETACHAIN" --json | jq -r '.contractAddress') +CONTRACT_ZETACHAIN=$(npx hardhat deploy --name Swap --network localhost --gateway "$GATEWAY_ZETACHAIN" --uniswap-router "$UNISWAP_ROUTER" --json | jq -r '.contractAddress') echo -e "\nšŸš€ Deployed contract on ZetaChain: $CONTRACT_ZETACHAIN" npx hardhat swap-from-evm \ diff --git a/examples/swap/tasks/deploy.ts b/examples/swap/tasks/deploy.ts index 88a0d1de..6d544fad 100644 --- a/examples/swap/tasks/deploy.ts +++ b/examples/swap/tasks/deploy.ts @@ -13,8 +13,8 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { const factory = await hre.ethers.getContractFactory(args.name); const contract = await (factory as any).deploy( - args.systemContract, - args.gateway + args.gateway, + args.uniswapRouter ); await contract.deployed(); @@ -39,11 +39,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { task("deploy", "Deploy the contract", main) .addFlag("json", "Output in JSON") .addOptionalParam("name", "Contract to deploy", "Swap") - .addOptionalParam( - "systemContract", - "System contract", - "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9" - ) + .addOptionalParam("uniswapRouter", "Uniswap v2 Router address on ZetaChain") .addOptionalParam( "gateway", "Gateway address (default: ZetaChain Gateway)", diff --git a/examples/swap/yarn.lock b/examples/swap/yarn.lock index e92f4268..03c511d8 100644 --- a/examples/swap/yarn.lock +++ b/examples/swap/yarn.lock @@ -2513,25 +2513,15 @@ "@zetachain/networks" "^10.0.0" ethers "5.6.8" -"@zetachain/protocol-contracts@10.0.0-rc11": - version "10.0.0-rc11" - resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-10.0.0-rc11.tgz#53f55ead492f7b5802b1feae4e51abc75730af33" - integrity sha512-qWazjqnIGRngf4OmyeSIv7sHICQRdMQ1CKPIQIqxA8qFR+gHhDHSfvMdRAvgWbsfkimXOIFiHVIATypyWhviJw== - dependencies: - "@openzeppelin/contracts" "^5.0.2" - "@openzeppelin/contracts-upgradeable" "^5.0.2" - "@zetachain/networks" "^10.0.0" - ethers "^6.13.1" - "@zetachain/protocol-contracts@9.0.0": version "9.0.0" resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-9.0.0.tgz#c20ad5da43f6f3676f31556b303d1cb4ea17357e" integrity sha512-L4A8bddlyhjaBAsIv/x1Bvxc38RJz8U8rbbBtxK5oVyOAd5Zz04ZiT3HqzO4FuKq6RGGM1uiA8jvUfmRkKchXw== -"@zetachain/toolkit@13.0.0-rc7": - version "13.0.0-rc7" - resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc7.tgz#d8710dfeed6c84d7d5808de253887da3e67bf050" - integrity sha512-rh9q66iipRF3XJ4jlkawYqc10eA2mYgIS2rl1PiWvcqi39R1PgUzperKVwwoVmRuJi0FxE5fetP4SmqzfkfBXw== +"@zetachain/toolkit@13.0.0-rc8": + version "13.0.0-rc8" + resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc8.tgz#1f8b975428f6f1b7bdef4ccc0a1312de81f90e7d" + integrity sha512-lXAyyMpgN/dsGIUTR/hi5M+6/tsnzONLAaisAnJzsrEUB4nYkoZtQCR4lwP4oWhNl4i3SK5k+bFjAfBo1DU3iw== dependencies: "@coral-xyz/anchor" "^0.30.1" "@inquirer/prompts" "^2.1.1" diff --git a/examples/token/contracts/Universal.sol b/examples/token/contracts/Universal.sol index 5caa5e22..4d940fb1 100644 --- a/examples/token/contracts/Universal.sol +++ b/examples/token/contracts/Universal.sol @@ -13,7 +13,7 @@ import "./shared/Events.sol"; contract Universal is ERC20, Ownable2Step, UniversalContract, Events { GatewayZEVM public immutable gateway; - SystemContract public immutable systemContract; + address public immutable uniswapRouter; uint256 private _nextTokenId; bool public isUniversal = true; uint256 public gasLimit; @@ -36,13 +36,13 @@ contract Universal is ERC20, Ownable2Step, UniversalContract, Events { string memory name, string memory symbol, uint256 gas, - address systemContractAddress + address uniswapRouterAddress ) ERC20(name, symbol) Ownable(owner) { if (gatewayAddress == address(0) || owner == address(0)) revert InvalidAddress(); if (gas == 0) revert InvalidGasLimit(); gateway = GatewayZEVM(gatewayAddress); - systemContract = SystemContract(systemContractAddress); + uniswapRouter = uniswapRouterAddress; gasLimit = gas; } @@ -112,7 +112,7 @@ contract Universal is ERC20, Ownable2Step, UniversalContract, Events { gasLimit ); SwapHelperLib.swapExactTokensForTokens( - systemContract, + uniswapRouter, zrc20, amount, destination, diff --git a/examples/token/package.json b/examples/token/package.json index 1e04fba6..6bb7708b 100644 --- a/examples/token/package.json +++ b/examples/token/package.json @@ -28,7 +28,7 @@ "@typescript-eslint/eslint-plugin": "^5.59.9", "@typescript-eslint/parser": "^5.59.9", "@zetachain/localnet": "4.0.0-rc4", - "@zetachain/toolkit": "13.0.0-rc4", + "@zetachain/toolkit": "13.0.0-rc8", "axios": "^1.3.6", "chai": "^4.2.0", "dotenv": "^16.0.3", diff --git a/examples/token/yarn.lock b/examples/token/yarn.lock index e897e2e7..aa2efc96 100644 --- a/examples/token/yarn.lock +++ b/examples/token/yarn.lock @@ -2758,7 +2758,7 @@ hardhat "^2.22.8" wait-on "^7.2.0" -"@zetachain/networks@^10.0.0": +"@zetachain/networks@10.0.0", "@zetachain/networks@^10.0.0": version "10.0.0" resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-10.0.0.tgz#dd5d14a0870f6b658644aded8c96859f15531089" integrity sha512-FPolaO19oVkSLSPDUA/Hu+8AhG3lDEslRDpLnMzbMbnNSC669Fkah0/TEf+6egrQbAifBRfFLzwWidAGs8oxtA== @@ -2780,10 +2780,10 @@ resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-9.0.0.tgz#c20ad5da43f6f3676f31556b303d1cb4ea17357e" integrity sha512-L4A8bddlyhjaBAsIv/x1Bvxc38RJz8U8rbbBtxK5oVyOAd5Zz04ZiT3HqzO4FuKq6RGGM1uiA8jvUfmRkKchXw== -"@zetachain/toolkit@13.0.0-rc4": - version "13.0.0-rc4" - resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc4.tgz#e137fc16043f1416469f709c48808cfa301d9299" - integrity sha512-4z4MKbQKjRIeNruUyDBjZDRO5oTLa1w/7wVn+PfMsXn++mFFGkiawkLcitnkH9dadBJiERzmo89MRJxsLQ3U6w== +"@zetachain/toolkit@13.0.0-rc8": + version "13.0.0-rc8" + resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc8.tgz#1f8b975428f6f1b7bdef4ccc0a1312de81f90e7d" + integrity sha512-lXAyyMpgN/dsGIUTR/hi5M+6/tsnzONLAaisAnJzsrEUB4nYkoZtQCR4lwP4oWhNl4i3SK5k+bFjAfBo1DU3iw== dependencies: "@coral-xyz/anchor" "^0.30.1" "@inquirer/prompts" "^2.1.1" @@ -2794,12 +2794,13 @@ "@solana/web3.js" "^1.95.3" "@uniswap/v2-periphery" "^1.1.0-beta.0" "@zetachain/faucet-cli" "^4.1.1" - "@zetachain/networks" "^10.0.0" + "@zetachain/networks" "10.0.0" "@zetachain/protocol-contracts" "9.0.0" axios "^1.4.0" bech32 "^2.0.0" bip39 "^3.1.0" bitcoinjs-lib "^6.1.3" + bs58 "^6.0.0" dotenv "16.0.3" ecpair "^2.1.0" envfile "^6.18.0"