cryptobalance

package
v1.36.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

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 (*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.

Jump to

Keyboard shortcuts

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