Skip to content

otmoic-cli swap

The otmoic-cli swap command is used to exchange tokens across different blockchains. This command interacts with various blockchain networks to facilitate token swaps.

Usage

sh
otmoiccli swap [OPTIONS]

Options

  • -r, --relay: Relay URL.
  • -n, --network: Network (mainnet/testnet).
  • -c, --chainRpc: RPC config JSON (e.g., { bsc: "<RPC_BSC>" }).
  • -b, --bridge: Bridge name (e.g., BSC-0x55d398326f99059fF775485246999027b3197955(USDT)-->OPT-0x94b08aa00579c1307b0ef2c499ad98a8ce58e58(USDT)).
  • -a, --amount: Amount to exchange.
  • -p, --privateKeyForSign: Your wallet private key for signing the deal.
  • -s, --privateKeyForSend: Your wallet private key for sending the source token.
  • -t, --to: Your wallet address for receiving the token.
  • -g, --useMaximumGasPriceAtMost: Use the defined maximum gas price if exceeds. usd -g if want to enable it.

Examples

sh
# Run the swap command with specified parameters
otmoic-cli swap --relay https://relay.example.com --network mainnet --chainRpc '{"bsc": "https://bsc.rpc.url"}' --bridge BSC-0x55d398326f99059ff775485246999027b3197955(USDT)-->OPT-0x94b008aa00579c1307b0ef2c499ad98a8ce58e58(USDT) --amount 100 --privateKeyForSign <PRIVATE_KEY> --privateKeyForSend <PRIVATE_KEY> --to <RECEIVING_ADDRESS> --useMaximumGasPriceAtMost

Detailed Steps

  1. Initialize SwapActuator: The command initializes a SwapActuator with the provided parameters.
  2. Fetch Quote: The actuator fetches a quote for the specified bridge and amount.
  3. Sign and Send Transaction: The actuator signs and sends the transaction using the provided private keys.
  4. Receive Tokens: The tokens are received at the specified receiving address.

Code Reference

The implementation of this command can be found in src/commands/swap.ts.