schema

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PoolInc  = "incentive"
	PoolEco  = "ecosystem"
	PoolInv  = "investor"
	PoolTeam = "team"
)
View Source
const (
	TxActionTransfer = "transfer"

	TxActionStake   = "stake"
	TxActionUnstake = "unstake"

	// router join or leave
	TxActionJoin  = "join"
	TxActionLeave = "leave"

	// proposal
	TxActionPropose = "propose"
	TxActionCall    = "call"

	TxActionSwap = "swap"
)
View Source
const (
	TxVersionV1 = "v1"
)

Variables

View Source
var (
	ErrInvalidFromRouter    = errors.New("err_invalid_from_router")
	ErrInvalidNonce         = errors.New("err_invalid_nonce")
	ErrInvalidAmount        = errors.New("err_invalid_amount")
	ErrInvalidFee           = errors.New("err_invalid_fee")
	ErrInvalidFeeRecipient  = errors.New("err_invalid_fee_recipient")
	ErrInvalidTx            = errors.New("err_invalid_tx")
	ErrInvalidTxField       = errors.New("err_invalid_tx_field")
	ErrInvalidTxAction      = errors.New("err_invalid_tx_action")
	ErrInvalidTxParams      = errors.New("err_invalid_tx_params")
	ErrInvalidProposer      = errors.New("err_invalid_proposer")
	ErrInvalidProposal      = errors.New("err_invalid_proposal")
	ErrTxExecuted           = errors.New("err_tx_executed")
	ErrInvalidStakePool     = errors.New("err_invalid_stake_pool")
	ErrInvalidRouterAddress = errors.New("err_invalid_router_address")
	ErrInvalidRouterName    = errors.New("err_invalid_router_name")
	ErrInsufficientStake    = errors.New("err_insufficient_stake")
	ErrRouterAlreadyJoined  = errors.New("err_router_already_joined")
	ErrNotARouter           = errors.New("err_not_a_router")
	ErrNoProposalFound      = errors.New("err_no_proposal_found")
	ErrInvalidAccountType   = errors.New("err_invalid_account_type")
)
View Source
var (
	Fee01   = "0.01"
	Fee003  = "0.003"
	Fee001  = "0.001"
	Fee0005 = "0.0005"
)

Functions

func CopyRouterState

func CopyRouterState(dst, src *RouterState)

func CopyToken

func CopyToken(dst, src *token.Token)

Types

type Executor

type Executor struct {
	LocalState     string `json:"localState"`
	LocalStateHash string `json:"localStateHash"`
	RunnedTimes    int64  `json:"runnedTimes"`
	// in: tx, state, oracle, localState, initData out: state, localState, localStateHash error
	Execute func(*Transaction, *StateForProposal, *Oracle, string, string) (*StateForProposal, string, string, error) `json:"-"`
}

type Oracle

type Oracle struct {
	EverTokens map[string]everSchema.TokenInfo
}

type Pool

type Pool struct {
	TokenXTag string `json:"tokenXTag"`
	TokenYTag string `json:"tokenYTag"`
	FeeRatio  string `json:"feeRatio"`
}

pool on permaswap

func (*Pool) ID

func (pool *Pool) ID() string

func (*Pool) String

func (pool *Pool) String() string

type Proposal

type Proposal struct {
	Name                  string   `json:"name"`
	ID                    string   `json:"id"`
	Start                 int64    `json:"start"`
	End                   int64    `json:"end"`
	RunTimes              int64    `json:"runTimes"`
	Source                string   `json:"source"`
	InitData              string   `json:"initData"`
	OnlyAcceptedTxActions []string `json:"onlyAcceptedTxActions"`

	Executor *Executor `json:"executor"`
}

func (*Proposal) Hash

func (p *Proposal) Hash() []byte

func (*Proposal) HexHash

func (p *Proposal) HexHash() string

func (*Proposal) String

func (p *Proposal) String() string

type RouterState

type RouterState struct {
	Router           string           `json:"router"` // router address
	Name             string           `json:"name"`
	Desc             string           `json:"desc"` // description
	Domain           string           `json:"domain"`
	Ip               string           `json:"ip"`
	SwapFeeRatio     string           `json:"swapFeeRatio"`
	SwapFeeRecipient string           `json:"swapFeeRecipient"`
	Pools            map[string]*Pool `json:"pools"`      // pool id -> pool
	LpMinStake       string           `json:"lpMinStake"` // minum amount lp stake
	LpPenalty        string           `json:"lpPenalty"`  // penalty for lp evil
}

