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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

roscaslim2 source pure

Package rosca is a dependency-free toolkit for building rotating savings and credit associations (ROSCA - "arisan", "...

Overview

Package rosca is a dependency-free toolkit for building rotating savings and credit associations (ROSCA - "arisan", "tanda", "chit fund", "susus") on Gno.land.

It contains no state and no realm capability of its own: the economics, the deterministic payout schedule and the presentation helpers are pure functions, so any realm can import this package and add a savings circle to its own state machine without re-deriving the hard parts.

The companion realm gno.land/r/<addr>/kolektif is the reference implementation; it imports exactly these helpers.

Constants 2

const MinSize, MaxSize, MinContribution, MaxContribution, MinRoundSpan, MaxRoundSpan, MaxNameLen, DefaultRoundSpan, UgnotPerGnot

 1const (
 2	MinSize          = 3
 3	MaxSize          = 50
 4	MinContribution  = int64(1000)         // 0.001 GNOT
 5	MaxContribution  = int64(100000000000) // 100,000 GNOT
 6	MinRoundSpan     = int64(60)           // 1 minute
 7	MaxRoundSpan     = int64(2592000)      // 30 days
 8	MaxNameLen       = 64
 9	DefaultRoundSpan = int64(604800) // 7 days
10	UgnotPerGnot     = int64(1000000)
11)
source

Limits keep a circle inside numbers the reference realm can render and settle safely. They are advisory: an importing realm may enforce others.

const StatusOpen, StatusActive, StatusComplete

1const (
2	// StatusOpen collects members and collateral. Nothing is paid out.
3	StatusOpen Status = iota
4	// StatusActive is a full circle that is paying round by round.
5	StatusActive
6	// StatusComplete means every payout happened and collateral was returned.
7	StatusComplete
8)
source

Types 2

type Params

struct
1type Params struct {
2	Contribution int64
3	Collateral   int64
4	Size         int
5	RoundSpan    int64 // seconds per round
6}
source

Params is the immutable economics of a circle.

Contribution is what each member pays every round. Collateral is what a member locks when joining; it is returned at completion and slashed into the penalty fund when the member defaults.

Methods on Params

func Locked

method on Params
1func (p Params) Locked() int64
source

Locked is the capital a circle needs at rest: every seat's collateral.

func NetPerMember

method on Params
1func (p Params) NetPerMember() int64
source

NetPerMember is the net cash flow of an ideal circle (no defaults) for a member who stays to the end: they pay Size contributions and receive one pot of Size contributions. It is always zero, which is the point of a ROSCA: it is a savings rotation, not a loan.

func Pot

method on Params
1func (p Params) Pot() int64
source

Pot is the payout one round produces when every seat pays.

func Validate

method on Params
1func (p Params) Validate() error
source

Validate checks the parameters of a circle.

type Status

ident
1type Status uint8
source

Status is the lifecycle stage of a circle.

Methods on Status

func String

method on Status
1func (s Status) String() string
source

String renders a status as a short label.

Dependencies

Imports 1

/p/g1udyt8ywv489087rn5td39m8t3peve3hxjz08w2/roscaslim2

Imported by indexer

Source Files 3