CreateOrder
Ask AI
CreateOrder creates an order that sells amountPerExecution of inputToken for outputToken every interval seconds, executionCount times, and returns its ID.
The caller must first approve Address() for amountPerExecution*executionCount. amountPerExecution must be at least GetMinAmountPerExecution(inputToken), and the pair direction needs a price limit (see SetPairPriceLimit). The order snapshots the execution fee rate in effect (see GetExecutionFeeRate) for its lifetime: the fee is that share of the order's output, deducted when the output is paid out. Later rate changes apply only to orders created afterwards. Orders with the same inputToken, outputToken, interval, and slotOffset share one group and execute together. Each round trades on the pair's best whitelisted pool, chosen at execution time (see GetExecutionQuote).
The caller also pays the storage deposit of the order's execution logs, one per three rounds; each is refunded to whoever releases it after all of its rounds execute (see ClaimGroupOrders).
Parameters:
- inputToken, outputToken: at least one whitelisted direct pool must connect them (see gno.land/r/gnoswap/order/whitelist.AddWhitelistedPool).
- interval: one of GetConfig().AllowedIntervals().
- slotOffset: seconds after each interval boundary of the unix epoch at which rounds run, a multiple of GetConfig().SlotStep(interval) in [0, interval). Boundaries are UTC midnights for daily intervals; weekly boundaries fall on Thursdays 00:00 UTC (1970-01-01 was one), so a Monday slot is 4 days. The first round waits for the next slot, or runs now if it is due.
Reverts while the execute operation is halted for DCA in gno.land/r/gnoswap/order/halt.
Command
# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.
gnokey maketx call -pkgpath "gno.land/r/gnoswap/order/dca" -func "CreateOrder" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/order/dca" -func "CreateOrder" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx