lighter.session
Documentation for eth_defi.lighter.session Python module.
HTTP session management for Lighter API.
Every Lighter API call goes through one of the classes in this module:
LighterSessionfor directrequestsreads, with retry logic and rate limiting. Rate limiting is thread-safe using SQLite backend, so the session can be shared across multiple threads when usingjoblib.Parallelor similar. The session carries the API URL so that downstream functions do not need a separateapi_urlargument.LighterSDKSessionfor the official SDK, which has its ownaiohttpclient. Create SDK clients witheth_defi.lighter.sdk.create_lighter_signer_client()andeth_defi.lighter.sdk.create_lighter_api_client(), which install it.create_lighter_submission_session()for a pre-signed transaction whose outcome is reconciled by hash.
Limits published in Lighter’s rate limit documentation, read on 2026-11-05:
L2CreateSubAccountandL2CreatePublicPool: 2 requests per minute.L2Withdraw: 2 requests per minute and 3 per 2 hours, per L1 address.Standard accounts: 60 requests per rolling minute, per IP and L1 address.
Exceeding a limit returns HTTP 429 or HTTP 405.
The firewall cooldown is a static 60 seconds.
Lighter documents no Retry-After header, and the 429 for the sub-account limit
carried none on 2026-11-04. Responses pass through CloudFront, though, so another
layer can send one. Both retrying classes honour it when it is present.
Executors on one host share the IP budget, so a limit can be reached without the current process being busy.
Module Attributes
Default number of retries for API requests. |
|
Default backoff factor for retries (seconds) |
|
Statuses Lighter documents for an exceeded rate limit. |
|
Statuses retried for a read. |
|
The only mutation path |
|
Seconds after which a pre-signed submission is not attempted again. |
|
Default policy for reads and live transactions. |
|
Policy for transactions with a low per-minute limit and no price or sizing exposure, such as sub-account creation. |
Functions
|
Create a |
|
Create a session for one pre-signed, persisted transaction. |
|
Read a |
Classes
Backoff settings for |
|
Exponential backoff for all HTTP traffic of the official Lighter SDK. |
|
A |
|
Send one pre-signed transaction, resending it only after a rate limit. |
- LIGHTER_RATE_LIMIT_SQLITE_DATABASE: pathlib.Path = PosixPath('/home/runner/.tradingstrategy/lighter/rate-limit.sqlite')
Default SQLite database path for rate limiting state.
Using SQLite ensures thread-safe rate limiting across multiple threads when using
joblib.Parallelor similar parallel processing.
- DEFAULT_RETRIES: int = 8
Default number of retries for API requests.
With
DEFAULT_BACKOFF_FACTORthe waits total about 127 seconds, which outlasts Lighter’s 60-second firewall cooldown.
- LIGHTER_RATE_LIMIT_STATUSES: frozenset[int] = frozenset({405, 429})
Statuses Lighter documents for an exceeded rate limit.
- LIGHTER_RETRYABLE_READ_STATUSES: frozenset[int] = frozenset({405, 429, 500, 502, 503, 504})
Statuses retried for a read.
- LIGHTER_SEND_TX_PATH: str = '/api/v1/sendTx'
The only mutation path
LighterSDKSessionretries.
- LIGHTER_SUBMISSION_DEADLINE: float = 15.0
Seconds after which a pre-signed submission is not attempted again.
Short because signed pool transactions have no USDC slippage limit and their sizing comes from an observation at most 30 seconds old.
- parse_lighter_retry_after(value)
Read a
Retry-Afterheader without trusting its format.Lighter does not document this header, so an unusable value must not turn a rate limit into a crash. urllib3’s parser covers both forms the header allows, seconds and an HTTP date. See RFC 9110.
- class LighterSDKRetryPolicy
Bases:
objectBackoff settings for
LighterSDKSession.Deadlines are measured from the first attempt. No new attempt starts if its wait would pass the deadline, so a call overruns by at most one request.
- max_delay: float
Longest computed wait between attempts, in seconds, including jitter. Longer than the firewall cooldown. A larger
Retry-Aftertakes precedence.
- LIGHTER_SDK_DEFAULT_POLICY = LighterSDKRetryPolicy(initial_delay=1.0, max_delay=64.0, read_deadline=130.0, transaction_deadline=30.0, request_timeout=30.0)
Default policy for reads and live transactions.
- LIGHTER_SDK_SLOW_TRANSACTION_POLICY = LighterSDKRetryPolicy(initial_delay=1.0, max_delay=64.0, read_deadline=130.0, transaction_deadline=300.0, request_timeout=30.0)
Policy for transactions with a low per-minute limit and no price or sizing exposure, such as sub-account creation. A signed transaction stays valid for longer than this deadline.
- class LighterSession
Bases:
requests.sessions.SessionA
requests.Sessionsubclass that carries the Lighter API URL.All Lighter API functions accept a
LighterSessionand readapi_urlfrom it, removing the need for a separateapi_urlargument on every call.Use
create_lighter_session()to create instances.- __init__(api_url=None, deployment=LighterAPIConfig(slug='ethereum', name='Lighter Ethereum', chain_id=9998, deployment_chain_id=1, api_url='https://mainnet.zklighter.elliot.ai', app_url='https://app.lighter.xyz', address_prefix='lighter-pool', denomination='USDC', lockup=datetime.timedelta(seconds=300), llp_account_index_override=None))
- Parameters
deployment (eth_defi.lighter.constants.LighterAPIConfig) –
- deployment: eth_defi.lighter.constants.LighterAPIConfig
Deployment whose API and vault namespace this session accesses.
- close()
Closes all adapters and as such the session
- delete(url, **kwargs)
Sends a DELETE request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- get(url, **kwargs)
Sends a GET request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- get_adapter(url)
Returns the appropriate connection adapter for the given URL.
- Return type
requests.adapters.BaseAdapter
- get_redirect_target(resp)
Receives a Response. Returns a redirect URI or
None
- head(url, **kwargs)
Sends a HEAD request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- merge_environment_settings(url, proxies, stream, verify, cert)
Check the environment and merge it with some settings.
- Return type
- mount(prefix, adapter)
Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
- options(url, **kwargs)
Sends a OPTIONS request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- patch(url, data=None, **kwargs)
Sends a PATCH request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- post(url, data=None, json=None, **kwargs)
Sends a POST request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.json – (optional) json to send in the body of the
Request.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- prepare_request(request)
Constructs a
PreparedRequestfor transmission and returns it. ThePreparedRequesthas settings merged from theRequestinstance and those of theSession.- Parameters
request –
Requestinstance to prepare with this session’s settings.- Return type
requests.PreparedRequest
- put(url, data=None, **kwargs)
Sends a PUT request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- rebuild_auth(prepared_request, response)
When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss.
- rebuild_method(prepared_request, response)
When being redirected we may want to change the method of the request based on certain specs or browser behavior.
- rebuild_proxies(prepared_request, proxies)
This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect).
This method also replaces the Proxy-Authorization header where necessary.
- Return type
- request(method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None, json=None)
Constructs a
Request, prepares it and sends it. ReturnsResponseobject.- Parameters
method – method for the new
Requestobject.url – URL for the new
Requestobject.params – (optional) Dictionary or bytes to be sent in the query string for the
Request.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.json – (optional) json to send in the body of the
Request.headers – (optional) Dictionary of HTTP Headers to send with the
Request.cookies – (optional) Dict or CookieJar object to send with the
Request.files – (optional) Dictionary of
'filename': file-like-objectsfor multipart encoding upload.auth – (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth.
timeout (float or tuple) – (optional) How many seconds to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
allow_redirects (bool) – (optional) Set to True by default.
proxies – (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy.
hooks – (optional) Dictionary mapping hook name to one event or list of events, event must be callable.
stream – (optional) whether to immediately download the response content. Defaults to
False.verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to
True. When set toFalse, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify toFalsemay be useful during local development or testing.cert – (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.
- Return type
requests.Response
- resolve_redirects(resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs)
Receives a Response. Returns a generator of Responses or Requests.
- send(request, **kwargs)
Send a given PreparedRequest.
- Return type
requests.Response
- should_strip_auth(old_url, new_url)
Decide whether Authorization header should be removed when redirecting
- headers
A case-insensitive dictionary of headers to be sent on each
Requestsent from thisSession.
- auth
Default Authentication tuple or object to attach to
Request.
- proxies
Dictionary mapping protocol or protocol and host to the URL of the proxy (e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’}) to be used on each
Request.
- hooks
Event-handling hooks.
- params
Dictionary of querystring data to attach to each
Request. The dictionary values may be lists for representing multivalued query parameters.
- stream
Stream response content default.
- verify
SSL Verification default. Defaults to True, requiring requests to verify the TLS certificate at the remote end. If verify is set to False, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Only set this to False for testing.
- cert
SSL client certificate default, if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.
- max_redirects
Maximum number of redirects allowed. If the request exceeds this limit, a
TooManyRedirectsexception is raised. This defaults to requests.models.DEFAULT_REDIRECT_LIMIT, which is 30.
- trust_env
Trust environment settings for proxy configuration, default authentication and similar.
- cookies
A CookieJar containing all currently outstanding cookies set on this session. By default it is a
RequestsCookieJar, but may be any othercookielib.CookieJarcompatible object.
- class LighterSDKSession
Bases:
objectExponential backoff for all HTTP traffic of the official Lighter SDK.
The SDK sends everything through
ApiClient.rest_client.request()usingaiohttp, soLighterSessioncannot see it. This class replacesrest_clientby composition, which keeps the optional SDK out of eth-defi’s imports. It does not change the SDK’s error handling: the final response is returned unchanged and the SDK raises its usualApiException.Retrying here rather than around a signer method matters. The SDK does not roll its nonce back when a 429 escapes, so a retry above this layer would sign again with a later nonce. Here the same signed body is resent, so the nonce and the transaction hash do not change.
Which requests are retried:
GETandHEAD:LIGHTER_RETRYABLE_READ_STATUSES, and connection, timeout or body-read errors.POSTtoLIGHTER_SEND_TX_PATH:LIGHTER_RATE_LIMIT_STATUSESonly. The resend carries the same nonce, so the sequencer cannot execute it twice. A 5xx or a timeout leaves the outcome unknown and is never retried.Anything else: never.
The SDK holds its per-key nonce lock during a wait. That keeps transactions in nonce order, and clients are built per operation, so nothing else is blocked.
Authenticated Lighter requests can carry a token in the query string, and bodies hold signed transactions, so logs only name the method and URL path.
The native Go signer has its own HTTP client, which this class cannot wrap. It is used when an SDK transaction method receives
api_key_indexwithout anonce, and bySignerClient.check_client(). Do not call them that way: omitapi_key_indexand the Python nonce manager fetches the nonce through this class.See Lighter’s rate limits and the SDK’s REST client.
- rest_client: Any
The SDK’s
RESTClientObject.
- policy: eth_defi.lighter.session.LighterSDKRetryPolicy
Delays and deadlines.
- clock: collections.abc.Callable[[], float]
Monotonic clock, injectable for deterministic tests.
- sleep: collections.abc.Callable[[float], collections.abc.Awaitable[None]]
Async sleep, injectable for deterministic tests.
- async close()
Close the wrapped SDK client.
- Return type
None
- async request(method, url, headers=None, body=None, post_params=None, _request_timeout=None)
Send one SDK request, matching
RESTClientObject.request().The body is read here because the SDK reads it only after this returns, which would leave a truncated read outside the retries.
RESTResponsecaches it, so the SDK’s later read returns the same bytes.- Parameters
- Returns
SDK
RESTResponsewith its body read.- Return type
- __init__(rest_client, policy=LighterSDKRetryPolicy(initial_delay=1.0, max_delay=64.0, read_deadline=130.0, transaction_deadline=30.0, request_timeout=30.0), clock=<built-in function monotonic>, sleep=<function sleep>)
- Parameters
rest_client (Any) –
clock (collections.abc.Callable[[], float]) –
sleep (collections.abc.Callable[[float], collections.abc.Awaitable[None]]) –
- Return type
None
- class LighterSubmissionSession
Bases:
eth_defi.lighter.session.LighterSessionSend one pre-signed transaction, resending it only after a rate limit.
A pool executor persists a transaction before posting it and reconciles an uncertain outcome by hash, so nothing here may replay one. Only
LIGHTER_RATE_LIMIT_STATUSESare retried. Connection and read errors, and every other status, reach the caller after one attempt.No attempt starts after a wall-clock deadline, because a slow refusal must not lead to a replay of stale sizing. Each attempt’s timeout is the time remaining.
requestsapplies it to the connection and the read separately, so an attempt already under way can finish slightly late, which cannot cause a replay. The loop lives here rather than in a urllib3Retry, which only counts attempts and which retries a 413 or 503 carryingRetry-Afterwhatever its status list says.This session has no client-side limiter: a submission is a single request.
See the sendTx API reference.
Create the session without retry adapters.
- Parameters
api_url – Optional Lighter API base URL override.
deployment – Deployment whose API this session accesses.
deadline – Seconds after which
post()starts no further attempt.
- __init__(api_url=None, deployment=LighterAPIConfig(slug='ethereum', name='Lighter Ethereum', chain_id=9998, deployment_chain_id=1, api_url='https://mainnet.zklighter.elliot.ai', app_url='https://app.lighter.xyz', address_prefix='lighter-pool', denomination='USDC', lockup=datetime.timedelta(seconds=300), llp_account_index_override=None), deadline=15.0)
Create the session without retry adapters.
- Parameters
api_url (Optional[str]) – Optional Lighter API base URL override.
deployment (eth_defi.lighter.constants.LighterAPIConfig) – Deployment whose API this session accesses.
deadline (float) – Seconds after which
post()starts no further attempt.
- close()
Closes all adapters and as such the session
- delete(url, **kwargs)
Sends a DELETE request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- get(url, **kwargs)
Sends a GET request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- get_adapter(url)
Returns the appropriate connection adapter for the given URL.
- Return type
requests.adapters.BaseAdapter
- get_redirect_target(resp)
Receives a Response. Returns a redirect URI or
None
- head(url, **kwargs)
Sends a HEAD request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- merge_environment_settings(url, proxies, stream, verify, cert)
Check the environment and merge it with some settings.
- Return type
- mount(prefix, adapter)
Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
- options(url, **kwargs)
Sends a OPTIONS request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- patch(url, data=None, **kwargs)
Sends a PATCH request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- post(url, data=None, **kwargs)
Post a signed transaction within the deadline.
- Parameters
- Returns
The final response. A rate limit that outlasts the deadline is returned for the caller to handle.
- Return type
requests.models.Response
- prepare_request(request)
Constructs a
PreparedRequestfor transmission and returns it. ThePreparedRequesthas settings merged from theRequestinstance and those of theSession.- Parameters
request –
Requestinstance to prepare with this session’s settings.- Return type
requests.PreparedRequest
- put(url, data=None, **kwargs)
Sends a PUT request. Returns
Responseobject.- Parameters
url – URL for the new
Requestobject.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.**kwargs – Optional arguments that
requesttakes.
- Return type
requests.Response
- rebuild_auth(prepared_request, response)
When being redirected we may want to strip authentication from the request to avoid leaking credentials. This method intelligently removes and reapplies authentication where possible to avoid credential loss.
- rebuild_method(prepared_request, response)
When being redirected we may want to change the method of the request based on certain specs or browser behavior.
- rebuild_proxies(prepared_request, proxies)
This method re-evaluates the proxy configuration by considering the environment variables. If we are redirected to a URL covered by NO_PROXY, we strip the proxy configuration. Otherwise, we set missing proxy keys for this URL (in case they were stripped by a previous redirect).
This method also replaces the Proxy-Authorization header where necessary.
- Return type
- request(method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None, json=None)
Constructs a
Request, prepares it and sends it. ReturnsResponseobject.- Parameters
method – method for the new
Requestobject.url – URL for the new
Requestobject.params – (optional) Dictionary or bytes to be sent in the query string for the
Request.data – (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the
Request.json – (optional) json to send in the body of the
Request.headers – (optional) Dictionary of HTTP Headers to send with the
Request.cookies – (optional) Dict or CookieJar object to send with the
Request.files – (optional) Dictionary of
'filename': file-like-objectsfor multipart encoding upload.auth – (optional) Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth.
timeout (float or tuple) – (optional) How many seconds to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
allow_redirects (bool) – (optional) Set to True by default.
proxies – (optional) Dictionary mapping protocol or protocol and hostname to the URL of the proxy.
hooks – (optional) Dictionary mapping hook name to one event or list of events, event must be callable.
stream – (optional) whether to immediately download the response content. Defaults to
False.verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to
True. When set toFalse, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Setting verify toFalsemay be useful during local development or testing.cert – (optional) if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.
- Return type
requests.Response
- resolve_redirects(resp, req, stream=False, timeout=None, verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs)
Receives a Response. Returns a generator of Responses or Requests.
- send(request, **kwargs)
Send a given PreparedRequest.
- Return type
requests.Response
- should_strip_auth(old_url, new_url)
Decide whether Authorization header should be removed when redirecting
- deployment: eth_defi.lighter.constants.LighterAPIConfig
Deployment whose API and vault namespace this session accesses.
- headers
A case-insensitive dictionary of headers to be sent on each
Requestsent from thisSession.
- auth
Default Authentication tuple or object to attach to
Request.
- proxies
Dictionary mapping protocol or protocol and host to the URL of the proxy (e.g. {‘http’: ‘foo.bar:3128’, ‘http://host.name’: ‘foo.bar:4012’}) to be used on each
Request.
- hooks
Event-handling hooks.
- params
Dictionary of querystring data to attach to each
Request. The dictionary values may be lists for representing multivalued query parameters.
- stream
Stream response content default.
- verify
SSL Verification default. Defaults to True, requiring requests to verify the TLS certificate at the remote end. If verify is set to False, requests will accept any TLS certificate presented by the server, and will ignore hostname mismatches and/or expired certificates, which will make your application vulnerable to man-in-the-middle (MitM) attacks. Only set this to False for testing.
- cert
SSL client certificate default, if String, path to ssl client cert file (.pem). If Tuple, (‘cert’, ‘key’) pair.
- max_redirects
Maximum number of redirects allowed. If the request exceeds this limit, a
TooManyRedirectsexception is raised. This defaults to requests.models.DEFAULT_REDIRECT_LIMIT, which is 30.
- trust_env
Trust environment settings for proxy configuration, default authentication and similar.
- cookies
A CookieJar containing all currently outstanding cookies set on this session. By default it is a
RequestsCookieJar, but may be any othercookielib.CookieJarcompatible object.
- create_lighter_session(api_url=None, retries=8, backoff_factor=0.5, max_retry_duration=None, requests_per_second=2.0, pool_maxsize=32, rate_limit_db_path=PosixPath('/home/runner/.tradingstrategy/lighter/rate-limit.sqlite'), deployment=LighterAPIConfig(slug='ethereum', name='Lighter Ethereum', chain_id=9998, deployment_chain_id=1, api_url='https://mainnet.zklighter.elliot.ai', app_url='https://app.lighter.xyz', address_prefix='lighter-pool', denomination='USDC', lockup=datetime.timedelta(seconds=300), llp_account_index_override=None))
Create a
LighterSessionconfigured for Lighter API.The session is configured with:
The API URL stored in
LighterSession.api_urlRate limiting to respect Lighter API throttling (thread-safe via SQLite)
Retry logic for handling transient errors using exponential backoff
Only idempotent reads are retried.
LoggingRetryleaves POST out by default. SDK traffic is not covered: seeLighterSDKSession.The rate limiter uses SQLite backend for thread-safe coordination across multiple threads (e.g., when using
joblib.Parallelwith threading backend).Example:
from eth_defi.lighter.session import create_lighter_session session = create_lighter_session()
- Parameters
api_url (Optional[str]) – Optional Lighter API base URL override. Defaults to the configured deployment URL.
retries (Optional[int]) – Maximum number of retry attempts for failed requests.
Nonebounds retries bymax_retry_durationalone.backoff_factor (float) – Backoff factor for exponential retry delays.
max_retry_duration (Optional[float]) – Optional seconds after the first failure during which a request is retried. Live executors set this to ride out a Lighter API outage instead of failing a fail-closed valuation after a few seconds. See
max_retry_duration.requests_per_second (float) – Maximum requests per second to avoid rate limiting.
pool_maxsize (int) – Maximum number of connections to keep in the connection pool. Should be at least as large as
max_workerswhen using parallel requests.rate_limit_db_path (pathlib.Path) – Path to SQLite database for storing rate limit state. Using SQLite ensures thread-safe rate limiting across multiple threads.
deployment (eth_defi.lighter.constants.LighterAPIConfig) – Deployment whose pool namespace this session accesses. Defaults to the backwards-compatible Ethereum deployment.
- Returns
Configured
LighterSessionwith rate limiting and retry logic.- Return type
- create_lighter_submission_session(api_url=None, deployment=LighterAPIConfig(slug='ethereum', name='Lighter Ethereum', chain_id=9998, deployment_chain_id=1, api_url='https://mainnet.zklighter.elliot.ai', app_url='https://app.lighter.xyz', address_prefix='lighter-pool', denomination='USDC', lockup=datetime.timedelta(seconds=300), llp_account_index_override=None), deadline=15.0)
Create a session for one pre-signed, persisted transaction.
- Parameters
api_url (Optional[str]) – Optional Lighter API base URL override.
deployment (eth_defi.lighter.constants.LighterAPIConfig) – Deployment whose API this session accesses.
deadline (float) – Seconds after which
post()starts no further attempt.
- Returns
Session whose
post()retries rate limits only, within the deadline.- Return type