Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
27a35d8
add auto redeem
mahsamoosavi Jun 23, 2025
c2bf3dd
add private key to the env sample
mahsamoosavi Jun 23, 2025
654a326
mark auto redeemed tickets as Ignore in Notion
mahsamoosavi Jun 23, 2025
cdb6d3e
Revert "mark auto redeemed tickets as Ignore in Notion"
mahsamoosavi Jun 23, 2025
206d1af
update State to "Bot Success" or "Bot Failed" based on auto-redeem re…
mahsamoosavi Jun 23, 2025
75439e3
Update packages/retryable-monitor/handlers/notion/alertUntriagedRetra…
mahsamoosavi Aug 22, 2025
dc1b174
Update packages/retryable-monitor/handlers/notion/alertUntriagedRetra…
mahsamoosavi Aug 22, 2025
3682e0c
Merge remote-tracking branch 'origin/main' into add-auto-redeem
mahsamoosavi Aug 22, 2025
be41b10
Merge branch 'add-auto-redeem' of https://github.com/OffchainLabs/arb…
mahsamoosavi Aug 22, 2025
a47300a
improve retryable alert flow and rename Notion column to Bot Redempti…
mahsamoosavi Aug 22, 2025
fd77cf8
add explicit type for Notion query response to resolve TS7022
mahsamoosavi Aug 22, 2025
2462f48
write 'Bot Redemption Status' on create/update/executed
mahsamoosavi Aug 22, 2025
2bd9b9d
improve redeemRetryable with env check, existing redeem detection, an…
mahsamoosavi Aug 22, 2025
163cc4d
update comments
mahsamoosavi Aug 25, 2025
1508b46
add --autoRedeem flag to enable optional silent redemption of retryables
mahsamoosavi Aug 27, 2025
be12747
add 24–72h Slack alert for Should Redeem when auto-redeem is disabled
mahsamoosavi Aug 27, 2025
f01bdae
Rename env-sample's PRIVATE_KEY
mahsamoosavi Aug 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NODE_ENV=

RETRYABLE_MONITORING_SLACK_TOKEN=
RETRYABLE_MONITORING_SLACK_CHANNEL=
PRIVATE_KEY=

BATCH_POSTER_MONITORING_SLACK_TOKEN=
BATCH_POSTER_MONITORING_SLACK_CHANNEL=
Expand Down
43 changes: 43 additions & 0 deletions packages/retryable-monitor/core/redeemRetryable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { providers, Wallet } from 'ethers'
import {
ParentTransactionReceipt,
ParentToChildMessageStatus,
} from '@arbitrum/sdk'
import { getConfig, DEFAULT_CONFIG_PATH } from '../../utils'
import dotenv from 'dotenv'

dotenv.config()

export const redeemRetryable = async (parentTxHash: string): Promise<string> => {
const config = getConfig({ configPath: DEFAULT_CONFIG_PATH })

for (const childChain of config.childChains) {
try {
const parentChainProvider = new providers.JsonRpcProvider(childChain.parentRpcUrl)
const receipt = await parentChainProvider.getTransactionReceipt(parentTxHash)
if (!receipt) continue // not found on this chain

// If we found the receipt, this is our matching chain
const childChainProvider = new providers.JsonRpcProvider(childChain.orbitRpcUrl)
const wallet = new Wallet(process.env.PRIVATE_KEY!, childChainProvider)

const parentReceipt = new ParentTransactionReceipt(receipt)
const messages = await parentReceipt.getParentToChildMessages(wallet)
const message = messages[0]

const result = await message.getSuccessfulRedeem()
if (result.status === ParentToChildMessageStatus.REDEEMED) {
return result.childTxReceipt.transactionHash
}

const tx = await message.redeem()
const redeemReceipt = await tx.waitForRedeem()
return redeemReceipt.transactionHash
} catch (err) {
// Catch and move to next chain silently
continue
}
}

throw new Error(`❌ Parent tx ${parentTxHash} not found on any known parent chain.`)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { notionClient, databaseId } from './createNotionClient'
import { postSlackMessage } from '../slack/postSlackMessage'
import { redeemRetryable } from '../../core/redeemRetryable'

const formatDate = (iso: string | undefined) => {
if (!iso) return '(unknown)'
Expand Down Expand Up @@ -69,10 +70,37 @@ export const alertUntriagedNotionRetryables = async () => {
message = `⚠️ Retryable ticket needs triage:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n• Parent Tx: ${parentTx}\n• Deposit: ${deposit}\n→ Please review and decide whether to redeem or ignore.`
}
} else if (decision === 'Should Redeem') {
if (!isNearExpiry(timeoutRaw)) continue
message = `🚨 Retryable marked for redemption and nearing expiry:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n• Parent Tx: ${parentTx}\n• Deposit: ${deposit}\n→ Check why it hasn't been executed.`
} else {
continue
const isUnder24h = isNearExpiry(timeoutRaw, 24)
const isOver4DaysLeft = hoursLeft > 96

if (isUnder24h) {
message = `🚨 Retryable marked for redemption and nearing expiry:\n• Retryable: ${retryableUrl}\n• Timeout: ${timeoutStr}\n• Parent Tx: ${parentTx}\n• Deposit: ${deposit}\n→ Check why it hasn't been executed.`
} else if (isOver4DaysLeft) {
try {
await redeemRetryable(parentTx)

await notionClient.pages.update({
page_id: page.id,
properties: {
State: {
select: { name: 'Bot Success' },
},
},
})
} catch (err) {
await notionClient.pages.update({
page_id: page.id,
properties: {
State: {
select: { name: 'Bot Failed' },
},
},
})
}
continue // no Slack message
} else {
continue // not under 24h or over 4d, skip
}
}

await postSlackMessage({ message })
Expand Down