Users only have to rely on two things: Tern’s contracts and your app. Everyone else involved, including Tern itself, can make a swap faster or slower, but can’t take the user’s funds or send them anywhere else.

What users don’t have to trust

  • Tern. Tern finds prices, watches the chains, submits transactions, and sends refunds. It can’t move a deposit except to its rightful recipient, or back to the user. If Tern went offline, swaps in progress would refund.
  • Solvers. A solver can only collect a deposit after the user has been paid.
  • Whoever sends refunds. A refund can only go back to the original sender, so it doesn’t matter who triggers it.

What users do rely on

  • Tern’s contracts. They have no owner, pause, allowlist, or upgrade mechanism, so their rules can never change. They have the same address on every EVM chain Tern supports. The full rules are in the escrow specification and the TernSwap specification.
  • Your app’s check before settlement. Before revealing the secret, your app checks on chain that the solver has really locked the user’s tokens. That check is what makes revealing safe.
  • The minimum, for same-chain swaps. Tern’s swap contract pays at least the quoted minimum, whatever the route does, or the swap reverts.

What your app must get right

  1. Use a new secret for every quote. Generate it with a secure random generator, store it before requesting the quote, and never log it. Reusing one is refused (409 condition_reused), because one revealed secret would unlock every swap that used it.
  2. Check before you reveal. Confirm the solver’s locked tokens through your own connection to the chain, as the cross-chain guide shows. Don’t rely on Tern’s status or a webhook alone. Once revealed, the secret is public.
  3. Use an address the user controls as sender. That’s where refunds go.
  4. Hard-code Tern’s contract addresses from Contract addresses. Before the user signs, check that a quote’s transactions only approve the token being sold to those contracts and then call them.
  5. Keep API keys on your server. A key can’t move funds, but anyone holding it can use your rate limit and have quotes counted as yours.

Known limitations

  • Leftover approvals in a route. If a same-chain route left a token approval behind, a later swap could lose the refund of any unspent input, never its minimum. Tern only builds routes from known DEX contracts, which keeps such routes out.
  • Audits. The contracts haven’t been externally audited yet.

Report a vulnerability

Email [email protected] with the details and a way to reach you. Please don’t share it publicly until we’ve replied.