@catalyst-team/poly-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +0 -0
- package/README.md +803 -0
- package/dist/__tests__/clob-api.test.d.ts +5 -0
- package/dist/__tests__/clob-api.test.d.ts.map +1 -0
- package/dist/__tests__/clob-api.test.js +240 -0
- package/dist/__tests__/clob-api.test.js.map +1 -0
- package/dist/__tests__/integration/bridge-client.integration.test.d.ts +11 -0
- package/dist/__tests__/integration/bridge-client.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/bridge-client.integration.test.js +260 -0
- package/dist/__tests__/integration/bridge-client.integration.test.js.map +1 -0
- package/dist/__tests__/integration/clob-api.integration.test.d.ts +13 -0
- package/dist/__tests__/integration/clob-api.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/clob-api.integration.test.js +170 -0
- package/dist/__tests__/integration/clob-api.integration.test.js.map +1 -0
- package/dist/__tests__/integration/ctf-client.integration.test.d.ts +17 -0
- package/dist/__tests__/integration/ctf-client.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/ctf-client.integration.test.js +234 -0
- package/dist/__tests__/integration/ctf-client.integration.test.js.map +1 -0
- package/dist/__tests__/integration/data-api.integration.test.d.ts +9 -0
- package/dist/__tests__/integration/data-api.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/data-api.integration.test.js +161 -0
- package/dist/__tests__/integration/data-api.integration.test.js.map +1 -0
- package/dist/__tests__/integration/gamma-api.integration.test.d.ts +9 -0
- package/dist/__tests__/integration/gamma-api.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/gamma-api.integration.test.js +170 -0
- package/dist/__tests__/integration/gamma-api.integration.test.js.map +1 -0
- package/dist/__tests__/test-utils.d.ts +92 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/test-utils.js +143 -0
- package/dist/__tests__/test-utils.js.map +1 -0
- package/dist/clients/bridge-client.d.ts +388 -0
- package/dist/clients/bridge-client.d.ts.map +1 -0
- package/dist/clients/bridge-client.js +587 -0
- package/dist/clients/bridge-client.js.map +1 -0
- package/dist/clients/clob-api.d.ts +318 -0
- package/dist/clients/clob-api.d.ts.map +1 -0
- package/dist/clients/clob-api.js +388 -0
- package/dist/clients/clob-api.js.map +1 -0
- package/dist/clients/ctf-client.d.ts +473 -0
- package/dist/clients/ctf-client.d.ts.map +1 -0
- package/dist/clients/ctf-client.js +915 -0
- package/dist/clients/ctf-client.js.map +1 -0
- package/dist/clients/data-api.d.ts +134 -0
- package/dist/clients/data-api.d.ts.map +1 -0
- package/dist/clients/data-api.js +265 -0
- package/dist/clients/data-api.js.map +1 -0
- package/dist/clients/gamma-api.d.ts +401 -0
- package/dist/clients/gamma-api.d.ts.map +1 -0
- package/dist/clients/gamma-api.js +352 -0
- package/dist/clients/gamma-api.js.map +1 -0
- package/dist/clients/trading-client.d.ts +252 -0
- package/dist/clients/trading-client.d.ts.map +1 -0
- package/dist/clients/trading-client.js +543 -0
- package/dist/clients/trading-client.js.map +1 -0
- package/dist/clients/websocket-manager.d.ts +100 -0
- package/dist/clients/websocket-manager.d.ts.map +1 -0
- package/dist/clients/websocket-manager.js +193 -0
- package/dist/clients/websocket-manager.js.map +1 -0
- package/dist/core/cache-adapter-bridge.d.ts +36 -0
- package/dist/core/cache-adapter-bridge.d.ts.map +1 -0
- package/dist/core/cache-adapter-bridge.js +81 -0
- package/dist/core/cache-adapter-bridge.js.map +1 -0
- package/dist/core/cache.d.ts +40 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +71 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/errors.d.ts +38 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +84 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/rate-limiter.d.ts +31 -0
- package/dist/core/rate-limiter.d.ts.map +1 -0
- package/dist/core/rate-limiter.js +70 -0
- package/dist/core/rate-limiter.js.map +1 -0
- package/dist/core/types.d.ts +314 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +19 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/unified-cache.d.ts +63 -0
- package/dist/core/unified-cache.d.ts.map +1 -0
- package/dist/core/unified-cache.js +114 -0
- package/dist/core/unified-cache.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +258 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +33 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/errors.js +86 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/index.d.ts +62 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +173 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +17 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +155 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/guide.d.ts +12 -0
- package/dist/mcp/tools/guide.d.ts.map +1 -0
- package/dist/mcp/tools/guide.js +801 -0
- package/dist/mcp/tools/guide.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +11 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +27 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/market.d.ts +11 -0
- package/dist/mcp/tools/market.d.ts.map +1 -0
- package/dist/mcp/tools/market.js +314 -0
- package/dist/mcp/tools/market.js.map +1 -0
- package/dist/mcp/tools/order.d.ts +10 -0
- package/dist/mcp/tools/order.d.ts.map +1 -0
- package/dist/mcp/tools/order.js +258 -0
- package/dist/mcp/tools/order.js.map +1 -0
- package/dist/mcp/tools/trade.d.ts +38 -0
- package/dist/mcp/tools/trade.d.ts.map +1 -0
- package/dist/mcp/tools/trade.js +314 -0
- package/dist/mcp/tools/trade.js.map +1 -0
- package/dist/mcp/tools/trader.d.ts +11 -0
- package/dist/mcp/tools/trader.d.ts.map +1 -0
- package/dist/mcp/tools/trader.js +277 -0
- package/dist/mcp/tools/trader.js.map +1 -0
- package/dist/mcp/tools/wallet.d.ts +274 -0
- package/dist/mcp/tools/wallet.d.ts.map +1 -0
- package/dist/mcp/tools/wallet.js +579 -0
- package/dist/mcp/tools/wallet.js.map +1 -0
- package/dist/mcp/types.d.ts +413 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +5 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/services/authorization-service.d.ts +97 -0
- package/dist/services/authorization-service.d.ts.map +1 -0
- package/dist/services/authorization-service.js +279 -0
- package/dist/services/authorization-service.js.map +1 -0
- package/dist/services/market-service.d.ts +108 -0
- package/dist/services/market-service.d.ts.map +1 -0
- package/dist/services/market-service.js +458 -0
- package/dist/services/market-service.js.map +1 -0
- package/dist/services/realtime-service.d.ts +82 -0
- package/dist/services/realtime-service.d.ts.map +1 -0
- package/dist/services/realtime-service.js +150 -0
- package/dist/services/realtime-service.js.map +1 -0
- package/dist/services/swap-service.d.ts +217 -0
- package/dist/services/swap-service.d.ts.map +1 -0
- package/dist/services/swap-service.js +695 -0
- package/dist/services/swap-service.js.map +1 -0
- package/dist/services/wallet-service.d.ts +94 -0
- package/dist/services/wallet-service.d.ts.map +1 -0
- package/dist/services/wallet-service.js +173 -0
- package/dist/services/wallet-service.js.map +1 -0
- package/dist/utils/price-utils.d.ts +153 -0
- package/dist/utils/price-utils.d.ts.map +1 -0
- package/dist/utils/price-utils.js +236 -0
- package/dist/utils/price-utils.js.map +1 -0
- package/docs/00-design.md +760 -0
- package/docs/01-mcp.md +2041 -0
- package/docs/02-API.md +1148 -0
- package/docs/e2e/01-trader-tools.md +159 -0
- package/docs/e2e/02-market-tools.md +180 -0
- package/docs/e2e/03-order-tools.md +166 -0
- package/docs/e2e/04-wallet-tools.md +224 -0
- package/docs/e2e/05-trading-tools.md +327 -0
- package/docs/e2e/06-integration-scenarios.md +481 -0
- package/docs/e2e/coordinator.md +376 -0
- package/examples/01-basic-usage.ts +68 -0
- package/examples/02-smart-money.ts +95 -0
- package/examples/03-market-analysis.ts +108 -0
- package/examples/04-kline-aggregation.ts +158 -0
- package/examples/05-follow-wallet-strategy.ts +156 -0
- package/examples/06-services-demo.ts +124 -0
- package/examples/07-realtime-websocket.ts +117 -0
- package/examples/08-trading-orders.ts +278 -0
- package/examples/09-rewards-tracking.ts +187 -0
- package/examples/10-ctf-operations.ts +336 -0
- package/examples/11-live-arbitrage-scan.ts +221 -0
- package/examples/12-trending-arb-monitor.ts +406 -0
- package/examples/README.md +179 -0
- package/package.json +62 -0
- package/scripts/README.md +163 -0
- package/scripts/approvals/approve-erc1155.ts +129 -0
- package/scripts/approvals/approve-neg-risk-erc1155.ts +149 -0
- package/scripts/approvals/approve-neg-risk.ts +102 -0
- package/scripts/approvals/check-all-allowances.ts +150 -0
- package/scripts/approvals/check-allowance.ts +129 -0
- package/scripts/approvals/check-ctf-approval.ts +158 -0
- package/scripts/datas/001-report.md +486 -0
- package/scripts/datas/clone-modal-screenshot.png +0 -0
- package/scripts/deposit/deposit-native-usdc.ts +179 -0
- package/scripts/deposit/deposit-usdc.ts +155 -0
- package/scripts/deposit/swap-usdc-to-usdce.ts +375 -0
- package/scripts/research/research-markets.ts +166 -0
- package/scripts/trading/check-orders.ts +50 -0
- package/scripts/trading/sell-nvidia-positions.ts +206 -0
- package/scripts/trading/test-order.ts +172 -0
- package/scripts/truth.md +440 -0
- package/scripts/verify/test-approve-trading.ts +98 -0
- package/scripts/verify/test-provider-fix.ts +43 -0
- package/scripts/verify/test-search-mcp.ts +113 -0
- package/scripts/verify/verify-all-apis.ts +160 -0
- package/scripts/wallet/check-wallet-balances.ts +75 -0
- package/scripts/wallet/test-wallet-operations.ts +191 -0
- package/scripts/wallet/verify-wallet-tools.ts +124 -0
- package/src/__tests__/clob-api.test.ts +301 -0
- package/src/__tests__/integration/bridge-client.integration.test.ts +314 -0
- package/src/__tests__/integration/clob-api.integration.test.ts +218 -0
- package/src/__tests__/integration/ctf-client.integration.test.ts +331 -0
- package/src/__tests__/integration/data-api.integration.test.ts +194 -0
- package/src/__tests__/integration/gamma-api.integration.test.ts +206 -0
- package/src/__tests__/test-utils.ts +170 -0
- package/src/clients/bridge-client.ts +841 -0
- package/src/clients/clob-api.ts +629 -0
- package/src/clients/ctf-client.ts +1216 -0
- package/src/clients/data-api.ts +469 -0
- package/src/clients/gamma-api.ts +597 -0
- package/src/clients/trading-client.ts +749 -0
- package/src/clients/websocket-manager.ts +267 -0
- package/src/core/cache-adapter-bridge.ts +94 -0
- package/src/core/cache.ts +85 -0
- package/src/core/errors.ts +117 -0
- package/src/core/rate-limiter.ts +74 -0
- package/src/core/types.ts +360 -0
- package/src/core/unified-cache.ts +153 -0
- package/src/index.ts +455 -0
- package/src/mcp/README.md +380 -0
- package/src/mcp/errors.ts +124 -0
- package/src/mcp/index.ts +309 -0
- package/src/mcp/server.ts +183 -0
- package/src/mcp/tools/guide.ts +821 -0
- package/src/mcp/tools/index.ts +73 -0
- package/src/mcp/tools/market.ts +363 -0
- package/src/mcp/tools/order.ts +326 -0
- package/src/mcp/tools/trade.ts +417 -0
- package/src/mcp/tools/trader.ts +322 -0
- package/src/mcp/tools/wallet.ts +683 -0
- package/src/mcp/types.ts +472 -0
- package/src/services/authorization-service.ts +357 -0
- package/src/services/market-service.ts +544 -0
- package/src/services/realtime-service.ts +196 -0
- package/src/services/swap-service.ts +896 -0
- package/src/services/wallet-service.ts +259 -0
- package/src/utils/price-utils.ts +307 -0
- package/tsconfig.json +8 -0
- package/vitest.config.ts +19 -0
- package/vitest.integration.config.ts +18 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Client for Polymarket Cross-Chain Deposits
|
|
3
|
+
*
|
|
4
|
+
* Enables depositing assets from multiple chains (Ethereum, etc.)
|
|
5
|
+
* and having them automatically converted to USDC.e on Polygon for trading.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Request deposit addresses for your Polymarket wallet
|
|
9
|
+
* 2. Send assets to the unique deposit address for each chain/token
|
|
10
|
+
* 3. Assets are automatically bridged and swapped to USDC.e on Polygon
|
|
11
|
+
* 4. USDC.e is credited to your Polymarket account
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.polymarket.com/developers/misc-endpoints/bridge-deposit
|
|
14
|
+
* @see https://docs.polymarket.com/developers/misc-endpoints/bridge-supported-assets
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Supported asset information from the bridge
|
|
18
|
+
*/
|
|
19
|
+
export interface BridgeSupportedAsset {
|
|
20
|
+
/** Blockchain chain ID (e.g., 1 for Ethereum) */
|
|
21
|
+
chainId: number;
|
|
22
|
+
/** Human-readable chain name (e.g., "Ethereum") */
|
|
23
|
+
chainName: string;
|
|
24
|
+
/** Token contract address on the source chain */
|
|
25
|
+
tokenAddress: string;
|
|
26
|
+
/** Token symbol (e.g., "USDC", "ETH") */
|
|
27
|
+
tokenSymbol: string;
|
|
28
|
+
/** Token name (e.g., "USD Coin") */
|
|
29
|
+
tokenName: string;
|
|
30
|
+
/** Token decimals (e.g., 6 for USDC) */
|
|
31
|
+
decimals: number;
|
|
32
|
+
/** Minimum deposit amount in token units */
|
|
33
|
+
minDeposit: string;
|
|
34
|
+
/** Minimum deposit amount in USD */
|
|
35
|
+
minDepositUsd: number;
|
|
36
|
+
/** Whether this asset is currently active */
|
|
37
|
+
active: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Deposit address for a specific chain/token combination
|
|
41
|
+
*/
|
|
42
|
+
export interface DepositAddress {
|
|
43
|
+
/** Blockchain chain ID */
|
|
44
|
+
chainId: number;
|
|
45
|
+
/** Human-readable chain name */
|
|
46
|
+
chainName: string;
|
|
47
|
+
/** Token contract address on source chain */
|
|
48
|
+
tokenAddress: string;
|
|
49
|
+
/** Token symbol */
|
|
50
|
+
tokenSymbol: string;
|
|
51
|
+
/** Unique deposit address to send funds to */
|
|
52
|
+
depositAddress: string;
|
|
53
|
+
/** Minimum deposit amount */
|
|
54
|
+
minDeposit: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Response from creating deposit addresses
|
|
58
|
+
*
|
|
59
|
+
* The Bridge API returns a single universal deposit address structure.
|
|
60
|
+
* - EVM address: Used for all EVM chains (Ethereum, Polygon, Arbitrum, Base, Optimism)
|
|
61
|
+
* - SVM address: Used for Solana
|
|
62
|
+
* - BTC address: Used for Bitcoin
|
|
63
|
+
*
|
|
64
|
+
* @example Response from API:
|
|
65
|
+
* ```json
|
|
66
|
+
* {
|
|
67
|
+
* "address": {
|
|
68
|
+
* "evm": "0x1234...",
|
|
69
|
+
* "svm": "ABC123...",
|
|
70
|
+
* "btc": "bc1q..."
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export interface CreateDepositResponse {
|
|
76
|
+
/** Universal deposit addresses for different chain types */
|
|
77
|
+
address: {
|
|
78
|
+
/** EVM deposit address (Ethereum, Polygon, Arbitrum, Base, Optimism) */
|
|
79
|
+
evm: string;
|
|
80
|
+
/** Solana deposit address */
|
|
81
|
+
svm: string;
|
|
82
|
+
/** Bitcoin deposit address */
|
|
83
|
+
btc: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Deposit status tracking
|
|
88
|
+
*/
|
|
89
|
+
export interface DepositStatus {
|
|
90
|
+
/** Unique deposit ID */
|
|
91
|
+
depositId: string;
|
|
92
|
+
/** Source chain ID */
|
|
93
|
+
sourceChainId: number;
|
|
94
|
+
/** Source transaction hash */
|
|
95
|
+
sourceTxHash: string;
|
|
96
|
+
/** Amount deposited */
|
|
97
|
+
amount: string;
|
|
98
|
+
/** Token symbol */
|
|
99
|
+
tokenSymbol: string;
|
|
100
|
+
/** Status of the deposit */
|
|
101
|
+
status: 'pending' | 'bridging' | 'swapping' | 'completed' | 'failed';
|
|
102
|
+
/** Destination transaction hash (when completed) */
|
|
103
|
+
destinationTxHash?: string;
|
|
104
|
+
/** USDC.e amount received (when completed) */
|
|
105
|
+
usdceReceived?: string;
|
|
106
|
+
/** Error message (if failed) */
|
|
107
|
+
errorMessage?: string;
|
|
108
|
+
/** Timestamp of last update */
|
|
109
|
+
updatedAt: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Bridge configuration
|
|
113
|
+
*/
|
|
114
|
+
export interface BridgeConfig {
|
|
115
|
+
/** Base URL for the bridge API (default: https://bridge.polymarket.com) */
|
|
116
|
+
baseUrl?: string;
|
|
117
|
+
/** Request timeout in ms (default: 30000) */
|
|
118
|
+
timeout?: number;
|
|
119
|
+
}
|
|
120
|
+
export declare const SUPPORTED_CHAINS: {
|
|
121
|
+
readonly ETHEREUM: {
|
|
122
|
+
readonly chainId: 1;
|
|
123
|
+
readonly name: "Ethereum";
|
|
124
|
+
readonly rpcUrl: "https://eth.llamarpc.com";
|
|
125
|
+
};
|
|
126
|
+
readonly POLYGON: {
|
|
127
|
+
readonly chainId: 137;
|
|
128
|
+
readonly name: "Polygon";
|
|
129
|
+
readonly rpcUrl: "https://polygon-rpc.com";
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export declare const BRIDGE_TOKENS: {
|
|
133
|
+
readonly ETH_USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
|
134
|
+
readonly ETH_WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
135
|
+
readonly ETH_DAI: "0x6B175474E89094C44Da98b954EeDeaC495271d0F";
|
|
136
|
+
readonly POLYGON_USDC_E: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
137
|
+
readonly POLYGON_NATIVE_USDC: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359";
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Client for interacting with Polymarket's cross-chain bridge
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const bridge = new BridgeClient();
|
|
145
|
+
*
|
|
146
|
+
* // Get supported assets
|
|
147
|
+
* const assets = await bridge.getSupportedAssets();
|
|
148
|
+
* console.log(`Supported: ${assets.map(a => a.tokenSymbol).join(', ')}`);
|
|
149
|
+
*
|
|
150
|
+
* // Create deposit addresses for your wallet
|
|
151
|
+
* const deposit = await bridge.createDepositAddresses('0xYourAddress');
|
|
152
|
+
* const ethUsdc = deposit.depositAddresses.find(
|
|
153
|
+
* d => d.chainName === 'Ethereum' && d.tokenSymbol === 'USDC'
|
|
154
|
+
* );
|
|
155
|
+
* console.log(`Send USDC on Ethereum to: ${ethUsdc.depositAddress}`);
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare class BridgeClient {
|
|
159
|
+
private baseUrl;
|
|
160
|
+
private timeout;
|
|
161
|
+
constructor(config?: BridgeConfig);
|
|
162
|
+
/**
|
|
163
|
+
* Get all supported assets for bridge deposits
|
|
164
|
+
*
|
|
165
|
+
* @returns Array of supported assets with their chain/token details
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const assets = await bridge.getSupportedAssets();
|
|
170
|
+
* for (const asset of assets) {
|
|
171
|
+
* console.log(`${asset.chainName} ${asset.tokenSymbol}: min $${asset.minDepositUsd}`);
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
getSupportedAssets(): Promise<BridgeSupportedAsset[]>;
|
|
176
|
+
/**
|
|
177
|
+
* Get unique deposit addresses for a Polymarket wallet
|
|
178
|
+
*
|
|
179
|
+
* The Bridge API returns a universal deposit address structure:
|
|
180
|
+
* - A single EVM address works for ALL EVM chains (Ethereum, Polygon, Arbitrum, Base, Optimism)
|
|
181
|
+
* - A Solana address for SVM deposits
|
|
182
|
+
* - A Bitcoin address for BTC deposits
|
|
183
|
+
*
|
|
184
|
+
* Funds sent to these addresses are automatically bridged to Polygon
|
|
185
|
+
* and converted to USDC.e for your Polymarket account.
|
|
186
|
+
*
|
|
187
|
+
* @param walletAddress - Your Polymarket wallet address (EOA address)
|
|
188
|
+
* @returns Universal deposit addresses for EVM, Solana, and Bitcoin
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const result = await bridge.createDepositAddresses('0xYourPolymarketWallet');
|
|
193
|
+
*
|
|
194
|
+
* // The EVM address works for Ethereum, Polygon, Arbitrum, Base, Optimism
|
|
195
|
+
* console.log(`EVM deposit address: ${result.address.evm}`);
|
|
196
|
+
*
|
|
197
|
+
* // For Solana deposits
|
|
198
|
+
* console.log(`Solana deposit address: ${result.address.svm}`);
|
|
199
|
+
*
|
|
200
|
+
* // For Bitcoin deposits
|
|
201
|
+
* console.log(`Bitcoin deposit address: ${result.address.btc}`);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
createDepositAddresses(walletAddress: string): Promise<CreateDepositResponse>;
|
|
205
|
+
/**
|
|
206
|
+
* Get the EVM deposit address for a wallet
|
|
207
|
+
*
|
|
208
|
+
* This address works for ALL supported EVM chains:
|
|
209
|
+
* - Ethereum (chainId: 1)
|
|
210
|
+
* - Polygon (chainId: 137)
|
|
211
|
+
* - Arbitrum (chainId: 42161)
|
|
212
|
+
* - Base (chainId: 8453)
|
|
213
|
+
* - Optimism (chainId: 10)
|
|
214
|
+
*
|
|
215
|
+
* @param walletAddress - Your Polymarket wallet address
|
|
216
|
+
* @returns The universal EVM deposit address
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* const evmAddr = await bridge.getEvmDepositAddress('0xYourWallet');
|
|
221
|
+
* // Send Native USDC on Polygon to this address
|
|
222
|
+
* // Or send USDC on Ethereum to this address
|
|
223
|
+
* console.log(`Deposit to: ${evmAddr}`);
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
getEvmDepositAddress(walletAddress: string): Promise<string>;
|
|
227
|
+
/**
|
|
228
|
+
* Get the Solana deposit address for a wallet
|
|
229
|
+
*
|
|
230
|
+
* @param walletAddress - Your Polymarket wallet address
|
|
231
|
+
* @returns The Solana deposit address
|
|
232
|
+
*/
|
|
233
|
+
getSolanaDepositAddress(walletAddress: string): Promise<string>;
|
|
234
|
+
/**
|
|
235
|
+
* Get the Bitcoin deposit address for a wallet
|
|
236
|
+
*
|
|
237
|
+
* @param walletAddress - Your Polymarket wallet address
|
|
238
|
+
* @returns The Bitcoin deposit address
|
|
239
|
+
*/
|
|
240
|
+
getBtcDepositAddress(walletAddress: string): Promise<string>;
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated Use getEvmDepositAddress(), getSolanaDepositAddress(), or getBtcDepositAddress() instead.
|
|
243
|
+
*
|
|
244
|
+
* The Bridge API returns universal addresses by chain type (EVM/SVM/BTC),
|
|
245
|
+
* not by specific chain/token combinations.
|
|
246
|
+
*
|
|
247
|
+
* For EVM chains (Ethereum, Polygon, Arbitrum, Base, Optimism), use getEvmDepositAddress()
|
|
248
|
+
*/
|
|
249
|
+
getDepositAddress(address: string, _chainId: number, _tokenSymbol: string): Promise<DepositAddress | null>;
|
|
250
|
+
/**
|
|
251
|
+
* Check if a chain/token combination is supported
|
|
252
|
+
*
|
|
253
|
+
* @param chainId - The chain ID to check
|
|
254
|
+
* @param tokenSymbol - The token symbol to check
|
|
255
|
+
* @returns True if supported, false otherwise
|
|
256
|
+
*/
|
|
257
|
+
isSupported(chainId: number, tokenSymbol: string): Promise<boolean>;
|
|
258
|
+
/**
|
|
259
|
+
* Get minimum deposit amount for a chain/token
|
|
260
|
+
*
|
|
261
|
+
* @param chainId - The chain ID
|
|
262
|
+
* @param tokenSymbol - The token symbol
|
|
263
|
+
* @returns Minimum deposit info or null if not supported
|
|
264
|
+
*/
|
|
265
|
+
getMinDeposit(chainId: number, tokenSymbol: string): Promise<{
|
|
266
|
+
amount: string;
|
|
267
|
+
usd: number;
|
|
268
|
+
} | null>;
|
|
269
|
+
/**
|
|
270
|
+
* Format deposit instructions for a user
|
|
271
|
+
*
|
|
272
|
+
* @param walletAddress - The Polymarket wallet address
|
|
273
|
+
* @returns Formatted instructions string
|
|
274
|
+
*/
|
|
275
|
+
getDepositInstructions(walletAddress: string): Promise<string>;
|
|
276
|
+
private fetch;
|
|
277
|
+
}
|
|
278
|
+
import { ethers } from 'ethers';
|
|
279
|
+
export interface DepositResult {
|
|
280
|
+
success: boolean;
|
|
281
|
+
txHash?: string;
|
|
282
|
+
amount: string;
|
|
283
|
+
depositAddress: string;
|
|
284
|
+
error?: string;
|
|
285
|
+
}
|
|
286
|
+
export interface DepositOptions {
|
|
287
|
+
/** Chain ID for the deposit (default: 137 for Polygon) */
|
|
288
|
+
chainId?: number;
|
|
289
|
+
/** Token to deposit: 'NATIVE_USDC' or 'USDC_E' (default: 'NATIVE_USDC') */
|
|
290
|
+
token?: 'NATIVE_USDC' | 'USDC_E';
|
|
291
|
+
/** Gas price multiplier (default: 1.2) */
|
|
292
|
+
gasPriceMultiplier?: number;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Deposit USDC to Polymarket via Bridge
|
|
296
|
+
*
|
|
297
|
+
* This function:
|
|
298
|
+
* 1. Gets the deposit address for your wallet
|
|
299
|
+
* 2. Transfers USDC to that address
|
|
300
|
+
* 3. The bridge automatically converts it to USDC.e for your Polymarket account
|
|
301
|
+
*
|
|
302
|
+
* @param signer - Ethers wallet/signer to send from
|
|
303
|
+
* @param amount - Amount in USDC (e.g., 10.5 for $10.50)
|
|
304
|
+
* @param options - Deposit options
|
|
305
|
+
* @returns Deposit result with transaction hash
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const bridge = new BridgeClient();
|
|
310
|
+
* const result = await bridge.depositUsdc(signer, 100);
|
|
311
|
+
* console.log(`Deposited $100: ${result.txHash}`);
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
export declare function depositUsdc(signer: ethers.Wallet, amount: number, options?: DepositOptions): Promise<DepositResult>;
|
|
315
|
+
export interface SwapAndDepositOptions {
|
|
316
|
+
/** Slippage tolerance for swap (default: 0.5%) */
|
|
317
|
+
slippage?: number;
|
|
318
|
+
/** Gas price multiplier (default: 1.2) */
|
|
319
|
+
gasPriceMultiplier?: number;
|
|
320
|
+
}
|
|
321
|
+
export interface SwapAndDepositResult {
|
|
322
|
+
success: boolean;
|
|
323
|
+
/** Swap transaction hash (if swap was needed) */
|
|
324
|
+
swapTxHash?: string;
|
|
325
|
+
/** Deposit transaction hash */
|
|
326
|
+
depositTxHash?: string;
|
|
327
|
+
/** Input token */
|
|
328
|
+
tokenIn: string;
|
|
329
|
+
/** Amount of input token */
|
|
330
|
+
amountIn: string;
|
|
331
|
+
/** Amount of USDC after swap */
|
|
332
|
+
usdcAmount: string;
|
|
333
|
+
/** Deposit address */
|
|
334
|
+
depositAddress: string;
|
|
335
|
+
/** Error message if failed */
|
|
336
|
+
error?: string;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Swap any supported Polygon token to USDC and deposit to Polymarket
|
|
340
|
+
*
|
|
341
|
+
* Supported tokens: MATIC, WMATIC, USDC, USDC_E, USDT, DAI, WETH
|
|
342
|
+
*
|
|
343
|
+
* Flow:
|
|
344
|
+
* 1. If token is not USDC, swap to USDC using QuickSwap
|
|
345
|
+
* 2. Deposit USDC to the bridge deposit address
|
|
346
|
+
*
|
|
347
|
+
* @param signer - Ethers wallet/signer
|
|
348
|
+
* @param token - Token symbol to deposit (e.g., 'MATIC', 'WETH', 'USDT')
|
|
349
|
+
* @param amount - Amount to deposit in token units
|
|
350
|
+
* @param options - Swap and deposit options
|
|
351
|
+
* @returns Result with transaction hashes
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* // Deposit 10 MATIC
|
|
356
|
+
* const result = await swapAndDeposit(signer, 'MATIC', '10');
|
|
357
|
+
*
|
|
358
|
+
* // Deposit 100 USDT
|
|
359
|
+
* const result = await swapAndDeposit(signer, 'USDT', '100');
|
|
360
|
+
*
|
|
361
|
+
* // Deposit 0.1 WETH
|
|
362
|
+
* const result = await swapAndDeposit(signer, 'WETH', '0.1');
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
export declare function swapAndDeposit(signer: ethers.Wallet, token: string, amount: string, options?: SwapAndDepositOptions): Promise<SwapAndDepositResult>;
|
|
366
|
+
/**
|
|
367
|
+
* Get list of supported tokens for swap and deposit
|
|
368
|
+
*/
|
|
369
|
+
export declare function getSupportedDepositTokens(): string[];
|
|
370
|
+
/**
|
|
371
|
+
* Calculate the expected USDC.e output after bridge fees
|
|
372
|
+
*
|
|
373
|
+
* Note: This is an estimate. Actual output depends on bridge/swap fees.
|
|
374
|
+
*
|
|
375
|
+
* @param amount - Input amount in source token
|
|
376
|
+
* @param tokenSymbol - Source token symbol
|
|
377
|
+
* @returns Estimated USDC.e output
|
|
378
|
+
*/
|
|
379
|
+
export declare function estimateBridgeOutput(amount: number, tokenSymbol: string): number;
|
|
380
|
+
/**
|
|
381
|
+
* Get explorer URL for a deposit transaction
|
|
382
|
+
*
|
|
383
|
+
* @param chainId - The chain ID
|
|
384
|
+
* @param txHash - The transaction hash
|
|
385
|
+
* @returns Block explorer URL
|
|
386
|
+
*/
|
|
387
|
+
export declare function getExplorerUrl(chainId: number, txHash: string): string;
|
|
388
|
+
//# sourceMappingURL=bridge-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-client.d.ts","sourceRoot":"","sources":["../../src/clients/bridge-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;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