predikt/oracle/backend/scripts/redo-contract-resolution-fees.ts
caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

48 lines
1.4 KiB
TypeScript

import { runScript } from 'run-script'
import { ProfitFeeTxn, UndoResolutionFeeTxn } from 'common/txn'
import { convertTxn } from 'common/supabase/txns'
import { runAdminTxnOutsideBetQueue } from 'shared/txn/run-txn'
if (require.main === module) {
runScript(async ({ pg }) => {
// Get all payout transactions for these contracts
const txns = await pg.map(
`SELECT * FROM txns
WHERE category = 'UNDO_CONTRACT_RESOLUTION_FEE'
and created_time > now() - interval '1 day'
`,
[],
(r) => convertTxn(r) as UndoResolutionFeeTxn
)
console.log('Total txns for redo resolution fees:', txns.length)
let count = 0
const payoutStartTime = Date.now()
for (const txn of txns) {
await pg.tx(async (tx) => {
await runAdminTxnOutsideBetQueue(
tx,
{
amount: txn.amount,
toId: txn.fromId,
fromType: 'USER',
fromId: txn.toId,
toType: 'BANK',
category: 'CONTRACT_RESOLUTION_FEE',
token: txn.token,
description: `Redo contract resolution fee payout from txn: ${txn.id}`,
data: {
contractId: txn.data.contractId,
payoutStartTime,
},
} as ProfitFeeTxn,
true
)
count++
console.log('reverted txn', txn.id)
console.log('reverted', count, 'txns')
})
}
console.log('reverted txns')
})
}