Skip to content

Conversation

@princetonbishop
Copy link
Collaborator

@princetonbishop princetonbishop commented Jan 15, 2026

Description

What does this PR solve?

Fixes # (issue)

Checklist

  • Code follows the style guide
  • I have performed a self-review of my own code
  • New and existing tests pass locally
  • This PR is targeting the correct branch

Summary by CodeRabbit

  • New Features

    • Automation now processes multiple spice auctions independently and sends per-auction notifications.
    • Added a helper to discover configured spice auctions.
  • Configuration

    • Added SENA contract addresses across mainnet and testnets.
    • New configurable max gas price for Temple Gold burn operations.
  • Behavioral Changes

    • Approval and burn flows updated to operate per-auction.

✏️ Tip: You can customize this high-level summary in your review settings.

@princetonbishop princetonbishop requested a review from a team as a code owner January 15, 2026 13:16
@princetonbishop
Copy link
Collaborator Author

@CodeRabbit summary

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

✅ Actions performed

Summary regeneration triggered.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This PR adds a new SENA address field to TEMPLE_GOLD.AUCTIONS.BID_FOR_SPICE across network configs and updates the ContractAddresses type. It introduces getSpiceAuctions(contracts) to extract valid auction addresses and changes task signatures/config to pass auctions[] instead of a single auction. The spice-auction burn-and-notify task and main-localtest setup are refactored to iterate over auctions[], performing per-auction approval, epoch inspection, burnAndNotify transactions, and per-auction gas handling and logging.

Sequence Diagram(s)

sequenceDiagram
    participant TaskRunner as Task Runner
    participant Config as Contract Config
    participant Helper as getSpiceAuctions
    participant BurnFlow as Burn & Notify Flow
    participant Auction as Spice Auction Contract
    participant TempleGold as TempleGold Contract

    TaskRunner->>Config: read TEMPLE_GOLD.AUCTIONS.BID_FOR_SPICE
    Config-->>Helper: provide BID_FOR_SPICE object
    Helper->>Helper: filter valid addresses (isAddress)
    Helper-->>TaskRunner: return auctions: Address[]

    TaskRunner->>BurnFlow: invoke with auctions[]
    loop for each auctionAddress
        BurnFlow->>Auction: instantiate contract at auctionAddress
        BurnFlow->>Auction: approveMaxTgld(auction)
        Auction-->>BurnFlow: approval confirmed
        BurnFlow->>Auction: read currentEpoch & epochInfo
        Auction-->>BurnFlow: epoch data
        BurnFlow->>BurnFlow: gather unnotified epochs (per-auction)
        BurnFlow-->>Auction: send burnAndNotify(tx) (with per-auction gas override if needed)
        Auction-->>BurnFlow: tx confirmed
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description uses only the template without filling in actual details about what the PR solves, with all checklist items unchecked and no issue number provided. Fill in the description with a summary of changes, provide the related issue number, and check off applicable checklist items before merging.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'handle multiple auctions TGLD burn' directly reflects the main objective of the PR, which refactors the codebase to support multiple spice auctions instead of a single auction for TGLD burn operations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@princetonbishop
Copy link
Collaborator Author

@CodeRabbit summary

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

✅ Actions performed

