add interest field to Asset

This commit is contained in:
c9s 2022-05-04 21:38:18 +08:00
parent e903bd5f69
commit 8ec47a4aaa
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 7 additions and 4 deletions

View File

@ -12,10 +12,13 @@ import (
type Asset struct { type Asset struct {
Currency string `json:"currency" db:"currency"` Currency string `json:"currency" db:"currency"`
Total fixedpoint.Value `json:"total" db:"total"` Total fixedpoint.Value `json:"total" db:"total"`
NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"` NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"`
Interest fixedpoint.Value `json:"interest" db:"interest"`
// InUSD is net asset in USD // InUSD is net asset in USD
InUSD fixedpoint.Value `json:"inUSD" db:"net_asset_in_usd"` InUSD fixedpoint.Value `json:"inUSD" db:"net_asset_in_usd"`

View File

@ -108,12 +108,11 @@ func (m BalanceMap) Assets(prices map[string]fixedpoint.Value, priceTime time.Ti
_, btcInUSD, hasBtcPrice := findUSDMarketPrice("BTC", prices) _, btcInUSD, hasBtcPrice := findUSDMarketPrice("BTC", prices)
for currency, b := range m { for currency, b := range m {
if b.Locked.IsZero() && b.Available.IsZero() && b.Borrowed.IsZero() {
continue
}
total := b.Total() total := b.Total()
netAsset := b.Net() netAsset := b.Net()
if total.IsZero() && netAsset.IsZero() {
continue
}
asset := Asset{ asset := Asset{
Currency: currency, Currency: currency,
@ -122,6 +121,7 @@ func (m BalanceMap) Assets(prices map[string]fixedpoint.Value, priceTime time.Ti
Locked: b.Locked, Locked: b.Locked,
Available: b.Available, Available: b.Available,
Borrowed: b.Borrowed, Borrowed: b.Borrowed,
Interest: b.Interest,
NetAsset: netAsset, NetAsset: netAsset,
} }