Skip to content

Instantly share code, notes, and snippets.

@0xbe1
Last active June 9, 2022 13:21
Show Gist options
  • Save 0xbe1/23056a47ce55c951e141108f85bed7a6 to your computer and use it in GitHub Desktop.
Save 0xbe1/23056a47ce55c951e141108f85bed7a6 to your computer and use it in GitHub Desktop.
syntax = "proto3";
package amm.types.v1;
message Token {
// smart contract address
string id = 1;
string name = 2;
string symbol = 3;
uint64 decimals = 4;
}
message Deposit {
// deposit-{transactio hash}-{log index}
string id = 1;
string hash = 2;
uint64 log_index = 3;
string token0_id = 4;
string token1_id = 5;
double token0_amount = 6;
double token1_amount = 7;
double token0_value_usd = 8;
double token1_value_usd = 9;
// address of trader
string trader = 10;
string pool_id = 11;
}
message Withdraw {
// withdraw-{transactio hash}-{log index}
string id = 1;
string hash = 2;
uint64 log_index = 3;
string token0_id = 4;
string token1_id = 5;
double token0_amount = 6;
double token1_amount = 7;
double token0_value_usd = 8;
double token1_value_usd = 9;
// address of trader
string trader = 10;
string pool_id = 11;
}
message Swap {
// swap-{transactio hash}-{log index}
string id = 1;
string hash = 2;
uint64 log_index = 3;
string token0_id = 4;
string token1_id = 5;
// for example, 1.20 ETH
double token0_amount = 6;
double token1_amount = 7;
double token0_value_usd = 8;
double token1_value_usd = 9;
// address of trader
string trader = 10;
string pool_id = 11;
}
message Pool {
// smart contract address
string id = 1;
// smart contract address of token0
string token0_id = 2;
// smart contract address of token1
string token1_id = 3;
// for example, 9810.35 ETH
double token0_reserve = 4;
double token1_reserve = 5;
// deposited token value in USD = token0_reserve * token0_price_usd + token1_reserve * token1_price_usd
double total_value_locked_usd = 6;
// sum value of deposited pairs where price is determined point-in-time
// lets say the pool has 2 deposits:
// 1st deposit: 1 * token0 + 2 * token1 where price(token0) = $100 and price(token1) = $50
// 2nd deposit: 1 * token0 + 2 * token1 where price(token0) = $110 and price(token1) = $55
// cumulative volume usd = (100 * 1 + 50 * 2) + (110 * 1 + 55 * 2) = 200 + 220 = 420
double cumulative_volume_usd = 7;
}
message PoolDailySnapshot {
// {pool id}-{days since epoch}
string id = 1;
// smart contract address of token0
string token0_id = 2;
// smart contract address of token1
string token1_id = 3;
// for example, 9810.35 ETH
double token0_reserve = 4;
double token1_reserve = 5;
double total_value_locked_usd = 6;
double cumulative_volume_usd = 7;
double daily_volume_usd = 8;
}
message UsageDailySnapshot {
// days since epoch days
string id = 1;
// distinct trader count of the day
uint64 daily_users = 2;
// distinct trader count by far
uint64 cumulative_users = 3;
uint64 daily_deposit_count = 4;
uint64 daily_swap_count = 5;
uint64 daily_withdraw_count = 6;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment