Files
Nawaz Haider 7508654d00 Add Safe contract ABI and implement token merging functionality
- Introduced `safeAbi.py` containing the ABI for the Safe contract, defining events and functions for managing ownership and transactions.
- Created `merger.py` to handle merging conditional tokens back to USDC, including logic for determining merge amounts, signing transactions, and executing them through the Safe contract.
- Integrated environment variable loading for sensitive data and RPC connection setup.
- Implemented asynchronous polling for mergeable positions from the Polymarket API, with error handling and transaction receipt verification.
2026-01-14 13:12:37 +06:00

721 lines
15 KiB
Python

ctf_abi = [
{
"constant":True,
"inputs":[
{
"name":"owner",
"type":"address"
},
{
"name":"id",
"type":"uint256"
}
],
"name":"balanceOf",
"outputs":[
{
"name":"",
"type":"uint256"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"interfaceId",
"type":"bytes4"
}
],
"name":"supportsInterface",
"outputs":[
{
"name":"",
"type":"bool"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"",
"type":"bytes32"
},
{
"name":"",
"type":"uint256"
}
],
"name":"payoutNumerators",
"outputs":[
{
"name":"",
"type":"uint256"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"from",
"type":"address"
},
{
"name":"to",
"type":"address"
},
{
"name":"ids",
"type":"uint256[]"
},
{
"name":"values",
"type":"uint256[]"
},
{
"name":"data",
"type":"bytes"
}
],
"name":"safeBatchTransferFrom",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"owners",
"type":"address[]"
},
{
"name":"ids",
"type":"uint256[]"
}
],
"name":"balanceOfBatch",
"outputs":[
{
"name":"",
"type":"uint256[]"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"operator",
"type":"address"
},
{
"name":"approved",
"type":"bool"
}
],
"name":"setApprovalForAll",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"",
"type":"bytes32"
}
],
"name":"payoutDenominator",
"outputs":[
{
"name":"",
"type":"uint256"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"owner",
"type":"address"
},
{
"name":"operator",
"type":"address"
}
],
"name":"isApprovedForAll",
"outputs":[
{
"name":"",
"type":"bool"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"from",
"type":"address"
},
{
"name":"to",
"type":"address"
},
{
"name":"id",
"type":"uint256"
},
{
"name":"value",
"type":"uint256"
},
{
"name":"data",
"type":"bytes"
}
],
"name":"safeTransferFrom",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"conditionId",
"type":"bytes32"
},
{
"indexed":True,
"name":"oracle",
"type":"address"
},
{
"indexed":True,
"name":"questionId",
"type":"bytes32"
},
{
"indexed":False,
"name":"outcomeSlotCount",
"type":"uint256"
}
],
"name":"ConditionPreparation",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"conditionId",
"type":"bytes32"
},
{
"indexed":True,
"name":"oracle",
"type":"address"
},
{
"indexed":True,
"name":"questionId",
"type":"bytes32"
},
{
"indexed":False,
"name":"outcomeSlotCount",
"type":"uint256"
},
{
"indexed":False,
"name":"payoutNumerators",
"type":"uint256[]"
}
],
"name":"ConditionResolution",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"stakeholder",
"type":"address"
},
{
"indexed":False,
"name":"collateralToken",
"type":"address"
},
{
"indexed":True,
"name":"parentCollectionId",
"type":"bytes32"
},
{
"indexed":True,
"name":"conditionId",
"type":"bytes32"
},
{
"indexed":False,
"name":"partition",
"type":"uint256[]"
},
{
"indexed":False,
"name":"amount",
"type":"uint256"
}
],
"name":"PositionSplit",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"stakeholder",
"type":"address"
},
{
"indexed":False,
"name":"collateralToken",
"type":"address"
},
{
"indexed":True,
"name":"parentCollectionId",
"type":"bytes32"
},
{
"indexed":True,
"name":"conditionId",
"type":"bytes32"
},
{
"indexed":False,
"name":"partition",
"type":"uint256[]"
},
{
"indexed":False,
"name":"amount",
"type":"uint256"
}
],
"name":"PositionsMerge",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"redeemer",
"type":"address"
},
{
"indexed":True,
"name":"collateralToken",
"type":"address"
},
{
"indexed":True,
"name":"parentCollectionId",
"type":"bytes32"
},
{
"indexed":False,
"name":"conditionId",
"type":"bytes32"
},
{
"indexed":False,
"name":"indexSets",
"type":"uint256[]"
},
{
"indexed":False,
"name":"payout",
"type":"uint256"
}
],
"name":"PayoutRedemption",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"operator",
"type":"address"
},
{
"indexed":True,
"name":"from",
"type":"address"
},
{
"indexed":True,
"name":"to",
"type":"address"
},
{
"indexed":False,
"name":"id",
"type":"uint256"
},
{
"indexed":False,
"name":"value",
"type":"uint256"
}
],
"name":"TransferSingle",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"operator",
"type":"address"
},
{
"indexed":True,
"name":"from",
"type":"address"
},
{
"indexed":True,
"name":"to",
"type":"address"
},
{
"indexed":False,
"name":"ids",
"type":"uint256[]"
},
{
"indexed":False,
"name":"values",
"type":"uint256[]"
}
],
"name":"TransferBatch",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":True,
"name":"owner",
"type":"address"
},
{
"indexed":True,
"name":"operator",
"type":"address"
},
{
"indexed":False,
"name":"approved",
"type":"bool"
}
],
"name":"ApprovalForAll",
"type":"event"
},
{
"anonymous":False,
"inputs":[
{
"indexed":False,
"name":"value",
"type":"string"
},
{
"indexed":True,
"name":"id",
"type":"uint256"
}
],
"name":"URI",
"type":"event"
},
{
"constant":False,
"inputs":[
{
"name":"oracle",
"type":"address"
},
{
"name":"questionId",
"type":"bytes32"
},
{
"name":"outcomeSlotCount",
"type":"uint256"
}
],
"name":"prepareCondition",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"questionId",
"type":"bytes32"
},
{
"name":"payouts",
"type":"uint256[]"
}
],
"name":"reportPayouts",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"collateralToken",
"type":"address"
},
{
"name":"parentCollectionId",
"type":"bytes32"
},
{
"name":"conditionId",
"type":"bytes32"
},
{
"name":"partition",
"type":"uint256[]"
},
{
"name":"amount",
"type":"uint256"
}
],
"name":"splitPosition",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"collateralToken",
"type":"address"
},
{
"name":"parentCollectionId",
"type":"bytes32"
},
{
"name":"conditionId",
"type":"bytes32"
},
{
"name":"partition",
"type":"uint256[]"
},
{
"name":"amount",
"type":"uint256"
}
],
"name":"mergePositions",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":False,
"inputs":[
{
"name":"collateralToken",
"type":"address"
},
{
"name":"parentCollectionId",
"type":"bytes32"
},
{
"name":"conditionId",
"type":"bytes32"
},
{
"name":"indexSets",
"type":"uint256[]"
}
],
"name":"redeemPositions",
"outputs":[
],
"payable":False,
"stateMutability":"nonpayable",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"conditionId",
"type":"bytes32"
}
],
"name":"getOutcomeSlotCount",
"outputs":[
{
"name":"",
"type":"uint256"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"oracle",
"type":"address"
},
{
"name":"questionId",
"type":"bytes32"
},
{
"name":"outcomeSlotCount",
"type":"uint256"
}
],
"name":"getConditionId",
"outputs":[
{
"name":"",
"type":"bytes32"
}
],
"payable":False,
"stateMutability":"pure",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"parentCollectionId",
"type":"bytes32"
},
{
"name":"conditionId",
"type":"bytes32"
},
{
"name":"indexSet",
"type":"uint256"
}
],
"name":"getCollectionId",
"outputs":[
{
"name":"",
"type":"bytes32"
}
],
"payable":False,
"stateMutability":"view",
"type":"function"
},
{
"constant":True,
"inputs":[
{
"name":"collateralToken",
"type":"address"
},
{
"name":"collectionId",
"type":"bytes32"
}
],
"name":"getPositionId",
"outputs":[
{
"name":"",
"type":"uint256"
}
],
"payable":False,
"stateMutability":"pure",
"type":"function"
}
]