Tables
accounts
```cpp
#pragma once
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>
using namespace eosio;
struct [[eosio::contract("adex.swap"), eosio::table]] account
{
asset balance;
uint64_t primary_key() const
{
return balance.symbol.code().raw();
}
};
using accounts = multi_index<name("accounts"), account>;
```
deposits
```cpp
#pragma once
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
#include "resources.hpp"
using namespace eosio;
struct [[eosio::contract("adex.swap"), eosio::table]] deposit_row
{
name owner;
extended_asset base_token;
extended_asset quote_token;
uint64_t primary_key() const {
return owner.value;
}
};
using deposits = multi_index<name("deposits"), deposit_row>;
```
pools
```cpp
#pragma once
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
#include "resources.hpp"
using namespace eosio;
struct [[eosio::contract("adex.swap"), eosio::table]] pool
{
uint64_t id;
symbol_code code;
extended_asset base_token;
extended_asset quote_token;
asset pool_fee;
asset platform_fee;
time_point created_at;
time_point updated_at;
uint64_t primary_key() const {
return id;
}
uint64_t code_key() const {
return code.raw();
}
std::string to_string(const extended_symbol &token)
{
std::string str = std::to_string(token.get_symbol().precision()) + "," + token.get_symbol().code().to_string() + "@" + token.get_contract().to_string();
return str;
}
checksum256 to_pair_hash(const extended_symbol &base_token, const extended_symbol "e_token)
{
std::string str = to_string(base_token) + "/" + to_string(quote_token);
return sha256(str.data(), str.size());
}
checksum256 pair_key() const {
return to_pair_hash(base_token.get_extended_symbol(), quote_token.get_extended_symbol());
}
};
using by_code = indexed_by<name("bycode"), const_mem_fun<pool, uint64_t, &pool::code_key>>;
using by_pair_key = indexed_by<name("bypair"), const_mem_fun<pool, checksum256, &pool::pair_key>>;
using pools = multi_index<name("pools"), pool, by_code, by_pair_key>;
```
stat
```cpp
#pragma once
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>
using namespace eosio;
struct [[eosio::contract("adex.swap"), eosio::table]] currency_stats
{
asset supply;
asset max_supply;
name issuer;
uint64_t primary_key() const
{
return supply.symbol.code().raw();
}
};
using stats = multi_index<name("stat"), currency_stats>;
```
Last updated