bridge

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package bridge provides a client for the Polymarket Bridge API.

Overview

The Bridge API manages cross-chain USDC bridge configuration, allowing users to configure their preferred bridge (Arbitrum, Base, Linea, Polygon zkEVM, etc.). All endpoints are public (no auth required).

Usage

client := bridge.New(bridge.Config{})  // defaults to bridge-api.polymarket.com

// Get all supported bridges
bridges, _ := client.GetBridges(ctx)

// Get user's configured bridge
config, _ := client.GetConfiguration(ctx, "0x...")

Default host: https://bridge-api.polymarket.com

Index

Constants

View Source
const DefaultHost = "https://bridge.polymarket.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainID

type ChainID int64

ChainID represents an EVM/SVM chain identifier that accepts both JSON numbers and quoted strings.

func (ChainID) MarshalJSON

func (c ChainID) MarshalJSON() ([]byte, error)

func (*ChainID) UnmarshalJSON

func (c *ChainID) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) *Client

New creates a Bridge API client.

func (*Client) CreateDepositAddress

func (c *Client) CreateDepositAddress(ctx context.Context, address string, out *DepositResponse) error

CreateDepositAddress generates a deposit address for the given wallet address to bridge assets into the Polymarket ecosystem.

func (*Client) GetQuote

func (c *Client) GetQuote(ctx context.Context, req QuoteRequest, out *QuoteResponse) error

GetQuote returns an estimated quote for bridging a specified amount of an asset.

func (*Client) GetStatus

func (c *Client) GetStatus(ctx context.Context, address string, out *StatusResponse) error

GetStatus checks the current bridging status for a given deposit address.

func (*Client) GetSupportedAssets

func (c *Client) GetSupportedAssets(ctx context.Context, out *SupportedAssetsResponse) error

GetSupportedAssets lists all assets supported by the Polymarket bridge.

func (*Client) Host

func (c *Client) Host() string

Host returns the configured Bridge API host.

func (*Client) Withdraw

func (c *Client) Withdraw(ctx context.Context, req WithdrawRequest, out *WithdrawResponse) error

Withdraw initiates a withdrawal (bridge-out) request for the specified asset and amount.

type Config

type Config struct {
	Host       string
	HTTPClient *http.Client
	UserAgent  string
}

Config configures a Bridge API client.

type DepositAddresses

type DepositAddresses struct {
	// EVM is the Ethereum-compatible deposit address.
	EVM string `json:"evm"`
	// SVM is the Solana-compatible deposit address.
	SVM string `json:"svm"`
	// BTC is the Bitcoin deposit address.
	BTC string `json:"btc"`
}

DepositAddresses holds deposit addresses across chain families.

type DepositRequest

type DepositRequest struct {
	// Address is the user's Polymarket proxy wallet.
	Address string `json:"address"`
}

DepositRequest is the body for creating deposit addresses.

type DepositResponse

type DepositResponse struct {
	// Address contains deposit addresses by chain family.
	Address DepositAddresses `json:"address"`
	// Note contains optional informational text.
	Note string `json:"note,omitempty"`
}

DepositResponse is returned after requesting deposit addresses.

type DepositTransaction

type DepositTransaction struct {
	// FromChainID is the source chain identifier.
	FromChainID ChainID `json:"fromChainId"`
	// FromTokenAddress is the source token contract address.
	FromTokenAddress string `json:"fromTokenAddress"`
	// FromAmountBaseUnit is the deposited amount in smallest units.
	FromAmountBaseUnit string `json:"fromAmountBaseUnit"`
	// ToChainID is the destination chain identifier.
	ToChainID ChainID `json:"toChainId"`
	// ToTokenAddress is the destination token contract address.
	ToTokenAddress string `json:"toTokenAddress"`
	// Status is the transaction processing status.
	Status string `json:"status"`
	// TxHash is the on-chain transaction hash.
	TxHash string `json:"txHash"`
	// CreatedTimeMs is when the transaction was created.
	CreatedTimeMs pmtypes.Uint64 `json:"createdTimeMs"`
}

DepositTransaction describes a single bridge deposit.

type EstimatedFeeBreakdown

type EstimatedFeeBreakdown struct {
	// AppFeeLabel is the application fee description.
	AppFeeLabel string `json:"appFeeLabel"`
	// AppFeePercent is the fee percentage of the transaction.
	AppFeePercent pmtypes.Float64 `json:"appFeePercent"`
	// AppFeeUSD is the application fee in USD.
	AppFeeUSD pmtypes.Float64 `json:"appFeeUsd"`
	// FillCostPercent is the liquidity provider cost percentage.
	FillCostPercent pmtypes.Float64 `json:"fillCostPercent"`
	// FillCostUSD is the liquidity provider cost in USD.
	FillCostUSD pmtypes.Float64 `json:"fillCostUsd"`
	// GasUSD is the estimated gas cost in USD.
	GasUSD pmtypes.Float64 `json:"gasUsd"`
	// MaxSlippage is the maximum expected slippage percentage.
	MaxSlippage pmtypes.Float64 `json:"maxSlippage"`
	// MinReceived is the minimum tokens received after fees.
	MinReceived pmtypes.Float64 `json:"minReceived"`
	// SwapImpact is the swap slippage percentage.
	SwapImpact pmtypes.Float64 `json:"swapImpact"`
	// SwapImpactUSD is the swap slippage in USD.
	SwapImpactUSD pmtypes.Float64 `json:"swapImpactUsd"`
	// TotalImpact is the total fee percentage.
	TotalImpact pmtypes.Float64 `json:"totalImpact"`
	// TotalImpactUSD is the total fee in USD.
	TotalImpactUSD pmtypes.Float64 `json:"totalImpactUsd"`
}

