github.com/condensat/bank-core@v0.1.0/database/model/swap.go (about) 1 // Copyright 2020 Condensat Tech. All rights reserved. 2 // Use of this source code is governed by a MIT 3 // license that can be found in the LICENSE file. 4 5 package model 6 7 import ( 8 "time" 9 ) 10 11 type SwapID ID 12 type SwapType String 13 14 const ( 15 SwapTypeBid SwapType = "bid" 16 SwapTypeAsk SwapType = "ask" 17 18 SwapTypeInternalBid SwapType = "internal_bid" 19 SwapTypeInternalAsk SwapType = "internal_ask" 20 ) 21 22 type Swap struct { 23 ID SwapID `gorm:"primary_key"` 24 Timestamp time.Time `gorm:"index;not null;type:timestamp"` // Creation timestamp 25 ValidUntil time.Time `gorm:"index;not null;type:timestamp"` // Valid Until 26 Type SwapType `gorm:"index;not null;size:16"` // SwapType [bid, ask] 27 CryptoAddressID CryptoAddressID `gorm:"index;not null"` // [FK] Reference to CryptoAddress table 28 DebitAsset AssetID `gorm:"index;not null"` // [FK] Reference to Asset table for Debit 29 DebitAmount Float `gorm:"default:0;not null"` // DebitAmount (strictly positive) 30 CreditAsset AssetID `gorm:"index;not null"` // [FK] Reference to Asset table for Credit 31 CreditAmount Float `gorm:"default:0;not null"` // CreditAmount (strictly positive) 32 }