Documentation
¶
Index ¶
- Constants
- Variables
- func BuildClobAuthTypedData(signer common.Address, chainID *big.Int, timestamp int64, nonce int) eip712.TypedData
- 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) GetExchangeFees() *exchangefees.ExchangeFees
- func (b *ContractInterface) GetGnosisSafeL2(safeAddress common.Address) (*gnosissafel2.GnosisSafeL2, error)
- func (b *ContractInterface) GetNegRisk() *negrisk.NegRisk
- func (b *ContractInterface) GetNegRiskAdapter() *negriskadapter.NegRiskAdapter
- func (b *ContractInterface) GetNegRiskFees() *negriskfees.NegRiskFees
- 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) MergeNegRisk(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) MergePositionsNegRiskForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner, conditionId [32]byte, ...) (common.Hash, error)
- func (b *ContractInterface) MergePositionsNegRiskForSafe(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) RedeemNegRisk(ctx context.Context, conditionId [32]byte, amounts []*big.Int) (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) RedeemPositionsNegRiskForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner, conditionId [32]byte, ...) (common.Hash, error)
- func (b *ContractInterface) RedeemPositionsNegRiskForSafe(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) SplitNegRisk(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)
- func (b *ContractInterface) SplitPositionNegRiskForEOA(ctx context.Context, eoaSigner signer.EOATradingSigner, conditionId [32]byte, ...) (common.Hash, error)
- func (b *ContractInterface) SplitPositionNegRiskForSafe(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 = 6
const CONDITIONAL_TOKEN_DECIMALS = 6
Variables ¶
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"), }
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 (*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) 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 (*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) MergeNegRisk ¶ added in v0.1.2
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) RedeemNegRisk ¶
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) SplitNegRisk ¶ added in v0.1.2
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
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_merge_positions_negrisk
command
|
|
|
safe_split_position
command
|
|
|
safe_split_position_negrisk
command
|
|