Closed Unique-Divine closed 2 years ago
It would be very useful to have a query that returns an array of all of a trader's active positions indexed by the string identifier for each vpool:
nibid query perp all-positions [address]
The returned response would be a an array of maps from string to QueryTraderPositionResponse types.
string
QueryTraderPositionResponse
[ "ubtc:unusd": { "position": { "trader_address": "nibi1ah8gqrtjllhc5ld4rxgl4uglvwl93ag0sh6e6v", "pair": { "token0": "ubtc", "token1": "unusd" }, "size": "200015.306895339315011385", "margin": "1999425346.948817872092699127", "open_notional": "4000000000.000000000000000000", "last_update_cumulative_premium_fraction": "-6831.818083040603478395", "block_number": "856652" }, "position_notional": "3999999999.999999999999993448", "unrealized_pnl": "-0.000000000000006552", "margin_ratio_mark": "0.482808126123902361", "margin_ratio_index": "0.484930504069882468", "block_number": "925768" }, "ueth:unusd": { "position": {"..."}, "position_notional": "20000000000.50", "unrealized_pnl": "-0.000000000000006552", "margin_ratio_mark": "0.482808126123902361", "margin_ratio_index": "0.484930504069882468", "block_number": "925768" }, "uatom:unusd": { "position": {"..."} "position_notional:": "..." // ... } // ... ]
The proto RPC method would look something like this:
rpc QueryAllPositions(QueryAllPositionsRequest) returns (QueryAllPositionsResponse) { option (google.api.http).get = "/nibiru/perp/all_positions"; }
@NibiruHeisenberg moved this issue to myself since I'm taking care of perp state refactoring.
Context
It would be very useful to have a query that returns an array of all of a trader's active positions indexed by the string identifier for each vpool:
Requested Functionality
The returned response would be a an array of maps from
string
toQueryTraderPositionResponse
types.The proto RPC method would look something like this: