Overview

ParaSwap Delta is an intent-based protocol that enables a ParaSwap user to make gasless swaps where multiple agents compete to execute the trade at the best price possible. This way the user doesn't need to make a transaction themselves but only to sign a Delta Order.

The easiest way to make use of the Delta is to use the Paraswap SDK. Refer here SDK Delta documentation.

Simple Delta flow using API with axios looks like this:

1. Request prices for a token pair

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

If you want to earn fees on your users orders, they have to be set on this step. For more details, check Order Building section.

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

// 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

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

// 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