pub struct PolymarketPositionClient { /* private fields */ }Expand description
Deposit Wallet client for split, merge, and redeem position operations.
Implementations§
Source§impl PolymarketPositionClient
impl PolymarketPositionClient
Sourcepub fn new(
private_key: &EvmPrivateKey,
deposit_wallet: &str,
relayer_api_key: RelayerApiKey,
base_url_relayer: Option<String>,
base_url_clob: Option<String>,
timeout_secs: Option<u64>,
proxy_url: Option<ProxyUrl>,
) -> Result<Self>
pub fn new( private_key: &EvmPrivateKey, deposit_wallet: &str, relayer_api_key: RelayerApiKey, base_url_relayer: Option<String>, base_url_clob: Option<String>, timeout_secs: Option<u64>, proxy_url: Option<ProxyUrl>, ) -> Result<Self>
Creates a Deposit Wallet position client.
§Errors
Returns an error if credentials are invalid, the deposit wallet is not distinct from the signer, or an HTTP client cannot be created.
Sourcepub fn with_rpc_url(self, rpc_url: String) -> Self
pub fn with_rpc_url(self, rpc_url: String) -> Self
Sets the Polygon RPC URL used to verify the Deposit Wallet before signing.
Sourcepub fn with_deadline_secs(self, deadline_secs: u64) -> Self
pub fn with_deadline_secs(self, deadline_secs: u64) -> Self
Sets the signed-batch deadline in seconds from now.
Defaults to 1,800 seconds; values below one second are raised to one. Longer deadlines extend the period in which a signed batch can execute and delay expiry-based recovery of an unknown submission. The wait timeout does not shorten this deadline or cancel the signed batch.
Sourcepub fn with_wait_timeout(self, wait_timeout: Duration) -> Self
pub fn with_wait_timeout(self, wait_timeout: Duration) -> Self
Sets how long PolymarketPositionTransaction::wait polls before timing out.
Sourcepub fn with_poll_interval(self, poll_interval: Duration) -> Self
pub fn with_poll_interval(self, poll_interval: Duration) -> Self
Sets the Relayer poll interval used by PolymarketPositionTransaction::wait.
Sourcepub async fn split_position(
&self,
condition_id: &str,
amount: Decimal,
) -> Result<PolymarketPositionTransaction>
pub async fn split_position( &self, condition_id: &str, amount: Decimal, ) -> Result<PolymarketPositionTransaction>
Splits amount pUSD into a complete set of outcome tokens.
§Errors
Returns an error if market metadata or encoding is invalid, V2 balance or Router permission checks fail, or Relayer submission is rejected or ambiguous.
Sourcepub async fn merge_positions(
&self,
condition_id: &str,
amount: Decimal,
) -> Result<PolymarketPositionTransaction>
pub async fn merge_positions( &self, condition_id: &str, amount: Decimal, ) -> Result<PolymarketPositionTransaction>
Merges amount complete sets of outcome tokens back into pUSD.
§Errors
Returns an error if market metadata or encoding is invalid, V2 balance or Router permission checks fail, or Relayer submission is rejected or ambiguous.
Sourcepub async fn redeem_positions(
&self,
condition_id: &str,
) -> Result<PolymarketPositionTransaction>
pub async fn redeem_positions( &self, condition_id: &str, ) -> Result<PolymarketPositionTransaction>
Redeems both CTF binary outcome balances for a resolved market.
§Errors
Returns an error if the market is V2, metadata or encoding is invalid, or Relayer submission is rejected or ambiguous.
Sourcepub async fn redeem_positions_batch(
&self,
condition_ids: &[&str],
) -> Result<PolymarketPositionTransaction>
pub async fn redeem_positions_batch( &self, condition_ids: &[&str], ) -> Result<PolymarketPositionTransaction>
Redeems CTF conditions in one ordered Deposit Wallet batch.
Preserves input order and duplicates. The caller chooses the batch size, subject to Relayer limits. All conditions are prepared before signing. Preparation errors retain their original type; a warning identifies the failing condition and its zero-based input index.
§Errors
Returns an error if input is empty, a market is unsupported or invalid, or submission is rejected or ambiguous. The returned transaction reports one outcome for the entire batch.
Sourcepub async fn redeem_position(
&self,
condition_id: &str,
outcome_index: u8,
amount: Decimal,
) -> Result<PolymarketPositionTransaction>
pub async fn redeem_position( &self, condition_id: &str, outcome_index: u8, amount: Decimal, ) -> Result<PolymarketPositionTransaction>
Redeems an explicit amount of V2 outcome index 0 or 1.
The index is the position ID’s final byte, independent of CLOB token-array order. Amounts are exact six-decimal share quantities. A zero losing payout is redeemable; a reverted or unavailable payout read fails before submission.
§Errors
Returns an error if metadata is unsupported, amounts or outcomes are invalid, Router permissions are missing, balances are insufficient, payout reads fail, or submission is rejected or ambiguous.
Sourcepub async fn approve_v2_trading(
&self,
collateral_limit: Decimal,
) -> Result<PolymarketPositionTransaction>
pub async fn approve_v2_trading( &self, collateral_limit: Decimal, ) -> Result<PolymarketPositionTransaction>
Approves ExchangeV3 trading from the Deposit Wallet holding the assets.
collateral_limit is an explicit pUSD limit covering BUY spend plus fees. The same batch
enables ExchangeV3 to transfer V2 positions for SELL orders. It does not redeem positions.
The Relayer requires unlimited ExchangeV3 approvals and rejects this bounded request.
V2 trading from a Deposit Wallet therefore requires existing approvals.
§Errors
Returns an error if the limit is invalid, wallet verification fails, or Relayer submission is rejected or ambiguous. A pending wallet submission must be reconciled before retrying.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PolymarketPositionClient
impl !RefUnwindSafe for PolymarketPositionClient
impl !UnwindSafe for PolymarketPositionClient
impl Send for PolymarketPositionClient
impl Sync for PolymarketPositionClient
impl Unpin for PolymarketPositionClient
impl UnsafeUnpin for PolymarketPositionClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more