Skip to content

Commit

Permalink
wallet: Fix behavior with wallets with small market balances
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Mar 27, 2024
1 parent eef00b1 commit 825c561
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions iface_ribs.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ type WalletInfo struct {
Balance string
MarketBalance string
MarketLocked string

MarketBalanceDetailed api.MarketBalance
}

type CrawlState struct {
Expand Down
15 changes: 7 additions & 8 deletions rbdeal/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
marketactor "github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/result"
iface "github.com/lotus-web3/ribs"
"golang.org/x/xerrors"

Expand Down Expand Up @@ -107,8 +106,7 @@ func (r *ribs) watchMarket(ctx context.Context) {
goto cooldown
}
{
avail := types.BigSub(abi.TokenAmount(result.Wrap(types.ParseFIL(i.MarketBalance)).Assert(_must)),
abi.TokenAmount(result.Wrap(types.ParseFIL(i.MarketLocked)).Assert(_must)))
avail := types.BigSub(i.MarketBalanceDetailed.Escrow, i.MarketBalanceDetailed.Locked)

if avail.GreaterThan(minMarketBalance) {
goto cooldown
Expand Down Expand Up @@ -187,11 +185,12 @@ func (r *ribs) WalletInfo() (iface.WalletInfo, error) {
}

wi := iface.WalletInfo{
Addr: addr.String(),
IDAddr: id.String(),
Balance: types.FIL(b).Short(),
MarketBalance: types.FIL(mb.Escrow).Short(),
MarketLocked: types.FIL(mb.Locked).Short(),
Addr: addr.String(),
IDAddr: id.String(),
Balance: types.FIL(b).Short(),
MarketBalance: types.FIL(mb.Escrow).Short(),
MarketLocked: types.FIL(mb.Locked).Short(),
MarketBalanceDetailed: mb,
}

if dc != nil {
Expand Down

0 comments on commit 825c561

Please sign in to comment.