Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

dca package

Overview

Package dca is the GnoSwap DCA (dollar-cost averaging) order realm.

Users escrow inputToken and sell amountPerExecution of it for outputToken every interval, executionCount times, at a chosen slot of the interval (e.g. 09:00 UTC daily). Orders of the same pair, interval, and slot form a group that keepers execute in one pool swap per round, on the pair's best whitelisted pool, without the router. Each round's swap output accrues to the orders and is paid by Claim, or by keepers through ClaimGroupOrders; each payout deducts the execution fee at the rate the order snapshotted when it was created.

This package is the permanent entry point. It owns the escrow address, the KV store shared by every version, and the upgrade switch; the business logic lives in a registered implementation (impl/v0).

Files:

  • proxy.gno: state-changing entry points
  • getter.gno: read-only queries
  • store.gno: KV store and store keys
  • state.gno: realm state and the active implementation
  • upgrade.gno: implementation registration and upgrades

Function

ForceCancelOrder

func ForceCancelOrder(cur realm, orderID uint64) (int64, int64)
Ask AI Claude ChatGPT

ForceCancelOrder closes an order that blocks its group's rounds. As with CancelOrder, accrued output and unsold input go to the order owner; the caller receives nothing but the freed storage deposit of the order's execution logs. It returns the refunded input and the output paid.

The order must have rounds left and be, as checked on-chain:

  • below the minimum per execution a new order of its token needs now (reason below_min_amount), or
  • in a due round that, as quoted now, credits it less than one output unit after its execution fee (no_order_output), or
  • the largest order (by amountPerExecution, ties included) of a due round that no pool can fill as quoted now while a pool fills part of it, with some output, within the price limit (exceeds_pool_capacity). A round that needs several orders gone is shrunk one largest order per call.

Any other order reverts with "order does not block its group". DCAOrderForceCancelled reports the reason.

Only accounts holding the role assigned to the ForceCancelOrder selector in gno.land/r/gnoswap/order/keeper (DCAKeeperRole at deployment). Reverts while the withdraw operation is halted.

Param

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 "ForceCancelOrder" -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 "ForceCancelOrder" -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
  

Gno Expression Evaluator

Evaluate any read-only Gno expression against gno.land/r/gnoswap/order/dca, for example a function call with arguments.