# Overview

Velora Delta is a new set of smart contracts developed by Velora. It's built on top of the Portikus Intents network and is currently available on the Ethereum and Base networks. 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 Velora Delta, you can protect your users’ swaps from events like sandwich attacks.
* **Price Competition:** Velora Delta is increasingly competitive as different agents compete to deliver the best possible prices to users.

{% hint style="info" %}
The easiest way to make use of the Delta is to use the [Velora SDK](https://github.com/paraswap/paraswap-sdk). Refer [here](https://github.com/paraswap/paraswap-sdk/blob/master/docs/DELTA.md) SDK Delta documentation.
{% endhint %}

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 **Velora's Delta API**.

```typescript
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.

{% hint style="info" %}
If you want to earn fees on your users orders, they have to be set on this step. For more details, check the [Partner Fees Section in Order Building](/api/velora-api/velora-delta-api/build-a-delta-order-to-sign.md#partner-fees).
{% endhint %}

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

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

### 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.

```typescript
// 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.

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

{% hint style="info" %}
For more details, check the [Submit a Delta order](https://developers.paraswap.network/api/paraswap-api/delta-api/submit-a-delta-order) section.
{% endhint %}

### 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.

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

{% hint style="info" %}
For more information on Order Auction Status, check the [Track Delta Order Auction Status](https://developers.paraswap.network/api/paraswap-api/delta-api/track-delta-order-auction-status) section.
{% endhint %}

**A more detailed example of Delta usage, including fallback to Market (traditional swapping flow), can be found in** [**examples**](/api/velora-api/velora-delta-api/example-quote-with-fallback.md)**.**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.velora.xyz/api/velora-api/velora-delta-api/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
