asset

package
v2.0.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBColumns = []string{
	"id",
	"uuid",
	"name",
	"alternate_name",
	"cusip",
	"ticker",
	"base_asset_id",
	"quote_asset_id",
	"description",
	"asset_type_id",
	"created_by",
	"created_at",
	"updated_by",
	"updated_at",
	"chain_id",
	"category_id",
	"sub_category_id",
	"is_default_quote",
	"ignore_market_data",
	"decimals",
	"contract_address",
	"starting_block_number",
	"import_geth",
	"import_geth_initial",
	"chainlink_usd_address",
	"chainlink_usd_chain_id",
	"total_supply",
}
View Source
var DBColumnsAssetWithSources = []string{
	"id",
	"uuid",
	"name",
	"alternate_name",
	"cusip",
	"ticker",
	"base_asset_id",
	"quote_asset_id",
	"description",
	"asset_type_id",
	"created_by",
	"created_at",
	"updated_by",
	"updated_at",
	"chain_id",
	"category_id",
	"sub_category_id",
	"is_default_quote",
	"ignore_market_data",
	"decimals",
	"contract_address",
	"starting_block_number",
	"import_geth",
	"import_geth_initial",
	"chainlink_usd_address",
	"chainlink_usd_chain_id",
	"total_supply",
	"assetSources.source_id",
	"assetSources.source_identifier",
}
View Source
var DBColumnsInsertAssets = []string{
	"uuid",
	"name",
	"alternate_name",
	"cusip",
	"ticker",
	"base_asset_id",
	"quote_asset_id",
	"description",
	"asset_type_id",
	"created_by",
	"created_at",
	"updated_by",
	"updated_at",
	"chain_id",
	"category_id",
	"sub_category_id",
	"is_default_quote",
	"ignore_market_data",
	"decimals",
	"contract_address",
	"starting_block_number",
	"import_geth",
	"import_geth_initial",
	"chainlink_usd_address",
	"chainlink_usd_chain_id",
	"total_supply",
}
View Source
var TestAllData = []Asset{TestData1, TestData2}
View Source
var TestAllDataAssetWithSources = []AssetWithSources{dataAssetWithSources1, dataAssetWithSources2}
View Source
var TestData1 = Asset{
	ID:                  utils.Ptr[int](1),
	UUID:                "880607ab-2833-4ad7-a231-b983a61c7b39",
	Name:                "ETHER",
	AlternateName:       "Ether",
	Cusip:               "",
	Ticker:              "ETH",
	BaseAssetID:         utils.Ptr[int](1),
	QuoteAssetID:        utils.Ptr[int](2),
	Description:         "",
	AssetTypeID:         utils.Ptr[int](1),
	CreatedBy:           "SYSTEM",
	CreatedAt:           utils.SampleCreatedAtTime,
	UpdatedBy:           "SYSTEM",
	UpdatedAt:           utils.SampleCreatedAtTime,
	ChainID:             utils.Ptr[int](2),
	CategoryID:          utils.Ptr[int](27),
	SubCategoryID:       utils.Ptr[int](10),
	IsDefaultQuote:      utils.Ptr[bool](true),
	IgnoreMarketData:    utils.Ptr[bool](false),
	Decimals:            utils.Ptr[int](1),
	ContractAddress:     "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
	StartingBlockNumber: utils.Ptr[uint64](1),
	ImportGeth:          nil,
	ImportGethInitial:   nil,
	ChainlinkUSDAddress: utils.Ptr[string]("0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"),
	ChainlinkUSDChainID: utils.Ptr[int](1),
	TotalSupply:         &decimalSampleValue,
}
View Source
var TestData2 = Asset{
	ID:                  utils.Ptr[int](2),
	UUID:                "880607ab-2833-4ad7-a231-b983a61c7b334",
	Name:                "BTC",
	AlternateName:       "Bitcoin",
	Cusip:               "",
	Ticker:              "BTC",
	BaseAssetID:         utils.Ptr[int](2),
	QuoteAssetID:        utils.Ptr[int](1),
	Description:         "",
	AssetTypeID:         utils.Ptr[int](1),
	CreatedBy:           "SYSTEM",
	CreatedAt:           utils.SampleCreatedAtTime,
	UpdatedBy:           "SYSTEM",
	UpdatedAt:           utils.SampleCreatedAtTime,
	ChainID:             utils.Ptr[int](1),
	CategoryID:          utils.Ptr[int](28),
	SubCategoryID:       utils.Ptr[int](20),
	IsDefaultQuote:      utils.Ptr[bool](true),
	IgnoreMarketData:    utils.Ptr[bool](false),
	Decimals:            utils.Ptr[int](1),
	ContractAddress:     "0x",
	StartingBlockNumber: utils.Ptr[uint64](1),
	ImportGeth:          nil,
	ImportGethInitial:   nil,
	ChainlinkUSDAddress: utils.Ptr[string]("0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"),
	ChainlinkUSDChainID: utils.Ptr[int](1),
	TotalSupply:         &decimalSampleValue,
}

