Documentation ¶
Index ¶
- Constants
- Variables
- func CalPrice(paths []coreSchema.Path, tokens map[string]*everSchema.Token, ...) (price, tokenInAmount, tokenOutAmount *big.Float)
- func ClosedMiddleware() gin.HandlerFunc
- func ConvertPathsToBundle(paths []coreSchema.Path, tokens map[string]*everSchema.Token, expireAt int64, ...) (bundle everSchema.Bundle, err error)
- func GetLpClientInfoConf(chainID int64) (lpClients map[string]*schema.LpClientInfo)
- func GetTokenPriceByRedstone(tokenSymbol string, currency string, timestamp string) (float64, error)
- func VerifyBundleAndPaths(bundle everSchema.Bundle, paths []coreSchema.Path, ...) (err error)
- func VerifyBundleByAddr(bundle everSchema.BundleWithSigs, address string, chainID int64) (accid string, accsig map[string]string, err error)
- func VerifySig(accType, accID string, msg, sig string, chainID int) (err error)
- type Config
- type NFT
- type NFTInfo
- type NFTOwnerChangeMsg
- type Order
- type Penalty
- func (p *Penalty) AddFailRecord(accid string, timestamp int64, everHash string, reason string)
- func (p *Penalty) ClearUpExpired()
- func (p *Penalty) GetBlackList() map[string]int64
- func (p *Penalty) GetFailureRecords() map[string][]schema.FailureRecord
- func (p *Penalty) GetPenalty() (map[string]int64, map[string][]schema.FailureRecord)
- func (p *Penalty) IsBlackListed(accid string) bool
- type Pool
- type Price
- type Router
- type Stats
- func (s *Stats) GetRewardsByAccid(accid string) (rewards []schema.PermaLpReward)
- func (s *Stats) GetTVLByPoolID(poolid string) (tvl schema.TVL)
- func (s *Stats) GetTVLsByAccid(accid string) (tvls []schema.TVL)
- func (s *Stats) GetVolumeByPoolID(poolid string) (volume schema.Volume)
- func (s *Stats) GetVolumesByAccid(accid string) (volumes []schema.Volume)
- func (s *Stats) Run()
- type WDB
- func (w *WDB) CreatePermaOrder(order *schema.PermaOrder, tx *gorm.DB) error
- func (w *WDB) CreatePermaVolume(volume *schema.PermaVolume, tx *gorm.DB) error
- func (w *WDB) GetOrders(page, count int, start, end time.Time) (orders []*schema.PermaOrder, err error)
- func (w *WDB) GetOrdersByUser(accid string, page, count int, start, end time.Time) (orders []*schema.PermaOrder, err error)
- func (w *WDB) GetPermaReward(lpid string, tx *gorm.DB) (reward *schema.PermaLpReward, err error)
- func (w *WDB) GetPermaRewards(accid string, tx *gorm.DB) (rewards []*schema.PermaLpReward, err error)
- func (w *WDB) GetVolumesByTime(start, end time.Time) (volumes []*schema.PermaVolume, err error)
- func (w *WDB) LoadNFTWhiteList() (list []*schema.NFTWhiteList, err error)
- func (w *WDB) LoadPermaLpsSnapshot() (lpsSnapshot *schema.PermaLpsSnapshot, err error)
- func (w *WDB) Migrate()
- func (w *WDB) SavePermaLpsSnapshot(lpsSnapshot *schema.PermaLpsSnapshot, tx *gorm.DB) (err error)
- func (w *WDB) SumPoolVolumesByTime(start, end time.Time) (res []*schema.SumPermaVolumeRes, err error)
- func (w *WDB) SumVolumesByTime(start, end time.Time) (res []*schema.SumPermaVolumeRes, err error)
- func (w *WDB) TotalOrdersNumByUser(accid string) (num int64, err error)
- func (w *WDB) UpdatePermaLpReward(lpReward *schema.PermaLpReward, tx *gorm.DB) (err error)
- type WsErr
Constants ¶
View Source
const ( PermaswapClosed = false // penalty config CumulativeFailures = 3 ExpirationDuration = 3600 )
Variables ¶
View Source
var ( WsErrNotFoundPath = NewWsErr("err_not_found_path") WsErrNotFoundSalt = NewWsErr("err_not_found_salt") WsErrNotFoundLp = NewWsErr("err_not_found_lp") WsErrNoAuthorization = NewWsErr("err_no_authorization") WsErrCanNotUpdateLp = NewWsErr("err_can_not_update_lp") WsErrDuplicateRegistration = NewWsErr("err_duplicate_registration") WsErrInvalidMsg = NewWsErr("err_invalid_msg") WsErrInvalidToken = NewWsErr("err_invalid_token") WsErrInvalidOrder = NewWsErr("err_invalid_order") WsErrInvalidAddress = NewWsErr("err_invalid_address") WsErrInvalidSignature = NewWsErr("err_invalid_signature") WsErrInvalidPathsOrBundle = NewWsErr("err_invalid_paths_or_bundle") WsErrNotNFTOwner = NewWsErr("err_not_nft_owner") WsErrInvalidNFTData = NewWsErr("err_invalid_nft_data") WsErrInvalidLpClient = NewWsErr("err_invalid_lp_client") WsErrBlackListed = NewWsErr("err_blacklisted") )
Functions ¶
func CalPrice ¶
func CalPrice( paths []coreSchema.Path, tokens map[string]*everSchema.Token, tokenInTag, tokenOutTag, userAddr string, ) (price, tokenInAmount, tokenOutAmount *big.Float)
func ClosedMiddleware ¶
func ClosedMiddleware() gin.HandlerFunc
func ConvertPathsToBundle ¶
func ConvertPathsToBundle(paths []coreSchema.Path, tokens map[string]*everSchema.Token, expireAt int64, salt string) (bundle everSchema.Bundle, err error)
func GetLpClientInfoConf ¶
func GetLpClientInfoConf(chainID int64) (lpClients map[string]*schema.LpClientInfo)
func GetTokenPriceByRedstone ¶
func VerifyBundleAndPaths ¶
func VerifyBundleAndPaths(bundle everSchema.Bundle, paths []coreSchema.Path, tokens map[string]*everSchema.Token) (err error)
func VerifyBundleByAddr ¶
func VerifyBundleByAddr(bundle everSchema.BundleWithSigs, address string, chainID int64) (accid string, accsig map[string]string, err error)
Types ¶
type Config ¶
type Config struct { Name string Logo string Desc string Domain string Ip string AccountType string `toml:"account_type"` KeyFile string `toml:"key_file"` Port string Mysql string ChainId int64 `toml:"chain_id"` EverpayApi string `toml:"everpay_api"` NftWhitelist bool `toml:"nft_whitelist"` NftApi string `toml:"nft_api"` FeeRatio string `toml:"fee_ratio"` FeeRecipient string `toml:"fee_recipient"` Pools []Pool }
type NFT ¶
type NFTInfo ¶
type NFTInfo struct { ApiURL string NFTs map[string]*NFT NFTToOwner map[string]string OwnerToNFTs map[string][]string Whitelist []string NFTOwnerChangeChan chan *NFTOwnerChangeMsg //notify the change of nft owner // contains filtered or unexported fields }
func NewNFTInfo ¶
func NewNFTInfo(apiURL string, whitelist []string, c chan *NFTOwnerChangeMsg) *NFTInfo
func (*NFTInfo) GetNFTInfo ¶
func (*NFTInfo) SetWhitelist ¶
type NFTOwnerChangeMsg ¶
type Order ¶
type Order struct { ChainID int64 UserMsg *schema.UserMsgSubmit Status string InternalErr *everSchema.InternalErr EverHash string Timestamp int64 Bundle *everSchema.BundleWithSigs Lps map[string]*coreSchema.Lp // lpID -> lp // contains filtered or unexported fields }
Order doing in order goroutines 1. make LP signature 2. submit order to everPay 3. update order status & notice update core
func NewOrder ¶
func NewOrder(ChainID int64, userMsg *schema.UserMsgSubmit, bundle everSchema.BundleWithSigs, lps map[string]*coreSchema.Lp, router *Router, lpSessions map[string]string, dryRun bool, ) *Order
NewOrder lpSessions: lp addr -> lp session id
type Penalty ¶
type Penalty struct {
// contains filtered or unexported fields
}
func NewPenalty ¶
func NewPenalty() *Penalty
func (*Penalty) AddFailRecord ¶
func (*Penalty) ClearUpExpired ¶
func (p *Penalty) ClearUpExpired()
func (*Penalty) GetBlackList ¶
func (*Penalty) GetFailureRecords ¶
func (p *Penalty) GetFailureRecords() map[string][]schema.FailureRecord
func (*Penalty) GetPenalty ¶
func (*Penalty) IsBlackListed ¶
type Router ¶
type Router struct { NFTWhiteList bool NFTInfo *NFTInfo NFTOwnerChange chan *NFTOwnerChangeMsg Stats *Stats LpClientInfo map[string]*schema.LpClientInfo // contains filtered or unexported fields }
func (*Router) CheckNFTOrNot ¶
type Stats ¶
type Stats struct { Price *Price AccIDToVolume24hs map[string][]*schema.Volume AccIDToRewards map[string][]*schema.PermaLpReward AccIDToTVLs map[string][]*schema.TVL PoolIDToVolume24h map[string]*schema.Volume PoolIDToTVL map[string]*schema.TVL // contains filtered or unexported fields }
func NewStats ¶
func NewStats(tokens map[string]*everSchema.Token, pools map[string]*coreSchema.Pool, w *WDB) *Stats
func (*Stats) GetRewardsByAccid ¶
func (s *Stats) GetRewardsByAccid(accid string) (rewards []schema.PermaLpReward)
func (*Stats) GetVolumeByPoolID ¶
func (*Stats) GetVolumesByAccid ¶
type WDB ¶
type WDB struct {
// contains filtered or unexported fields
}
func (*WDB) CreatePermaOrder ¶
func (*WDB) CreatePermaVolume ¶
func (*WDB) GetOrdersByUser ¶
func (*WDB) GetPermaReward ¶
func (*WDB) GetPermaRewards ¶
func (*WDB) GetVolumesByTime ¶
func (*WDB) LoadNFTWhiteList ¶
func (w *WDB) LoadNFTWhiteList() (list []*schema.NFTWhiteList, err error)
func (*WDB) LoadPermaLpsSnapshot ¶
func (w *WDB) LoadPermaLpsSnapshot() (lpsSnapshot *schema.PermaLpsSnapshot, err error)
func (*WDB) SavePermaLpsSnapshot ¶
func (*WDB) SumPoolVolumesByTime ¶
func (*WDB) SumVolumesByTime ¶
func (*WDB) TotalOrdersNumByUser ¶
func (*WDB) UpdatePermaLpReward ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.