Skip to content
SwapWalletDocs
فارسیGet an API key

Balance

The business balance holds payments your business has received, minus SwapWallet's fee, that haven't been settled to the owner's SwapWallet account yet.

By default a payment is settled the moment it arrives, so this balance is usually zero. If your business has a hold period (lockedHours on your business), each payment stays here until its hold period ends; SwapWallet settles everything whose hold period has ended once an hour.

The balance object

What your business balance holds, per token and in total.

Attributes

  • totalValueobject

    The whole balance valued in Toman and in US dollars.

    Show child attributesHide child attributes
    • availablearray of Money

      Sum of every token's available value: one entry in Toman (IRT), one in US dollars (USD).

      Show child attributesHide child attributes
      • numberdecimal string

        The amount as a decimal string, without trailing zeros.

      • unitstring

        Currency or token code, such as USDT, IRT (Toman) or USD.

    • onHoldarray of Money

      Always zero for a business balance.

      Show child attributesHide child attributes
      • numberdecimal string

        The amount as a decimal string, without trailing zeros.

      • unitstring

        Currency or token code, such as USDT, IRT (Toman) or USD.

  • tokensarray of objects

    One entry for every crypto token SwapWallet supports, zero balances included, highest Toman value first.

    Show child attributesHide child attributes
    • namestring

      Token code, such as USDT.

    • availableobject

      Funds not yet settled to the owner's account, including payments still in their hold period.

      Show child attributesHide child attributes
      • amountMoney

        Amount in the token.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

      • valuesarray of Money

        The amount valued in Toman (IRT) and in US dollars (USD), in that order.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

    • onHoldobject

      Always zero for a business balance.

      Show child attributesHide child attributes
      • amountMoney

        Amount in the token.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

      • valuesarray of Money

        The amount valued in Toman (IRT) and in US dollars (USD), in that order.

        Show child attributesHide child attributes
        • numberdecimal string

          The amount as a decimal string, without trailing zeros.

        • unitstring

          Currency or token code, such as USDT, IRT (Toman) or USD.

    • marketDataarray of objects

      The token's markets against the Toman and against USDT, which values are priced from. Empty for a token that isn't traded.

      Show child attributesHide child attributes
      • sourcestring

        The token being priced.

      • destinationstring

        Quote currency, IRT or USDT. For USDT against USDT every price is 1.

      • marketDataobject

        Prices in destination per one unit of source.

        Show child attributesHide child attributes
        • bestSelldecimal string

          Best sell price.

        • bestBuydecimal string

          Best buy price.

        • latestPricedecimal string

          Price of the last trade.

        • dayChangedecimal string

          Price change over the last 24 hours, in percent.

        • volume24hdecimal string

          Trading volume over the last 24 hours.

The balance object
{
  "totalValue": {
    "available": [
      {
        "number": "4951251",
        "unit": "IRT"
      },
      {
        "number": "18.1764",
        "unit": "USD"
      }
    ],
    "onHold": [
      {
        "number": "0",
        "unit": "IRT"
      },
      {
        "number": "0",
        "unit": "USD"
      }
    ]
  },
  "tokens": [
    {
      "name": "USDT",
      "available": {
        "amount": {
          "number": "18.1764",
          "unit": "USDT"
        },
        "values": [
          {
            "number": "4951251",
            "unit": "IRT"
          },
          {
            "number": "18.1764",
            "unit": "USD"
          }
        ]
      },
      "onHold": {
        "amount": {
          "number": "0",
          "unit": "USDT"
        },
        "values": [
          {
            "number": "0",
            "unit": "IRT"
          },
          {
            "number": "0",
            "unit": "USD"
          }
        ]
      },
      "marketData": [
        {
          "source": "USDT",
          "destination": "IRT",
          "marketData": {
            "bestSell": "272410",
            "bestBuy": "272390",
            "latestPrice": "272400",
            "dayChange": "-0.08",
            "volume24h": "418230.6"
          }
        },
        {
          "source": "USDT",
          "destination": "USDT",
          "marketData": {
            "bestSell": "1",
            "bestBuy": "1",
            "latestPrice": "1",
            "dayChange": "0.00",
            "volume24h": "0"
          }
        }
      ]
    },
    {
      "name": "TON",
      "available": {
        "amount": {
          "number": "0",
          "unit": "TON"
        },
        "values": [
          {
            "number": "0",
            "unit": "IRT"
          },
          {
            "number": "0",
            "unit": "USD"
          }
        ]
      },
      "onHold": {
        "amount": {
          "number": "0",
          "unit": "TON"
        },
        "values": [
          {
            "number": "0",
            "unit": "IRT"
          },
          {
            "number": "0",
            "unit": "USD"
          }
        ]
      },
      "marketData": [
        {
          "source": "TON",
          "destination": "IRT",
          "marketData": {
            "bestSell": "266320",
            "bestBuy": "265980",
            "latestPrice": "266144",
            "dayChange": "1.89",
            "volume24h": "5120.4"
          }
        },
        {
          "source": "TON",
          "destination": "USDT",
          "marketData": {
            "bestSell": "0.9781",
            "bestBuy": "0.9768",
            "latestPrice": "0.977",
            "dayChange": "1.98",
            "volume24h": "8930.12"
          }
        }
      ]
    }
  ]
}

Retrieve the balance

GET/v1/merchants/balance

Retrieves your business balance: what each token holds and what the whole balance is worth in Toman and in US dollars.

The response lists every supported token, most of them at zero, so read the tokens whose available.amount is above zero.

Parameters

No parameters.

Returns

Returns the Balance object. The example shows two of the tokens.

GET/v1/merchants/balance
curl https://swapwallet.app/api/v1/merchants/balance \
  -H "Authorization: Bearer $SWAPWALLET_BUSINESS_KEY"
Response
{
  "status": "OK",
  "result": {
    "totalValue": {
      "available": [
        {
          "number": "4951251",
          "unit": "IRT"
        },
        {
          "number": "18.1764",
          "unit": "USD"
        }
      ],
      "onHold": [
        {
          "number": "0",
          "unit": "IRT"
        },
        {
          "number": "0",
          "unit": "USD"
        }
      ]
    },
    "tokens": [
      {
        "name": "USDT",
        "available": {
          "amount": {
            "number": "18.1764",
            "unit": "USDT"
          },
          "values": [
            {
              "number": "4951251",
              "unit": "IRT"
            },
            {
              "number": "18.1764",
              "unit": "USD"
            }
          ]
        },
        "onHold": {
          "amount": {
            "number": "0",
            "unit": "USDT"
          },
          "values": [
            {
              "number": "0",
              "unit": "IRT"
            },
            {
              "number": "0",
              "unit": "USD"
            }
          ]
        },
        "marketData": [
          {
            "source": "USDT",
            "destination": "IRT",
            "marketData": {
              "bestSell": "272410",
              "bestBuy": "272390",
              "latestPrice": "272400",
              "dayChange": "-0.08",
              "volume24h": "418230.6"
            }
          },
          {
            "source": "USDT",
            "destination": "USDT",
            "marketData": {
              "bestSell": "1",
              "bestBuy": "1",
              "latestPrice": "1",
              "dayChange": "0.00",
              "volume24h": "0"
            }
          }
        ]
      },
      {
        "name": "TON",
        "available": {
          "amount": {
            "number": "0",
            "unit": "TON"
          },
          "values": [
            {
              "number": "0",
              "unit": "IRT"
            },
            {
              "number": "0",
              "unit": "USD"
            }
          ]
        },
        "onHold": {
          "amount": {
            "number": "0",
            "unit": "TON"
          },
          "values": [
            {
              "number": "0",
              "unit": "IRT"
            },
            {
              "number": "0",
              "unit": "USD"
            }
          ]
        },
        "marketData": [
          {
            "source": "TON",
            "destination": "IRT",
            "marketData": {
              "bestSell": "266320",
              "bestBuy": "265980",
              "latestPrice": "266144",
              "dayChange": "1.89",
              "volume24h": "5120.4"
            }
          },
          {
            "source": "TON",
            "destination": "USDT",
            "marketData": {
              "bestSell": "0.9781",
              "bestBuy": "0.9768",
              "latestPrice": "0.977",
              "dayChange": "1.98",
              "volume24h": "8930.12"
            }
          }
        ]
      }
    ]
  }
}