package models

import "time"

// YTSwapRecord records each Swap event emitted by YT Vault contracts.
// Swap(address account, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut, uint256 feeBasisPoints)
// account/tokenIn/tokenOut are indexed (topics), amountIn/amountOut are in data.
type YTSwapRecord struct {
	ID          uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	TxHash      string    `gorm:"size:66;uniqueIndex:uk_tx_log" json:"tx_hash"`
	LogIndex    uint      `gorm:"uniqueIndex:uk_tx_log" json:"log_index"`
	ChainID     int       `gorm:"index" json:"chain_id"`
	BlockNumber uint64    `json:"block_number"`
	BlockTime   time.Time `gorm:"index" json:"block_time"`
	VaultAddr   string    `gorm:"size:42;index" json:"vault_addr"`
	Account     string    `gorm:"size:42;index" json:"account"`
	TokenIn     string    `gorm:"size:42" json:"token_in"`
	TokenOut    string    `gorm:"size:42" json:"token_out"`
	AmountIn    string    `gorm:"size:78" json:"amount_in"`  // wei string, base units
	AmountOut   string    `gorm:"size:78" json:"amount_out"` // wei string, base units
	CreatedAt   time.Time `json:"created_at"`
}

func (YTSwapRecord) TableName() string { return "yt_swap_records" }
