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

v1 source pure

Package fairmath prices whole-lot fair-sale commitments without holding funds. No sale is active until a separate rea...

Overview

Package fairmath prices whole-lot fair-sale commitments without holding funds. No sale is active until a separate realm accounts for custody and exit rights. All amounts are token or quote base units.

Constants 1

Functions 4

func MaxLots

1func MaxLots(allocation, lotSize int64) int64
source

MaxLots requires the escrowed sale allocation to consist of whole lots. No token dust is created by dividing the allocation between buyers.

func Claim

1func Claim(success bool, lots, deposit, lotSize, closePrice int64) BuyerClaim
source

Claim computes one buyer's exact rights after Clear. Claims over the same orders telescope to its aggregate settlement, regardless of claim order.

func QuoteOrder

1func QuoteOrder(lots, lotSize, entryPrice int64) Order
source

QuoteOrder gives the exact token and quote amounts for a whole-lot order.

func Clear

1func Clear(c Caps, allocation, lotSize, totalLots, totalDeposits, closePrice int64) Settlement
source

Clear partitions all whole-lot commitments at one pinned clearing price. A missed soft cap returns all deposits and all tokens. On success, deposits above the clearing-price gross remain buyer refund liabilities.

Types 5

type BuyerClaim

struct
1type BuyerClaim struct {
2	Tokens      int64
3	SpentQuote  int64
4	RefundQuote int64
5}
source

type Caps

struct
1type Caps struct {
2	HardLots  int64
3	SoftQuote int64
4}
source

Caps snapshots the sale's hard cap in whole lots and soft cap in quote atoms actually spent at the final clearing price. Entry deposits and later refunds do not count toward the soft cap.

Methods on Caps

func AddLots

method on Caps
1func (c Caps) AddLots(current, order int64) (int64, bool)
source

AddLots rejects an order that would exceed the hard cap. Equality signals an early close at the contribution transaction's block time.

func Validate

method on Caps
1func (c Caps) Validate(allocation, lotSize, highestPrice int64)
source

type Order

struct
1type Order struct {
2	Lots    int64
3	Tokens  int64
4	Deposit int64
5}
source

type Schedule

struct
1type Schedule struct {
2	Start           int64
3	End             int64
4	StartPrice      int64
5	FloorPrice      int64
6	Decrement       int64
7	IntervalSeconds int64
8}
source

Schedule defines quote atoms per lot. A zero decrement is a fixed-price sale; otherwise the price falls by Decrement every IntervalSeconds, never below FloorPrice. End is the scheduled close instant. An inventory or hard- cap close must pass its recorded transaction time to PriceAt instead.

Methods on Schedule

func PriceAt

method on Schedule
1func (s Schedule) PriceAt(at int64) int64
source

func Validate

method on Schedule
1func (s Schedule) Validate()
source

type Settlement

struct
1type Settlement struct {
2	Succeeded    bool
3	SoldTokens   int64
4	GrossQuote   int64
5	RefundQuote  int64
6	UnsoldTokens int64
7}
source

Imports 1

Source Files 2