CurveCryptoViews

Methods

get_dx_ex_fees

function get_dx_ex_fees(contract ICryptoSwap cryptoSwap, uint256 i, uint256 j, uint256 dy) external view returns (uint256)

Get the amount of coin i one would have to pay for receiving dy of coin j (before any trading fees are charged)

Does not get the identical estimate (i.e. get_dy(get_dx(100))) ~= 100) Question: Why is that the case? Answer: Newton_y stops when the converge limit is reached: https://github.com/curvefi/curve-crypto-contract/blob/d7d04cd9ae038970e40be850df99de8c1ff7241b/contracts/two/CurveCryptoSwap2.vy#L355Should be used for external contracts to get a fairly precise "estimate" of the amount of tokens one has to pay to receive dy tokenssimplified version where we use that PRECISIONS = [1, 1]

Parameters

Name
Type
Description

cryptoSwap

contract ICryptoSwap

Curve Cryptoswap contract

i

uint256

Index of the coin to sell

j

uint256

Index of the coin to buy

dy

uint256

Amount to tokens to receive

Returns

Name
Type
Description

_0

uint256

Amount of tokens to sell

get_dy

function get_dy(contract ICryptoSwap cryptoSwap, uint256 i, uint256 j, uint256 dx) external view returns (uint256)

Get the amount of coin j one would receive for swapping dx of coin i

solidity wrapper around CryptoSwap's get_dy

Parameters

Name
Type
Description

cryptoSwap

contract ICryptoSwap

Curve Cryptoswap contract

i

uint256

Index of the coin to sell

j

uint256

Index of the coin to buy

dx

uint256

Amount to sell

Returns

Name
Type
Description

_0

uint256

Amount of tokens to received (in j)

get_dy_fees

function get_dy_fees(contract ICryptoSwap cryptoSwap, uint256 i, uint256 j, uint256 dx) external view returns (uint256)

Get the amount of coin j one would have to pay as trading fees for swapping dx of coin i

Parameters

Name
Type
Description

cryptoSwap

contract ICryptoSwap

Curve Cryptoswap contract

i

uint256

Index of the coin to sell

j

uint256

Index of the coin to buy

dx

uint256

Amount to sell

Returns

Name
Type
Description

_0

uint256

Amount of token j paid as trading fees. 18 decimals

get_dy_fees_perc

function get_dy_fees_perc(contract ICryptoSwap cryptoSwap, uint256 i, uint256 j, uint256 dx) external view returns (uint256)

Get the share of coin j one would have to pay as trading fees for swapping dx of coin i

Parameters

Name
Type
Description

cryptoSwap

contract ICryptoSwap

Curve Cryptoswap contract

i

uint256

Index of the coin to sell

j

uint256

Index of the coin to buy

dx

uint256

Amount to sell

Returns

Name
Type
Description

_0

uint256

Share of token j paid as trading fees. 18 decimals

get_dy_no_fee_deduct

function get_dy_no_fee_deduct(contract ICryptoSwap cryptoSwap, uint256 i, uint256 j, uint256 dx) external view returns (uint256)

Get the amount of coin j one would receive for swapping dx of coin i (excl. fees)

solidity implementation of the get_dy excluding the last last line where fees are deductedsimplified version where we use that PRECISIONS = [1, 1] https://github.com/curvefi/curve-crypto-contract/blob/d7d04cd9ae038970e40be850df99de8c1ff7241b/contracts/tricrypto/CurveCryptoViews3.vy#L40-L78

Parameters

Name
Type
Description

cryptoSwap

contract ICryptoSwap

Curve Cryptoswap contract

i

uint256

Index of the coin to sell

j

uint256

Index of the coin to buy

dx

uint256

Amount to sell

Returns

Name
Type
Description

_0

uint256

Amount of tokens to received + Any trading fees paid (in j)

math

function math() external view returns (contract IMath)

Curve Math Contract

Returns

Name
Type
Description

_0

contract IMath

undefined

Errors

PRBMath__MulDivOverflow

error PRBMath__MulDivOverflow(uint256 prod1, uint256 denominator)

Emitted when the result overflows uint256.

Parameters

Name
Type
Description

prod1

uint256

undefined

denominator

uint256

undefined

Last updated