Skip to content

Binance: import Simple Earn history, dust conversions and dividends #760

Description

@NikolayMetchev

Problem

The built-in Binance strategy (app/strategies/.../BuiltInApiStrategies.kt, binance()) covers
deposits, withdrawals, fiat orders, fiat payments, convert and spot myTrades. Several endpoints that
move real balances are not covered at all. Verified against the live account behind the default
database (read-only probes):

endpoint what it holds evidence
sapi/v1/simple-earn/flexible/history/subscriptionRecord SPOT → Earn subscriptions 73 rows in Nov 2020, 154 rows in Mar 2021 (e.g. GBP 6000, XMR 5.81, BUSD, BNB)
sapi/v1/simple-earn/flexible/history/redemptionRecord Earn → SPOT redemptions 29 rows in Mar 2021 (BUSD 1373.16, BNB 0.1, …)
sapi/v1/simple-earn/flexible/history/rewardsRecord interest / bonus real income, currently invisible
sapi/v1/asset/dribblet small-balance ("dust") → BNB conversions 3 conversions in Mar 2021, 3 in Jun 2022 (e.g. XRP 0.17015309 → BNB)
sapi/v1/asset/assetDividend airdrops / distributions / referral payouts empty on this account, but generally a balance source

Subscription/redemption pairs net out over a lifetime, so they matter less for the closing balance
than for the running balance and the timeline; rewards and dust conversions are genuine, unmatched
balance changes.

Notes / constraints found while probing

  • sapi/v1/asset/transfer and sapi/v1/accountSnapshot reject windows longer than 30 days
    (-5026 Start time query records range is too large), so they need windowDays = 30, not the 90 used
    by the crypto deposit/withdraw window.
  • sapi/v1/lending/union/purchaseRecord (legacy Savings) is dead — 405 This endpoint has been deprecated. Simple Earn replaces it; don't wire the old paths.
  • Simple Earn history reaches back to at least Nov 2020 on this account, i.e. far further back than
    spot trade history does (see the companion issue about the unrecoverable pre-2022 trade history).
  • Earn subscriptions/redemptions are wallet-to-wallet moves within one exchange. Deciding whether they
    become transfers to a separate "Binance Earn" account or are collapsed is a modelling call worth
    making before implementing — a separate account keeps the spot balance honest against
    getUserAsset (see Reconcile exchange-reported balances against computed balances after an API import #759).

Should be config-only work in the strategy definition, apart from the 30-day window and whatever
modelling choice is made for the Earn wallet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions