Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buyback #34

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions dashboard/modules/base_mainnet/perp_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,25 @@ def fetch_data(filters):
db,
)

df_buyback = pd.read_sql_query(
f"""
SELECT
ts,
snx_amount,
usd_amount,
cumulative_snx_amount,
cumulative_usd_amount
FROM base_mainnet.fct_buyback_{resolution}
WHERE ts >= '{start_date}' and ts <= '{end_date}'
""",
db,
)

db.close()

return {
"stats": df_stats,
"buyback": df_buyback,
}


Expand Down Expand Up @@ -94,6 +109,21 @@ def make_charts(data):
["liquidation_rewards"],
"Liquidation Rewards",
),
"buyback": chart_bars(
data["buyback"],
"ts",
["snx_amount"],
"SNX Buyback",
y_format="#",
),
"cumulative_buyback": chart_lines(
data["buyback"],
"ts",
["cumulative_snx_amount"],
"Cumulative SNX Buyback",
y_format="#",
smooth=True,
),
}


Expand Down Expand Up @@ -128,12 +158,14 @@ def main():
st.plotly_chart(charts["cumulative_fees"], use_container_width=True)
st.plotly_chart(charts["account_liquidations"], use_container_width=True)
st.plotly_chart(charts["liquidation_rewards"], use_container_width=True)
st.plotly_chart(charts["cumulative_buyback"], use_container_width=True)
pass

with col2:
st.plotly_chart(charts["volume"], use_container_width=True)
st.plotly_chart(charts["fees"], use_container_width=True)
st.plotly_chart(charts["trades"], use_container_width=True)
st.plotly_chart(charts["buyback"], use_container_width=True)
pass

## export
Expand Down
4 changes: 2 additions & 2 deletions extractors/src/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def clean_data(chain_name, contract, function_name, write=True):
contract, function_name, decode_hex(f"0x{x[10:]}")
)
)
if x
if x is not None
else None
)
)
Expand All @@ -92,7 +92,7 @@ def clean_data(chain_name, contract, function_name, write=True):
contract, function_name, decode_hex(x), is_input=False
)
)
if x
if x is not None
else None
)
)
Expand Down
181 changes: 181 additions & 0 deletions indexers/base-mainnet/abi/BuybackSnx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
[
{
"inputs": [
{
"internalType": "uint256",
"name": "_premium",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_snxFeeShare",
"type": "uint256"
},
{
"internalType": "address",
"name": "_oracleManager",
"type": "address"
},
{
"internalType": "bytes32",
"name": "_snxNodeId",
"type": "bytes32"
},
{
"internalType": "address",
"name": "_snxToken",
"type": "address"
},
{
"internalType": "address",
"name": "_usdToken",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "OverflowInt256ToUint256",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "buyer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "snx",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "usd",
"type": "uint256"
}
],
"name": "BuybackProcessed",
"type": "event"
},
{
"inputs": [],
"name": "DEAD",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getPremium",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getSnxFeeShare",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getSnxNodeId",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "snxAmount",
"type": "uint256"
}
],
"name": "processBuyback",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint128",
"name": "marketId",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "feeAmount",
"type": "uint256"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "quoteFees",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
}
]
10 changes: 10 additions & 0 deletions indexers/base-mainnet/squidgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ contracts:
abi: ./abi/SpotMarketProxy.json
events: true
functions: false
- name: BuybackSnxLegacy
address: "0x53f1E640C058337a12D036265681bC172e6fB962"
abi: ./abi/BuybackSnx.json
events: true
functions: false
- name: BuybackSnx
address: "0x632cAa10A56343C5e6C0c066735840c096291B18"
abi: ./abi/BuybackSnx.json
events: true
functions: false
Loading