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>
48 lines
1.4 KiB
TypeScript
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')
|
|
})
|
|
}
|