Closed DenisCarriere closed 4 years ago
@yudilevi modified table structure for converter_v2
Have a review, I've added two new flexible fields:
protocol_features
(enable/disable features in the future, ex: staking )metadata_json
(extend converter metadata, ex: website URL)TABLE converter_v2_t {
/**
* @brief symbol of the smart token -- representing a share in the reserves of this converter
* @details PRIMARY KEY for this table is `currency.code().raw()`
*/
symbol currency;
/**
* @brief creator of the converter
*/
name owner;
/**
* @brief conversion fee for this converter, applied on every hop
*/
uint64_t fee;
/**
* @brief reserve weights relative to the other reserves
* @example
* {
* "key: "BNT",
* "value": 500000
* }
*/
map<symbol_code, uint64_t> reserve_weights;
/**
* @brief balances in each reserve
* @example
* {
* "key: "BNT",
* "value": "10000.0000 BNT"
* }
*/
map<symbol_code, extended_asset> reserve_balances;
/**
* @brief [optional] protocol features for converter
* @example
* {
* "key: "stake",
* "value": true
* }
*/
map<name, bool> protocol_features;
/**
* @brief [optional] additional metadata for converter
* @example
* {
* "key: "website",
* "value": "https://mywebsite.com"
* }
*/
map<name, string> metadata_json;
}
@yudilevi Added activate
ACTION as a general purpose protocol_feature
activation.
This replaces actions such as enablestake
.
activate( const symbol_code currency, const name protocol_feature, const bool enabled )
cleos
$ cleos push action bancorcnvrtr activate '["BNTEOS", "stake", false]' -p myowner
Which will add a boolean values to the converters.protocol_features
[ { "key": "stake", "value": 1 } ]
scopes
from bancorcnvrtr::converters
const { createDfuseClient } = require("@dfuse/client")
const { name, symbol_code } = require("eos-common");
global.fetch = require("node-fetch")
global.WebSocket = require("ws")
const client = createDfuseClient({ apiKey: process.env.DFUSE_API_KEY, network: "mainnet" })
async function main() {
const results = await client.stateTableScopes("bancorcnvrtr", "converters");
for ( const scope of results.scopes ) {
const symcode = symbol_code( name(scope).value ).to_string();
console.log(symcode);
}
client.release()
}
main();
BNTVG
BNTET
BNTBOD
BNTUSD
BNTINF
BNTCHL
BNTAPP
BNTPXS
TCNBNT
BOSBNT
EOSBNT
TPTBNT
MEVBNT
BNTMPT
BNTSOV
BNTAPX
TESTAAA
BNTEDNA
TCNUSDB
BNTTRYB
BNTSEED
BNTPIXE
TESTING
BNTEIDO
BNTATMO
BNTGOVR
BNTSENS
BNTPEOS
BNTUSDT
BNTMEET
EOSABNT
PBTCBNT
AZZIBNT
GOVRBNT
SENSBNT
FASTBNT
EOSTBNT
UVUVBNT
KROWBNT
WIZZBNT
BNTCHEX
Converters
No significant changes, simply added scoped data to main scope
get_self()
Will be used right away in new migration upgrade
Reserves
Removal of scopes requires the
currency
symbol code as scope andmap
objects forratios
&balances
.before
after
How to migrate
Once code is deployed,
migrate
action must be called on all the currently active converters, this will update theconverters
table to use the main scope andreserves.v2
table will be populated usingreserves
legacy table structure.TO-DO
migrate_reserve
to main code, continuously updates after initial migrate step