directbuy

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRequiredBalance

func CheckRequiredBalance(summaries []Summary, tokenname string, token Token, cf ethereum.ContractFactory) errstack.E

CheckRequiredBalance verifies if the `cf` transactor address has enough `token` balance to cover all distribution.

func Distribute

func Distribute(dryRun bool, summaries []Summary, token Token, gasPrice *big.Int, cf ethereum.ContractFactory, db *pg.DB) errstack.E

Distribute performs on-chain token distirubtion based of aggregated summaries. If gasPrice (in wei) is provided then it's used for setting the gas price of a transaction. Otherwise the gas price oracle is used for estimation.

func DistributeSWC

func DistributeSWC(dryRun bool, summaries []Summary, gasPrice *big.Int, cf ethereum.ContractFactory, db *pg.DB) errstack.E

DistributeSWC performs on-chain SWC token distirubtion based of aggregated summaries.

func FindDistributionAccount

func FindDistributionAccount(userID pgt.UUID, db *pg.DB) (common.Address, errstack.E)

FindDistributionAccount selects user etherum account used to distribute SWC tokens.

Types

type Account

type Account struct {
	ID           pgt.UUID `sql:"id,pk"`
	IndividualID pgt.UUID `sql:"individual_id"`
	Number       string   `sql:"account_number"`
	Name         string   `sql:"account_name"`
	Reference    string   `sql:"reference"`

	CreatedAt time.Time `sql:"created_at,notnull"`
	UpdatedAt time.Time `sql:"updated_at,notnull"`
	// contains filtered or unexported fields
}

Account represents DB members account record

type DirectBuy

type DirectBuy struct {
	ID        int64              `sql:"direct_buy_id,pk"`
	Hash      []byte             `sql:"hash"`
	UserID    pgt.UUID           `sql:"individual_id"`
	Email     string             `sql:"email"`
	TrancheID uint64             `sql:"tranche_id,notnull"`
	AmountOut float64            `sql:"amount_out,notnull"`
	AmountIn  float64            `sql:"amount_in,notnull"`
	Currency  liquidity.Currency `sql:"currency_id"`
	UsdRate   float64            `sql:"usd_rate,notnull"`
	SenderID  string             `sql:"sender_id"`
	Status    Status             `sql:"status,notnull"`
	HashOut   *ethereum.PgtHash  `sql:"hash_out,notnull"`
	Nonce     uint64             `sql:"nonce,notnull"`

	TransactionDate time.Time `sql:"transaction_date,notnull"`
	CreatedAt       time.Time `sql:"created_at,notnull"`
	UpdatedAt       time.Time `sql:"updated_at,notnull"`
}

DirectBuy represents the swc direct buy for the next distribution.

func GetPendingDirectBuys

func GetPendingDirectBuys(trancheID uint64, db *pg.DB) ([]DirectBuy, errstack.E)

GetPendingDirectBuys retrieves pending direct buys from given trancheID.

func (*DirectBuy) MkHash

func (d *DirectBuy) MkHash(txHash string) errstack.E

MkHash computes and assigns hash to the DirectBuy record

type ReportRecord

type ReportRecord struct {
	List      string
	Address   common.Address
	AmountIn  float64
	AmountOut float64
	Comment   string
	Done      bool
	DBs       []DirectBuy
}

ReportRecord represent SWC distribution record aligned to swc-distributor

func CreateDirectBuyReport

func CreateDirectBuyReport(title string, trancheID uint64, db *pg.DB) ([]*ReportRecord, errstack.E)

CreateDirectBuyReport creates aggregated SWC distribution report of DirectBuys from given tranche id. `title` is used for the report field. TrancheID is automatically appended to the title using "_" as the separator

type Status

type Status uint

Status a type for DirectBuy.Status field

const (
	StatusOnHold Status = iota
	StatusPending
	StatusSent
)

DirectBuy statuses

func ParseStatusErrp

func ParseStatusErrp(s string, errp errstack.Putter) Status

ParseStatusErrp converts string status verose name to uint and sets error into errp

type Summary

type Summary struct {
	Idx     int // report row index
	List    string
	Address common.Address
	Amount  *big.Int
	DBs     []DirectBuy
}

Summary represents the aggregated (per user) view of DirectBuy distribution

func ReportRecordsToSummary

func ReportRecordsToSummary(rs []*ReportRecord) ([]Summary, errstack.E)

ReportRecordsToSummary converts aggregated DirectBuy records into Summary

func (Summary) SetStatusSent

func (s Summary) SetStatusSent(db *pg.DB, tx *types.Transaction) errstack.E

SetStatusSent update the status for each DirectBuy record in summary to Done

func (Summary) String

func (s Summary) String() string

String implements stringer interface

type Token

type Token interface {
	BalanceOf(opts *bind.CallOpts, who common.Address) (*big.Int, error)
	Transfer(opts *bind.TransactOpts, dst common.Address, wad *big.Int) (*types.Transaction, error)
}

Token is the minimum interface to execute distribution

Jump to

Keyboard shortcuts

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