Overview

ParaSwap Delta is a new set of smart contracts developed by ParaSwap. It's built on top of the Portikus Intents network and is currently available on the Ethereum network and Base. This development unlocks several benefits for swapping tokens, including:

  • Gas-less trading: users can submit a trade without using a gas token, as Delta will execute the trades on their behalf.

  • MEV Protection: By submitting your trade through ParaSwap Delta, you can protect your users’ swaps from events like sandwich attacks.

  • Price Competition: ParaSwap Delta is increasingly competitive as different agents compete to deliver the best possible prices to users.

Simple Delta flow using API with axios looks like this:

1. Request prices for a token pair

This function is used to fetch a price quote for swapping

In this case, we’re swapping 100 DAI for PSP tokens on Ethereum (chainId: 1) using ParaSwap’s Delta API.

const API_URL = 'https://api.paraswap.io';
const DAI_TOKEN = '0x6b175474e89094c44da98b954eedeac495271d0f';
const PSP_TOKEN = '0xcafe001067cdef266afb7eb5a286dcfd277f3de5';

const { data: quote } = await axios.get(`${API_URL}/quote`, {
  params: {
    chainId: 1,
    srcToken: DAI_TOKEN,
    destToken: PSP_TOKEN,
    amount: '100000000000000000000', // 100 DAI
    srcDecimals: 18,
    destDecimals: 18,
    mode: 'delta',
    side: 'SELL',
  },
});

2. Build a Delta order

On this section, partners can pick between two models:

  • Fee Model: It allows partners to take up to 2% of the trade in partner fees (200 bps)

  • Surplus Model: Which only works if a surplus is generated from the trade. On this case, the partner will collect 50% of the order surplus instead of a flat percent fee to the specified partner address.

const accountWallet = new ethers.Wallet(/*Private Key or Mnemonic*/);

const { data: builtOrder } = await axios.post(`${API_URL}/orders/build`, {
  price: quote.delta,
  chainId: 1,
  owner: account.address,
  /* if you want to collect fees
  partnerAddress: /.../,
  partnerFeeBps: /.../,
  */
});

3. Sign the received Order

This part of the code uses EIP-712 for Signing, which is a standard for signing structured data on Ethereum, allowing off-chain signatures that can be verified on-chain without gas costs. This ensures a secure, gas-efficient, and human-readable signing process.

// Delta protocol works with EIP-712 signatures
const signature = accountWallet.signTypedData(
  builtOrder.domain,
  builtOrder.types,
  builtOrder.value,
);

// compact the signature
const compactSignature = ethers.Signature.from(signature).compactSerialized;

4. Submit the signed Order

At this stage, the signed order is sent and an auction is performed between all the available Agents.

const { data: deltaAuction } = await axios.post(`${API_URL}/orders`, {
  chainId: 1,
  order: builtOrder.value,
  signature: compactSignature,
  // partner: '...' // if available
});

5. Check the Order Auction Status

This function is used to check the status of an order and retrieve a result.

If the order status is executed, it means a taker has filled the order, and the swap has been completed.

If the status is still 'PENDING' or 'OPEN', the order is waiting for execution.

// poll if necessary
const { data: auction } = await axios.get(`${API_URL}/orders/${deltaAuction.id}`);
if (auction?.status === 'EXECUTED') {
  console.log('Auction was executed');
}

A more detailed example of Delta usage, including fallback to Market (traditional swapping flow), can be found in examples.

Last updated