Slippage Calculation (for Uniswap V2 and its forks)
curl --request GET \
--url https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}import requests
url = "https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
// Response
}
DeFi Data
Slippage Calculation (for Uniswap V2 and its forks)
To predict the amount of tokens required to reach a specified slippage, you can use Pool Slippage endpoint. It works for any pool that exists on Uniswap V2 or any fork DEX on supported list of exchanges.
GET
/
v1
/
poolSlippage
/
{blockchain}
/
{pool_address}
/
{token1_address}
/
{pool_type}
/
{desired_slippage}
Slippage Calculation (for Uniswap V2 and its forks)
curl --request GET \
--url https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}import requests
url = "https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.diadata.org/v1/poolSlippage/{blockchain}/{pool_address}/{token1_address}/{pool_type}/{desired_slippage}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
// Response
}
The logic is as follows:
Provide the address of the pool, select a token in which you wish to have slippage calculated (e.g. if selected ETH from ETH-USDC, it will show how much is ETH is required to move the price by selected amount) and determine the goal for price movement.
Path Parameters
string
required
Name of the blockchain of the requested pool (e.g. Ethereum, Moonbeam, etc.)
string
required
Address of the requested pool
string
required
Address of either of the tokens in the pool
string
required
Type of the pool (e.g. UniswapV2)
integer
required
Desired slippage in per mille (e.g. 100 will result in 10% slippage)
{
// Response
}
Was this page helpful?