type State

type State struct {
	Dapp         string `json:"dapp"`
	ChainID      string `json:"chainID"`
	Govern       string `json:"govern"` // govern is an temporary solution and will use voting in the future
	FeeRecipient string `json:"feeRecipient"`

	RouterMinStake string                  `json:"routerMinStake"` // minum amount router stake
	Routers        []string                `json:"routers"`        // [] router address
	RouterStates   map[string]*RouterState `json:"routerState"`    // router address -> router state

	Token    *token.Token                `json:"-"`       // halo token
	Accounts map[string]*account.Account `json:"account"` // account ID -> account

	Proposals []*Proposal `json:"proposals"` // proposal hash -> proposal

	StakePools []string `json:"stakePools"` // stake pool
	//stakes pool only accept unstake
	OnlyUnStakePools []string `json:"onlyUnStakePools"`

	Executed []string        `json:"executed"` // executed tx everhash hash
	Validity map[string]bool `json:"validity"` // executed tx everhash hash -> bool

	LatestTxHash     string `json:"latestTxHash"`
	LatestTxEverHash string `json:"latestTxEverHash"`

	StateHash string `json:"stateHash"`
}

func (*State) GetStateForProposal

func (s *State) GetStateForProposal() *StateForProposal

func (*State) Hash

func (s *State) Hash() string

func (*State) UpdateState

func (s *State) UpdateState(ns *StateForProposal)

type StateForProposal

type StateForProposal struct {
	Dapp         string `json:"dapp"`
	ChainID      string `json:"chainID"`
	Govern       string `json:"govern"` // govern is an temporary solution and will use voting in the future
	FeeRecipient string `json:"feeRecipient"`

	RouterMinStake string                  `json:"minRouterStake"` // minum amount router stake
	Routers        []string                `json:"routers"`
	RouterStates   map[string]*RouterState `json:"routerState"` // router id -> router state

	StakePools       []string `json:"stakePools"` // stake pool
	OnlyUnStakePools []string `json:"onlyUnStakePools"`

	Token *token.Token `json:"token"` // halo token
}

type Transaction

type Transaction struct {
	Dapp         string `json:"dapp"`
	ChainID      string `json:"chainID"`
	EverHash     string `json:"everHash"` // tx hash from everpay
	Router       string `json:"router"`   // tx from which router
	Action       string `json:"action"`
	From         string `json:"from"`
	Fee          string `json:"fee"`
	FeeRecipient string `json:"feeRecipient"`
	Nonce        string `json:"nonce"`
	Version      string `json:"version"`
	Params       string `json:"params"`
	Sig          string `json:"sig"`
}

func (*Transaction) ArHash

func (t *Transaction) ArHash() []byte

func (*Transaction) Hash

func (t *Transaction) Hash() []byte

func (*Transaction) HexHash

func (t *Transaction) HexHash() string

func (*Transaction) String

func (t *Transaction) String() string

type TxApply

type TxApply struct {
	Tx     Transaction `json:"tx"`
	DryRun bool        `json:"dryRun"`
}

type TxCallParams

type TxCallParams struct {
	ProposalID string `json:"proposalID"` // proposal id is hexhash
	Function   string `json:"function"`
	Params     string `json:"params"`
}

type TxProposeParams

type TxProposeParams struct {
	Name                  string   `json:"name"`
	Start                 int64    `json:"start"`
	End                   int64    `json:"end"`
	RunTimes              int64    `json:"runTimes"`
	Source                string   `json:"source"`
	InitData              string   `json:"initData"`
	OnlyAcceptedTxActions []string `json:"onlyAcceptedTxActions"`
}

type TxStakeParams

type TxStakeParams struct {
	StakePool string `json:"StakePool"`
	Amount    string `json:"Amount"`
}

type TxSwapParams

type TxSwapParams struct {
}

type TxTransferParams

type TxTransferParams struct {
	To     string `json:"To"`
	Amount string `json:"Amount"`
}

type TxUnstakeParams

type TxUnstakeParams struct {
	StakePool string `json:"StakePool"`
	Amount    string `json:"Amount"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL