-
Notifications
You must be signed in to change notification settings - Fork 43
/
exchange_state.hpp
41 lines (29 loc) · 1.09 KB
/
exchange_state.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <eosio/asset.hpp>
#include <cmath>
namespace eosiosystem {
using eosio::asset;
using eosio::symbol;
typedef double real_type;
/**
* Uses Bancor math to create a 50/50 relay between two asset types. The state of the
* bancor exchange is entirely contained within this struct. There are no external
* side effects associated with using this API.
*/
struct [[eosio::table, eosio::contract("eosio.system")]] exchange_state {
asset supply;
struct connector {
asset balance;
double weight = .5;
EOSLIB_SERIALIZE( connector, (balance)(weight) )
};
connector base;
connector quote;
uint64_t primary_key()const { return supply.symbol.raw(); }
asset convert_to_exchange( connector& c, asset in );
asset convert_from_exchange( connector& c, asset in );
asset convert( asset from, const symbol& to );
EOSLIB_SERIALIZE( exchange_state, (supply)(base)(quote) )
};
typedef eosio::multi_index< "rammarket"_n, exchange_state > rammarket;
} /// namespace eosiosystem