Functions

func AddAssetToMockRows

func AddAssetToMockRows(mock pgxmock.PgxPoolIface, dataList []Asset) *pgxmock.Rows

func AddAssetWithSourcesToMockRows

func AddAssetWithSourcesToMockRows(mock pgxmock.PgxPoolIface, dataList []AssetWithSources) *pgxmock.Rows

func CreateLookupByContractAddressFromAssetList

func CreateLookupByContractAddressFromAssetList(assetList []Asset) map[string]*Asset

lowercase for the contract address

func GetTotalAssetCount

func GetTotalAssetCount(dbConnPgx utils.PgxIface) (*int, error)

func InsertAsset

func InsertAsset(dbConnPgx utils.PgxIface, asset *Asset) (int, error)

func InsertAssets

func InsertAssets(dbConnPgx utils.PgxIface, assets []Asset) error

func RemoveAsset

func RemoveAsset(dbConnPgx utils.PgxIface, assetID *int) error

func UpdateAsset

func UpdateAsset(dbConnPgx utils.PgxIface, asset *Asset) error

Types

type Asset

type Asset struct {
	ID                  *int             `json:"id" db:"id"`                                      //1
	UUID                string           `json:"uuid" db:"uuid"`                                  //2
	Name                string           `json:"name" db:"name"`                                  //3
	AlternateName       string           `json:"alternateName" db:"alternate_name"`               //4
	Cusip               string           `json:"cusip" db:"cusip"`                                //5
	Ticker              string           `json:"ticker" db:"ticker"`                              //6
	BaseAssetID         *int             `json:"baseAssetId" db:"base_asset_id"`                  //7
	QuoteAssetID        *int             `json:"quoteAssetId" db:"quote_asset_id"`                //8
	Description         string           `json:"description" db:"description"`                    //9
	AssetTypeID         *int             `json:"assetTypeId" db:"asset_type_id"`                  //10
	CreatedBy           string           `json:"createdBy" db:"created_by"`                       //11
	CreatedAt           time.Time        `json:"createdAt" db:"created_at"`                       //12
	UpdatedBy           string           `json:"updatedBy" db:"updated_by"`                       //13
	UpdatedAt           time.Time        `json:"updatedAt" db:"updated_at"`                       //14
	ChainID             *int             `json:"chainId" db:"chain_id"`                           //15
	CategoryID          *int             `json:"categoryId" db:"category_id"`                     //16
	SubCategoryID       *int             `json:"subCategoryId" db:"sub_category_id"`              //17
	IsDefaultQuote      *bool            `json:"isDefaultQuote" db:"is_default_quote"`            //18
	IgnoreMarketData    *bool            `json:"ignoreMarketData" db:"ignore_market_data"`        //19
	Decimals            *int             `json:"decimals" db:"decimals"`                          //20
	ContractAddress     string           `json:"contractAddress" db:"contract_address"`           //21
	StartingBlockNumber *uint64          `json:"startingBlockNumber" db:"starting_block_number"`  //22
	ImportGeth          *bool            `json:"importGeth" db:"import_geth"`                     //23
	ImportGethInitial   *bool            `json:"importGethInitial" db:"import_geth_initial"`      //24
	ChainlinkUSDAddress *string          `json:"chainlinkUSDAddress" db:"chainlink_usd_address"`  //25
	ChainlinkUSDChainID *int             `json:"chainlinkUSDChainId" db:"chainlink_usd_chain_id"` //26
	TotalSupply         *decimal.Decimal `json:"totalSupply" db:"total_supply"`                   //27
}

