predikt/oracle/backend/scripts/top-up-oracle.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

63 lines
1.9 KiB
TypeScript

import {
DEV_HOUSE_LIQUIDITY_PROVIDER_ID,
HOUSE_LIQUIDITY_PROVIDER_ID,
} from 'common/antes'
import { runScript } from 'run-script'
import { isProd } from 'shared/utils'
import { runTxnFromBank } from 'shared/txn/run-txn'
const userId = isProd()
? HOUSE_LIQUIDITY_PROVIDER_ID
: DEV_HOUSE_LIQUIDITY_PROVIDER_ID
const askQuestion = (query: string): Promise<string> => {
return new Promise((resolve) => {
process.stdout.write(query)
process.stdin.once('data', (data) => {
resolve(data.toString().trim())
})
})
}
if (require.main === module) {
runScript(async ({ pg }) => {
const amount = await askQuestion(
'Enter the amount to top up: '
)
const token = await askQuestion('Enter the token (M$ / CASH): ')
const confirmedAmount = amount ? parseInt(amount) : 0
if (isNaN(confirmedAmount) || !Number.isInteger(confirmedAmount) || confirmedAmount < 1 || confirmedAmount > 1000000) {
console.error('Invalid amount. Please enter an integer between 1 and 1,000,000.');
process.exit(1);
}
const confirmedToken = token.toUpperCase()
if (confirmedToken !== 'M$' && confirmedToken !== 'CASH') {
console.error('Invalid token. Please enter either M$ or CASH.')
process.exit(1)
}
console.log(`Confirming: Top up ${confirmedAmount} ${token}`)
const confirm = await askQuestion('Proceed? (y/n): ')
if (confirm.toLowerCase() === 'y') {
await pg.tx(async (tx) => {
await runTxnFromBank(tx, {
amount: confirmedAmount,
description: 'Top up Oracle account',
category: 'MANIFOLD_TOP_UP',
fromType: 'BANK',
toType: 'USER',
toId: userId,
token: confirmedToken as 'M$' | 'SHARE' | 'SPICE' | 'CASH',
})
})
console.log('Transaction completed.')
} else {
console.log('Transaction cancelled.')
}
process.exit(0)
})
}