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>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { getCpmmInitialLiquidity } from 'common/antes'
|
|
import { BinaryContract, CPMMMultiContract } from 'common/contract'
|
|
import { convertContract } from 'common/supabase/contracts'
|
|
import { runScript } from 'run-script'
|
|
import { insertLiquidity } from 'shared/supabase/liquidity'
|
|
import { contractColumnsToSelect } from 'shared/utils'
|
|
|
|
runScript(async ({ pg }) => {
|
|
const contracts = await pg.map(
|
|
`
|
|
select ${contractColumnsToSelect} from contracts
|
|
where (outcome_type = 'MULTI_NUMERIC' or outcome_type = 'DATE')
|
|
and created_time < now()
|
|
`,
|
|
[],
|
|
convertContract
|
|
)
|
|
|
|
for (const contract of contracts) {
|
|
const providerId = contract.creatorId
|
|
|
|
if (
|
|
contract.mechanism === 'cpmm-multi-1' &&
|
|
!contract.shouldAnswersSumToOne
|
|
) {
|
|
const { answers } = contract
|
|
for (const answer of answers) {
|
|
const ante = Math.sqrt(answer.poolYes * answer.poolNo)
|
|
|
|
const lp = getCpmmInitialLiquidity(
|
|
providerId,
|
|
contract,
|
|
ante,
|
|
contract.createdTime,
|
|
answer.id
|
|
)
|
|
|
|
await insertLiquidity(pg, lp)
|
|
}
|
|
} else if (
|
|
contract.mechanism === 'cpmm-multi-1' ||
|
|
contract.mechanism === 'cpmm-1'
|
|
) {
|
|
const lp = getCpmmInitialLiquidity(
|
|
providerId,
|
|
contract as BinaryContract | CPMMMultiContract,
|
|
contract.totalLiquidity,
|
|
contract.createdTime
|
|
)
|
|
|
|
await insertLiquidity(pg, lp)
|
|
}
|
|
}
|
|
})
|