Last updated: March 2023
Last updated: 2025-05-09
Last updated: 2025-05-09
Last updated: 2025-05-09
This example subgraph stores TokenSwap objects that represents token swaps made using the GAMM (Generalized Automated Market Maker) in the Osmosis chain. In order to do that, an event handler is used to filter token_swapped events. The type of event to be filtered is specified in the subgraph manifest file. That way, the handler will just receive events of that type.
By running this example subgraph, and with the following query, you can retrieve all the swaps made by a given address:
query SwapsForAccount($senderAddress: String!) {
tokenSwaps(where: {sender: $senderAddress}) {
tokenIn {
amount
denom
},
tokenOut {
amount
denom
}
}
}
{
"senderAddress": "osmo1wd3j7cvcnr3pfey4fx2mz9xml9euu68z6zg0xp"
}
For more information see the docs on https://thegraph.com/docs/.