Author Topic: Bitshares-2-ui: Limit Order Create Operation issue  (Read 1489 times)

0 Members and 1 Guest are viewing this topic.

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
I am using bitshares2-ui library to create my app. I have created limit_order_create operation to trade currency from my app. But limit_order_create operations behaves very weird.
For example if I want 0.1 EUR for 19.98414 BTS, it shows Sell 19.98414 BTS. Then if I want 0.1 EUR for 19.99 BTS it shows Sell 199841417742.87936 BTS. Please guide me to resolve this issue. Following is the limit_order_create operation definition which takes asset type in amount_to_sell.

Code: [Select]
limit_order_create = new Serializer(
    "limit_order_create"
    fee: asset
    seller: protocol_id_type "account"
    amount_to_sell: asset
    min_to_receive: asset
    expiration: time_point_sec
    fill_or_kill: bool
    extensions: set future_extensions
)

Following is asset type definition

Code: [Select]
asset = new Serializer(
    "asset"
    amount: int64
    asset_id: protocol_id_type "asset"
)
The former is correct, but the latter is incorrect? Rounding issue? Can you paste the transaction you've built here (json format)?
BitShares committee member: abit
BitShares witness: in.abit

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
in graphene .. all amounts are INTEGERS .. hence if you want to sell 19.0002 BTS  .. you need to multiply by 10^(precision) .. which is 10k for BTS.
the precision can be seen from the assets details (5 in the case of BTS with 10^5=10k)

Offline sharique-knysys

  • Newbie
  • *
  • Posts: 19
    • View Profile
I am using bitshares2-ui library to create my app. I have created limit_order_create operation to trade currency from my app. But limit_order_create operations behaves very weird.
For example if I want 0.1 EUR for 19.98414 BTS, it shows Sell 19.98414 BTS. Then if I want 0.1 EUR for 19.99 BTS it shows Sell 199841417742.87936 BTS. Please guide me to resolve this issue. Following is the limit_order_create operation definition which takes asset type in amount_to_sell.

Code: [Select]
limit_order_create = new Serializer(
    "limit_order_create"
    fee: asset
    seller: protocol_id_type "account"
    amount_to_sell: asset
    min_to_receive: asset
    expiration: time_point_sec
    fill_or_kill: bool
    extensions: set future_extensions
)

Following is asset type definition

Code: [Select]
asset = new Serializer(
    "asset"
    amount: int64
    asset_id: protocol_id_type "asset"
)