-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-mint-timing-pattern.ts
More file actions
225 lines (185 loc) · 7.2 KB
/
check-mint-timing-pattern.ts
File metadata and controls
225 lines (185 loc) · 7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/**
* Check mint timing patterns - specifically looking for "11 minutes after the hour" pattern
* Uses Beratrail API to get successful mint transactions
*/
import 'dotenv/config'
import { writeFileSync } from 'fs'
import { createPublicClient, http, parseAbi } from 'viem'
import { beraChain } from './config.js'
const MITEDDY_CONTRACT = '0x111111111fd1a588bdb8254e3af1fc2fb0d9078a' as const
const TRANSFER_ABI = parseAbi([
'event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)',
])
interface MintEvent {
txHash: string
blockNumber: number
blockTimestamp: number
blockTimeMs: number
minutesAfterHour: number
timeString: string
}
async function getMintEventsFromRPC(client: ReturnType<typeof createPublicClient>, fromBlock: bigint, toBlock: bigint): Promise<any[]> {
const BATCH_SIZE = 10000n
const allEvents: any[] = []
let currentFrom = fromBlock
let batchNum = 1
while (currentFrom <= toBlock) {
const currentTo = currentFrom + BATCH_SIZE - 1n > toBlock
? toBlock
: currentFrom + BATCH_SIZE - 1n
try {
const events = await client.getLogs({
address: MITEDDY_CONTRACT,
event: TRANSFER_ABI[0],
fromBlock: currentFrom,
toBlock: currentTo,
})
allEvents.push(...events)
console.log(` Batch ${batchNum}: Blocks ${currentFrom}-${currentTo} - Found ${events.length} events`)
} catch (error: any) {
console.log(` Batch ${batchNum}: Error - ${error.message}`)
}
currentFrom = currentTo + 1n
batchNum++
if (currentFrom <= toBlock) {
await new Promise(resolve => setTimeout(resolve, 200))
}
}
return allEvents
}
async function checkMintTimingPattern() {
console.log('🔍 Checking Mint Timing Patterns\n')
console.log('='.repeat(80))
console.log(`Analyzing successful mints from MiTeddy contract: ${MITEDDY_CONTRACT}\n`)
// Use public RPCs
const publicRPCs = [
'https://rpc.berachain.com',
'https://berachain-rpc.publicnode.com',
'https://berachain.drpc.org',
]
let client: ReturnType<typeof createPublicClient>
let rpcUsed = ''
for (const rpc of publicRPCs) {
try {
const testClient = createPublicClient({
chain: beraChain,
transport: http(rpc, { timeout: 10000 }),
})
await testClient.getBlockNumber()
client = testClient
rpcUsed = rpc
break
} catch (e) {
continue
}
}
if (!client!) {
throw new Error('Failed to connect to any RPC')
}
console.log(`📡 Using RPC: ${rpcUsed}\n`)
// Get current block
const currentBlock = await client.getBlockNumber()
console.log(`Current block: ${currentBlock}\n`)
// Search last 50,000 blocks (roughly 2-3 days)
const searchRange = 50000n
const fromBlock = currentBlock - searchRange
console.log(`Searching blocks ${fromBlock} to ${currentBlock} for Transfer events...\n`)
// Get Transfer events (batched to respect 10,000 block limit)
const transferEvents = await getMintEventsFromRPC(client, fromBlock, currentBlock)
console.log(`\nFound ${transferEvents.length} total Transfer events\n`)
// Filter for mints (Transfer from zero address)
const mints: MintEvent[] = []
for (const event of transferEvents) {
// Check if this is a mint (from zero address)
if (event.args.from?.toLowerCase() === '0x0000000000000000000000000000000000000000') {
// Get block to get timestamp
const block = await client.getBlock({ blockNumber: event.blockNumber })
const blockTimeMs = Number(block.timestamp) * 1000
const date = new Date(blockTimeMs)
// Calculate minutes after the hour
const minutesAfterHour = date.getUTCMinutes()
mints.push({
txHash: event.transactionHash,
blockNumber: Number(event.blockNumber),
blockTimestamp: Number(block.timestamp),
blockTimeMs,
minutesAfterHour,
timeString: date.toISOString(),
})
}
}
console.log(`✅ Found ${mints.length} successful mints\n`)
if (mints.length === 0) {
console.log('No mints found in the search range.')
return
}
// Analyze timing patterns
console.log('='.repeat(80))
console.log('📊 MINT TIMING ANALYSIS\n')
// Group by minutes after hour
const minutesDistribution: { [key: number]: number } = {}
mints.forEach(m => {
minutesDistribution[m.minutesAfterHour] = (minutesDistribution[m.minutesAfterHour] || 0) + 1
})
console.log('Mints by Minutes After Hour:')
const sortedMinutes = Object.entries(minutesDistribution)
.map(([min, count]) => ({ minute: parseInt(min), count }))
.sort((a, b) => b.count - a.count)
sortedMinutes.forEach(({ minute, count }) => {
const bar = '█'.repeat(count)
console.log(` ${minute.toString().padStart(2)} minutes: ${bar} (${count})`)
})
// Check specifically for 11 minutes pattern
const mintsAt11 = mints.filter(m => m.minutesAfterHour === 11)
console.log(`\n🎯 Mints at 11 minutes after the hour: ${mintsAt11.length}/${mints.length}`)
if (mintsAt11.length > 0) {
const percentage = (mintsAt11.length / mints.length) * 100
console.log(` Percentage: ${percentage.toFixed(1)}%`)
console.log(`\n Examples:`)
mintsAt11.slice(0, 5).forEach(m => {
const date = new Date(m.blockTimeMs)
console.log(` ${date.toISOString()} (Block ${m.blockNumber})`)
})
}
// Show all mints with their timing
console.log(`\n📋 All Successful Mints:`)
mints.sort((a, b) => Number(a.blockNumber) - Number(b.blockNumber))
mints.forEach((m, idx) => {
const date = new Date(m.blockTimeMs)
const timeStr = date.toISOString().substring(11, 19)
const dateStr = date.toISOString().substring(0, 10)
console.log(` ${(idx + 1).toString().padStart(2)}. ${dateStr} ${timeStr} UTC (${m.minutesAfterHour} min after hour) - Block ${m.blockNumber}`)
})
// Calculate average minutes after hour
const avgMinutes = mints.reduce((sum, m) => sum + m.minutesAfterHour, 0) / mints.length
console.log(`\n📊 Average minutes after hour: ${avgMinutes.toFixed(1)}`)
// Check if pattern is consistent
const percentage = mintsAt11.length > 0 ? (mintsAt11.length / mints.length) * 100 : 0
if (mintsAt11.length >= mints.length * 0.5) {
console.log(`\n✅ STRONG PATTERN: ${percentage.toFixed(1)}% of mints occur at 11 minutes after the hour!`)
console.log(` This suggests the unlock time is consistently at XX:11:XX`)
} else if (mintsAt11.length > 0) {
console.log(`\n⚠️ Some mints at 11 minutes, but not a strong pattern`)
}
// Save results
const results = {
totalMints: mints.length,
mintsAt11Minutes: mintsAt11.length,
percentageAt11: mintsAt11.length > 0 ? (mintsAt11.length / mints.length) * 100 : 0,
averageMinutesAfterHour: avgMinutes,
minutesDistribution,
allMints: mints.map(m => ({
txHash: m.txHash,
blockNumber: m.blockNumber.toString(),
timestamp: m.timeString,
minutesAfterHour: m.minutesAfterHour,
})),
}
const fs = await import('fs')
fs.writeFileSync('mint-timing-analysis.json', JSON.stringify(results, null, 2))
console.log(`\n💾 Results saved to mint-timing-analysis.json`)
}
checkMintTimingPattern().catch((error) => {
console.error('Fatal error:', error)
process.exit(1)
})