/**
* Polymarket CTF redeem: burn winning outcome tokens → receive USDC.
*
* Regular markets: call CTF contract `redeemPositions`
* Neg risk markets: call NegRiskAdapter `redeemPositions`
*
* Polygon gas is ~0.001 MATIC per tx, negligible cost.
*/
// Contract addresses (Polygon mainnet)
const CTF_ADDRESS = '0x4D97DCd97eC945f40cF65F87097ACe5EA0476045' as const;
const NEG_RISK_ADAPTER = '0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296' as const;
const USDC_ADDRESS = '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as const;
// Zero bytes32 for parentCollectionId
const PARENT_COLLECTION_ID = '0x0000000000000000000000000000000000000000000000000000000000000000' as const;
// CTF + NegRiskAdapter share the same redeemPositions ABI
const REDEEM_ABI = [
{
name: 'redeemPositions',
type: 'function',
stateMutability: 'nonpayable',
inputs: [
{ name: 'collateralToken', type: 'address' },
{ name: 'parentCollectionId', type: 'bytes32' },
{ name: 'conditionId', type: 'bytes32' },
{ name: 'indexSets', type: 'uint256[]' },
],
outputs: [],
},
] as const;
/**
* Build redeem tx params for wagmi writeContract.
* indexSets [1, 2] redeems both YES and NO outcomes.
*/
export function buildRedeemParams(conditionId: string, negRisk: boolean) {
return {
address: negRisk ? NEG_RISK_ADAPTER : CTF_ADDRESS,
abi: REDEEM_ABI,
functionName: 'redeemPositions' as const,
args: [
USDC_ADDRESS,
PARENT_COLLECTION_ID,
conditionId as `0x${string}`,
[1n, 2n], // both outcomes
] as const,
};
}
📜 Git History
6c47fa4chore: local Polikopi project home + Phase 1 redesign artifacts12 days ago
Show last diff
Loading...