Advanced Swap Errors Podcast

Understanding Swap Errors on the Goblins Protocol

When using the Goblins Protocol, you might encounter various swap errors. Here’s a detailed guide to understanding and troubleshooting these errors:

1. Goblins SPL (Square Root Price Limit)

Explanation:

  • SPL determines the highest price in the swap when swapping directly on a pool contract. It must be set appropriately to finalize the swap without exceeding limits.

Settings:

  • Goblins routers use the following values for sqrtPrice:
    • TickMath.MIN_SQRT_RATIO +1
    • TickMath.MAX_SQRT_RATIO -1

Requirements:

  • The sqrtPriceLimit must be above or below the current sqrtPrice but within the max/min sqrt_ratio.

2. STF Error (Safe Transfer Failed)

Possible Causes:

  • Missing Token Approvals: Ensure all required token contracts are approved for the appropriate amount.
  • Fee on Transfer or Honeypot Tokens: These tokens can cause transfer issues.
  • Insufficient Tokens: Verify you have enough tokens for the transaction.

3. TRANSFER_FAILED / TF

Meaning:

  • The core contract couldn’t send tokens to the recipient.

Possible Reasons:

  • Broken Token Contract: Review and test your code.
  • Insufficient Approvals: Approve a larger amount of tokens before swapping.
  • Disabled Transfer Function: The token creator might have disabled transfers to prevent selling.

4. Goblins: LOK (LOCKED)

Explanation:

  • This error is a security feature to prevent reentrancy attacks by blocking malicious code attempts.

Cause:

  • It occurs when attempting to call the same pool within the callback.

5. Goblins: Transaction Too Old / Universal Router: TransactionDeadlinePassed

Explanation:

  • This error occurs when a transaction takes too long to be included in a block.

Solution:

  • Increase Gas Prices: Ensure your gas settings are high enough to get your transaction processed quickly.
  • Extend Deadline: Adjust the transaction deadline to accommodate longer processing times.

6. Price/Token Change Errors

Common Errors:

  • Insufficient WBCH9 / InsufficientToken
  • IIA: Insufficient Input Amount
  • InsufficientBCH
  • V3TooLittleReceived / V3TooMuchRequested / V3InvalidAmountOut

Explanation:

  • These errors mean the price changed after you submitted the transaction. Increasing your slippage can help execute the transaction despite price changes.

Considerations:

  • Fee on Transfer Tokens: Include additional slippage to cover changes due to token fees.

7. Goblins: OLD

Explanation:

  • This error indicates that an observation on a pool hasn’t been extended, preventing the call.

8. Goblins NP

Explanation:

  • This occurs when trying to call a burn on a position without zero liquidity.

Rare Errors

  • T: The tick must be less than or equal to the maximum tick.
  • R: The sqrtPrice cannot be greater or less than the max/min sqrt_Ratio.
  • TLU: The lower tick must be below the upper tick.
  • TLM: The lower tick must be greater or equal to the minimum tick.
  • TUM: The upper tick must be less than or equal to the maximum tick.
  • AI: The pool is already initialized.
  • M0: Balance of token0 must be less than or equal to after minting.
  • M1: Balance of token1 must be less than or equal to after minting.
  • AS: The amount specified cannot be zero.
  • L: Liquidity must be greater than zero for a flash transaction.
  • F0/F1: Balance of token0/token1 before the flash transaction must be less than or equal to after the flash plus the fee.

Tips and Considerations

  • Adjust Slippage: Modify slippage limits in ‘Transaction settings’ to prevent errors due to price fluctuations.
  • Check Token Approvals: Ensure all necessary approvals are in place for the tokens involved.
  • Monitor Gas Fees: Set appropriate gas prices to avoid delays and deadline expirations.
  • Research Tokens: Verify token properties to ensure compatibility with Goblins.

By understanding swap errors and following the provided tips, you can enhance your experience and success rate when using the Goblins Protocol.