bitshares研究系列【 bitshares资产数据】

资产是bitshares中重要的一部分,看下bitshares的资产数据和获取方法。

asset json数据结构

先看一下资产的json数据结构,便于与界面、类等对应。

BTS "1.3.0"

{

    "id": "1.3.0",

    "symbol": "BTS",

    "precision": 5,

    "issuer": "1.2.3",

    "options": {

        "max_supply": "360057050210207",

        "market_fee_percent": 0,

        "max_market_fee": "1000000000000000",

        "issuer_permissions": 0,

        "flags": 0,

        "core_exchange_rate": {

            "base": {

                "amount": 1,

                "asset_id": "1.3.0"

            },

            "quote": {

                "amount": 1,

                "asset_id": "1.3.0"

            }

        },

        "whitelist_authorities": [],

        "blacklist_authorities": [],

        "whitelist_markets": [],

        "blacklist_markets": [],

        "description": "",

        "extensions": []

    },

    "dynamic_asset_data_id": "2.3.0"

}

bitUSD "1.3.121"

{

    "id": "1.3.121",

    "symbol": "USD",

    "precision": 4,

    "issuer": "1.2.0",

    "options": {

        "max_supply": "1000000000000000",

        "market_fee_percent": 10,

        "max_market_fee": "1000000000000000",

        "issuer_permissions": 511,

        "flags": 129,

        "core_exchange_rate": {

            "base": {

                "amount": 26150000,

                "asset_id": "1.3.121"

            },

            "quote": {

                "amount": 871200000,

                "asset_id": "1.3.0"

            }

        },

        "whitelist_authorities": [],

        "blacklist_authorities": [],

        "whitelist_markets": [],

        "blacklist_markets": [],

        "description": "{\"main\":\"1 United States dollar\",\"market\":\"\"}",

        "extensions": []

    },

    "dynamic_asset_data_id": "2.3.121",

    "bitasset_data_id": "2.4.21"

}

bitCNY "1.3.113"

{

    "id": "1.3.113",

    "symbol": "CNY",

    "precision": 4,

    "issuer": "1.2.0",

    "options": {

        "max_supply": "1000000000000000",

        "market_fee_percent": 10,

        "max_market_fee": "1000000000000000",

        "issuer_permissions": 511,

        "flags": 129,

        "core_exchange_rate": {

            "base": {

                "amount": 1425,

                "asset_id": "1.3.113"

            },

            "quote": {

                "amount": 7504,

                "asset_id": "1.3.0"

            }

        },

        "whitelist_authorities": [],

        "blacklist_authorities": [],

        "whitelist_markets": [],

        "blacklist_markets": [],

        "description": "{\"main\":\"1 Chinese yuan\",\"market\":\"\"}",

        "extensions": []

    },

    "dynamic_asset_data_id": "2.3.113",

    "bitasset_data_id": "2.4.13"

}

再看用get_objects方法取到的资产数据:

dynamic_asset_data_id:2.3.0

{"id":"2.3.0","current_supply":"261744197937804","confidential_supply":"28808061460","accumulated_fees":0,"fee_pool":10100000}

dynamic_asset_data_id:2.3.121

{"id":"2.3.121","current_supply":"123892155618","confidential_supply":3459,"accumulated_fees":52087049,"fee_pool":"12833117715"}

bitasset_data_id:2.4.21

{

    "id": "2.4.21",

    "feeds": [

        ["1.2.167", ["2018-04-20T05:37:39", {

            "settlement_price": {

                "base": {

                    "amount": 23360000,

                    "asset_id": "1.3.121"

                },

                "quote": {

                    "amount": 946500000,

                    "asset_id": "1.3.0"

                }

            },

            "maintenance_collateral_ratio": 1750,

            "maximum_short_squeeze_ratio": 1100,

            "core_exchange_rate": {

                "base": {

                    "amount": 25860000,

                    "asset_id": "1.3.121"

                },

                "quote": {

                    "amount": 997900000,

                    "asset_id": "1.3.0"

                }

            }

        }]],

    "comment":"此处省掉很多喂价方信息",

    "current_feed": {

        "settlement_price": {

            "base": {

                "amount": 2479,

                "asset_id": "1.3.121"

            },

            "quote": {

                "amount": 99498,

                "asset_id": "1.3.0"

            }

        },

        "maintenance_collateral_ratio": 1750,

        "maximum_short_squeeze_ratio": 1100,

        "core_exchange_rate": {

            "base": {

                "amount": 26150000,

                "asset_id": "1.3.121"

            },

            "quote": {

                "amount": 871200000,

                "asset_id": "1.3.0"

            }

        }

    },

    "current_feed_publication_time": "2018-04-19T18:14:30",

    "options": {

        "feed_lifetime_sec": 86400,

        "minimum_feeds": 7,

        "force_settlement_delay_sec": 86400,

        "force_settlement_offset_percent": 100,

        "maximum_force_settlement_volume": 50,

        "short_backing_asset": "1.3.0",

        "extensions": []

    },

    "force_settled_volume": 0,

    "is_prediction_market": false,

    "settlement_price": {

        "base": {

            "amount": 0,

            "asset_id": "1.3.0"

        },

        "quote": {

            "amount": 0,

            "asset_id": "1.3.0"

        }

    },

    "settlement_fund": 0

}

bitshares-core asset对象定义

graphene/chain/asset_object.hpp

asset_dynamic_data_object

asset_object

asset_bitasset_data_object

在这三个类中有asset对象定义,可以与数据一一对应。

bitshares-ui界面

从这个图中可以与数据、与对象对应起来。

bitshares-ui代码

AssetActions.js

getAssetList

直接调用api "list_assets",取到资产列表。

每个资产加入dynamicIDS列表,如果是bitAssetIDS则加入bitAssetIDS列表。

再调用api "get_objects"取得资产详细数据。

几个名词

CR(collateral ratio)

担保比率=担保物价值 / 债务

CP(call price)

CP = 担保物价值 / (债务 * 维持担保比率)

CER(core exchange rate)

maintenance collateral ratio (MCR): A ratio defined by the witnesses as minimum required collateral ratio

maximum short squeeze ratio (MSQR): A ratio defined by the witnesses as to how far shorts are protected against short squeezes

short squeeze protection (SQP): Defines the most that a margin position will ever be forced to pay to cover

call price (CP): The price at which short/borrow positions are margin called

感谢您阅读 @chaimyu 的帖子,期待您能留言交流!

https://steemit.com/bitshares/@chaimyu/bitshares-bitshares

你可能感兴趣的:(bitshares研究系列【 bitshares资产数据】)