Documentation
¶
Index ¶
- func Query(db *datastore.Datastore) datastore.Query
- type CryptoBalance
- func (cb *CryptoBalance) Available() (*big.Int, error)
- func (cb *CryptoBalance) Credit(amount string) error
- func (cb *CryptoBalance) Debit(amount string) error
- func (cb *CryptoBalance) IsZero() bool
- func (cb *CryptoBalance) Release(amount string) error
- func (cb *CryptoBalance) Reserve(amount string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CryptoBalance ¶
type CryptoBalance struct {
mixin.Model[CryptoBalance]
// Customer who owns the balance
CustomerId string `json:"customerId"`
// Blockchain
Chain string `json:"chain"` // ethereum, solana, base, etc.
// Token identifier
Token string `json:"token"` // usdc, usdt, eth, sol, etc.
// Balance in smallest unit (wei, lamports, etc.) as string for precision
Balance string `json:"balance" orm:"default:0"`
// Custody address for this customer+chain+token
Address string `json:"address"`
// Reserved amount (pending withdrawal or payment)
Reserved string `json:"reserved,omitempty" orm:"default:0"`
Metadata Map `json:"metadata,omitempty" orm:"default:{}"`
}
CryptoBalance tracks custodial crypto holdings for a customer.
func New ¶
func New(db *datastore.Datastore) *CryptoBalance
func (*CryptoBalance) Available ¶
func (cb *CryptoBalance) Available() (*big.Int, error)
Available returns the available balance (total - reserved).
func (*CryptoBalance) Credit ¶
func (cb *CryptoBalance) Credit(amount string) error
Credit adds to the balance.
func (*CryptoBalance) Debit ¶
func (cb *CryptoBalance) Debit(amount string) error
Debit subtracts from the balance.
func (*CryptoBalance) IsZero ¶
func (cb *CryptoBalance) IsZero() bool
IsZero returns true if the balance is zero or empty.
func (*CryptoBalance) Release ¶
func (cb *CryptoBalance) Release(amount string) error
Release removes a hold on funds.
func (*CryptoBalance) Reserve ¶
func (cb *CryptoBalance) Reserve(amount string) error
Reserve places a hold on funds.
Click to show internal directories.
Click to hide internal directories.