EstimatedFeeBreakdown describes the fees for a bridge quote.

type QuoteRequest

type QuoteRequest struct {
	// FromAmountBaseUnit is the source amount in smallest units.
	FromAmountBaseUnit string `json:"fromAmountBaseUnit"`
	// FromChainID is the source chain identifier.
	FromChainID ChainID `json:"fromChainId"`
	// FromTokenAddress is the source token contract address.
	FromTokenAddress string `json:"fromTokenAddress"`
	// RecipientAddress is the destination wallet address.
	RecipientAddress string `json:"recipientAddress"`
	// ToChainID is the destination chain identifier.
	ToChainID ChainID `json:"toChainId"`
	// ToTokenAddress is the destination token contract address.
	ToTokenAddress string `json:"toTokenAddress"`
}

QuoteRequest is the body for requesting a bridge quote.

type QuoteResponse

type QuoteResponse struct {
	// QuoteID is the unique quote identifier.
	QuoteID string `json:"quoteId"`
	// EstCheckoutTimeMs is the estimated time to receive funds.
	EstCheckoutTimeMs pmtypes.Uint64 `json:"estCheckoutTimeMs"`
	// EstFeeBreakdown lists all fees and costs.
	EstFeeBreakdown EstimatedFeeBreakdown `json:"estFeeBreakdown"`
	// EstInputUSD is the input value in USD.
	EstInputUSD pmtypes.Float64 `json:"estInputUsd"`
	// EstOutputUSD is the estimated output value in USD.
	EstOutputUSD pmtypes.Float64 `json:"estOutputUsd"`
	// EstToTokenBaseUnit is the estimated output in smallest units.
	EstToTokenBaseUnit string `json:"estToTokenBaseUnit"`
}

QuoteResponse is the estimated bridge checkout details.

type StatusResponse

type StatusResponse struct {
	// Transactions lists the user's bridge deposits.
	Transactions []DepositTransaction `json:"transactions"`
}

StatusResponse lists deposit transactions for a user.

type SupportedAsset

type SupportedAsset struct {
	// ChainID is the source chain identifier.
	ChainID ChainID `json:"chainId"`
	// ChainName is the human-readable chain name.
	ChainName string `json:"chainName"`
	// Token describes the token on this chain.
	Token Token `json:"token"`
	// MinCheckoutUSD is the minimum checkout amount in USD.
	MinCheckoutUSD pmtypes.Float64 `json:"minCheckoutUsd"`
}

SupportedAsset describes a bridgeable asset on a specific chain.

type SupportedAssetsResponse

type SupportedAssetsResponse struct {
	// SupportedAssets lists the bridgeable assets.
	SupportedAssets []SupportedAsset `json:"supportedAssets"`
	// Note contains optional informational text.
	Note string `json:"note,omitempty"`
}

SupportedAssetsResponse lists all bridgeable assets.

type Token

type Token struct {
	// Name is the token display name.
	Name string `json:"name"`
	// Symbol is the ticker symbol.
	Symbol string `json:"symbol"`
	// Address is the contract address.
	Address string `json:"address"`
	// Decimals is the token precision.
	Decimals pmtypes.Int `json:"decimals"`
}

Token describes a supported ERC-20 or SPL token.

type WithdrawRequest

type WithdrawRequest struct {
	// Address is the user's Polymarket proxy wallet.
	Address string `json:"address"`
	// ToChainID is the destination chain identifier.
	ToChainID ChainID `json:"toChainId"`
	// ToTokenAddress is the destination token contract address.
	ToTokenAddress string `json:"toTokenAddress"`
	// RecipientAddr is the external recipient address.
	RecipientAddr string `json:"recipientAddr"`
}

WithdrawRequest is the body for creating withdrawal addresses.

type WithdrawResponse

type WithdrawResponse struct {
	// Address contains withdrawal addresses by chain family.
	Address WithdrawalAddresses `json:"address"`
	// Note contains informational text.
	Note string `json:"note"`
}

WithdrawResponse is returned after requesting withdrawal addresses.

type WithdrawalAddresses

type WithdrawalAddresses struct {
	// EVM is the Ethereum-compatible withdrawal address.
	EVM string `json:"evm"`
	// SVM is the Solana-compatible withdrawal address.
	SVM string `json:"svm"`
	// BTC is the Bitcoin withdrawal address.
	BTC string `json:"btc"`
}

WithdrawalAddresses holds withdrawal addresses across chain families.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL