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

NewSwapCallback

func NewSwapCallback(_ int, rlm realm, tokenIn string, zeroForOne bool, maxAmountIn int64) func(cur realm, amount0Delta, amount1Delta int64, _ *pool.CallbackMarker) error
Ask AI Claude ChatGPT

NewSwapCallback returns the callback of one round's pool.Swap. It pays the pool the round input, at most maxAmountIn of tokenIn, from the escrow.

The callback is declared in this realm, so it transfers as the escrow itself: the escrow never grants an allowance for a swap. That makes the callback a payment capability, so it is guarded on creation and on use:

  • only the escrow's own current realm can create one, so only code the proxy hands its realm to (the active implementation) can;
  • only the pool can invoke it (cur.Previous()); the pool's swap lock admits no other swap while a round's swap runs;
  • it pays only while a round is executing, once, and only an exact-input delta of the sold token: positive input, no positive output, at most maxAmountIn.

zeroForOne is the swap direction: it selects which pool delta is tokenIn.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/gnoswap/order/dca.NewSwapCallback(,,,,)"

Result

Gno Expression Evaluator

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