diff --git a/scripts/test_scripts/dex_router/onchaintest_dackieV3_adapter.js b/scripts/test_scripts/dex_router/onchaintest_dackieV3_adapter.js new file mode 100644 index 0000000..f3c3bca --- /dev/null +++ b/scripts/test_scripts/dex_router/onchaintest_dackieV3_adapter.js @@ -0,0 +1,74 @@ +const { ethers } = require("hardhat"); +require("../../tools"); +let { direction, FOREVER } = require("./utils") + +async function main() { + const dexRouter = await ethers.getContractAt("DexRouter", "0x127a986cE31AA2ea8E1a6a0F0D5b7E5dbaD7b0bE"); + const tokenApprove = await ethers.getContractAt("TokenApprove", "0x8b773D83bc66Be128c60e07E17C8901f7a64F000"); + console.log("DexRouter: " + dexRouter.address); + const gasPirce = await ethers.provider.getGasPrice(); + console.log("gasPrice: " + gasPirce); + const adapter = "0x329F0b78D7850Db32a35043c0DA9a63b3672617C" + let poolAddress = "0xa5388037b5FEf0EfCdFC9e1d6d7bC6E7e61C7082"; + toToken = await ethers.getContractAt( + "MockERC20", + "0xe538905cf8410324e03A5A23C1c177a474D59b2b"//WOKB + ) + fromToken = await ethers.getContractAt( + "MockERC20", + "0x1e4a5963abfd975d8c9021ce480b42188849d41d"//USDT + ) + let fromTokenAmount = ethers.utils.parseUnits("0.1", 6); + let minReturnAmount = 0; + let deadLine = FOREVER; + let mixAdapter1 = [adapter]; + let assertTo1 = [adapter]; + let weight1 = Number(10000).toString(16).replace('0x', ''); + let rawData1 = [ + "0x" + + direction(fromToken.address, toToken.address) + + "0000000000000000000" + + weight1 + + poolAddress.replace("0x", "") + ]; + const moreInfo = ethers.utils.defaultAbiCoder.encode( + ["uint160", "bytes"], + [ + 0, + ethers.utils.defaultAbiCoder.encode( + ["address", "address", "uint24"], + [ + fromToken.address, + toToken.address, + 2500 + ] + ) + ] + ) + let extraData1 = [moreInfo]; + let router1 = [mixAdapter1, assertTo1, rawData1, extraData1, fromToken.address]; + let layer1 = [router1]; + let orderId = 0; + let baseRequest = [ + fromToken.address, + toToken.address, + fromTokenAmount, + minReturnAmount, + deadLine, + ] + let pmmReq = [] + await dexRouter.smartSwapByOrderId( + orderId, + baseRequest, + [fromTokenAmount], + [layer1], + pmmReq + ); +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error); + process.exit(1); +}); diff --git a/src/tests/DackieV3Adapter.t.sol b/src/tests/DackieV3Adapter.t.sol new file mode 100644 index 0000000..f42d7f3 --- /dev/null +++ b/src/tests/DackieV3Adapter.t.sol @@ -0,0 +1,25 @@ +pragma solidity ^0.8.0; + +import "forge-std/test.sol"; +import "forge-std/console2.sol"; +import "@dex/adapter/PancakeswapV3Adapter.sol"; + +contract DackieSwapV3AdapterTest is Test { + + PancakeswapV3Adapter adapter; + address WOKB = 0xe538905cf8410324e03A5A23C1c177a474D59b2b; + address USDT = 0x1E4a5963aBFD975d8c9021ce480b42188849D41d; + address USDTWETH = 0xa5388037b5FEf0EfCdFC9e1d6d7bC6E7e61C7082; + + function test_WOKBtoUSDC() public { + vm.createSelectFork(vm.envString("XLAYER_RPC_URL")); + adapter = PancakeswapV3Adapter(address(0x329F0b78D7850Db32a35043c0DA9a63b3672617C)); + deal(USDT, address(this), 1 * 10 ** 6); + IERC20(USDT).transfer(address(adapter), 1 * 10 ** 6); + uint160 sqrtPriceLimitX96 = 0; + bytes memory data = abi.encode(USDT, WOKB, uint24(2500)); + bytes memory moreInfo = abi.encode(sqrtPriceLimitX96, data); + adapter.sellBase(address(this), USDTWETH, moreInfo); + console2.log("WOKB", IERC20(WOKB).balanceOf(address(this))); + } +}