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

feat(#major); kwenta; new subgraph #2297

Merged
merged 7 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion deployment/deployment.json
amritkumarj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8840,7 +8840,7 @@
},
"options": {
"prepare:yaml": true,
"prepare:constants": false
"prepare:constants": true
}
}
}
Expand Down
61 changes: 61 additions & 0 deletions subgraphs/kwenta/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Kwenta Subgraph

## Calculation Methodology v1.0.0

### Total Value Locked (TVL)

Sum of all the margin deposits

> TVL of a Pool = ∑ value of all assets to be provided as collateral pool

> TVL of the Protocol = ∑ TVL of of all the pools

### Open Intereest

> Open Interest = ∑ value of open positions

Calculated by fetching pool contract market size and skew data

> Long Open Interest = (marketSize + marketSkew) / 2

> Short Open Interest = (marketSize - marketSkew) / 2

> Total Open Interest = Long + Short Open Interest

### Volume

- Volume: The total cumulative value of all the trades executed

- Inflow Volume: The total cumulative value of margin deposited
- Outflow Volume: The total cumulative value of margin withdrawn

### Revenue/Fees

The protocol take two fees - Keeper Fees and Maker/Takes Fees

- Keeper Fees: A dynamic fees to execute the trade
- Maker/Taker Fees: Normal Maker/Taker fees they vary depending on the market

Protocol Side Revenue = Zero

Supply-Side Revenue = Total Fees (currently Kwenta don't charge any fees)

Total Revenue = Total Fees

### Unique Users

**Count of Unique Addresses which have interacted with the protocol via any transaction:**

- Margin deposits and withdrawals

- Position Modified - new, updated or closed

- Liquidations

## References and Useful Links

- Other existing subgraph: https://thegraph.com/hosted-service/subgraph/kwenta/optimism-main

- Other official and unofficial data sources: https://kwenta.eth.limo/stats/, https://tokenterminal.com/terminal/projects/kwenta

- Documentation: https://docs.kwenta.io/
222 changes: 222 additions & 0 deletions subgraphs/kwenta/abis/ERC20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_spender",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
},
{
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
]
17 changes: 17 additions & 0 deletions subgraphs/kwenta/abis/ERC20NameBytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
17 changes: 17 additions & 0 deletions subgraphs/kwenta/abis/ERC20SymbolBytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
Loading