Documentation ¶
Index ¶
- Constants
- func Args1(a1 interface{}) ([]byte, error)
- func Args2(a1 interface{}, a2 interface{}) ([]byte, error)
- func Args3(a1 interface{}, a2 interface{}, a3 interface{}) ([]byte, error)
- func ArgsNull() []byte
- func CheckOrder(order *types.Order) error
- func EthCall(args *rtypes.SendTxArgs) (hexutil.Bytes, error)
- func GenesisBlockNumber() (*hexutil.Uint64, error)
- func MarshalTx(args *rtypes.SendTxArgs) map[string]interface{}
- func Ret(ret []byte) (string, error)
- func SendRawTx(b hexutil.Bytes, txType string) (common.Hash, error)
- func WalletEstimateGas(args *rtypes.SendTxArgs) (hexutil.Uint64, error)
- func WalletGetTransactionCount(addr common.Address) (uint64, error)
- func WalletSendRawTransaction(b hexutil.Bytes) (common.Hash, error)
- func WalletSignHash(addr common.Address, hash common.Hash) (hexutil.Bytes, error)
- func WalletSignTx(args *rtypes.SendTxArgs) (*rtypes.SignTransactionResult, error)
- type AccountModel
- type BlockSyncModel
- type Dex
- func (dex *Dex) DexAvailableVolume(order *types.Order) (*big.Int, error)
- func (dex *Dex) DexCallRequest(from common.Address, txData []byte) (hexutil.Bytes, error)
- func (dex *Dex) DexCancelOrder(order *types.SignOrder) (common.Hash, error)
- func (dex *Dex) DexDeposit(a common.Address, token common.Address, amount *hexutil.Big) (common.Hash, error)
- func (dex *Dex) DexGetDepositAmount(user *common.Address, token *common.Address) (*big.Int, error)
- func (dex *Dex) DexPostOrder(order *types.SignOrder) (common.Hash, error)
- func (dex *Dex) DexPostRequest(from common.Address, txData []byte) (common.Hash, error)
- func (dex *Dex) DexTestTakerTrade(order *types.Order, taker common.Address, amount *big.Int) (string, error)
- func (dex *Dex) DexTrade(a common.Address, order *types.SignOrder, amount *hexutil.Big) (common.Hash, error)
- func (dex *Dex) DexUsedVolumeByHash(hash *common.Hash) (*big.Int, error)
- func (dex *Dex) DexWithDraw(a common.Address, token common.Address, amount *hexutil.Big) (common.Hash, error)
- func (dex *Dex) PostChainTx(tx *rtypes.SendTxArgs) (common.Hash, error)
- func (dex *Dex) SignDexOrder(order *types.Order) ([]byte, error)
- type DexSubscription
- type OrderModel
- type OrderRet
- type SQLDBBackend
- func (db *SQLDBBackend) CreateAccountBalance(account common.Address) error
- func (db *SQLDBBackend) CreateOrder(order *types.SignOrder, state uint64) error
- func (db *SQLDBBackend) CreateSync() error
- func (db *SQLDBBackend) CreateTrade(orderHash common.Hash, FilledAmount *big.Int, DealAmount *big.Int, ...) error
- func (db *SQLDBBackend) DeleteAccountBalance(account common.Address) error
- func (db *SQLDBBackend) DeleteOrder(hash common.Hash) error
- func (db *SQLDBBackend) QueryOrderByTxPair(tokenGet common.Address, tokenGive common.Address, index uint64, count uint64) ([]*types.SignOrder, error)
- func (db *SQLDBBackend) ReadAccountBalance(account common.Address) (*AccountModel, error)
- func (db *SQLDBBackend) ReadOrder(hash common.Hash) (*types.SignOrder, error)
- func (db *SQLDBBackend) ReadSync() (uint64, uint64, error)
- func (db *SQLDBBackend) SetLogger(logger log.Logger)
- func (db *SQLDBBackend) UpdateAccountBalance(account common.Address, token common.Address, amount *big.Int) error
- func (db *SQLDBBackend) UpdateFillAmount(hash common.Hash, amount string) error
- func (db *SQLDBBackend) UpdateOrderState(hash common.Hash, state uint64) error
- func (db *SQLDBBackend) UpdateSync(begin, end uint64) error
- type SignOrderRet
- type TradeModel
- type TradeRet
Constants ¶
View Source
const ( Sending = iota Trading Finish )
Variables ¶
This section is empty.
Functions ¶
func CheckOrder ¶
func EthCall ¶
func EthCall(args *rtypes.SendTxArgs) (hexutil.Bytes, error)
GenesisBlockNumber return genesisBlock init height
func GenesisBlockNumber ¶
GenesisBlockNumber return genesisBlock init height
func MarshalTx ¶
func MarshalTx(args *rtypes.SendTxArgs) map[string]interface{}
func WalletEstimateGas ¶
func WalletEstimateGas(args *rtypes.SendTxArgs) (hexutil.Uint64, error)
func WalletSignHash ¶
func WalletSignTx ¶
func WalletSignTx(args *rtypes.SendTxArgs) (*rtypes.SignTransactionResult, error)
Types ¶
type AccountModel ¶
type AccountModel struct { UserID string `gorm:"primary_key;type:char(42)"` Token string `gorm:"type:char(42)"` Amount string }
Account Balance DateBase: not used
type BlockSyncModel ¶
type Dex ¶
Dex dex
func (*Dex) DexAvailableVolume ¶
func (*Dex) DexCallRequest ¶
func (*Dex) DexCancelOrder ¶
func (*Dex) DexDeposit ¶
func (*Dex) DexGetDepositAmount ¶
func (*Dex) DexPostOrder ¶
func (*Dex) DexPostRequest ¶
user call contract
func (*Dex) DexTestTakerTrade ¶
func (*Dex) DexUsedVolumeByHash ¶
func (*Dex) DexWithDraw ¶
func (*Dex) PostChainTx ¶
type DexSubscription ¶
type DexSubscription struct {
// contains filtered or unexported fields
}
func NewDexSubscription ¶
func NewDexSubscription(peer string, contractAddr string, logger log.Logger, db *SQLDBBackend) (*DexSubscription, error)
func (*DexSubscription) FilterrLog ¶
func (c *DexSubscription) FilterrLog(vlog *lktypes.Log) error
func (*DexSubscription) OnStart ¶
func (c *DexSubscription) OnStart() error
func (*DexSubscription) SubLoop ¶
func (c *DexSubscription) SubLoop(chanLog chan lktypes.Log, cli *rpc.ClientSubscription)
type OrderModel ¶
type OrderModel struct { HashID string `gorm:"primary_key;type:char(66)"` //Order HashID TokenGet string `gorm:"type:char(42);not null"` //Get Token Address AmountGet string `gorm:"not null"` //Get Token Amount TokenGive string `gorm:"type:char(42);not null"` //Give Token Address AmountGive string `gorm:"not null"` //Give Token Amount Nonce sql.NullInt64 `gorm:"not null"` //Nonce Expires sql.NullInt64 `gorm:"not null"` //Expire time (Unix Timestamp) Maker string `gorm:"type:char(42);not null"` //Maker Address R string `gorm:"type:char(34);not null"` //Sign R S string `gorm:"type:char(34);not null"` //Sign S V string `gorm:"type:char(4);not null"` //Sign V State sql.NullInt64 `gorm:"not null"` //0:Sending(not save in block) 1:Trading 2:Finish(Cancel) Price sql.NullFloat64 `gorm:"type:numeric(225,20);not null"` //Order Price Calculated from AmountGive and AmountGet FilledAmount string `gorm:"not null"` //Order FilledAmount default:0 }
OrderModel Order DateBase
func (*OrderModel) ToSignOrder ¶
func (o *OrderModel) ToSignOrder() (*types.SignOrder, error)
type OrderRet ¶
type SQLDBBackend ¶
func (*SQLDBBackend) CreateAccountBalance ¶
func (db *SQLDBBackend) CreateAccountBalance(account common.Address) error
Account: CURD
func (*SQLDBBackend) CreateOrder ¶
func (db *SQLDBBackend) CreateOrder(order *types.SignOrder, state uint64) error
Order: CURD
func (*SQLDBBackend) CreateTrade ¶
func (db *SQLDBBackend) CreateTrade(orderHash common.Hash, FilledAmount *big.Int, DealAmount *big.Int, BlockNum uint64, txHash common.Hash, taker common.Address) error
Trade: CURD
func (*SQLDBBackend) DeleteAccountBalance ¶
func (db *SQLDBBackend) DeleteAccountBalance(account common.Address) error
func (*SQLDBBackend) DeleteOrder ¶
func (db *SQLDBBackend) DeleteOrder(hash common.Hash) error
func (*SQLDBBackend) QueryOrderByTxPair ¶
func (db *SQLDBBackend) QueryOrderByTxPair(tokenGet common.Address, tokenGive common.Address, index uint64, count uint64) ([]*types.SignOrder, error)
TODO:Query transactions on special demand QueryOrderByTxPair: order by price
func (*SQLDBBackend) ReadAccountBalance ¶
func (db *SQLDBBackend) ReadAccountBalance(account common.Address) (*AccountModel, error)
func (*SQLDBBackend) SetLogger ¶
func (db *SQLDBBackend) SetLogger(logger log.Logger)
func (*SQLDBBackend) UpdateAccountBalance ¶
func (*SQLDBBackend) UpdateFillAmount ¶
func (db *SQLDBBackend) UpdateFillAmount(hash common.Hash, amount string) error
func (*SQLDBBackend) UpdateOrderState ¶
func (db *SQLDBBackend) UpdateOrderState(hash common.Hash, state uint64) error
func (*SQLDBBackend) UpdateSync ¶
func (db *SQLDBBackend) UpdateSync(begin, end uint64) error
type SignOrderRet ¶
type SignOrderRet struct { OrderRet `json:"order"` R string `json:"R"` S string `json:"S"` V string `json:"V"` }
func (*SignOrderRet) ToSignOrder ¶
func (o *SignOrderRet) ToSignOrder() (*types.SignOrder, error)
type TradeModel ¶
type TradeModel struct { gorm.Model HashID string `gorm:"type:char(66);FOREIGNKEY"` //Order Hash DealAmount string `gorm:"not null"` //Deal amount FilledAmount string `gorm:"not null"` //Trade Amount BlockNum sql.NullInt64 `gorm:"not null"` //Deal BlockNum TxHash string `gorm:"type:char(66);not null"` //Deal Tx hash Taker string `gorm:"type:char(42);not null"` //Taker Address }
TradeModel Trade history DateBase
Click to show internal directories.
Click to hide internal directories.