最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Execute swap transaction using CETUS protocol - Stack Overflow

programmeradmin1浏览0评论

I am trying to execute a raw SUI swap(SUI -> SUIDENG) transaction using CETUS protocol. The problem is I don't know how to give the movevec params as I don't have any SUIDENG in my wallet. Below is my current code, which would make more sense than my words.

tx.setGasBudget(1000000);  
tx.moveCall({
    target: `${packageId}::router::swap`,
    typeArguments: [suiAddr, suidengAddr],
    arguments: [
      tx.pure(process.env.CETUS_CONTRACT_ADDR), //
      tx.pure(
        "0xb785e6eed355c1f8367c06d2b0cb9303ab167f8359a129bb003891ee54c6fce0"
      ),
      // tx.pure(suiAddr),
      // tx.pure(suidengAddr),
      tx.makeMoveVec({
        objects: [
          tx.object(
            "0x278c016658478a5694ad4a7b03f367f01589d9b123f599a9bfb356613a2cd6da"
          ),
          tx.object(
            "0x221d8536273338c8d2c54470f31de83ecd559c6b69f75f3248c4b2870aa0a480"
          ),
        ],
      }),
      tx.makeMoveVec({
        objects: [],
      }),
      tx.pure.bool(true),
      tx.pure.bool(!!amount),
      tx.pure.u64(amount),
      tx.pure.u64(amount.toString()),
      tx.pure.u128("4295048016"), // use coin value always set false.
      tx.object(
        "0x0000000000000000000000000000000000000000000000000000000000000006"
      ),
    ],
  });

It says the argument can't be an empty array.

      tx.makeMoveVec({
        objects: [],
      })

Do I need to use other module/function to handle this kind of case?

I tried with pool_script module's swap_a2b function, which apparently doesn't seem to require coinB argument and it fails with typemismatch error. Here's the tx digest.
zsoFt94pvGBQVvq54k7v4Qg1Q7EN1qMyCXxTNFvNbkv

  tx.moveCall({
    target: `${publishedAt}::pool_script::swap_a2b`,
    arguments: [
      tx.pure(process.env.CETUS_CONTRACT_ADDR), //
      tx.pure(
        "0xb785e6eed355c1f8367c06d2b0cb9303ab167f8359a129bb003891ee54c6fce0"
      ),
      tx.makeMoveVec({
        objects: [
          tx.object(
            "0x278c016658478a5694ad4a7b03f367f01589d9b123f599a9bfb356613a2cd6da"
          ),
          // tx.object(
          //   "0x221d8536273338c8d2c54470f31de83ecd559c6b69f75f3248c4b2870aa0a480"
          // ),
        ],
      }),
      tx.pure.bool(true),
      tx.pure.u64(amount), // amount
      tx.pure.u64(10000000000000), // amount_limit
      tx.pure.u128(4295048016), // getDefaultSqrtPriceLimit, hardcode
      tx.pure("0x6"), // clock
    ],
    typeArguments: [suiAddr, suidengAddr],
  });

I have found correct parameters myself and I assume only this issue now remains, hopefully.

发布评论

评论列表(0)

  1. 暂无评论