models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package models contains teh database models TODO: move back to db

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllModels

func GetAllModels() (allModels []interface{})

GetAllModels gets all models to migrate.

Types

type Quote

type Quote struct {
	ID            uint            `gorm:"primaryKey" json:"id" uri:"id"`
	Relayer       string          `json:"relayer" binding:"required"`
	OriginChainID uint            `json:"origin_chain_id" binding:"required"`
	DestChainID   uint            `json:"dest_chain_id" binding:"required"`
	OriginToken   string          `json:"origin_token" binding:"required"`
	DestToken     string          `json:"dest_token" binding:"required"`
	OriginAmount  decimal.Decimal `json:"origin_amount" binding:"required" gorm:"type:numeric"`
	DestAmount    decimal.Decimal `json:"dest_amount" binding:"required" gorm:"type:numeric"`
	Price         decimal.Decimal `json:"price" gorm:"type:numeric"` // price = destAmount <quote> / originAmount <base>
	CreatedAt     time.Time       `json:"created_at"`
	UpdatedAt     time.Time       `json:"updated_at"`
	DeletedAt     gorm.DeletedAt  `gorm:"index" json:"deleted_at"`
}

Quote represents bindings/FastBridge.go::IFastBridgeBridgeTransaction.

func (*Quote) BeforeCreate

func (q *Quote) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate hook to set price on insert.

func (*Quote) BeforeSave

func (q *Quote) BeforeSave(tx *gorm.DB) (err error)

BeforeSave hook to set price on update.

func (*Quote) GetPrice

func (q *Quote) GetPrice() (price decimal.Decimal)

GetPrice is a util to get the quote price inferred from dest, origin amounts.

func (*Quote) Validate

func (q *Quote) Validate() (err error)

Validate validates the quote attributes.

type Request

type Request struct {
	OriginChainID uint            `form:"origin_chain_id"`
	DestChainID   uint            `form:"dest_chain_id"`
	OriginToken   string          `form:"origin_token"`
	DestToken     string          `form:"dest_token"`
	OriginAmount  decimal.Decimal `form:"origin_amount" gorm:"type:numeric"`
	UpdatedAtLast time.Time       `form:"updated_at_last"` // for liveness checks on q.UpdatedAt
}

Request is the request to get a quote.

Jump to

Keyboard shortcuts

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