Skip to content

Limit Order fixes#22

Open
dkuthoore wants to merge 4 commits intooyaprotocol:mainfrom
dkuthoore:dk/limitOrder-fixes
Open

Limit Order fixes#22
dkuthoore wants to merge 4 commits intooyaprotocol:mainfrom
dkuthoore:dk/limitOrder-fixes

Conversation

@dkuthoore
Copy link
Contributor

Summary

This PR addresses the remaining review comments from #20:
(1) enforce the price limit predicate in validateToolCalls before approving swaps;
(2) enforce the SMA predicate in the SMA variant;
(3) set the hydration lock only after a successful ProposalExecuted log fetch so failed fetches are retried. It also adds a validity guard for SMA and price data in the limit-order-sma agent.

Changes

1. Enforce limit predicate (limit-order)

  • agent-library/agents/limit-order/agent.js: Added LIMIT_PRICE_USD = 2000 and a price check in validateToolCalls before validated.push. Fetches ethPriceUSD via Chainlink (with CoinGecko fallback) and throws if ethPriceUSD > LIMIT_PRICE_USD.

2. Enforce SMA predicate (limit-order-sma)

  • agent-library/agents/limit-order-sma/agent.js: In validateToolCalls, before validated.push, fetches ethPriceUSD and smaEth200USD from fetchEthPriceDataFromCoinGecko() and throws if ethPriceUSD > smaEth200USD. Adds a validity guard that throws if smaEth200USD or ethPriceUSD is null, undefined, or not finite before the comparison.

3. Defer hydration lock until log fetch succeeds

  • agent-library/agents/limit-order/agent.js and agent-library/agents/limit-order-sma/agent.js: In reconcileProposalSubmission, moved hydratedFromChain = true from before the getLogs call to after it (inside the try block). If getLogs throws, hydration is not marked complete and the next poll retries.

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.

1 participant