Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Polymarket by adding new exchange trade type #54

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions schema/metadata/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/rss3-network/protocol-go/schema"
"github.com/rss3-network/protocol-go/schema/typex"
"github.com/shopspring/decimal"
)

var _ Metadata = (*ExchangeSwap)(nil)
Expand Down Expand Up @@ -105,3 +106,34 @@ const (
ActionExchangeLoanLiquidate
ActionExchangeLoanSeize
)

var _ Metadata = (*ExchangeTrade)(nil)

type ExchangeTrade struct {
Action ExchangeTradeAction `json:"action"`
OrderHash string `json:"order_hash"`
Maker string `json:"maker"`
Taker string `json:"taker"`
MakerAssetID uint64 `json:"maker_asset_id"`
TakerAssetID uint64 `json:"taker_asset_id"`
MakerAmountFilled *decimal.Decimal `json:"maker_amount_filled"`
TakerAmountFilled *decimal.Decimal `json:"taker_amount_filled"`
Fee *decimal.Decimal `json:"fee,omitempty"`
}

func (e ExchangeTrade) Type() schema.Type {
return typex.ExchangeTrade
}

//go:generate go run --mod=mod github.com/dmarkham/enumer --values --type=ExchangeTradeAction --transform=snake --trimprefix=ActionExchangeTrade --output exchange_trade.go --json --sql
type ExchangeTradeAction uint64

//goland:noinspection GoMixedReceiverTypes
func (t ExchangeTradeAction) Type() schema.Type {
return typex.ExchangeTrade
}

const (
ActionExchangeTradeFinalized ExchangeTradeAction = iota + 1
ActionExchangeTradeMatched
)
132 changes: 132 additions & 0 deletions schema/metadata/exchange_trade.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 136 additions & 0 deletions schema/metadata/governance_vote.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions schema/typex/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ const (
ExchangeStaking
ExchangeSwap
ExchangeLoan
ExchangeTrade
)
12 changes: 8 additions & 4 deletions schema/typex/exchange_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading