Documentation ¶
Index ¶
- func CheckRequiredBalance(summaries []Summary, tokenname string, token Token, ...) errstack.E
- func Distribute(dryRun bool, summaries []Summary, token Token, gasPrice *big.Int, ...) errstack.E
- func DistributeSWC(dryRun bool, summaries []Summary, gasPrice *big.Int, ...) errstack.E
- func FindDistributionAccount(userID pgt.UUID, db *pg.DB) (common.Address, errstack.E)
- type Account
- type DirectBuy
- type ReportRecord
- type Status
- type Summary
- type Token
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.
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 ¶
GetPendingDirectBuys retrieves pending direct buys from given trancheID.
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 ¶
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 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 ¶
SetStatusSent update the status for each DirectBuy record in summary to Done