Skip to content

Instantly share code, notes, and snippets.

from pycoingecko import CoinGeckoAPI
import pandas as pd
cg = CoinGeckoAPI()
dydx_trades = cg.get_coin_ohlc_by_id("dydx", "usd", 7)
dydx_df = pd.DataFrame(dydx_trades, columns=['time', 'open', 'high', 'low', 'close'])
twap_price = dydx_df[['open', 'high', 'low', 'close']].mean(axis=None)
print(twap_price)
## Ran on Feb 19th at 18:00 UTC
{
"title": "Min Deposit and Max Deposit Period Change",
"deposit": "1000000adv4tnt",
"summary": "This is a proposal to decrease the min deposit and increase max deposit period.",
"messages": [
{
"@type": "/cosmos.gov.v1.MsgExecLegacyContent",
"content": {
"@type": "/cosmos.params.v1beta1.ParameterChangeProposal",
"changes": [
@cbergz
cbergz / gist:110cd9cefc11ec34aa179b32dcc0ef7b
Created February 12, 2024 15:01
Gov Params Update Proposal
{
"title": "Min Deposit and Max Deposit Period Change",
"deposit": "1000000adv4tnt",
"summary": "Test proposal to decrease min_deposit and increase max_deposit_period.",
"messages": [
{
"@type": "/cosmos.gov.v1.MsgUpdateParams",
"authority": "dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky",
"params": {
"min_deposit": [{"amount": "100000000", "denom": "adv4tnt"}],
@cbergz
cbergz / unsigned_proposal.json
Last active January 22, 2024 16:46
Season 1 Rewards Proposal
{"body":{"messages":[{"@type":"/cosmos.gov.v1.MsgSubmitProposal","messages":[{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky","sender_module_name":"community_treasury","recipient":"dydx100l9m6g70j28g2tk3jj4plmge8vsmj6jdrlzhk","coin":{"denom":"adydx","amount":"206151260000000000000000"}},{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky","sender_module_name":"community_treasury","recipient":"dydx1g6vlujs2fw7c4886uc8g092474d54uhcf2swrg","coin":{"denom":"adydx","amount":"195541810000000000000000"}},{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky","sender_module_name":"community_treasury","recipient":"dydx1ph7ek4yk82gdaw0r4yzluuchxwe96yrjdjq9wr","coin":{"denom":"adydx","amount":"161947650000000000000000"}},{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr7
@cbergz
cbergz / unsigned_proposal_tx.json
Created January 16, 2024 17:45
Launch Incentives Proposal
{"body":{"messages":[{"@type":"/cosmos.gov.v1.MsgSubmitProposal","messages":[{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky","sender_module_name":"community_treasury","recipient":"dydx100l9m6g70j28g2tk3jj4plmge8vsmj6jdrlzhk","coin":{"denom":"adydx","amount":"206151260000000000000000"}},{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky","sender_module_name":"community_treasury","recipient":"dydx1g6vlujs2fw7c4886uc8g092474d54uhcf2swrg","coin":{"denom":"adydx","amount":"195541810000000000000000"}},{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky","sender_module_name":"community_treasury","recipient":"dydx1ph7ek4yk82gdaw0r4yzluuchxwe96yrjdjq9wr","coin":{"denom":"adydx","amount":"161947650000000000000000"}},{"@type":"/dydxprotocol.sending.MsgSendFromModuleToAccount","authority":"dydx10d07y265gmmuvt4z0w9aw880jnsr7
WITH
taker AS (
SELECT
"taker" AS user_side,
JSON_EXTRACT_SCALAR(m.attributes, '$.tx_msg_type') AS order_type,
JSON_EXTRACT_SCALAR(m.attributes, '$.timestamp') AS order_submitted_time,
m.publish_time AS numia_publish_time,
(
SELECT
MAX(block_timestamp)
{
"mev_node_to_node": {
"validator_mev_matches": {
"matches": [
{
"taker_order_subaccount_id": {
"owner": "dydx17cyzu9lmhszszspy33jtk6adgzkaunksr4eedt"
},
"taker_fee_ppm": 500,
"maker_order_subaccount_id": {
@cbergz
cbergz / 4857378.json
Created January 1, 2024 17:59
MEV data from block 4857378
{
"mev_node_to_node": {
"validator_mev_matches": {
"matches": [
{
"taker_order_subaccount_id": {
"owner": "dydx1g6vlujs2fw7c4886uc8g092474d54uhcf2swrg",
"number": 1
},
"taker_fee_ppm": 250,
@cbergz
cbergz / v4-text-proposal.json
Created November 28, 2023 13:50
dYdX v4 Text Proposal
{
"title": "Title",
"deposit": "2000000000000000000000adydx",
"summary": "Summary",
"messages": [
{
"@type": "/cosmos.gov.v1.MsgExecLegacyContent",
"content": {
"@type": "/cosmos.gov.v1beta1.TextProposal",
"title": "Title goes here.",
@cbergz
cbergz / DIP-3.md
Created November 28, 2023 00:28
dYdX v4 social mitigation for MEV proposal

DIP 3 - Launch a Social Mitigation Strategy for MEV

Simple Summary

Launch a social strategy for mitigating MEV on behalf of active validators by appointing a grants funded committee and agreeing on the intent to take action against bad actors.

Abstract

With the launch of full trading on dYdX v4, we expect trading activity to pick up significantly. With that increase in volume comes an opportunity for validators to profit from MEV. Since there is no in-protocol solution for preventing MEV at this time, the protocol is at risk of validators deploying MEV strategies that can pose a significant threat to the trading experience of dYdX users.