Errors

Smart Contract Errors

This section provides an overview of custom errors used across the TRP Protocol smart contracts.

1. Atomic Transactions

AtomicTransaction_SlippageError

Description: Triggered when the bought amount of tokens during a swap is less than expected, meaning slippage tolerance was exceeded. Use Case: Common in splitAndSwap when price movement becomes unfavorable.

AtomicTransaction_SwapError

Description: Indicates a generic failure during a swap operation. Use Case: Placeholder for future swap-related error states.

AtomicTransaction_InvalidBalance

Description: Raised when the user’s approved balance is insufficient for the operation. Use Case: Occurs in deposit if allowance < deposit amount.

AtomicTransaction_InvalidParams

Description: Triggered when input parameters are invalid (e.g., zero address or zero amounts). Use Case: Happens in splitAndSwap when any required parameter is improperly set.

AtomicTransaction_BalancerError

Description: Raised when the Balancer pool does not support the provided tokens. Use Case: Thrown in splitAndSwap if sell/buy tokens are not bound to the pool.

AtomicTransaction_ExpiryReached

Description: Operation attempted after the expiry date has passed. Use Case: Used in the expiryDateCheck modifier.


2. Flash Loans

FlashLoan__InsufficientUnderlying

Description: Pool lacks sufficient underlying assets for the flash loan. Use Case: Raised in flashLoan when assets available < assets requested.

FlashLoan__FailedExecOps

Description: Receiver contract failed to execute the flash loan logic. Use Case: Thrown when executeOperation returns false.

FlashLoan__FailedRepayments

Description: Borrower did not repay loan + premiums. Use Case: Thrown during post-loan repayment checks.

FlashLoan__InvalidReceiver

Description: Receiver address is zero or invalid. Use Case: Occurs if an invalid receiver is passed to flashLoan.


3. Misc Errors

BaseContract__SanctionedAddress

Description: Address interacting with the contract is sanctioned. Use Case: Thrown by onlyNotSanctioned.

BaseContract__DepositCircuitBreaker

Description: Deposits blocked by deposit circuit breaker. Use Case: Thrown by stopDeposit.

BaseContract__WithdrawCircuitBreaker

Description: Withdrawals blocked by withdraw circuit breaker. Use Case: Thrown by stopWithdraw.

BaseContract__TransferCircuitBreaker

Description: Transfers blocked by transfer circuit breaker. Use Case: Thrown by stopTransfer.

BaseContract__RebalanceCircuitBreaker

Description: Rebalance actions are halted. Use Case: Thrown by stopRebalance.

BaseContract__FlashLoanCircuitBreaker

Description: Flash loan actions are halted. Use Case: Thrown by stopFlashLoan.


4. Smart Token Errors

SmartToken__NotTokenFactory

Description: Caller is not the TokenFactory. Use Case: Enforced by onlyTokenFactory.

SmartToken__MethodNotAllowed

Description: Operation is not permitted in this context. Use Case: E.g., handling of non-native tokens.

SmartToken__DepositMoreThanMax

Description: Deposit exceeds user-specific maximum. Use Case: Thrown in deposit functions.

SmartToken__MintMoreThanMax

Description: Minting exceeds allowed maximum. Use Case: Thrown in mint.

SmartToken__WithdrawMoreThanMax

Description: Withdrawal exceeds allowed user maximum. Use Case: Thrown in withdraw.

SmartToken__RedeemMoreThanMax

Description: Redemption exceeds user maximum. Use Case: Thrown in redeem.

SmartToken__OnlyAssetOwner

Description: Caller is not the asset owner. Use Case: Enforced by onlyAssetOwner.

SmartToken__ZeroDeposit

Description: Deposit amount is zero. Use Case: Thrown when zero deposit is attempted.

SmartToken__InsufficientUnderlying

Description: Not enough underlying assets to complete operation. Use Case: Often occurs during withdrawals.

SmartToken__DepositLimitHit

Description: User reached periodic deposit limit. Use Case: Thrown in deposit flows.

SmartToken__WithdrawLimitHit

Description: User reached periodic withdrawal limit. Use Case: Thrown in withdraw flows.

SmartToken__ExpiryDateReached

Description: Operation attempted after expiry date. Use Case: Thrown by expiry checks.

SmartToken__WithdrawNativeFailed