Summary regeneration triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/automation/automation-v2/src/main-localtest/mainnet.ts`:
- Around line 273-277: The code currently reads the daoExecutor from the
hardcoded config.contracts.TEMPLE_GOLD.AUCTIONS.BID_FOR_SPICE.ENA which can be
the placeholder '0x' in some environments; update the logic in the block that
sets executorAddress (the tclient.readContract call) to first attempt using
config value but fall back to the first valid auction address returned by
getSpiceAuctions() (or filter out invalid '0x' entries) and use that address for
the readContract call so spiceAuctionTestSetup can run against anvil/local
configs.
🧹 Nitpick comments (4)
apps/automation/automation-v2/src/tasks/index.ts (1)

172-175: Use const instead of let for immutable variable.

The auctions variable is never reassigned, so const is more appropriate.

Suggested fix
 export function getSpiceAuctions(contracts: ContractAddresses): Address[] {
-    let auctions = Object.values(contracts.TEMPLE_GOLD.AUCTIONS.BID_FOR_SPICE) as Address[];
+    const auctions = Object.values(contracts.TEMPLE_GOLD.AUCTIONS.BID_FOR_SPICE) as Address[];
     return auctions.filter((auction) => isAddress(auction));
 }
apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts (2)

26-28: Rename type aliases to avoid shadowing imported namespaces.

The type aliases AuctionBase and TempleGold shadow the namespace imports of the same names. While TypeScript separates type and value bindings (so AuctionBase.ABI still resolves to the namespace), this creates confusion and triggers static analysis warnings.

Suggested fix
-type Auction = GetContractReturnType<typeof Spice.ABI, PublicClient>;
-type AuctionBase = GetContractReturnType<typeof AuctionBase.ABI, PublicClient>;
-type TempleGold = GetContractReturnType<typeof TempleGold.ABI, PublicClient>;
+type SpiceAuctionContract = GetContractReturnType<typeof Spice.ABI, PublicClient>;
+type AuctionBaseContract = GetContractReturnType<typeof AuctionBase.ABI, PublicClient>;
+type TempleGoldContract = GetContractReturnType<typeof TempleGold.ABI, PublicClient>;

Then update all usages of these types throughout the file (e.g., approveMaxTgld(auction: SpiceAuctionContract), getTotalBidTokenAmount(auctionBase: AuctionBaseContract, ...), etc.).


114-170: Consider adding per-auction error handling to prevent one failure from blocking others.

Currently, if burnAndNotify fails for one auction, the entire task fails and subsequent auctions won't be processed. Depending on operational requirements, you may want to catch errors per-auction, log them, and continue processing remaining auctions.

Optional: wrap per-auction processing in try-catch
   for (const auctionAddress of params.contracts.auctions) {
+    try {
       const auction = getContract({
         address: auctionAddress,
         abi: Spice.ABI,
         client: pclient
       });
       // ... rest of auction processing ...
+    } catch (error) {
+      ctx.logger.error(`Failed to process auction ${auctionAddress}: ${error}`);
+      // Optionally: continue to next auction instead of failing task
+    }
   }
apps/automation/automation-v2/src/main-localtest/mainnet.ts (1)

284-294: Consider per-auction error handling

If setOperator fails for one auction, the remaining auctions won't be processed. For test setup this may be acceptable, but you might want to wrap each iteration in a try-catch to ensure all auctions are attempted and failures are logged.

Optional: Add per-iteration error handling
  for (const auctionAddress of auctionAddresses) {
+   try {
      const hash = await tclient.writeContract({
        abi: ISpiceAuction.ABI,
        address: auctionAddress,
        functionName: 'setOperator',
        args: [tclient.account.address],
        account: executorAddress,
      });
      const txReceipt = await tclient.waitForTransactionReceipt({ hash });
      console.log(txReceipt);
+   } catch (e) {
+     ctx.logger.error(`Failed to set operator for auction ${auctionAddress}: ${e}`);
+   }
  }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a3c762 and a3fa103.

📒 Files selected for processing (8)
  • apps/automation/automation-v2/src/config/contract_addresses/anvil.ts
  • apps/automation/automation-v2/src/config/contract_addresses/arbsepolia.ts
  • apps/automation/automation-v2/src/config/contract_addresses/mainnet.ts
  • apps/automation/automation-v2/src/config/contract_addresses/sepolia.ts
  • apps/automation/automation-v2/src/config/contract_addresses/types.ts
  • apps/automation/automation-v2/src/main-localtest/mainnet.ts
  • apps/automation/automation-v2/src/tasks/index.ts
  • apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-30T23:20:17.523Z
Learnt from: frontier159
Repo: TempleDAO/temple PR: 1214
File: protocol/scripts/deploys/mainnet/team-payments/deploy.ts:9-9
Timestamp: 2025-08-30T23:20:17.523Z
Learning: In Temple DAO's protocol/scripts/deploys/mainnet/team-payments/deploy.ts, the user prefers to keep hard-coded imports for epoch snapshot JSON files (like epoch29b.json) rather than parametrizing them. Avoid suggesting refactoring to make snapshot files runtime parameters.

Applied to files:

  • apps/automation/automation-v2/src/tasks/index.ts
  • apps/automation/automation-v2/src/main-localtest/mainnet.ts
📚 Learning: 2026-01-13T14:59:55.049Z
Learnt from: marshall2112
Repo: TempleDAO/temple PR: 1224
File: apps/dapp/src/components/Pages/Core/DappPages/SpiceBazaar/MyActivity/BidsForSpice/hooks/use-myActivity-bidsSpiceHistory.ts:133-136
Timestamp: 2026-01-13T14:59:55.049Z
Learning: In apps/dapp/src/components/Pages/Core/DappPages/SpiceBazaar/MyActivity/BidsForSpice/hooks/use-myActivity-bidsSpiceHistory.ts, the useEffect that calls fetchData intentionally only depends on wallet, not on fetchData, allAuctions, or getClaimableAtEpoch. This is by design to refetch only when the wallet changes, not when auction data updates.

Applied to files:

  • apps/automation/automation-v2/src/tasks/index.ts
  • apps/automation/automation-v2/src/main-localtest/mainnet.ts
  • apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts
📚 Learning: 2025-12-12T00:37:50.665Z
Learnt from: marshall2112
Repo: TempleDAO/temple PR: 1224
File: apps/dapp/src/components/Pages/Core/DappPages/SpiceBazaar/Spend/Details/Details.tsx:89-105
Timestamp: 2025-12-12T00:37:50.665Z
Learning: In apps/dapp/src/components/Pages/Core/DappPages/SpiceBazaar/Spend/Details/Details.tsx, timestamp fields auctionStartTime and auctionEndTime are already in milliseconds from the provider, while nextAuctionStartTimestamp is in seconds and must be converted with * 1000 at the call site. Treating timestamp value 0 as invalid/unset is correct domain behavior for auction timestamps.

Applied to files:

  • apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts
🧬 Code graph analysis (2)
apps/automation/automation-v2/src/tasks/index.ts (1)
apps/automation/automation-v2/src/config/contract_addresses/types.ts (1)
  • ContractAddresses (3-34)
apps/automation/automation-v2/src/main-localtest/mainnet.ts (1)
apps/automation/automation-v2/src/tasks/index.ts (1)
  • getSpiceAuctions (172-175)
🪛 Biome (2.1.2)
apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts

[error] 27-27: Shouldn't redeclare 'AuctionBase'. Consider to delete it or rename it.

'AuctionBase' is defined here:

(lint/suspicious/noRedeclare)


[error] 28-28: Shouldn't redeclare 'TempleGold'. Consider to delete it or rename it.

'TempleGold' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (11)
apps/automation/automation-v2/src/tasks/index.ts (1)

146-147: LGTM - multi-auction integration looks correct.

Both Sepolia and mainnet burn tasks now properly use getSpiceAuctions to extract valid auction addresses, enabling the multi-auction burn flow.

Also applies to: 161-162

apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts (2)

57-71: LGTM - approval logic correctly parameterized per-auction.

The approveMaxTgld function now properly accepts an auction context and approves spending for that specific auction address when allowance is zero.


78-107: LGTM - epoch gathering logic correctly parameterized.

The gatherAllUnnotifiedEpochs function properly accepts auction and auctionBase contexts, enabling per-auction epoch processing with appropriate logging.

apps/automation/automation-v2/src/config/contract_addresses/types.ts (1)

19-23: LGTM - type extension for SENA auction support.

The addition of SENA: Address properly extends the BID_FOR_SPICE type to support the new auction.

apps/automation/automation-v2/src/config/contract_addresses/sepolia.ts (1)

19-23: LGTM - placeholder value will be correctly filtered.

The '0x' placeholder for SENA (and ENA) will be correctly filtered out by isAddress in getSpiceAuctions, so only the valid DAI auction address will be processed on Sepolia.

apps/automation/automation-v2/src/config/contract_addresses/arbsepolia.ts (1)

19-23: LGTM - placeholder configuration for arbsepolia.

All BID_FOR_SPICE addresses are placeholders ('0x'), which will result in an empty array from getSpiceAuctions. The burn task will iterate over an empty array and complete successfully (no-op until auctions are deployed).

apps/automation/automation-v2/src/config/contract_addresses/anvil.ts (1)

19-23: LGTM - Consistent placeholder pattern

The SENA field with placeholder '0x' follows the same pattern used in other test/dev environments. The getSpiceAuctions helper filters out invalid addresses via isAddress, so this won't cause runtime issues.

apps/automation/automation-v2/src/config/contract_addresses/mainnet.ts (1)

22-22: LGTM - New SENA auction address

The SENA auction contract address is added with valid format. This enables the multi-auction burn functionality for mainnet.

apps/automation/automation-v2/src/main-localtest/mainnet.ts (3)

14-14: LGTM - Import addition

The getSpiceAuctions import is correctly added to support the multi-auction iteration pattern introduced in this PR.


49-49: LGTM - Gas price configuration

New burn_tgld_max_gas_price config variable added with reasonable default for local testing.


430-443: LGTM - Multi-auction burn integration

The burnTempleGold function correctly passes the filtered auction addresses via getSpiceAuctions and uses the new dedicated burn_tgld_max_gas_price configuration variable. The getSpiceAuctions helper ensures only valid addresses (filtering out '0x' placeholders) are processed.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

frontier159
frontier159 previously approved these changes Jan 16, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@apps/automation/automation-v2/src/tasks/spice-auction-burn-and-notify.ts`:
- Around line 128-129: The log and sort are wrong: replace ctx.logger.info using
unnotifiedEpochs.keys.length with unnotifiedEpochs.size, and fix the BigInt
comparator in Array.from(unnotifiedEpochs.keys()).sort by using an ordinal
comparator that works for BigInt (e.g. (a,b) => a < b ? -1 : a > b ? 1 : 0);
also ensure epochId is declared (e.g. let epochId) when iterating. Target
symbols: ctx.logger.info, unnotifiedEpochs,
Array.from(unnotifiedEpochs.keys()).sort, and epochId.
- Around line 10-33: The file declares an imported namespace `TempleGold` and
also a type alias `type TempleGold = GetContractReturnType<typeof
TempleGold.ABI, PublicClient>;`, causing a duplicate identifier; rename the type
alias (for example to `TempleGoldContract` or `TempleGoldInstance`) and update
every use of that type alias (references to `TempleGold` as a type, e.g., where
`Auction` and the former `TempleGold` type are used) so the import namespace
`TempleGold` remains unchanged and TypeScript compiles.

@princetonbishop princetonbishop merged commit 9e60b1f into stage Jan 19, 2026
3 checks passed
@princetonbishop princetonbishop deleted the spice-burn-update branch January 19, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants