1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- // const { POOLS } = require("@layerzerolabs/sg-sdk")
- const {getEndpointId} = require("../utils/network")
- const {getEndpointIdByName} = require("../utils/layerzero")
- const {getPoolsByNetwork} = require("../utils/layerzero")
- task("createChainPaths", "given a mirrorgate router, create chainPaths for a token")
- .addParam("targetNetwork", "the mirrorgate router address")
- .setAction(async (taskArgs) => {
- let router = await ethers.getContract("Router")
- console.log(`router.address: ${router.address}`)
- const pools = getPoolsByNetwork(hre.network.name);
- // const poolData = POOLS[hre.network.name]
- const mirrorgateEthVault = await ethers.getContract("MirrorgateEthVault");
- pools.push({
- info: {
- poolId: 0,
- address: mirrorgateEthVault.address,
- sharedDecimals: await mirrorgateEthVault.decimals(),
- },
- chainPaths: [
- {
- dstChainId: getEndpointIdByName(taskArgs.targetNetwork),
- dstPoolId: 0,
- weight: 1000,
- }
- ]
- })
- console.table(pools)
- let tx
- for (let pool of pools) {
- console.log(`mapping ${hre.network.name}[${getEndpointId()}] srcPoolId: ${pool.info.poolId}`)
- let chainPaths = pool.chainPaths
- for (let dstObj of chainPaths) {
- let {dstChainId, dstPoolId, weight} = dstObj
- if (dstChainId != getEndpointIdByName(taskArgs.targetNetwork)) {
- continue
- }
- try {
- tx = await (await router.createChainPath(pool.info.poolId, dstChainId, dstPoolId, weight)).wait()
- console.log(`✅ createChainPath: poolId:${pool.info.poolId} dstChainId:${dstChainId} dstPoolId:${dstPoolId} weight:${weight}`)
- console.log(` -> tx: ${tx.transactionHash}`)
- } catch (e) {
- if (e.error.message.includes("Mirrorgate: cant createChainPath of existing dstChainId and _dstPoolId")) {
- console.log(
- `✅ createChainPath: poolId:${pool.info.poolId} dstChainId:${dstChainId} dstPoolId:${dstPoolId} weight:${weight} | *already exists*`
- )
- } else {
- console.log(e)
- console.log("^ ERROR")
- }
- }
- }
- }
- })
|