Skip to main content

Integration

Integrate ElfomoFi as a liquidity source on EVM

Quote

Prices are updated every block based on a mix of the ElfomoFi oracle and additional onchain signals.

function getAmountOut(
address fromToken,
address toToken,
uint256 fromAmount
) external view returns (uint256 toAmount)
function getAmountIn(
address fromToken,
address toToken,
uint256 toAmount
) external view returns (uint256 fromAmount)

Swap

For flexible integrations, ElfomoFi supports three swap methods:

  1. swap - for standard swaps when msg.sender has approved fromToken.
  2. swapWithContractBalance - swaps fromToken to toToken using the ElfomoFi contract’s existing fromToken balance. Useful for partial fills when the exact input amount is unknown; simply transfer fromToken to the contract and call this function.
  3. swapWithCallback – performs a swap without prior approval by pulling fromToken via a callback.
/// @param fromToken The address of the token to swap from
/// @param toToken The address of the token to swap to
/// @param specifiedAmount Positive for exact input in fromToken, negative for exact output in toToken
/// @param limitAmount Minimum toAmount for exact input, maximum fromAmount for exact output
/// @param receiver The address to receive the toToken
/// @param partnerId Partner identifier for rebates/tracking, 0 if not used
function swap(
address fromToken,
address toToken,
int256 specifiedAmount,
uint256 limitAmount,
address receiver,
uint256 partnerId
)
/// @param fromToken The address of the token to swap from
/// @param toToken The address of the token to swap to
/// @param minAmountOut Minimum amount of output token
/// @param receiver The address to receive the toToken
/// @param partnerId Partner identifier for rebates/tracking, 0 if not used
function swapWithContractBalance(
address fromToken,
address toToken,
uint256 minAmountOut,
address receiver,
uint256 partnerId
)
/// @param fromToken The address of the token to swap from
/// @param toToken The address of the token to swap to
/// @param specifiedAmount Positive for exact input in fromToken, negative for exact output in toToken
/// @param limitAmount Minimum toAmount for exact input, maximum fromAmount for exact output
/// @param receiver The address to receive the toToken
/// @param partnerId Partner identifier for rebates/tracking, 0 if not used
/// @param callbackData Data passed to the callback function
function swapWithCallback(
address fromToken,
address toToken,
int256 specifiedAmount,
uint256 limitAmount,
address receiver,
uint256 partnerId,
bytes calldata callbackData
)

Supported pairs

Integrators can query supported pairs using getSupportedPairs() on the ElfomoFi contract.

Pair updates can also be tracked by listening to:
event PairAdded(address tokenA, address tokenB)

Fees

Integrators may add fees on top of our quotes. We widen prices by the specified fee, and the accumulated fees are paid out in USDC at the beginning of each month.
For more details, contact us on Telegram: http://t.me/el_genby