zeitgeist
zeitgeist copied to clipboard
[Swaps] getSpotPrices RPC for Scalar markets does not work as expected
After @Robiquet reported the problem of invoking the getSpotPrices
rpc for scalar market to me, I was also unable to invoke it correctly. It seems to be impossible to invoke the RPC with correct parameters. The following should work, but it does not:
{
"scalarOutcome": [
19,
"short"
]
}
What is going on?
"long", "Long", "Short", 0
and 1
also give the same error message. However a random string or number gives a different error
Any news on this? The new sdk uses the rpc call to fetch prices more heavily and this would need to be fixed for that to work as expected.
We'll investigate. @yornaath
Currently I am not able to debug this with sdk as it has other issues to fix first.
It seems like SDK needs to update types for get_spot_price after #937 currently I see it has following getSpotPrice: { description: 'get spot price', params: [ { name: 'poolId', type: 'u128', }, { name: 'assetIn', type: 'SwapsAsset', }, { name: 'assetOut', type: 'SwapsAsset', }, { name: 'at', type: 'Option<BlockHash>', }, { name: 'withFees', type: 'bool', }, ], type: 'u128', },
Following works for me
console.log( "Vivek " +
await api.rpc.swaps.getSpotPrice(
1,
{ ScalarOutcome: [0, 'long'] },
{ Ztg: null },
false,
)
);
but I have to change following thing in type.json Change
"ScalarPosition": {
"_enum": [
"Long",
"Short"
]
},
to following
"ScalarPosition": {
"_enum": [
"long",
"short"
]
},
@yornaath @Robiquet as per my above observation it feels this is not an issue on substrate node.