Documentation
¶
Index ¶
- Constants
- Variables
- func BuildCreateProxyTypedData(chainID *big.Int, safeFactory, paymentToken common.Address, payment *big.Int, ...) eip712.TypedData
- func BuildSafeTransactionTypedData(chainID *big.Int, safeAddr common.Address, to common.Address, value *big.Int, ...) eip712.TypedData
- type BalanceAllowanceInfo
- type ContractConfig
- type ContractInterface
- func (b *ContractInterface) CheckBalanceAndAllowance(ctx context.Context, address common.Address) (*BalanceAllowanceInfo, error)
- func (b *ContractInterface) CheckBalanceAndAllowanceAtBlock(ctx context.Context, address common.Address, blockNumber *big.Int) (*BalanceAllowanceInfo, error)
- func (b *ContractInterface) DeploySafe() (safeProxy common.Address, txHash common.Hash, err error)
- func (b *ContractInterface) DeploySafeBySender(txSender sender.TransactionSender, signer ethsig.TypedDataSigner) (safeProxy common.Address, txHash common.Hash, err error)
- func (b *ContractInterface) DeploySafeWithSig(txSender sender.TransactionSender, chainID *big.Int, ...) (safeProxy common.Address, txHash common.Hash, err error)
- func (b *ContractInterface) EnableTrading(ctx context.Context) ([]common.Hash, error)
- func (b *ContractInterface) EnableTradingForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner) ([]common.Hash, error)
- func (b *ContractInterface) EnableTradingForSafe(ctx context.Context, safeSigner signer.SafeTradingSigner, chainID *big.Int) ([]common.Hash, error)
- func (b *ContractInterface) EstimateSafeTxGas(safeAddr, to common.Address, value *big.Int, data []byte, ...) (*big.Int, error)
- func (b *ContractInterface) ExecuteTransactionBySafe(txSender sender.TransactionSender, safeAddr common.Address, to common.Address, ...) (common.Hash, error)
- func (b *ContractInterface) ExecuteTransactionBySafeAndSingleSigner(safeSigner signer.SafeTradingSigner, chainID *big.Int, safeAddr common.Address, ...) (common.Hash, error)
- func (b *ContractInterface) GetClient() ethclient.EthClientInterface
- func (b *ContractInterface) GetCollateral() *erc20.Erc20
- func (b *ContractInterface) GetConditionalTokens() *conditional_tokens.ConditionalTokens
- func (b *ContractInterface) GetConfig() *ContractConfig
- func (b *ContractInterface) GetEOATradingSigner() signer.EOATradingSigner
- func (b *ContractInterface) GetExchange() *exchange.Exchange
- func (b *ContractInterface) GetGnosisSafeL2(safeAddress common.Address) (*gnosissafel2.GnosisSafeL2, error)
- func (b *ContractInterface) GetPositionBalance(ctx context.Context, owner common.Address, tokenID *big.Int) (*big.Int, error)
- func (b *ContractInterface) GetPositionBalanceBatch(ctx context.Context, owners []common.Address, tokenIDs []*big.Int) ([]*big.Int, error)
- func (b *ContractInterface) GetSafeAddress(eoa common.Address) (common.Address, error)
- func (b *ContractInterface) GetSafeProxyFactory() *safeproxyfactory.SafeProxyFactory
- func (b *ContractInterface) GetSafeTradingSigner() signer.SafeTradingSigner
- func (b *ContractInterface) GetSignatureType() SignatureType
- func (b *ContractInterface) GetTxSender() sender.TransactionSender
- func (b *ContractInterface) Merge(ctx context.Context, conditionId [32]byte, amount *big.Int) (common.Hash, error)
- func (b *ContractInterface) MergePositionsForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner, conditionId [32]byte, ...) (common.Hash, error)
- func (b *ContractInterface) MergePositionsForSafe(ctx context.Context, safeSigner signer.SafeTradingSigner, chainID *big.Int, ...) (common.Hash, error)
- func (b *ContractInterface) PrintBalanceAndAllowance(ctx context.Context, address common.Address) error
- func (b *ContractInterface) Redeem(ctx context.Context, conditionId [32]byte) (common.Hash, error)
- func (b *ContractInterface) RedeemPositionsForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner, conditionId [32]byte, ...) (common.Hash, error)
- func (b *ContractInterface) RedeemPositionsForSafe(ctx context.Context, safeSigner signer.SafeTradingSigner, chainID *big.Int, ...) (common.Hash, error)
- func (b *ContractInterface) Split(ctx context.Context, conditionId [32]byte, amount *big.Int) (common.Hash, error)
- func (b *ContractInterface) SplitPositionForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner, conditionId [32]byte, ...) (common.Hash, error)
- func (b *ContractInterface) SplitPositionForSafe(ctx context.Context, safeSigner signer.SafeTradingSigner, chainID *big.Int, ...) (common.Hash, error)
- type ContractInterfaceConfig
- type ContractInterfaceOption
- func WithContractConfig(cc *ContractConfig) ContractInterfaceOption
- func WithEOASigner(eoaSigner signer.EOATradingSigner) ContractInterfaceOption
- func WithSafeSigner(safeSigner signer.SafeTradingSigner) ContractInterfaceOption
- func WithTransactionSender(txSender sender.TransactionSender) ContractInterfaceOption
- type SafeOperation
- type SignatureType
Constants ¶
const COLLATERAL_TOKEN_DECIMALS = 18
const CONDITIONAL_TOKEN_DECIMALS = 18
Variables ¶
var BNB_CHAIN_CONTRACTS = &ContractConfig{ Exchange: common.HexToAddress("0xF99F5367ce708c66F0860B77B4331301A5597c86"), Collateral: common.HexToAddress("0x55d398326f99059fF775485246999027B3197955"), ConditionalTokens: common.HexToAddress("0x364d05055614B506e2b9A287E4ac34167204cA83"), SafeProxyFactory: common.HexToAddress("0xB99159aBF0bF59a512970586F38292f8b9029924"), }
BNB_CHAIN_CONTRACTS holds contract addresses for Probable Markets on BNB Chain Mainnet (Chain ID: 56) All addresses are from @prob/core SDK: addresses[56]
Functions ¶
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 // USDT/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 Probable Markets
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 ¶
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 (*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 (*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 (*ContractInterface) GetClient ¶
func (b *ContractInterface) GetClient() ethclient.EthClientInterface
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) 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) GetPositionBalance ¶
func (b *ContractInterface) GetPositionBalance(ctx context.Context, owner common.Address, tokenID *big.Int) (*big.Int, error)
GetPositionBalance queries the on-chain balance of a CTF position (ERC1155 token). This is the source of truth for position sizes since the API may have stale/cached data.
Parameters:
- ctx: Context for the request
- owner: The address that owns the position (typically the Safe wallet address)
- tokenID: The ERC1155 token ID (asset ID) of the position
Returns:
- *big.Int: The on-chain balance in wei (18 decimals)
- error: Returns error if the query fails
NOTE: The API position endpoint has a known caching issue where position sizes may not reflect recent on-chain changes (e.g., after merge/split operations). Always use this method to get the actual on-chain balance as source of truth.
func (*ContractInterface) GetPositionBalanceBatch ¶
func (b *ContractInterface) GetPositionBalanceBatch(ctx context.Context, owners []common.Address, tokenIDs []*big.Int) ([]*big.Int, error)
GetPositionBalanceBatch queries multiple CTF position balances in a single call. More efficient than calling GetPositionBalance multiple times.
Parameters:
- ctx: Context for the request
- owners: Array of owner addresses (can be the same address repeated)
- tokenIDs: Array of token IDs corresponding to each owner
Returns:
- []*big.Int: Array of balances in wei (18 decimals)
- error: Returns error if the query fails
func (*ContractInterface) GetSafeAddress ¶
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) 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) 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) 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) 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
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
Directories
¶
| Path | Synopsis |
|---|---|
|
contracts
|
|
|
examples
|
|
|
deploy_safe
command
|
|
|
deploy_safe_for_mpc
command
|
|
|
enable_trading
command
|
|
|
enable_trading_for_mpc_safe
command
|
|
|
safe_enable_trading
command
|
|
|
safe_merge_positions
command
|
|
|
safe_split_position
command
|
|