Skip to main content

Common Types

CrossChainRecipient

Euclid enables the movement of assets and execution of actions across multiple chains within a unified routing system. In this context, it's very common for developers to work with recipients that exist on different chains. Whether you're sending tokens, triggering a remote swap, or executing logic across chains, you need to define who the recipient is and what chain they belong to.

Whether you’re sending funds, executing a remote contract call, or initiating a swap that settles elsewhere, you’ll often need to define who the receiver is, what chain they’re on, and how much they can receive.

This is where the CrossChainUser family of types comes into play.

Common Use Case: Cross-Chain Funds Delivery

Let's say you're building a swap mechanism where tokens from Ethereum are swapped and sent to a Cosmos chain. You’ll need to specify:

  • The recipient address
  • The destination chain (chain_uid)
  • A limit (optional) to cap the amount being sent

All of this is covered by the types below, used in our APIs.

Types

CrossChainUser

export interface CrossChainUser {
address: string | null;
chain_uid: string | null;
}

Return Fields

FieldTypeDescription
addressstringThe user’s address on the given chain.
chain_uidstringThe unique identifier of the chain.

CrossChainUserInput

export interface CrossChainUser {
  address: string | null;
  chain_uid: string | null;
}
{
  "address": "0xB0b123456789abcdef123456789abcdef1234567",
  "chain_uid": "base"
}

Input Fields

FieldTypeDescription
addressstring?The user’s address to look up or act on.
chain_uidstring?The chain UID of the user.

CrossChainUserWithLimit

export interface CrossChainUserWithLimit {
limit?: Limit | null;
user: CrossChainUser;
}

Return Fields

FieldTypeDescription
limitLimit?Optional token limit for the user (e.g., escrow cap).
userCrossChainUserThe user address and chain metadata.

Limit

export type Limit =
  | { less_than_or_equal: string }
  | { equal: string }
  | { greater_than_or_equal: string };
{
  "less_than_or_equal": "1000000000000000000"
}

TokenWithDenom

Represents a token and how it should be interpreted on-chain. The token_type determines if it's a native chain token, a smart contract token, or a voucher.

Structure

interface TokenWithDenom {
  token: string;
  token_type: TokenType;
}

type TokenType =
  | { native: { denom: string } }
  | { smart: { contract_address: string } }
  | { voucher: {} };
{
  "token": "usdc",
  "token_type": {
    "smart": {
      "contract_address": "0xA1b2C3d4E5F67890123456789abcdef123456789"
    }
  }
}

TokenType Variants

type TokenType =
| { native: { denom: string } }
| { smart: { contract_address: string } }
| { voucher: {} }

PairWithDenomAndAmount

Used when representing a pair of tokens along with their amounts and token type. Commonly used in swaps and pool-related contexts.

Structure

interface PairWithDenomAndAmount {
  token_1: TokenWithDenomAndAmount;
  token_2: TokenWithDenomAndAmount;
}

interface TokenWithDenomAndAmount {
  token: string;
  amount: string;
  token_type: TokenType;
}

type TokenType =
  | { native: { denom: string } }
  | { smart: { contract_address: string } }
  | { voucher: {} };
{
  "token_1": {
    "token": "usdt",
    "amount": "1000000",
    "token_type": {
      "native": {
        "denom": "usdt"
      }
    }
  },
  "token_2": {
    "token": "weth",
    "amount": "500000000000000000",
    "token_type": {
      "smart": {
        "contract_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
      }
    }
  }
}