-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add Bridge client #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds Bridge API integration to enable cross-chain deposits from EVM chains, Solana, and Bitcoin into USDC.e on Polygon for Polymarket accounts. However, the PR introduces critical bugs by referencing a non-existent Data class.
- Adds a new
Bridgeclient for handling cross-chain deposit operations - Introduces
Depositsresource with methods for generating deposit addresses and querying supported assets - Expands configuration to include bridge and data API endpoints
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
src/Bridge.php |
New Bridge API client class implementing cross-chain deposit functionality |
src/Resources/Bridge/Deposits.php |
New resource class with deposit address generation and supported assets querying methods |
src/Config.php |
Adds bridgeBaseUrl and dataBaseUrl configuration properties |
src/Client.php |
Integrates Bridge and Data clients with lazy initialization (Data class doesn't exist - critical bug) |
examples/bridge-deposit.php |
Comprehensive example demonstrating bridge deposit workflows |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function data(): Data | ||
| { | ||
| if ($this->dataClient === null) { | ||
| $this->dataClient = new Data($this->config); | ||
| } | ||
|
|
||
| return $this->dataClient; | ||
| } |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Data class does not exist in the codebase. This method should be removed, or the Data class needs to be created.
| class Deposits extends Resource | ||
| { | ||
| /** | ||
| * Generate deposit addresses for bridging assets to Polygon USDC.e. | ||
| * | ||
| * Returns deposit addresses for each supported chain type (EVM, Solana, Bitcoin). | ||
| * Users can send assets to these addresses, which will be automatically bridged | ||
| * to USDC.e on Polygon for trading on Polymarket. | ||
| * | ||
| * @param array<string, mixed> $depositData Deposit request data (amount, destinationAddress, etc.) | ||
| * | ||
| * @return array<string, mixed> Deposit addresses for each chain | ||
| * { | ||
| * "evm": "0x...", | ||
| * "solana": "...", | ||
| * "bitcoin": "..." | ||
| * } | ||
| * | ||
| * @throws PolymarketException | ||
| */ | ||
| public function generate(array $depositData): array | ||
| { | ||
| $response = $this->httpClient->post('/deposit', $depositData); | ||
|
|
||
| return $response->json(); | ||
| } | ||
|
|
||
| /** | ||
| * Get available chains and supported tokens for bridging. | ||
| * | ||
| * Returns information about: | ||
| * - Supported blockchain networks (EVM chains, Solana, Bitcoin) | ||
| * - Available tokens on each chain | ||
| * - Minimum deposit thresholds in USD | ||
| * - Chain IDs and network details | ||
| * | ||
| * @return array<string, mixed> Supported assets and chains | ||
| * { | ||
| * "chains": [...], | ||
| * "tokens": [...], | ||
| * "minimums": {...} | ||
| * } | ||
| * | ||
| * @throws PolymarketException | ||
| */ | ||
| public function supportedAssets(): array | ||
| { | ||
| $response = $this->httpClient->get('/supported-assets'); | ||
|
|
||
| return $response->json(); | ||
| } | ||
| } |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Deposits resource lacks test coverage. The codebase has comprehensive tests for other resources. Test coverage should be added for both the generate() and supportedAssets() methods to ensure deposit address generation and asset querying work correctly.
| try { | ||
| echo "2. Generating deposit addresses...\n"; | ||
|
|
||
| // Your Polygon destination address (where USDC.e will be sent) |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The placeholder address '0x0000000000000000000000000000000000000000' is the zero address and should not be used for actual deposits. While this is acceptable in an example file, consider adding a more prominent warning comment that users must replace this with their actual Polygon address to avoid loss of funds.
| // Your Polygon destination address (where USDC.e will be sent) | |
| // Your Polygon destination address (where USDC.e will be sent) | |
| // WARNING: This is a placeholder address (the zero address) and MUST be replaced | |
| // with your actual Polygon wallet address before using this script with real funds. | |
| // Depositing to the zero address will result in permanent loss of funds. |
| public function deposits(): Deposits | ||
| { | ||
| return new Deposits($this->httpClient); | ||
| } |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deposits() method lacks a docblock. For consistency with the codebase pattern (see Gamma.php), public methods that return resources should have docblocks explaining their purpose and return type.
| public function bridge(): Bridge | ||
| { | ||
| if ($this->bridgeClient === null) { | ||
| $this->bridgeClient = new Bridge($this->config); | ||
| } | ||
|
|
||
| return $this->bridgeClient; | ||
| } |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bridge() method lacks a docblock. For consistency with other accessor methods in this class (like gamma() and clob()), this method should have a docblock explaining its purpose and return type.
| * @param array<string, mixed> $depositData Deposit request data (amount, destinationAddress, etc.) | ||
| * | ||
| * @return array<string, mixed> Deposit addresses for each chain | ||
| * { | ||
| * "evm": "0x...", | ||
| * "solana": "...", | ||
| * "bitcoin": "..." | ||
| * } | ||
| * | ||
| * @throws PolymarketException | ||
| */ | ||
| public function generate(array $depositData): array |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter names in the example ('destination_address' and 'amount_usd') use snake_case, but it's unclear if this matches the actual API requirements. The docblock in the generate() method doesn't specify the expected parameter structure. Consider documenting the expected parameter names and format in the method's docblock.
|
|
||
| private ?Clob $clobClient = null; | ||
|
|
||
| private ?Data $dataClient = null; |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Data class is referenced here but does not exist in the codebase. This will cause a fatal error when the Client class is instantiated. Either the Data class needs to be created or these references should be removed from the Client class.
| ?HttpClientInterface $gammaHttpClient = null, | ||
| ?HttpClientInterface $clobHttpClient = null | ||
| ?HttpClientInterface $clobHttpClient = null, | ||
| ?HttpClientInterface $dataHttpClient = null, |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Data class does not exist in the codebase. This constructor parameter should be removed, or the Data class needs to be created.
| class Bridge | ||
| { | ||
| private HttpClientInterface $httpClient; | ||
|
|
||
| /** | ||
| * @param Config $config | ||
| * @param HttpClientInterface|null $httpClient | ||
| */ | ||
| public function __construct( | ||
| private readonly Config $config, | ||
| ?HttpClientInterface $httpClient = null | ||
| ) { | ||
| $this->httpClient = $httpClient ?? new GuzzleHttpClient($this->config->bridgeBaseUrl, $this->config); | ||
| } | ||
|
|
||
| public function deposits(): Deposits | ||
| { | ||
| return new Deposits($this->httpClient); | ||
| } | ||
| } |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new Bridge class lacks test coverage. The codebase has comprehensive tests for other clients like Gamma and Clob. Similar test coverage should be added for the Bridge client to ensure reliability of cross-chain deposit functionality.
| if ($dataHttpClient !== null) { | ||
| $this->dataClient = new Data($this->config, $dataHttpClient); | ||
| } |
Copilot
AI
Jan 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Data class does not exist in the codebase. This initialization block should be removed, or the Data class needs to be created.
This pull request introduces a new Bridge API integration, enabling cross-chain deposits from EVM chains, Solana, and Bitcoin into USDC.e on Polygon for Polymarket accounts. It adds a dedicated
Bridgeclient, expands configuration options, and provides example usage and resource classes for bridge operations.Bridge API Integration
Bridgeclient (src/Bridge.php) to handle cross-chain deposits, including methods for generating deposit addresses and querying supported assets.Depositsresource (src/Resources/Bridge/Deposits.php) with methods to generate deposit addresses and fetch supported assets/chains/tokens for bridging.Client and Configuration Enhancements
Clientclass (src/Client.php) to support the newBridgeclient, including lazy initialization and constructor options for bridge-specific HTTP clients. [1] [2] [3] [4]Configclass (src/Config.php) to includebridgeBaseUrlanddataBaseUrl, allowing configuration of bridge and data API endpoints. [1] [2]Documentation and Examples
examples/bridge-deposit.php) demonstrating how to query supported assets/chains and generate deposit addresses for EVM, Solana, and Bitcoin, with workflow explanations and usage notes.