Skip to content

Conversation

@danielgnh
Copy link
Owner

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 Bridge client, expands configuration options, and provides example usage and resource classes for bridge operations.

Bridge API Integration

  • Added the Bridge client (src/Bridge.php) to handle cross-chain deposits, including methods for generating deposit addresses and querying supported assets.
  • Introduced the Deposits resource (src/Resources/Bridge/Deposits.php) with methods to generate deposit addresses and fetch supported assets/chains/tokens for bridging.

Client and Configuration Enhancements

  • Updated the main Client class (src/Client.php) to support the new Bridge client, including lazy initialization and constructor options for bridge-specific HTTP clients. [1] [2] [3] [4]
  • Expanded the Config class (src/Config.php) to include bridgeBaseUrl and dataBaseUrl, allowing configuration of bridge and data API endpoints. [1] [2]

Documentation and Examples

  • Added a comprehensive example script (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.

Copy link

Copilot AI left a 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 Bridge client for handling cross-chain deposit operations
  • Introduces Deposits resource 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.

Comment on lines +114 to +121
public function data(): Data
{
if ($this->dataClient === null) {
$this->dataClient = new Data($this->config);
}

return $this->dataClient;
}
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +67
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();
}
}
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
try {
echo "2. Generating deposit addresses...\n";

// Your Polygon destination address (where USDC.e will be sent)
Copy link

Copilot AI Jan 8, 2026

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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +38
public function deposits(): Deposits
{
return new Deposits($this->httpClient);
}
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +123 to +130
public function bridge(): Bridge
{
if ($this->bridgeClient === null) {
$this->bridgeClient = new Bridge($this->config);
}

return $this->bridgeClient;
}
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +36
* @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
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.

private ?Clob $clobClient = null;

private ?Data $dataClient = null;
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
?HttpClientInterface $gammaHttpClient = null,
?HttpClientInterface $clobHttpClient = null
?HttpClientInterface $clobHttpClient = null,
?HttpClientInterface $dataHttpClient = null,
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +39
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);
}
}
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +50
if ($dataHttpClient !== null) {
$this->dataClient = new Data($this->config, $dataHttpClient);
}
Copy link

Copilot AI Jan 8, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants