Closed bvotteler closed 1 year ago
Sample query:
fragment AmountFields on PooledAmount {
amount
amountHuman
token {
... on NativeToken {
__typename
token
}
... on ForeignAsset {
__typename
asset
}
... on StableLpToken {
__typename
poolId
}
... on LendToken {
__typename
lendTokenId
}
}
}
query SwapQuery {
swaps(limit: 10) {
id
timestamp
fromAccount
toAccount
feeRate
from {
...AmountFields
}
to {
...AmountFields
}
}
}
Sample result:
{
"id": "swap_(KSM,KBTC)_0002681725-000012-2842a",
"timestamp": "2023-03-23T03:01:36.212000Z",
"fromAccount": "a3dkY3yWweLMkUjbSSNC2NawWegH3NZkWpYjsnBr2srQsp9LZ",
"toAccount": "a3dkY3yWweLMkUjbSSNC2NawWegH3NZkWpYjsnBr2srQsp9LZ",
"feeRate": "0.0015",
"from": {
"amount": "21370527482",
"amountHuman": "0.021370527482",
"token": {
"__typename": "NativeToken",
"token": "KSM"
}
},
"to": {
"amount": "2538",
"amountHuman": "0.00002538",
"token": {
"__typename": "NativeToken",
"token": "KBTC"
}
}
}
It looks a bit awkward to have the from/to account ids outside of the fields from
and to
which contain PooledAmount
data (ie. no account in there, because it's also used for cumulative volumes).
I was in two minds whether we should introduce a new type including the account ids, or keep it as is. Slightly leaning towards keeping it so we can better reuse fragments when structuring queries. Having said that, I am more than happy to be challenged on that.
Resolves #106
Store swap information:
Todo before ready for review: