Documentation ¶
Index ¶
- Constants
- Variables
- func DoSettleBalance(coinbase common.Address, takerOrder, makerOrder *lendingstate.LendingItem, ...) error
- func GetLendQuantity(takerSide string, collateralTokenDecimal *big.Int, depositRate *big.Int, ...) (*big.Int, bool)
- type Lending
- func (l *Lending) APIs() []rpc.API
- func (l *Lending) ApplyOrder(header *types.Header, coinbase common.Address, chain consensus.ChainContext, ...) ([]*lendingstate.LendingTrade, []*lendingstate.LendingItem, error)
- func (l *Lending) AutoTopUp(statedb *state.StateDB, tradingState *tradingstate.TradingStateDB, ...) (*lendingstate.LendingTrade, error)
- func (l *Lending) CommitOrder(header *types.Header, coinbase common.Address, chain consensus.ChainContext, ...) ([]*lendingstate.LendingTrade, []*lendingstate.LendingItem, error)
- func (l *Lending) GetCollateralPrices(header *types.Header, chain consensus.ChainContext, statedb *state.StateDB, ...) (*big.Int, *big.Int, error)
- func (l *Lending) GetLendingState(block *types.Block, author common.Address) (*lendingstate.LendingStateDB, error)
- func (l *Lending) GetLendingStateRoot(block *types.Block, author common.Address) (common.Hash, error)
- func (l *Lending) GetLevelDB() XDCxDAO.XDCXDAO
- func (l *Lending) GetMediumTradePriceBeforeEpoch(chain consensus.ChainContext, statedb *state.StateDB, ...) (*big.Int, error)
- func (l *Lending) GetMongoDB() XDCxDAO.XDCXDAO
- func (l *Lending) GetStateCache() lendingstate.Database
- func (l *Lending) GetTriegc() *prque.Prque
- func (l *Lending) GetXDCBasePrices(header *types.Header, chain consensus.ChainContext, statedb *state.StateDB, ...) (*big.Int, error)
- func (l *Lending) HasLendingState(block *types.Block, author common.Address) bool
- func (l *Lending) LiquidationExpiredTrade(header *types.Header, chain consensus.ChainContext, ...) (*lendingstate.LendingTrade, error)
- func (l *Lending) LiquidationTrade(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, ...) (*lendingstate.LendingTrade, error)
- func (l *Lending) ProcessCancelOrder(header *types.Header, lendingStateDB *lendingstate.LendingStateDB, ...) (error, bool)
- func (l *Lending) ProcessLiquidationData(header *types.Header, chain consensus.ChainContext, statedb *state.StateDB, ...) (updatedTrades map[common.Hash]*lendingstate.LendingTrade, ...)
- func (l *Lending) ProcessOrderPending(header *types.Header, coinbase common.Address, chain consensus.ChainContext, ...) ([]*lendingstate.LendingItem, map[common.Hash]lendingstate.MatchingResult)
- func (l *Lending) ProcessRecallLendingTrade(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, ...) (error, bool, *lendingstate.LendingTrade)
- func (l *Lending) ProcessRepay(header *types.Header, chain consensus.ChainContext, ...) (trade *lendingstate.LendingTrade, err error)
- func (l *Lending) ProcessRepayLendingTrade(header *types.Header, chain consensus.ChainContext, ...) (trade *lendingstate.LendingTrade, err error)
- func (l *Lending) ProcessTopUp(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, ...) (error, bool, *lendingstate.LendingTrade)
- func (l *Lending) ProcessTopUpLendingTrade(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, ...) (error, bool, *lendingstate.LendingTrade)
- func (l *Lending) Protocols() []p2p.Protocol
- func (l *Lending) RollbackLendingData(txhash common.Hash) error
- func (l *Lending) SaveData()
- func (l *Lending) Start(server *p2p.Server) error
- func (l *Lending) Stop() error
- func (l *Lending) SyncDataToSDKNode(chain consensus.ChainContext, statedb *state.StateDB, block *types.Block, ...) error
- func (l *Lending) UpdateLendingItemCache(LendingToken, CollateralToken common.Address, hash common.Hash, ...)
- func (l *Lending) UpdateLendingTrade(trades map[common.Hash]*lendingstate.LendingTrade, txhash common.Hash, ...) error
- func (l *Lending) UpdateLendingTradeCache(hash common.Hash, txhash common.Hash, ...)
- func (l *Lending) UpdateLiquidatedTrade(blockTime uint64, result lendingstate.FinalizedResult, ...) error
- func (l *Lending) Version() uint64
- type PublicXDCXLendingAPI
Constants ¶
const ( ProtocolName = "XDCxlending" ProtocolVersion = uint64(1) ProtocolVersionStr = "1.0" )
Variables ¶
var ( ErrNonceTooHigh = errors.New("nonce too high") ErrNonceTooLow = errors.New("nonce too low") )
var ( ErrOrderNonceTooLow = errors.New("OrderNonce too low") ErrOrderNonceTooHigh = errors.New("OrderNonce too high") )
List of errors
Functions ¶
func DoSettleBalance ¶
func DoSettleBalance(coinbase common.Address, takerOrder, makerOrder *lendingstate.LendingItem, settleBalance *lendingstate.LendingSettleBalance, statedb *state.StateDB) error
Types ¶
type Lending ¶
type Lending struct { Triegc *prque.Prque // Priority queue mapping block numbers to tries to gc StateCache lendingstate.Database // State database to reuse between imports (contains state cache) *lendingstate.TradingStateDB XDCx *XDCx.XDCX // contains filtered or unexported fields }
func (*Lending) ApplyOrder ¶
func (l *Lending) ApplyOrder(header *types.Header, coinbase common.Address, chain consensus.ChainContext, statedb *state.StateDB, lendingStateDB *lendingstate.LendingStateDB, tradingStateDb *tradingstate.TradingStateDB, lendingOrderBook common.Hash, order *lendingstate.LendingItem) ([]*lendingstate.LendingTrade, []*lendingstate.LendingItem, error)
func (*Lending) AutoTopUp ¶
func (l *Lending) AutoTopUp(statedb *state.StateDB, tradingState *tradingstate.TradingStateDB, lendingState *lendingstate.LendingStateDB, lendingBook, lendingTradeId common.Hash, currentPrice *big.Int) (*lendingstate.LendingTrade, error)
func (*Lending) CommitOrder ¶
func (l *Lending) CommitOrder(header *types.Header, coinbase common.Address, chain consensus.ChainContext, statedb *state.StateDB, lendingStateDB *lendingstate.LendingStateDB, tradingStateDb *tradingstate.TradingStateDB, lendingOrderBook common.Hash, order *lendingstate.LendingItem) ([]*lendingstate.LendingTrade, []*lendingstate.LendingItem, error)
func (*Lending) GetCollateralPrices ¶
func (l *Lending) GetCollateralPrices(header *types.Header, chain consensus.ChainContext, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, collateralToken common.Address, lendingToken common.Address) (*big.Int, *big.Int, error)
LendToken and CollateralToken must meet at least one of following conditions - Have direct pair in XDCX: lendToken/CollateralToken or CollateralToken/LendToken - Have pairs with XDC: - lendToken/XDC and CollateralToken/XDC - XDC/lendToken and XDC/CollateralToken
func (*Lending) GetLendingState ¶
func (l *Lending) GetLendingState(block *types.Block, author common.Address) (*lendingstate.LendingStateDB, error)
func (*Lending) GetLendingStateRoot ¶
func (*Lending) GetLevelDB ¶
func (*Lending) GetMediumTradePriceBeforeEpoch ¶
func (l *Lending) GetMediumTradePriceBeforeEpoch(chain consensus.ChainContext, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, baseToken common.Address, quoteToken common.Address) (*big.Int, error)
func (*Lending) GetMongoDB ¶
func (*Lending) GetStateCache ¶
func (l *Lending) GetStateCache() lendingstate.Database
func (*Lending) GetXDCBasePrices ¶
func (l *Lending) GetXDCBasePrices(header *types.Header, chain consensus.ChainContext, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, token common.Address) (*big.Int, error)
func (*Lending) HasLendingState ¶
func (*Lending) LiquidationExpiredTrade ¶
func (l *Lending) LiquidationExpiredTrade(header *types.Header, chain consensus.ChainContext, lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingstateDB *tradingstate.TradingStateDB, lendingBook common.Hash, lendingTradeId uint64) (*lendingstate.LendingTrade, error)
return liquidatedTrade
func (*Lending) LiquidationTrade ¶
func (l *Lending) LiquidationTrade(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingstateDB *tradingstate.TradingStateDB, lendingBook common.Hash, lendingTradeId uint64) (*lendingstate.LendingTrade, error)
return liquidatedTrade
func (*Lending) ProcessCancelOrder ¶
func (l *Lending) ProcessCancelOrder(header *types.Header, lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, chain consensus.ChainContext, coinbase common.Address, lendingOrderBook common.Hash, order *lendingstate.LendingItem) (error, bool)
func (*Lending) ProcessLiquidationData ¶
func (l *Lending) ProcessLiquidationData(header *types.Header, chain consensus.ChainContext, statedb *state.StateDB, tradingState *tradingstate.TradingStateDB, lendingState *lendingstate.LendingStateDB) (updatedTrades map[common.Hash]*lendingstate.LendingTrade, liquidatedTrades, autoRepayTrades, autoTopUpTrades, autoRecallTrades []*lendingstate.LendingTrade, err error)
func (*Lending) ProcessOrderPending ¶
func (l *Lending) ProcessOrderPending(header *types.Header, coinbase common.Address, chain consensus.ChainContext, pending map[common.Address]types.LendingTransactions, statedb *state.StateDB, lendingStatedb *lendingstate.LendingStateDB, tradingStateDb *tradingstate.TradingStateDB) ([]*lendingstate.LendingItem, map[common.Hash]lendingstate.MatchingResult)
func (*Lending) ProcessRecallLendingTrade ¶
func (l *Lending) ProcessRecallLendingTrade(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, lendingBook common.Hash, lendingTradeId common.Hash, newLiquidationPrice *big.Int) (error, bool, *lendingstate.LendingTrade)
func (*Lending) ProcessRepay ¶
func (l *Lending) ProcessRepay(header *types.Header, chain consensus.ChainContext, lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingstateDB *tradingstate.TradingStateDB, lendingBook common.Hash, order *lendingstate.LendingItem) (trade *lendingstate.LendingTrade, err error)
return hash: hash of lendingTrade
func (*Lending) ProcessRepayLendingTrade ¶
func (l *Lending) ProcessRepayLendingTrade(header *types.Header, chain consensus.ChainContext, lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingstateDB *tradingstate.TradingStateDB, lendingBook common.Hash, lendingTradeId uint64) (trade *lendingstate.LendingTrade, err error)
func (*Lending) ProcessTopUp ¶
func (l *Lending) ProcessTopUp(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, order *lendingstate.LendingItem) (error, bool, *lendingstate.LendingTrade)
func (*Lending) ProcessTopUpLendingTrade ¶
func (l *Lending) ProcessTopUpLendingTrade(lendingStateDB *lendingstate.LendingStateDB, statedb *state.StateDB, tradingStateDb *tradingstate.TradingStateDB, lendingTradeId common.Hash, lendingBook common.Hash, quantity *big.Int) (error, bool, *lendingstate.LendingTrade)
func (*Lending) RollbackLendingData ¶
func (*Lending) SyncDataToSDKNode ¶
func (l *Lending) SyncDataToSDKNode(chain consensus.ChainContext, statedb *state.StateDB, block *types.Block, takerLendingItem *lendingstate.LendingItem, txHash common.Hash, txMatchTime time.Time, trades []*lendingstate.LendingTrade, rejectedItems []*lendingstate.LendingItem, dirtyOrderCount *uint64) error
there are 3 tasks need to complete (for SDK nodes) after matching 1. Put takerLendingItem to database 2.a Update status, filledAmount of makerLendingItem 2.b. Put lendingTrade to database 3. Update status of rejected items
func (*Lending) UpdateLendingItemCache ¶
func (l *Lending) UpdateLendingItemCache(LendingToken, CollateralToken common.Address, hash common.Hash, txhash common.Hash, lastState lendingstate.LendingItemHistoryItem)
func (*Lending) UpdateLendingTrade ¶
func (l *Lending) UpdateLendingTrade(trades map[common.Hash]*lendingstate.LendingTrade, txhash common.Hash, txTime time.Time) error
func (*Lending) UpdateLendingTradeCache ¶
func (l *Lending) UpdateLendingTradeCache(hash common.Hash, txhash common.Hash, lastState lendingstate.LendingTradeHistoryItem)
func (*Lending) UpdateLiquidatedTrade ¶
func (l *Lending) UpdateLiquidatedTrade(blockTime uint64, result lendingstate.FinalizedResult, trades map[common.Hash]*lendingstate.LendingTrade) error
type PublicXDCXLendingAPI ¶
type PublicXDCXLendingAPI struct {
// contains filtered or unexported fields
}
PublicXDCXLendingAPI provides the XDCX RPC service that can be use publicly without security implications.
func NewPublicXDCXLendingAPI ¶
func NewPublicXDCXLendingAPI(t *Lending) *PublicXDCXLendingAPI
NewPublicXDCXLendingAPI create a new RPC XDCX service.
Directories ¶
Path | Synopsis |
---|---|
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |