POST Position State
/position-state
position-state/{start}/{size}Example Query:
https://base-hedger82.rasa.capital/position-state/{start}/{size}Overview
This endpoint gives insights into historical lifecycle updates for positions based on a quote ID or counterparty address. Results are sourced from the Notifications, Positions, and Symbol tables, then mapped into the response schema.
Endpoint Specification
URL: https://base-hedger82.rasa.capital/position-state/{start}/{size}
Method: POST
Headers
Content-Type: application/jsonOptional:
App-Name:(client identifier)
cURL Example (Limit Open — Reserved but not yet Opened)
curl -X POST "https://base-hedger82.rasa.capital/position-state/0/10" \
-H "Content-Type: application/json" \
-H "App-Name: Cloverfield" \
-d '{"quote_id": "131388"}'Response (HTTP 200):
Path Parameters
start
integer
0-based pagination offset
size
integer
Number of records to return (max 100)
Body Parameters (JSON)
Provide at least quote_id or address of the following to filter results; other fields are optional:
Field
Type
Description
quote_id
string
Exact quote ID (string). One of quote_id or address is required.
address
string
Counterparty address (Ethereum hex string). One of quote_id or address is required.
symbols
string[]
Optional filter by trading symbols (e.g., ["ETHUSD"]).
states
string[]
Optional filter by position state enums (e.g., ["alert"]).
create_time_gte
integer
Optional: include records with Notifications.create_time >= epoch seconds UTC.
modify_time_gte
integer
Optional: include records with Notifications.modify_time >= epoch seconds UTC.
Request & Response Schemas
Define Schemas
Create PositionsStateRequestSchema and PositionStateResponseSchema + PositionsStateOutputSchema in the schema file.
Data Sources & Field Mapping
id
Notifications.id
Primary key (UUID) -> in some solver implementations this is also the quote ID.
create_time
Notifications.create_time
Epoch seconds UTC
modify_time
Notifications.modify_time
Epoch seconds UTC
quote_id
Notifications.quote_id
quote_id.
temp_quote_id
Notifications.temp_quote_id
Used for instant trades or null.
counterparty_address
Notifications.counterparty_address
partyA address
filled_amount_open
Notifications.filled_amount_open
Recorded open fill amount
avg_price_open
Notifications.avg_price_open
Recorded open fill price
filled_amount_close
Notifications.filled_amount_close
Recorded close fill amount
avg_price_close
Notifications.avg_price_close
Recorded close fill price
last_seen_action
Notifications.last_seen_action
e.g., SendQuote, FillLimitOrderOpen
action_status
Notifications.action_status
success, seen, etc.
failure_type
Notifications.failure_type
If action failed
error_code
Notifications.error_code
Numeric code
order_type
Notifications.order_type
Limit = 0, Market = 1
state_type
Notifications.state_type
"alert" or "report"
Implementation Details (Annotated)
This section explains how each piece fits together.
Router Layer (routers.py)
routers.py)Controller Layer (controllers.py)
controllers.py)Example (Full Open Position -> Close Position Flow)
cURL Query
fResponse (HTTP 200):
By Address
Response (200 OK):
Full Lifecycle Flow
Below is the end-to-end sequence of events and how they map to the records you see in the /position-state response:
RFQ Observed
On-Chain Event Poller listens for
SendQuoteevents.Creates a “alert” notification (
state_type = "alert") withaction_status = "seen"and zeros in all fill fields.At this point the hedger can lock the quote. The quote is seen but not yet filled.
Hedger Confirmation & Opening of the position
The hedger’s risk engine executes the quote on-chain.
Updates the
Notificationstable with actualfilled_amount_openandavg_price_openvalues.Emits a “report” notification (
state_type = "report") withaction_status = "success"and real fill data.
On-Chain Fill Event
Almost immediately thereafter, the contract itself emits an
OpenPositionevent when the transaction finally lands on-chain.Poller picks it up and creates another “alert” (
state_type = "alert") with zeros in fill fields until the DB update completes.The same poller picks up that on-chain event and writes a fresh Notification with
last_seen_action = "FillLimitOrderOpen"action_status = "success"
Last updated
