Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Package vault demonstrates a minimal time-locked token vault built on top of the grc20 token package. Deposited token...

Readme View source

gno.land/r/moul/demo/vault/v0

TODO: describe this package.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/demo/vault/v0 dependency graph

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.

Overview

Package vault demonstrates a minimal time-locked token vault built on top of the grc20 token package. Deposited tokens are held at the realm's own address; withdrawing them is a two-step process: Unvault marks an amount for withdrawal and starts a lock timer, then (once the lock elapses) Redeem moves the tokens back to the depositor.

Variables 1

var Token, privateLedger, vaultAddr, vaulted, pending, unlockAt, recoverOf

 1var (
 2	Token         *tokens.Token
 3	privateLedger *tokens.PrivateLedger
 4	vaultAddr     address // address holding all deposited tokens
 5
 6	vaulted   = map[address]uint{}    // still-locked deposits per owner
 7	pending   = map[address]uint{}    // amount marked for withdrawal
 8	unlockAt  = map[address]int64{}   // block height at which pending unlocks
 9	recoverOf = map[address]address{} // recovery address per depositor
10)
source

Token and FooVault-equivalent state are exported for reading; privateLedger stays unexported (unrestricted mint/burn/transfer).

Functions 5

func Deposit

crossing Action
1func Deposit(cur realm, amount uint, recoverAddress address)
source

Deposit moves amount tokens from the caller into the vault, recording a recovery address for later use.

func Recover

crossing Action
1func Recover(cur realm, target address)
source

Recover sends target's still-locked deposit to its recorded recovery address.

func Redeem

crossing Action
1func Redeem(cur realm, amount uint)
source

Redeem transfers amount of the caller's matured pending withdrawal back to the caller.

func Unvault

crossing Action
1func Unvault(cur realm, amount uint)
source

Unvault marks amount of the caller's deposit for withdrawal and starts the lock timer.

Imports 3

Source Files 3