doc.gno
1.44 Kb · 27 lines
1// Package dca holds the immutable building blocks of the GnoSwap DCA
2// (dollar-cost averaging) order realm:
3//
4// - types.gno: interfaces between the proxy and its implementations
5// - order.gno, group.gno, config.gno: domain types stored by the realm
6// - math.gno: scheduling, accumulator, fee, and payout math
7// - keys.gno: B+tree key encodings
8//
9// Nothing here holds state. Storage, authorization, and token transfers live
10// in gno.land/r/gnoswap/order/dca and its implementations under impl/.
11//
12// Accounting: orders selling the same token for the same token at the same
13// interval and slot offset share a group. A group's rounds run at the unix
14// times t with t % interval == slotOffset, so the slot fixes the time of day
15// (or day of week) of every round. Each round sells the sum of the active orders'
16// per-round input and adds the whole output per unit of input, scaled by
17// 2^128, to the group accumulator. An order accrues
18//
19// amountPerExecution * (acc(endRound) - debtX128) / 2^128
20//
21// of gross output, rounded down, where debtX128 starts at the accumulator when
22// the order joins. A payout moves debtX128 only by the accumulator share its
23// gross output pays for, so the remainder below one unit stays owed and is
24// paid once later rounds add it up to a whole unit.
25// Each payout deducts the order's execution fee, at the rate it snapshotted
26// when created, from that gross output (see CalculatePayoutExecutionFeeAmount).
27package dca