Skip to content

Commit

Permalink
test izumiadapter on xlayer (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: lu.zhang <lu.zhang@okg.com>
  • Loading branch information
LuZHANG1109 and lu.zhang authored Apr 16, 2024
1 parent 372acd5 commit 77fc3d6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
10 changes: 10 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,16 @@ module.exports = {
runs: 200
},
}
},
xlayer: {
url: 'https://rpc.xlayer.tech',
accounts: [`${PRIVATE_KEY}`],
settings: {
optimizer: {
enabled: true,
runs: 200
},
}
}
},
paths: {
Expand Down
68 changes: 68 additions & 0 deletions scripts/test_scripts/dex_router/onchaintest_IZumiAdapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 = "0xe0806b2027cc821F741792eE634ae42b2D519dB0"
let poolAddress = "0xd5E29Fc407582d3972Bb4a99dcDBe9B684ab945e";
fromToken = await ethers.getContractAt(
"MockERC20",
"0xe538905cf8410324e03A5A23C1c177a474D59b2b"//WOKB
)
toToken = await ethers.getContractAt(
"MockERC20",
"0xf782E172A14Ee1c85cD980C15375bA0E87957028"//TCAT
)
let fromTokenAmount = ethers.utils.parseUnits("0.001", 18);
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", "")
];
let moreInfo = ethers.utils.defaultAbiCoder.encode(
["address", "address"],
[
fromToken.address,
toToken.address,
]
)
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 fromToken.approve(tokenApprove.address, fromTokenAmount);
await dexRouter.smartSwapByOrderId(
orderId,
baseRequest,
[fromTokenAmount],
[layer1],
pmmReq
);
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});

0 comments on commit 77fc3d6

Please sign in to comment.