Asset

func GetAsset

func GetAsset(dbConnPgx utils.PgxIface, assetID *int) (*Asset, error)

func GetAssetByBaseAndQuoteID

func GetAssetByBaseAndQuoteID(dbConnPgx utils.PgxIface, baseAssetID *int, quoteAssetID *int) (*Asset, error)

GetAssetByBaseAndQuoteID : get asset by base and quote id

func GetAssetByContractAddress

func GetAssetByContractAddress(dbConnPgx utils.PgxIface, contractAddress string) (*Asset, error)

GetAssetByContractAddress : get asset by contract address

func GetAssetByCusip

func GetAssetByCusip(dbConnPgx utils.PgxIface, cusip string) (*Asset, error)

GetAssetByCusip : get asset by cusip

func GetAssetByTicker

func GetAssetByTicker(dbConnPgx utils.PgxIface, ticker string) (*Asset, error)

GetAssetByTicker : get asset by ticker

func GetAssetList

func GetAssetList(dbConnPgx utils.PgxIface, ids []int) ([]Asset, error)

func GetAssetListByPagination

func GetAssetListByPagination(dbConnPgx utils.PgxIface, _start, _end *int, _order, _sort string, _filters []string) ([]Asset, error)

for refinedev

func GetAssetsByChainId

func GetAssetsByChainId(dbConnPgx utils.PgxIface, chainID *int) ([]Asset, error)

func GetCryptoAssets

func GetCryptoAssets(dbConnPgx utils.PgxIface) ([]Asset, error)

func GetCryptoAssetsBySourceID

func GetCryptoAssetsBySourceID(dbConnPgx utils.PgxIface, sourceID *int, excludeIgnoreMarketData bool) ([]Asset, error)

func GetCurrentTradingAssets

func GetCurrentTradingAssets(dbConnPgx utils.PgxIface) ([]Asset, error)

func GetDefaultQuoteAssetList

func GetDefaultQuoteAssetList(dbConnPgx utils.PgxIface) ([]Asset, error)

func GetGethImportAssets

func GetGethImportAssets(dbConnPgx utils.PgxIface) ([]Asset, error)

type AssetWithSources

type AssetWithSources struct {
	Asset
	SourceID         *int   `json:"sourceId" db:"assetSources.source_id"`
	SourceIdentifier string `json:"sourceIdentifier" db:"assetSources.source_identifier"`
}

Asset

func GetAssetWithSourceByAssetIdAndSourceID

func GetAssetWithSourceByAssetIdAndSourceID(dbConnPgx utils.PgxIface, assetID, sourceID *int, excludeIgnoreMarketData bool) (*AssetWithSources, error)

func GetAssetWithSourceByAssetIdsAndSourceID

func GetAssetWithSourceByAssetIdsAndSourceID(dbConnPgx utils.PgxIface, assetIDs []int, sourceID *int, excludeIgnoreMarketData bool) ([]AssetWithSources, error)

func GetAssetsByAssetTypeAndSource

func GetAssetsByAssetTypeAndSource(dbConnPgx utils.PgxIface, assetTypeID *int, sourceID *int, excludeIgnoreMarketData bool) ([]AssetWithSources, error)

func GetCryptoAssetsBySourceId

func GetCryptoAssetsBySourceId(dbConnPgx utils.PgxIface, sourceID *int, excludeIgnoreMarketData bool) ([]AssetWithSources, error)

func GetDefaultQuoteAssetListBySourceID

func GetDefaultQuoteAssetListBySourceID(dbConnPgx utils.PgxIface, sourceID *int) ([]AssetWithSources, error)

Jump to

Keyboard shortcuts

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