Zondax/rosetta-filecoin-proxy

/Account/Balance returns incorrect spendable balance

Closed this issue · 2 comments

qiwu7 commented

For this mulsig actor, I have queried total balance, locked, and spendable but locked + spendable does not equal to total.

Total = 0.0999
Locked = 0.0819
Spendable = 0.00796

See details below.

curl --location --request POST 'http://10.200.129.214:8080/account/balance' \
--header 'Content-Type: application/json' \
--data-raw '{
    "network_identifier": {
        "blockchain": "Filecoin",
        "network": "ignition"
    },
     "account_identifier": {
        "address": "t020406",
        "metadata": {}
    }
}'

total balance = 0.099999999999992679

{
    "block_identifier": {
        "index": 112421,
        "hash": "0171a0e40220c8c2bb351445b2726f6eaf5908081f8e5df3217faa5adda5611e2c95ac3bd18e"
    },
    "balances": [
        {
            "value": "99999999999992679",
            "currency": {
                "symbol": "FIL",
                "decimals": 18
            }
        }
    ]
}

Locked balance = 0.081926440328920288

curl --location --request POST 'http://10.200.129.214:8080/account/balance' \
--header 'Content-Type: application/json' \
--data-raw '{
    "network_identifier": {
        "blockchain": "Filecoin",
        "network": "ignition"
    },
     "account_identifier": {
        "address": "t020406",
        "sub_account": {
            "address": "LockedBalance",
            "metadata": {}
        },
        "metadata": {}
    }
}'
{
    "block_identifier": {
        "index": 112432,
        "hash": "0171a0e40220e192d18be72f39babd51eb9759d235be89b6251907d5da260d4288631446f0cb"
    },
    "balances": [
        {
            "value": "81926440328920288",
            "currency": {
                "symbol": "FIL",
                "decimals": 18
            }
        }
    ]
}

Spendable balance = 0.007960873199915737

curl --location --request POST 'http://10.200.129.214:8080/account/balance' \
--header 'Content-Type: application/json' \
--data-raw '{
    "network_identifier": {
        "blockchain": "Filecoin",
        "network": "ignition"
    },
     "account_identifier": {
        "address": "t020406",
        "sub_account": {
            "address": "SpendableBalance",
            "metadata": {}
        },
        "metadata": {}
    }
}'
{
    "block_identifier": {
        "index": 112434,
        "hash": "0171a0e40220f2c374ee1c76250a7b3307678fe484c47f35ebdef80026d77b85eda625fe3c9c"
    },
    "balances": [
        {
            "value": "7960873199915737",
            "currency": {
                "symbol": "FIL",
                "decimals": 18
            }
        }
    ]
}

I'll look into it, it's weird because spendable just returns the output of

// MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)

Ok, I've found an error when calculating the locked part of the funds. The integration test for this endpoint now runs using the same msig actor and checks that total = locked + spendable

Numbers are not the same as filfox's, though