polymarketcontracts

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 26 Imported by: 1

README

Polymarket Go Contracts

A Go library for interacting with Polymarket smart contracts on Polygon network. This library provides a convenient interface for trading on Polymarket using both EOA (Externally Owned Account) and Gnosis Safe wallets.

Features

  • 🔐 Support for both EOA and Gnosis Safe signers
  • 🔄 Complete trading operations (enable trading, split, merge, redeem)
  • 🏭 Safe deployment and management
  • 🔌 MPC wallet integration (Cobo MPC)
  • ⚡ Built on go-ethereum
  • 🚀 Enhanced transaction inclusion speed (1.3x gas price multiplier)

Installation

go get github.com/ivanzzeth/polymarket-go-contracts

Quick Start

EOA Signer (Direct Private Key)

EOA signer allows you to interact with Polymarket directly using a private key. This is the simplest approach for individual accounts.

package main

import (
    "github.com/ethereum/go-ethereum/crypto"
    "github.com/ethereum/go-ethereum/ethclient"
    "github.com/ivanzzeth/ethsig"
    polymarketcontracts "github.com/ivanzzeth/polymarket-go-contracts"
)

func main() {
    // Connect to Polygon RPC
    client, _ := ethclient.Dial(os.Getenv("RPC_URL"))

    // Load private key
    privateKey, _ := crypto.HexToECDSA(os.Getenv("PRIVATE_KEY"))

    // Create EOA signer
    eoaSigner := ethsig.NewEthPrivateKeySigner(privateKey)

    // Initialize contract interface
    config := polymarketcontracts.GetContractConfig(big.NewInt(137)) // Polygon mainnet
    polymarketInterface, _ := polymarketcontracts.NewContractInterface(
        client,
        polymarketcontracts.WithContractConfig(config),
        polymarketcontracts.WithEOASigner(eoaSigner),
    )

    // Enable trading
    ctx := context.Background()
    txHashes, _ := polymarketInterface.EnableTrading(ctx)
}
Safe Signer (Gnosis Safe Single-Owner)

Safe signer uses Gnosis Safe with a single owner for fund isolation and simplified protocol interaction. Transactions are signed using EIP-712 typed data signatures and executed through the Safe proxy contract.

package main

import (
    "github.com/ethereum/go-ethereum/crypto"
    "github.com/ethereum/go-ethereum/ethclient"
    polymarketcontracts "github.com/ivanzzeth/polymarket-go-contracts"
    "github.com/ivanzzeth/polymarket-go-contracts/signer"
)

func main() {
    // Connect to Polygon RPC
    client, _ := ethclient.Dial(os.Getenv("RPC_URL"))
    chainID, _ := client.ChainID(context.Background())

    // Load private key
    privateKey, _ := crypto.HexToECDSA(os.Getenv("PRIVATE_KEY"))

    // Create Safe signer
    safeSigner, _ := signer.NewSafeTradingPrivateKeySigner(chainID, client, privateKey)

    // Initialize contract interface
    config := polymarketcontracts.GetContractConfig(big.NewInt(137))
    polymarketInterface, _ := polymarketcontracts.NewContractInterface(
        client,
        polymarketcontracts.WithContractConfig(config),
        polymarketcontracts.WithSafeSigner(safeSigner),
    )

    // Deploy Safe (first time only)
    safeProxy, txHash, _ := polymarketInterface.DeploySafe()

    // Enable trading through Safe
    ctx := context.Background()
    txHashes, _ := polymarketInterface.EnableTrading(ctx)
}

EOA vs Safe: Key Differences

Feature EOA Signer Safe Signer
Setup Direct private key usage Requires Safe deployment
Owner Model Single private key Single owner (via Safe proxy)
Transaction Cost Lower gas costs Higher gas costs (Safe proxy)
Signing Method Standard transaction signing EIP-712 typed data signatures
Primary Benefit Simplicity and low cost Fund isolation & protocol abstraction
Use Case Direct wallet interaction Isolated trading accounts
Recovery No built-in recovery Owner can be changed if needed
When to Use EOA Signer
  • Personal trading accounts
  • Quick prototyping and testing
  • Lower transaction costs are important
  • Direct wallet control is preferred
When to Use Safe Signer
  • Fund Isolation: Separate trading funds from main wallet
  • Protocol Abstraction: Simplified interaction with Polymarket contracts
  • MPC Integration: Use with MPC wallets (e.g., Cobo) for institutional security
  • Account Management: Easier to change ownership or upgrade
  • Professional Trading: Isolated accounts for different trading strategies

Environment Variables

# Required for all examples
RPC_URL=https://polygon-rpc.com
PRIVATE_KEY=your_private_key_hex

# Required for split/merge examples
CONDITION_ID=0x... # The condition ID from Polymarket
AMOUNT=100         # Amount in USDC (for split) or tokens (for merge)

# Required for MPC examples
COBO_PRIVATE_KEY=your_cobo_api_private_key
COBO_WALLET_ID=your_cobo_wallet_id
COBO_ADDRESS=your_mpc_wallet_address
COBO_ENV=dev  # or 'prod'

Examples

For complete, runnable examples, see the examples/ directory:

EOA Examples
  • enable_trading - Enable trading for an EOA account
    • Direct USDC and CTF token approvals
    • Simplest setup for individual traders
Safe Examples with Private Key
  • deploy_safe - Deploy a new Gnosis Safe (single-owner)

    • One-time setup for isolated trading account
    • Creates a Safe proxy with single owner for fund isolation
  • safe_enable_trading - Enable trading for a Safe wallet

    • Configures all necessary token approvals through Safe
    • Owner signs transactions via EIP-712
  • safe_split_position - Split USDC into conditional tokens via Safe

    • Locks USDC collateral and receives outcome tokens
    • Demonstrates position creation through Safe
  • safe_merge_positions - Merge conditional tokens back to USDC via Safe

    • Burns all outcome tokens to unlock USDC
    • Requires holding complete set of outcome tokens
Safe Examples with MPC (Cobo)
  • deploy_safe_for_mpc - Deploy Safe using Cobo MPC wallet

    • Single-owner Safe with MPC wallet as owner
    • Institutional-grade key management
  • enable_trading_for_mpc_safe - Enable trading for MPC Safe

    • Complete MPC-based Safe trading setup
    • Combines Safe fund isolation with MPC security

Running Examples

Basic Example (Enable Trading)
# Navigate to an example directory
cd examples/enable_trading

# Set environment variables
export RPC_URL=https://polygon-rpc.com
export PRIVATE_KEY=your_private_key_hex

# Run the example
go run main.go
Split/Merge Examples
# Navigate to split position example
cd examples/safe_split_position

# Set environment variables
export RPC_URL=https://polygon-rpc.com
export PRIVATE_KEY=your_private_key_hex
export CONDITION_ID=0x1234...  # Get from Polymarket market
export AMOUNT=100               # 100 USDC to split

# Run split
go run main.go

# Navigate to merge positions example
cd ../safe_merge_positions

# Set same environment variables
# Run merge (requires holding all outcome tokens)
go run main.go

Core Operations

Enable Trading

Sets up all required token approvals for trading on Polymarket:

  • USDC approvals for Exchange, NegRiskAdapter, and NegRiskExchange
  • CTF token approvals for the same contracts
txHashes, err := polymarketInterface.EnableTrading(ctx)
Split Position

Split collateral tokens into conditional tokens. The partition parameter is automatically set to [1, 2] for Polymarket's binary markets (Yes/No outcomes):

txHash, err := polymarketInterface.Split(ctx, conditionId, amount)
Merge Positions

Merge conditional tokens back to collateral. The partition parameter is automatically set to [1, 2] for Polymarket's binary markets:

txHash, err := polymarketInterface.Merge(ctx, conditionId, amount)
Redeem Positions

Redeem conditional tokens after market resolution. The indexSets parameter is automatically set to [1, 2] for Polymarket's binary markets:

txHash, err := polymarketInterface.Redeem(ctx, conditionId)

Architecture

polymarket-go-contracts/
├── interface.go              # Main contract interface
├── config.go                 # Contract addresses and configs
├── types.go                  # Type definitions
├── signer/                   # Signing implementations
│   ├── eoa_trading_signer.go     # EOA signer interface
│   ├── safe_trading_signer.go    # Safe signer implementations
│   ├── mpc_remote_signer.go      # Cobo MPC integration
│   └── transaction_sender.go     # Transaction sending logic
├── sender/                   # Transaction sender interface
├── contracts/                # Generated contract bindings
└── examples/                 # Complete usage examples

Supported Networks

  • Polygon Mainnet (Chain ID: 137)
  • Polygon Amoy Testnet (Chain ID: 80002)

Pre-configured contract addresses are available via GetContractConfig().

Security Considerations

  • Private Keys: Never commit private keys to version control
  • Environment Variables: Use .env files or secure secret management
  • Safe Wallets: Recommended for institutional use and large funds
  • MPC Wallets: Provide hardware-backed security for enterprise applications
  • Transaction Inclusion: The library automatically applies a 1.3x multiplier to suggested gas prices to improve transaction inclusion speed on Polygon network
  • Gas Estimation: Always verify gas costs before mainnet deployment

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions:

Documentation

Index

Constants

View Source
const COLLATERAL_TOKEN_DECIMALS = 6
View Source
const CONDITIONAL_TOKEN_DECIMALS = 6

Variables

View Source
var AMOY_CONTRACTS = &ContractConfig{
	Exchange:          common.HexToAddress("0xdFE02Eb6733538f8Ea35D585af8DE5958AD99E40"),
	NegRiskAdapter:    common.HexToAddress("0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"),
	NegRiskExchange:   common.HexToAddress("0xC5d563A36AE78145C45a50134d48A1215220f80a"),
	Collateral:        common.HexToAddress("0x9c4e1703476e875070ee25b56a58b008cfb8fa78"),
	ConditionalTokens: common.HexToAddress("0x69308FB512518e39F9b16112fA8d994F4e2Bf8bB"),
	SafeProxyFactory:  common.HexToAddress("0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b"),
}
View Source
var MATIC_CONTRACTS = &ContractConfig{
	Exchange:          common.HexToAddress("0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E"),
	NegRiskAdapter:    common.HexToAddress("0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296"),
	NegRiskExchange:   common.HexToAddress("0xC5d563A36AE78145C45a50134d48A1215220f80a"),
	Collateral:        common.HexToAddress("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"),
	ConditionalTokens: common.HexToAddress("0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"),
	SafeProxyFactory:  common.HexToAddress("0xaacFeEa03eb1561C4e67d661e40682Bd20E3541b"),
}

Functions

func BuildClobAuthTypedData

func BuildClobAuthTypedData(signer common.Address, chainID *big.Int, timestamp int64, nonce int) eip712.TypedData

BuildClobAuthTypedData builds the typed data for CLOB authentication

func BuildCreateProxyTypedData

func BuildCreateProxyTypedData(chainID *big.Int, safeFactory, paymentToken common.Address, payment *big.Int, paymentReceiver common.Address) eip712.TypedData

BuildCreateProxyTypedData builds the typed data for creating proxy of Safe

func BuildSafeTransactionTypedData

func BuildSafeTransactionTypedData(chainID *big.Int, safeAddr common.Address, to common.Address, value *big.Int, data []byte, operation SafeOperation, safeTxGas *big.Int, baseGas *big.Int, gasPrice *big.Int, gasToken common.Address, refundReceiver common.Address, nonce *big.Int) eip712.TypedData

BuildSafeTransactionTypedData builds the typed data for Gnosis Safe transaction This follows the standard Gnosis Safe EIP-712 SafeTx structure

Types

type BalanceAllowanceInfo

type BalanceAllowanceInfo struct {
	Balance                    *big.Int
	AllowanceExchange          *big.Int
	AllowanceConditionalTokens *big.Int
	AllowanceNegRiskAdapter    *big.Int
	AllowanceNegRiskExchange   *big.Int
	CTFApprovedExchange        bool
	CTFApprovedNegRiskAdapter  bool
	CTFApprovedNegRiskExchange bool
}

BalanceAllowanceInfo holds balance and allowance information

type ContractConfig

type ContractConfig struct {
	Collateral        common.Address // USDC token address
	ConditionalTokens common.Address // CTF contract address
	Exchange          common.Address // Exchange contract address
	NegRiskAdapter    common.Address // NegRisk adapter address
	NegRiskExchange   common.Address // NegRisk exchange address
	SafeProxyFactory  common.Address // Safe Proxy Factory address
}

ContractConfig holds all contract addresses for Polymarket

func GetContractConfig

func GetContractConfig(chainID *big.Int) *ContractConfig

type ContractInterface

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

func NewContractInterface

func NewContractInterface(
	client ethclient.EthClientInterface,
	options ...ContractInterfaceOption,
) (*ContractInterface, error)

func (*ContractInterface) CheckBalanceAndAllowance

func (b *ContractInterface) CheckBalanceAndAllowance(ctx context.Context, address common.Address) (*BalanceAllowanceInfo, error)

CheckBalanceAndAllowance checks the USDC balance and all allowances for the given address

func (*ContractInterface) CheckBalanceAndAllowanceAtBlock added in v0.1.0

func (b *ContractInterface) CheckBalanceAndAllowanceAtBlock(ctx context.Context, address common.Address, blockNumber *big.Int) (*BalanceAllowanceInfo, error)

CheckBalanceAndAllowanceAtBlock checks the USDC balance and all allowances for the given address at a specific block If blockNumber is nil, it uses the latest block

func (*ContractInterface) DeploySafe

func (b *ContractInterface) DeploySafe() (safeProxy common.Address, txHash common.Hash, err error)

func (*ContractInterface) DeploySafeBySender

func (b *ContractInterface) DeploySafeBySender(txSender sender.TransactionSender, signer ethsig.TypedDataSigner) (safeProxy common.Address, txHash common.Hash, err error)

func (*ContractInterface) DeploySafeWithSig

func (b *ContractInterface) DeploySafeWithSig(txSender sender.TransactionSender, chainID *big.Int, safeFactory, paymentToken common.Address, payment *big.Int, paymentReceiver common.Address, createSig safeproxyfactory.SafeProxyFactorySig) (safeProxy common.Address, txHash common.Hash, err error)

func (*ContractInterface) EnableTrading

func (b *ContractInterface) EnableTrading(ctx context.Context) ([]common.Hash, error)

func (*ContractInterface) EnableTradingForEOA

func (b *ContractInterface) EnableTradingForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
) ([]common.Hash, error)

EnableTradingForEOA enables trading for an EOA wallet by setting all required allowances This function directly calls contract methods without going through Safe

func (*ContractInterface) EnableTradingForSafe

func (b *ContractInterface) EnableTradingForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,

	chainID *big.Int,
) ([]common.Hash, error)

EnableTradingForSafe enables trading for a Safe wallet by setting all required allowances This function uses ExecuteTransactionBySafeAndSingleSigner to execute all approval operations

func (*ContractInterface) EstimateSafeTxGas

func (b *ContractInterface) EstimateSafeTxGas(safeAddr, to common.Address, value *big.Int, data []byte, operation SafeOperation) (*big.Int, error)

EstimateSafeTxGas estimates the gas required for a Safe transaction execution This uses simulateAndRevert to accurately estimate gas without requiring valid signatures

func (*ContractInterface) ExecuteTransactionBySafe

func (b *ContractInterface) ExecuteTransactionBySafe(txSender sender.TransactionSender, safeAddr common.Address, to common.Address, value *big.Int, data []byte, operation SafeOperation, safeTxGas *big.Int, baseGas *big.Int, gasPrice *big.Int, gasToken common.Address, refundReceiver common.Address, signatures []byte) (common.Hash, error)

func (*ContractInterface) ExecuteTransactionBySafeAndSingleSigner

func (b *ContractInterface) ExecuteTransactionBySafeAndSingleSigner(safeSigner signer.SafeTradingSigner, chainID *big.Int, safeAddr common.Address, to common.Address, value *big.Int, data []byte, operation SafeOperation, safeTxGas *big.Int) (common.Hash, error)

func (*ContractInterface) GetClient

GetClient returns the Ethereum client

func (*ContractInterface) GetCollateral

func (b *ContractInterface) GetCollateral() *erc20.Erc20

GetCollateral returns the Collateral (USDC) contract instance

func (*ContractInterface) GetConditionalTokens

func (b *ContractInterface) GetConditionalTokens() *conditional_tokens.ConditionalTokens

GetConditionalTokens returns the Conditional Tokens Framework contract instance

func (*ContractInterface) GetConfig

func (b *ContractInterface) GetConfig() *ContractConfig

GetConfig returns the contract configuration

func (*ContractInterface) GetEOATradingSigner

func (b *ContractInterface) GetEOATradingSigner() signer.EOATradingSigner

GetEOATradingSigner returns the EOA trading signer

func (*ContractInterface) GetExchange

func (b *ContractInterface) GetExchange() *exchange.Exchange

GetExchange returns the Exchange contract instance

func (*ContractInterface) GetExchangeFees

func (b *ContractInterface) GetExchangeFees() *exchangefees.ExchangeFees

GetExchangeFees returns the Exchange Fees contract instance

func (*ContractInterface) GetGnosisSafeL2

func (b *ContractInterface) GetGnosisSafeL2(safeAddress common.Address) (*gnosissafel2.GnosisSafeL2, error)

GetGnosisSafeL2 creates and returns a GnosisSafeL2 contract instance for the given Safe address

func (*ContractInterface) GetNegRisk

func (b *ContractInterface) GetNegRisk() *negrisk.NegRisk

GetNegRisk returns the NegRisk Exchange contract instance

func (*ContractInterface) GetNegRiskAdapter

func (b *ContractInterface) GetNegRiskAdapter() *negriskadapter.NegRiskAdapter

GetNegRiskAdapter returns the NegRisk Adapter contract instance

func (*ContractInterface) GetNegRiskFees

func (b *ContractInterface) GetNegRiskFees() *negriskfees.NegRiskFees

GetNegRiskFees returns the NegRisk Fees contract instance

func (*ContractInterface) GetSafeAddress

func (b *ContractInterface) GetSafeAddress(eoa common.Address) (common.Address, error)

func (*ContractInterface) GetSafeProxyFactory

func (b *ContractInterface) GetSafeProxyFactory() *safeproxyfactory.SafeProxyFactory

GetSafeProxyFactory returns the Safe Proxy Factory contract instance (may be nil)

func (*ContractInterface) GetSafeTradingSigner

func (b *ContractInterface) GetSafeTradingSigner() signer.SafeTradingSigner

GetSafeTradingSigner returns the Safe trading signer

func (*ContractInterface) GetSignatureType

func (b *ContractInterface) GetSignatureType() SignatureType

GetSignatureType returns the signature type used by this interface

func (*ContractInterface) GetTxSender

func (b *ContractInterface) GetTxSender() sender.TransactionSender

GetTxSender returns the transaction sender

func (*ContractInterface) Merge

func (b *ContractInterface) Merge(ctx context.Context, conditionId [32]byte, amount *big.Int) (common.Hash, error)

func (*ContractInterface) MergeNegRisk added in v0.1.2

func (b *ContractInterface) MergeNegRisk(ctx context.Context, conditionId [32]byte, amount *big.Int) (common.Hash, error)

func (*ContractInterface) MergePositionsForEOA

func (b *ContractInterface) MergePositionsForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
	conditionId [32]byte,
	partition []*big.Int,
	amount *big.Int,
) (common.Hash, error)

MergePositionsForEOA merges conditional tokens back into collateral for an EOA wallet

func (*ContractInterface) MergePositionsForSafe

func (b *ContractInterface) MergePositionsForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,
	chainID *big.Int,
	conditionId [32]byte,
	partition []*big.Int,
	amount *big.Int,
) (common.Hash, error)

MergePositionsForSafe merges conditional tokens back into collateral for a Safe wallet

func (*ContractInterface) MergePositionsNegRiskForEOA added in v0.1.2

func (b *ContractInterface) MergePositionsNegRiskForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
	conditionId [32]byte,
	amount *big.Int,
) (common.Hash, error)

MergePositionsNegRiskForEOA merges NegRisk market positions using EOA

func (*ContractInterface) MergePositionsNegRiskForSafe added in v0.1.2

func (b *ContractInterface) MergePositionsNegRiskForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,
	chainID *big.Int,
	conditionId [32]byte,
	amount *big.Int,
) (common.Hash, error)

MergePositionsNegRiskForSafe merges NegRisk market positions using Safe

func (*ContractInterface) PrintBalanceAndAllowance

func (b *ContractInterface) PrintBalanceAndAllowance(ctx context.Context, address common.Address) error

PrintBalanceAndAllowance prints the balance and allowance information in a user-friendly format

func (*ContractInterface) Redeem

func (b *ContractInterface) Redeem(ctx context.Context, conditionId [32]byte) (common.Hash, error)

func (*ContractInterface) RedeemNegRisk

func (b *ContractInterface) RedeemNegRisk(ctx context.Context, conditionId [32]byte, amounts []*big.Int) (common.Hash, error)

func (*ContractInterface) RedeemPositionsForEOA

func (b *ContractInterface) RedeemPositionsForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
	conditionId [32]byte,
	indexSets []*big.Int,
) (common.Hash, error)

