Documentation ¶
Index ¶
- Constants
- func SortOutputs(outputs []*Output)
- type Action
- type Asset
- type AssetService
- type AssetStore
- type Collateral
- type CollateralStore
- type Flip
- type FlipEvent
- type FlipStore
- type ListVaultRequest
- type Message
- type MessageService
- type MessageStore
- type Notifier
- type Oracle
- type OracleFeed
- type OracleService
- type OracleStore
- type Output
- type Parliament
- type Proposal
- type ProposalStore
- type RawTransaction
- type Session
- type System
- type Transaction
- type TransactionAction
- type TransactionStatus
- type TransactionStore
- type Transfer
- type TransferAction
- type TransferStatus
- type User
- type UserService
- type UserStore
- type Vault
- type VaultEvent
- type VaultStore
- type WalletService
- type WalletStore
Constants ¶
const (
TransferSourceRefund = "Refund"
)
Variables ¶
This section is empty.
Functions ¶
func SortOutputs ¶
func SortOutputs(outputs []*Output)
Types ¶
type Action ¶
type Action int
const ( // ActionProposal Proposal Actions ActionProposal Action = iota + 10 // ActionProposalMake Make a new proposal ActionProposalMake // ActionProposalShout Call on other mtg members to vote for this proposal, mtg member only ActionProposalShout // ActionProposalVote Vote for this proposal, mtg member only ActionProposalVote )
const ( // ActionCat Collateral Actions ActionCat Action = iota + 20 // ActionCatCreate Create a new collateral type, Gov required ActionCatCreate // ActionCatSupply Supply Dai to this collateral type ActionCatSupply // ActionCatEdit Edit Collateral parameters, Gov required ActionCatEdit // ActionCatFold Update Collateral's Rate ActionCatFold // ActionCatMove move supply from ont to another ActionCatMove // ActionCatGain withdraw profits from collateral ActionCatGain // ActionCatFill make up for the loss ActionCatFill )
const ( // ActionVat Vault Actions ActionVat Action = iota + 30 // ActionVatOpen Open a new Vault ActionVatOpen // ActionVatDeposit Deposit gem into Vault ActionVatDeposit // ActionVatWithdraw Withdraw gem from Vault ActionVatWithdraw // ActionVatPayback Pay back dai for Vault ActionVatPayback // ActionVatGenerate Generate dai from Vault ActionVatGenerate )
const ( // ActionOracle Oracle Actions ActionOracle Action = iota + 50 // ActionOracleCreate Create a new price ActionOracleCreate // ActionOracleEdit Edit can modify Next, hop & Threshold ActionOracleEdit // ActionOraclePoke Poke push the next price to be current ActionOraclePoke // ActionOracleRely Rely add a new oracle feed ActionOracleRely // ActionOracleDeny Deny remove a existed oracle feed ActionOracleDeny )
func (Action) MarshalBinary ¶
func (*Action) UnmarshalBinary ¶
type Asset ¶
type Asset struct { ID string `sql:"size:36;PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Version int64 `json:"version,omitempty"` Name string `sql:"size:64" json:"name,omitempty"` Symbol string `sql:"size:32" json:"symbol,omitempty"` Logo string `sql:"size:256" json:"logo,omitempty"` ChainID string `sql:"size:36" json:"chain_id,omitempty"` Price decimal.Decimal `sql:"type:decimal(24,12)" json:"price,omitempty"` }
Asset represent mixin asset
type AssetService ¶
type AssetService interface { Find(ctx context.Context, id string) (*Asset, error) List(ctx context.Context) ([]*Asset, error) }
AssetService provides access to remote mixin assets information
type AssetStore ¶
type AssetStore interface { Save(ctx context.Context, asset *Asset) error Find(ctx context.Context, id string) (*Asset, error) List(ctx context.Context) ([]*Asset, error) }
AssetStore defines operations for working with assets on db.
type Collateral ¶
type Collateral struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` TraceID string `sql:"size:36" json:"trace_id,omitempty"` Version int64 `json:"version,omitempty"` Name string `sql:"size:64" json:"name,omitempty"` // Gem represent deposit asset id Gem string `sql:"size:36" json:"gem,omitempty"` // Dai represent debt asset id Dai string `sql:"size:36" json:"dai,omitempty"` // Ink represent All Locked Collateral Ink decimal.Decimal `sql:"type:decimal(64,8)" json:"ink,omitempty"` // Total Normalised Debt Art decimal.Decimal `sql:"type:decimal(64,16)" json:"art,omitempty"` // Accumulated Rates Rate decimal.Decimal `sql:"type:decimal(64,16)" json:"rate,omitempty"` // Time of last drip [unix epoch time] Rho time.Time `json:"rho,omitempty"` // Debt the total quantity of dai issued Debt decimal.Decimal `sql:"type:decimal(64,8)" json:"debt,omitempty"` // the debt ceiling Line decimal.Decimal `sql:"type:decimal(64,8)" json:"line,omitempty"` // total debt supplied Supply decimal.Decimal `sql:"type:decimal(64,8)" json:"supply,omitempty"` // the debt floor, eg 100 Dust decimal.Decimal `sql:"type:decimal(64,8)" json:"dust,omitempty"` // Price = Gem.Price / Dai.Price Price decimal.Decimal `sql:"type:decimal(32,12)" json:"price,omitempty"` // Liquidation ratio, eg 150% Mat decimal.Decimal `sql:"type:decimal(10,8)" json:"mat,omitempty"` // stability fee, eg 110% Duty decimal.Decimal `sql:"type:decimal(20,8)" json:"duty,omitempty"` // Liquidation Penalty, eg 113% Chop decimal.Decimal `sql:"type:decimal(10,8)" json:"chop,omitempty"` // Dunk, max liquidation Quantity, eg 50000 Dunk decimal.Decimal `sql:"type:decimal(64,8)" json:"dunk,omitempty"` // Flip Options // Box, Max Dai out for liquidation Box decimal.Decimal `sql:"type:decimal(64,8)" json:"box,omitempty"` // Litter, Balance of Dai out for liquidation Litter decimal.Decimal `sql:"type:decimal(64,8)" json:"litter,omitempty"` // Beg minimum bid increase Beg decimal.Decimal `sql:"type:decimal(8,4)" json:"beg,omitempty"` // TTL bid duration in seconds TTL int64 `json:"ttl,omitempty"` // Tau flip duration in seconds Tau int64 `json:"tau,omitempty"` // Live Live int `json:"live,omitempty"` }
Collateral (CAT) represent collateral type
type CollateralStore ¶
type CollateralStore interface { Create(ctx context.Context, collateral *Collateral) error Update(ctx context.Context, collateral *Collateral, version int64) error Find(ctx context.Context, traceID string) (*Collateral, error) List(ctx context.Context) ([]*Collateral, error) }
CollateralStore define operations for working with collateral on db
type Flip ¶
type Flip struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Version int64 `json:"version,omitempty"` TraceID string `sql:"size:36" json:"trace_id,omitempty"` CollateralID string `sql:"size:36" json:"collateral_id,omitempty"` VaultID string `sql:"size:36" json:"vault_id,omitempty"` Action Action `json:"action,omitempty"` // bid expiry time Tic int64 `json:"tic,omitempty"` // auction expiry time End int64 `json:"end,omitempty"` // pUSD paid Bid decimal.Decimal `sql:"type:decimal(64,8)" json:"bid,omitempty"` // gems in return for bid Lot decimal.Decimal `sql:"type:decimal(64,8)" json:"lot,omitempty"` // total pUSD wanted Tab decimal.Decimal `sql:"type:decimal(64,8)" json:"tab,omitempty"` // Art Art decimal.Decimal `sql:"type:decimal(64,16)" json:"art,omitempty"` // high bidder Guy string `sql:"size:36" json:"guy,omitempty"` }
Flip represent auction by kicking unsafe vaults
type FlipEvent ¶
type FlipEvent struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` FlipID string `sql:"size:36" json:"flip_id,omitempty"` Version int64 `json:"version,omitempty"` Action Action `json:"action,omitempty"` Bid decimal.Decimal `sql:"type:decimal(64,8)" json:"bid,omitempty"` Lot decimal.Decimal `sql:"type:decimal(64,8)" json:"lot,omitempty"` Guy string `sql:"size:36" json:"guy,omitempty"` }
FlipEvent define operation history on flip
type FlipStore ¶
type FlipStore interface { Create(ctx context.Context, flip *Flip) error Update(ctx context.Context, flip *Flip, version int64) error Find(ctx context.Context, traceID string) (*Flip, error) List(ctx context.Context, from int64, limit int) ([]*Flip, error) // Event CreateEvent(ctx context.Context, event *FlipEvent) error FindEvent(ctx context.Context, flipID string, version int64) (*FlipEvent, error) ListEvents(ctx context.Context, flipID string) ([]*FlipEvent, error) }
FlipStore define operations for working on Flip & FlipEvent on db
type ListVaultRequest ¶
type Message ¶
type Message struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` MessageID string `sql:"size:36" json:"message_id,omitempty"` UserID string `sql:"size:36" json:"user_id,omitempty"` Raw types.JSONText `sql:"type:TEXT" json:"raw,omitempty"` }
Message define mixin messenger messages
func BuildMessage ¶
func BuildMessage(req *mixin.MessageRequest) *Message
BuildMessage convert mixin.MessageRequest to core.Message
type MessageService ¶
type MessageService interface { Send(ctx context.Context, messages []*Message, batch bool) error Meet(ctx context.Context, userID string) error }
MessageService provide access to handle message with mixin messenger service
type MessageStore ¶
type MessageStore interface { Create(ctx context.Context, messages []*Message) error List(ctx context.Context, limit int) ([]*Message, error) Delete(ctx context.Context, messages []*Message) error }
MessageStore defines operations for working with messages on db.
type Notifier ¶
type Notifier interface { // Auth called when a user login successfully Auth(ctx context.Context, user *User) error // Transaction called when a new tx created Transaction(ctx context.Context, tx *Transaction) error // Snapshot called when a transfer confirmed by mixin main net Snapshot(ctx context.Context, transfer *Transfer, TxHash string) error // VaultUnsafe notify the vault's owner the risk VaultUnsafe(ctx context.Context, cat *Collateral, vault *Vault) error // VaultLiquidatedSoon notify the owner of vault which is going to be liquidated VaultLiquidatedSoon(ctx context.Context, cat *Collateral, vault *Vault) error }
Notifier define operations to send notification to users
type Oracle ¶
type Oracle struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` AssetID string `sql:"size:36" json:"asset_id,omitempty"` Version int64 `json:"version,omitempty"` // Current Price Value Current decimal.Decimal `sql:"type:decimal(24,12)" json:"current,omitempty"` // Next Price Value Next decimal.Decimal `sql:"type:decimal(24,12)" json:"next,omitempty"` // Time of last update PeekAt time.Time `json:"peek_at,omitempty"` // Hop time delay (seconds) between poke calls Hop int64 `json:"hop,omitempty"` // Threshold represents the number of signatures required at least; // don't accept any updates by set to zero Threshold int64 `json:"threshold,omitempty"` // next price providers Governors pq.StringArray `sql:"type:varchar(1024)" json:"governors,omitempty"` }
Oracle represent price information
func (*Oracle) NextPeekAt ¶ added in v1.3.0
type OracleFeed ¶ added in v1.2.8
type OracleService ¶
OracleService define operations to parse new price from oracle service outside
type OracleStore ¶
type OracleStore interface { Create(ctx context.Context, oracle *Oracle) error Find(ctx context.Context, assetID string) (*Oracle, error) Update(ctx context.Context, oracle *Oracle, version int64) error List(ctx context.Context) ([]*Oracle, error) ListCurrent(ctx context.Context) (number.Values, error) // Rely approve a new feed Rely(ctx context.Context, userID, publicKey string) error // Deny remove an existing feed Deny(ctx context.Context, userID string) error ListFeeds(ctx context.Context) ([]*OracleFeed, error) }
OracleStore defines operations for working with oracles on db.
type Output ¶
type Output struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Version int64 `sql:"NOT NULL" json:"version,omitempty"` TraceID string `sql:"type:char(36)" json:"trace_id,omitempty"` // mixin id of operator Sender string `sql:"type:char(36)" json:"sender,omitempty"` AssetID string `sql:"type:char(36)" json:"asset_id,omitempty"` Amount decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"` Memo string `sql:"size:320" json:"memo,omitempty"` State string `sql:"size:24" json:"state,omitempty"` // unspent,signed,spent TransactionHash string `sql:"size:64" json:"hash,omitempty"` // utxo.transaction_hash.hex OutputIndex int `json:"output_index,omitempty"` // utxo.output_index SignedTx string `sql:"type:TEXT" json:"signed_tx,omitempty"` // utxo.signed_tx // SpentBy represent the associated transfer trace id SpentBy string `sql:"type:char(36);NOT NULL" json:"spent_by,omitempty"` }
Output represent Mixin Network multisig Outputs
type Parliament ¶
type Parliament interface { // ProposalCreated Called when a new proposal created ProposalCreated(ctx context.Context, proposal *Proposal) error // ProposalApproved called when a proposal has a new vote ProposalApproved(ctx context.Context, proposal *Proposal) error // ProposalPassed called when a proposal is passed ProposalPassed(ctx context.Context, proposal *Proposal) error // FlipCreated called when a new flip created FlipCreated(ctx context.Context, flip *Flip) error // FlipBid called when a flip bid created FlipBid(ctx context.Context, flip *Flip, event *FlipEvent) error // FlipDeal called when a flip completed FlipDeal(ctx context.Context, flip *Flip) error }
Parliament is a proposal version notifier to mtg member admins
type Proposal ¶
type Proposal struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` PassedAt sql.NullTime `json:"passed_at,omitempty"` Version int64 `json:"version,omitempty"` TraceID string `sql:"size:36" json:"trace_id,omitempty"` Creator string `sql:"size:36" json:"creator,omitempty"` AssetID string `sql:"size:36" json:"asset_id,omitempty"` Amount decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"` // Action the proposal applied Action Action `json:"action,omitempty"` // Data action parameters Data string `sql:"size:256" json:"data,omitempty"` // Votes mtg member voted for this proposal Votes pq.StringArray `sql:"type:varchar(1024)" json:"votes,omitempty"` }
type ProposalStore ¶
type ProposalStore interface { Create(ctx context.Context, proposal *Proposal) error Find(ctx context.Context, trace string) (*Proposal, error) Update(ctx context.Context, proposal *Proposal, version int64) error List(ctx context.Context, fromID int64, limit int) ([]*Proposal, error) }
ProposalStore define operations for working with proposals on db.
type RawTransaction ¶
type System ¶
type System struct { Admins []string ClientID string ClientSecret string Members []string Threshold uint8 GasAssetID string GasAmount decimal.Decimal PrivateKey ed25519.PrivateKey PublicKey ed25519.PublicKey Version string }
System stores system information.
type Transaction ¶
type Transaction struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` TraceID string `sql:"size:36" json:"trace_id,omitempty"` Version int64 `json:"version,omitempty"` UserID string `sql:"size:36" json:"user_id,omitempty"` FollowID string `sql:"size:36" json:"follow_id,omitempty"` AssetID string `sql:"size:36" json:"asset_id,omitempty"` Amount decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"` Action Action `json:"action,omitempty"` Status TransactionStatus `json:"status,omitempty"` Message string `sql:"size:128" json:"message,omitempty"` Parameters types.JSONText `sql:"type:varchar(1024)" json:"parameters,omitempty"` // []interface{} }
type TransactionAction ¶
type TransactionAction struct { FollowID []byte `msgpack:"f,omitempty"` Body []byte `msgpack:"b,omitempty"` }
func DecodeTransactionAction ¶
func DecodeTransactionAction(b []byte) (*TransactionAction, error)
func (TransactionAction) Encode ¶
func (action TransactionAction) Encode() ([]byte, error)
type TransactionStatus ¶
type TransactionStatus int
const ( TransactionStatusPending TransactionStatus = iota TransactionStatusAbort TransactionStatusOk )
func (TransactionStatus) String ¶
func (i TransactionStatus) String() string
type TransactionStore ¶
type TransactionStore interface { Create(ctx context.Context, tx *Transaction) error Find(ctx context.Context, trace string) (*Transaction, error) // FindFollow Find the last tx with the userID & followID FindFollow(ctx context.Context, userID, followID string) (*Transaction, error) // List list transactions List(ctx context.Context, fromID int64, limit int) ([]*Transaction, error) }
type Transfer ¶
type Transfer struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Version int64 `json:"version,omitempty"` TraceID string `sql:"type:char(36)" json:"trace_id,omitempty"` AssetID string `sql:"type:char(36)" json:"asset_id,omitempty"` Amount decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"` Memo string `sql:"size:200" json:"memo,omitempty"` Status TransferStatus `sql:"not null" json:"status,omitempty"` Threshold uint8 `json:"threshold,omitempty"` Opponents pq.StringArray `sql:"type:varchar(1024)" json:"opponents,omitempty"` }
type TransferAction ¶
func (TransferAction) Encode ¶
func (action TransferAction) Encode() string
type TransferStatus ¶ added in v1.4.8
type TransferStatus int
const ( TransferStatusPending TransferStatus = iota TransferStatusAssigned TransferStatusHandled TransferStatusPassed )
func (TransferStatus) String ¶ added in v1.4.8
func (i TransferStatus) String() string
type User ¶
type User struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` Version int64 `json:"version,omitempty"` MixinID string `sql:"size:36" json:"mixin_id,omitempty"` Role string `sql:"size:24" json:"role,omitempty"` Lang string `sql:"size:36" json:"lang,omitempty"` Name string `sql:"size:64" json:"name,omitempty"` Avatar string `sql:"size:255" json:"avatar,omitempty"` AccessToken string `sql:"size:512" json:"access_token,omitempty"` }
type UserService ¶
type Vault ¶
type Vault struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` TraceID string `sql:"size:36" json:"trace_id,omitempty"` Version int64 `sql:"not null" json:"version,omitempty"` UserID string `sql:"size:36" json:"user_id,omitempty"` // CollateralID represent collateral id CollateralID string `sql:"size:36" json:"collateral_id,omitempty"` // Locked Collateral Ink decimal.Decimal `sql:"type:decimal(64,8)" json:"ink,omitempty"` // Normalised Debt Art decimal.Decimal `sql:"type:decimal(64,16)" json:"art,omitempty"` // Rate is art per ink Rate decimal.Decimal `sql:"type:decimal(64,16)" json:"rate,omitempty"` }
type VaultEvent ¶
type VaultEvent struct { ID int64 `sql:"PRIMARY_KEY" json:"id,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` VaultID string `sql:"size:36" json:"vault_id,omitempty"` Version int64 `json:"version,omitempty"` Action Action `json:"action,omitempty"` // Locked Collateral change Dink decimal.Decimal `sql:"type:decimal(64,8)" json:"dink,omitempty"` // Normalised Debt change Dart decimal.Decimal `sql:"type:decimal(64,16)" json:"dart,omitempty"` // Debt change Debt decimal.Decimal `sql:"type:decimal(64,8)" json:"debt,omitempty"` }
type VaultStore ¶
type VaultStore interface { Create(ctx context.Context, vault *Vault) error Update(ctx context.Context, vault *Vault, version int64) error Find(ctx context.Context, traceID string) (*Vault, error) List(ctx context.Context, req ListVaultRequest) ([]*Vault, error) CountCollateral(ctx context.Context) (map[string]int64, error) // Events CreateEvent(ctx context.Context, event *VaultEvent) error FindEvent(ctx context.Context, vaultID string, version int64) (*VaultEvent, error) ListEvents(ctx context.Context, vaultID string) ([]*VaultEvent, error) }
type WalletService ¶
type WalletService interface { // Pull fetch NEW Output updates Pull(ctx context.Context, offset time.Time, limit int) ([]*Output, error) // Spend spend multiple Output Spend(ctx context.Context, outputs []*Output, transfer *Transfer) (*RawTransaction, error) // ReqTransfer generate payment code for multisig transfer ReqTransfer(ctx context.Context, transfer *Transfer) (string, error) // HandleTransfer handle a transfer request HandleTransfer(ctx context.Context, transfer *Transfer) error }
type WalletStore ¶
type WalletStore interface { // Save batch update multiple Output Save(ctx context.Context, outputs []*Output, end bool) error // List return a list of Output by order List(ctx context.Context, fromID int64, limit int) ([]*Output, error) // ListUnspent list unspent Output ListUnspent(ctx context.Context, assetID string, limit int) ([]*Output, error) FindSpentBy(ctx context.Context, assetID, spentBy string) (*Output, error) ListSpentBy(ctx context.Context, assetID, spentBy string) ([]*Output, error) // Transfers CreateTransfers(ctx context.Context, transfers []*Transfer) error UpdateTransfer(ctx context.Context, transfer *Transfer, status TransferStatus) error ListTransfers(ctx context.Context, status TransferStatus, limit int) ([]*Transfer, error) Assign(ctx context.Context, outputs []*Output, transfer *Transfer) error // mixin net transaction CreateRawTransaction(ctx context.Context, tx *RawTransaction) error ListPendingRawTransactions(ctx context.Context, limit int) ([]*RawTransaction, error) ExpireRawTransaction(ctx context.Context, tx *RawTransaction) error // CountOutputs return a count of outputs CountOutputs(ctx context.Context) (int64, error) // CountUnhandledTransfers return a count of pending transfers CountUnhandledTransfers(ctx context.Context) (int64, error) }