From 8ec47a4aaa7ac16a246ae33f2877450cf3d42cfc Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 4 May 2022 21:38:18 +0800 Subject: [PATCH] add interest field to Asset --- pkg/types/asset.go | 3 +++ pkg/types/balance.go | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/types/asset.go b/pkg/types/asset.go index 043fa89c6..4bd13183b 100644 --- a/pkg/types/asset.go +++ b/pkg/types/asset.go @@ -12,10 +12,13 @@ import ( type Asset struct { Currency string `json:"currency" db:"currency"` + Total fixedpoint.Value `json:"total" db:"total"` NetAsset fixedpoint.Value `json:"netAsset" db:"net_asset"` + Interest fixedpoint.Value `json:"interest" db:"interest"` + // InUSD is net asset in USD InUSD fixedpoint.Value `json:"inUSD" db:"net_asset_in_usd"` diff --git a/pkg/types/balance.go b/pkg/types/balance.go index eb63e971d..5399936fe 100644 --- a/pkg/types/balance.go +++ b/pkg/types/balance.go @@ -108,12 +108,11 @@ func (m BalanceMap) Assets(prices map[string]fixedpoint.Value, priceTime time.Ti _, btcInUSD, hasBtcPrice := findUSDMarketPrice("BTC", prices) for currency, b := range m { - if b.Locked.IsZero() && b.Available.IsZero() && b.Borrowed.IsZero() { - continue - } - total := b.Total() netAsset := b.Net() + if total.IsZero() && netAsset.IsZero() { + continue + } asset := Asset{ Currency: currency, @@ -122,6 +121,7 @@ func (m BalanceMap) Assets(prices map[string]fixedpoint.Value, priceTime time.Ti Locked: b.Locked, Available: b.Available, Borrowed: b.Borrowed, + Interest: b.Interest, NetAsset: netAsset, }