RedeemPositionsForEOA redeems conditional tokens for a resolved market using EOA

func (*ContractInterface) RedeemPositionsForSafe

func (b *ContractInterface) RedeemPositionsForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,
	chainID *big.Int,
	conditionId [32]byte,
	indexSets []*big.Int,
) (common.Hash, error)

RedeemPositionsForSafe redeems conditional tokens for a resolved market using TransactionSender

func (*ContractInterface) RedeemPositionsNegRiskForEOA

func (b *ContractInterface) RedeemPositionsNegRiskForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
	conditionId [32]byte,
	amounts []*big.Int,
) (common.Hash, error)

RedeemPositionsNegRiskForEOA redeems NegRisk market positions using EOA

func (*ContractInterface) RedeemPositionsNegRiskForSafe

func (b *ContractInterface) RedeemPositionsNegRiskForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,
	chainID *big.Int,
	conditionId [32]byte,
	amounts []*big.Int,
) (common.Hash, error)

RedeemPositionsNegRiskForSafe redeems NegRisk market positions using TransactionSender

func (*ContractInterface) Split

func (b *ContractInterface) Split(ctx context.Context, conditionId [32]byte, amount *big.Int) (common.Hash, error)

func (*ContractInterface) SplitNegRisk added in v0.1.2

func (b *ContractInterface) SplitNegRisk(ctx context.Context, conditionId [32]byte, amount *big.Int) (common.Hash, error)

func (*ContractInterface) SplitPositionForEOA

func (b *ContractInterface) SplitPositionForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
	conditionId [32]byte,
	partition []*big.Int,
	amount *big.Int,
) (common.Hash, error)

SplitPositionForEOA splits collateral into conditional tokens for an EOA wallet

func (*ContractInterface) SplitPositionForSafe

func (b *ContractInterface) SplitPositionForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,
	chainID *big.Int,
	conditionId [32]byte,
	partition []*big.Int,
	amount *big.Int,
) (common.Hash, error)

SplitPositionForSafe splits collateral into conditional tokens for a Safe wallet

func (*ContractInterface) SplitPositionNegRiskForEOA added in v0.1.2

func (b *ContractInterface) SplitPositionNegRiskForEOA(
	ctx context.Context,
	eoaSigner signer.EOATradingSigner,
	conditionId [32]byte,
	amount *big.Int,
) (common.Hash, error)

SplitPositionNegRiskForEOA splits NegRisk market positions using EOA

func (*ContractInterface) SplitPositionNegRiskForSafe added in v0.1.2

func (b *ContractInterface) SplitPositionNegRiskForSafe(
	ctx context.Context,
	safeSigner signer.SafeTradingSigner,
	chainID *big.Int,
	conditionId [32]byte,
	amount *big.Int,
) (common.Hash, error)

SplitPositionNegRiskForSafe splits NegRisk market positions using Safe

type ContractInterfaceConfig

type ContractInterfaceConfig struct {
	SignatureType     SignatureType
	TxSender          sender.TransactionSender
	EOATradingSigner  signer.EOATradingSigner
	SafeTradingSigner signer.SafeTradingSigner

	ContractConfig *ContractConfig
}

type ContractInterfaceOption

type ContractInterfaceOption func(c *ContractInterfaceConfig)

func WithContractConfig

func WithContractConfig(cc *ContractConfig) ContractInterfaceOption

func WithEOASigner

func WithEOASigner(eoaSigner signer.EOATradingSigner) ContractInterfaceOption

func WithSafeSigner

func WithSafeSigner(safeSigner signer.SafeTradingSigner) ContractInterfaceOption

func WithTransactionSender

func WithTransactionSender(txSender sender.TransactionSender) ContractInterfaceOption

type SafeOperation

type SafeOperation uint8
const (
	SafeOperationCall         SafeOperation = 0
	SafeOperationDelegateCall SafeOperation = 1
)

type SignatureType

type SignatureType int

SignatureType represents the type of signature used for signing orders

const (
	SignatureTypeEOA            SignatureType = 0 // Externally Owned Account
	SignatureTypePolyProxy      SignatureType = 1 // Polymarket Proxy
	SignatureTypePolyGnosisSafe SignatureType = 2 // Polymarket Gnosis Safe
)

Signature type constants

Jump to

Keyboard shortcuts

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