Description: Native token withdrawal failed. Use Case: E.g., ETH transfer failure.


5. TokenFactory Errors

TokenFactory__MethodNotAllowed

Description: Function restricted to specific caller. Use Case: Guarded by onlySmartTokens, onlyOrchestrator, etc.

TokenFactory__InvalidDivision

Description: Invalid division (divide by zero, invalid period). Use Case: Fee calculation and similar processes.

TokenFactory__InvalidRebalanceParams

Description: Provided params invalid for rebalance. Use Case: Asset values or smart token prices mismatch.

TokenFactory__InvalidSequenceNumber

Description: Rebalance sequence number is incorrect or reused. Use Case: Checked in executeRebalance.

TokenFactory__InvalidNaturalRebalance

Description: Natural rebalance attempted too early. Use Case: Timestamp does not meet interval.

TokenFactory__AlreadyInitialized

Description: Initialization attempted more than once. Use Case: Thrown in initializeSMART.

TokenFactory__InvalidSignature

Description: Signature does not match authorized signers. Use Case: In verifyAndDecode.

TokenFactory__InvalidSignatureLength

Description: Signature length invalid. Use Case: During signature verification.

TokenFactory__InvalidManagementFees

Description: Management fee > allowed limit. Use Case: Thrown in setManagementFeeRate.

TokenFactory__SmartTokenArrayOutOfBounds

Description: Index out of smart token array bounds. Use Case: Accessing non-existing tokens.

TokenFactory__NoPremiumsToDrain

Description: No flashloan premiums available. Use Case: In drainFlashloanPremiums.


6. Orchestrator Errors

Orchestrator_FailedOperation

Description: Downstream operation failed. Use Case: During rebalance calls.

Orchestrator_Index_Out_Bounds

Description: Provided index is invalid. Use Case: When modifying operations or pool lists.

Orchestrator_Wrong_Dest_Addr

Description: Destination address mismatch for given operation index. Use Case: Thrown in setOperationEnabled.


7. Swap Operations

SwapNotPublic

Description: Swap attempted while public swap is disabled. Use Case: In swapExactAmountIn and swapExactAmountOut.

BadLimitPrice

Description: Spot price before swap > user’s max price. Use Case: Pre-swap limit check.

LimitPrice

Description: Spot price after swap exceeds max price. Use Case: Post-swap limit check.

LimitIn

Description: Input amount exceeds allowed maximum. Use Case: In joinPool, join-swap, swap-out.

LimitOut

Description: Output amount < minimum expected. Use Case: In exitPool, exit-swap, swap-in.

MaxInRatio

Description: tokenAmountIn > balance × MAX_IN_RATIO. Use Case: Safety cap for swap/join.

MaxOutRatio

Description: tokenAmountOut > balance × MAX_OUT_RATIO. Use Case: Safety cap for swap/exit.


8. Volatility-Based Fee System

InvalidSignature

Description: ECDSA verification failed; signer unauthorized. Use Case: In verifyAndDecodeFee.

StaleData

Description: Fee data timestamp older than staleness threshold. Use Case: In _getDynamicFee.

FeeOutOfBounds

Description: Fee < minFee or > maxFee. Use Case: Thrown in _getDynamicFee.


9. Pool Configuration Errors

NotController

Description: Caller not pool controller. Use Case: Admin operations.

IsFinalized

Description: Operation requires unfinalized pool. Use Case: bind/rebind/unbind/setPublicSwap.

NotFinalized

Description: Pool not finalized but operation requires it. Use Case: swap/join/exit.

IsBound

Description: Token already bound. Use Case: In bind.

NotBound

Description: Token not bound to pool. Use Case: swap/query/rebind.

MinTokens / MaxTokens

Description: Token count < min or > max. Use Case: During finalize and bind.

MinWeight / MaxWeight / MaxTotalWeight

Description: Weight parameters invalid. Use Case: rebind.

MinBalance

Description: Token balance < minimum allowed. Use Case: rebind.


10. Circuit Breakers (Balancer Pool)

BPOOL_Swap_Circuit_Breaker

BPOOL_Join_Circuit_Breaker

BPOOL_Exit_Circuit_Breaker

BPOOL_Join_Swap_Circuit_Breaker

BPOOL_Exit_Swap_Circuit_Breaker

All indicate that specific operations are disabled due to emergency circuit breakers.

Last updated