getChainPath.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const { ChainId } = require("@layerzerolabs/lz-sdk")
  2. const { PoolId } = require("@layerzerolabs/sg-sdk")
  3. task("getChainPath", "get chain path from the chainpaths map")
  4. .addParam("poolId", "the poolId")
  5. .setAction(async (taskArgs) => {
  6. // console.log(`taskArgs: ${JSON.stringify(taskArgs)}`);
  7. let accounts = await ethers.getSigners()
  8. let owner = accounts[0] // me
  9. console.log(`owner: ${owner.address}`)
  10. //
  11. // let Factory = await ethers.getContractFactory("Factory")
  12. // let factory = await Factory.attach(taskArgs.factory)
  13. //
  14. // let Router = await ethers.getContractFactory("Router")
  15. // let router = await Router.attach(taskArgs.router)
  16. // const Factory = await ethers.getContractFactory("Factory")
  17. // const factoryAddr = (await hre.deployments.get("Factory")).address
  18. // const factory = await Factory.attach(factoryAddr)
  19. const factory = await hre.ethers.getContract("Factory")
  20. let poolAddr = await factory.getPool(taskArgs.poolId)
  21. let Pool = await ethers.getContractFactory("Pool")
  22. let pool = await Pool.attach(poolAddr)
  23. const chainId = await getChainId(hre.network.name)
  24. console.log("chainId", chainId)
  25. const chainPathIndex = await pool.chainPathIndexLookup(ChainId.BSC_TESTNET, PoolId.USDC)
  26. console.log(`chainPathIndex: ${chainPathIndex}`)
  27. console.log(await pool.chainPaths(chainPathIndex))
  28. console.log(`poolAddr: ${poolAddr}`)
  29. console.log(`pool.poolId: ${await pool.poolId()}`)
  30. console.log(`pool.token: ${await pool.token()}`)
  31. console.log(`pool.sharedDecmals: ${await pool.sharedDecimals()}`)
  32. console.log(`pool.localDecimals: ${await pool.localDecimals()}`)
  33. console.log(`pool.totalLiquidity: ${await pool.totalLiquidity()}`)
  34. console.log(await pool.name(), await pool.symbol())
  35. })