trancheq

package
v0.0.0-...-086ef7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SWCqueueABI = ethereum.MustParseABI("SWCqueue", contracts.SWCqueueABI)
)

SWCqueue globals

Functions

func LogSWCqueueDirectPledge

func LogSWCqueueDirectPledge() abi.Event

LogSWCqueueDirectPledge returns event

Types

type EventDirectPledge

type EventDirectPledge struct {
	Who      common.Address
	Wad      *big.Int
	Currency liquidity.Currency
}

EventDirectPledge represents LogSWCqueueDirectPledge event payload

func (*EventDirectPledge) Unmarshal

func (e *EventDirectPledge) Unmarshal(log *types.Log) errstack.E

Unmarshal blockchain log into the event structure

type LogPledger

type LogPledger interface {
	NewPledge(log *types.Log) (Pledge, errstack.E)
}

LogPledger is an interface for an object which is able to construct new pledges from a Log

func NewLogTransferPledger

func NewLogTransferPledger(brgs map[common.Address]liquidity.Currency) LogPledger

NewLogTransferPledger constructs new Pledge from a Transfer event. It uses mapping for various BRG* flavours handling different currencies

type Pledge

type Pledge struct {
	Tx         string              `sql:"pledge_queue_id,pk"` // ID is a Tx hash
	WalletAddr ethereum.PgtAddress `sql:"wallet_addr"`
	CtrAddr    ethereum.PgtAddress `sql:"ctr_addr,notnull"`
	Wad        pgt.BigInt          `sql:",notnull"`
	CreatedAt  time.Time           `sql:"created_at"`
	Currency   liquidity.Currency  `sql:",notnull"`
	Direct     bool                `sql:",notnull"`
	// contains filtered or unexported fields
}

Pledge represents pledge_queue entry

func NewPledgeFromDirectPledge

func NewPledgeFromDirectPledge(log *types.Log) (Pledge, errstack.E)

NewPledgeFromDirectPledge constructs new Pledge from the event

type Pledger

type Pledger struct {
	BRG      *contracts.BridgeToken
	SWCQ     *contracts.SWCqueue
	SWCQaddr common.Address
	// contains filtered or unexported fields
}

Pledger provides functionality for creating pledges

func NewPledger

func NewPledger(cf ethereum.ContractFactory) (Pledger, errstack.E)

NewPledger constructs Pledger

func (Pledger) Post

Post mints new BRG for the SWCqueue and posts the pledge request to the blockchain It reteurns transaction objects for Mint and for DirectPledge respectively.

type Token

type Token struct {
	ID        string    `sql:"token_id,pk" json:"id"` // token name
	CreatedAt time.Time `sql:"created_at,notnull" json:"createdAt"`
	Comment   string    `sql:"comment,notnull" json:"comment"`

	MaxTotalContrib pgt.BigInt `sql:"max_total_contrib" json:"maxTotalContrib"` // in wad, 0 = no limit
}

Token represents tokens DB table entry

func GetToken

func GetToken(id string, db *pg.DB) (Token, errstack.E)

GetToken returns token from DB

func (*Token) Validate

func (t *Token) Validate() errstack.Builder

Validate checks if all fields are sematically correct. It also sets the automatic fields (ID, CreatedAt)

type Tranche

type Tranche struct {
	TrancheDB
	Prices map[liquidity.Currency]float64 `json:"prices"`
}

Tranche represents tranche model

func GetTranche

func GetTranche(id int64, db *pg.DB) (Tranche, errstack.E)

GetTranche returns tranche from DB

func GetTranches

func GetTranches(db *pg.DB) ([]Tranche, errstack.E)

GetTranches returns Tranches combined with prices from DB. TODO: in the future we need to return only active tranches.

func (*Tranche) Save

func (t *Tranche) Save(db *pg.DB) errstack.E

Save stores the object into DB

func (*Tranche) Validate

func (t *Tranche) Validate() errstack.Builder

Validate checks if all fields are sematically correct. It also resets the automatic fields (ID, CreatedAt)

type TrancheDB

type TrancheDB struct {
	ID         int64      `sql:"tranche_id,pk" json:"id"`
	TokenID    string     `sql:",notnull" json:"tokenID"`
	CreatedAt  time.Time  `sql:"created_at,notnull" json:"createdAt"`
	StartsAt   time.Time  `sql:"starts_at,notnull" json:"startsAt"`
	ExecutesAt time.Time  `sql:"executes_at,notnull" json:"executesAt"`
	EndsAt     *time.Time `sql:"ends_at" json:"endsAt"`
	Supply     pgt.BigInt `sql:"supply,notnull" json:"supply"`          // in wad
	MaxContrib pgt.BigInt `sql:"max_contrib,notnull" json:"maxContrib"` // in wad, 0=no limit
	// contains filtered or unexported fields
}

TrancheDB represents tranches DB table entry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL