1.0.0-alpha.12 • Published 1 year ago

@soulsolidity/soul-zap-api v1.0.0-alpha.12

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

SoulZap API

API Documentation

Description

This API endpoint facilitates the execution of a specific zap order involving token swaps, adding of liquidity and custom protocols. It is designed to handle various types of liquidity pools and protocols based on the provided parameters.

Endpoint

GET /zap

Parameters

ParameterTypeDescriptionRequiredOptions/Schema
recipientStringThe recipient of the order.Yes-
userStringThe user initiating the order.Yes-
chainStringThe blockchain chain to use (SoulSolidity chosen rpc).Yeseth, bnb, pol, arb, lna
rpcStringOptional custom RPC to overwrite the chosen one.No-
lpTypeStringThe type of liquidity pool.Yesuniv2, gamma, ichi, arrakis, steer, lynex
lpDataObjectData specific to the liquidity pool type.Yes-
protocolStringThe protocol to use.NoApeBond, LynexGauge
protocolDataObjectData specific to the chosen protocol.Yes (if protocol specified)-

LPData Options/Schema

UniV2LPSchema

ParameterTypeDescriptionRequired
fromTokenStringToken addressYes
fromAmountStringAmount of the tokenYes
toToken0StringToken addressYes
toToken1StringToken addressYes
lpAddressStringLP addressYes
routerStringRouter addressYes

Example:

{
    "fromToken": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
    "fromAmount": "1000000000000000000",
    "toToken0": "0x003d87d02A2A01E9E8a20f507C83E15DD83A33d1",
    "toToken1": "0x55d398326f99059fF775485246999027B3197955",
    "lpAddress": "0xAB1E062Ab03b11fF7Dd943C50b9aa2bF9933C1F3",
    "router": "0x10ED43C718714eb63d5aA57B78B54704E256024E",
}

LynexLPSchema

ParameterTypeDescriptionRequired
fromTokenStringToken addressYes
fromAmountStringAmount of the tokenYes
toToken0StringToken addressYes
toToken1StringToken addressYes
lpAddressStringLP addressYes
routerStringRouter addressYes

Example:

{
    "fromToken": "0xA219439258ca9da29E9Cc4cE5596924745e12B93",
    "fromAmount": "1000000",
    "toToken0": "0x176211869cA2b568f2A7D4EE941E073a821EE1ff",
    "toToken1": "0x1a51b19CE03dbE0Cb44C1528E34a7EDD7771E9Af",
    "lpAddress": "0x3E78c1F766D7FE2c3dceF6aFe6609966540B6391",
    "router": "0x610D2f07b7EdC67565160F587F37636194C34E74",
}

GammaLPSchema

ParameterTypeDescriptionRequired
fromTokenStringToken addressYes
fromAmountStringAmount of the tokenYes
toToken0StringToken addressYes
toToken1StringToken addressYes
uniProxyStringUniProxy addressYes
hypervisorStringHypervisor addressYes

Example:

{
    "fromToken": "0xA219439258ca9da29E9Cc4cE5596924745e12B93",
    "fromAmount": "1000000",
    "toToken0": "0x176211869cA2b568f2A7D4EE941E073a821EE1ff",
    "toToken1": "0x1a51b19CE03dbE0Cb44C1528E34a7EDD7771E9Af",
    "uniProxy": "0xFc13Ebe7FEB9595D70195E9168aA7F3acE153621",
    "hypervisor": "0xcC86572Ce5a6EEe74c76c57E9ea7b08221F06bb9"
}

IchiLPSchema

ParameterTypeDescriptionRequired
fromTokenStringToken addressYes
fromAmountStringAmount of the tokenYes
toToken0StringToken addressYes
routerStringRouter addressYes
vaultStringVault addressYes
vaultDeployerStringDeployer addressYes

Example:

{
    "fromToken": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
    "fromAmount": "1000000000000000000",
    "toToken0": "0x53E0bca35eC356BD5ddDFebbD1Fc0fD03FaBad39",
    "router": "0xA5cE107711789b350e04063D4EffBe6aB6eB05a4",
    "vault": "0x692437de2cAe5addd26CCF6650CaD722d914d974",
    "vaultDeployer": "0x0768A75F616B98ee0937673bD83B7aBF142236Ea"
}

ProtocolData Options/Schema

ApeBondSchema

ParameterTypeDescriptionRequired
bondStringBond addressYes

Example:

{
    "bond":"0x71a53F6b3207a8EBDBF692Ea3ffD8F506d78540d"
}

LynexGaugeSchema

ParameterTypeDescriptionRequired
gaugeStringGauge addressYes

Example:

{
    "gauge":"0xbD9Ac1dae15608ee839838F91796d9281C7342FB"
}

Return Data

The return data from the API can be directly passed into the ZapRouter contract without requiring any additional processing. It is structured in a format that aligns with the expected input parameters of the ZapRouter contract, ensuring seamless integration with minimal effort.

  • order: (Object) - The order details.

    • inputs: (Array) - List of input token details.
      • token: (String) - Token address.
      • amount: (BigNumberish) - Amount of the token.
    • outputs: (Array) - List of output token details.
      • token: (String) - Token address.
      • minOutputAmount: (BigNumberish) - Minimum output amount.
    • relay: (Object) - Relay details.
      • target: (String) - Target address.
      • value: (BigNumberish) - Value of the relay.
      • data: (String) - Relay data.
    • user: (String) - Initiator of the order.
    • recipient: (String) - Recipient of the order.
  • steps: (Array) - List of steps involved in the order.

    • target: (String) - Target address.
    • value: (BigNumberish) - Value of the step.
    • data: (String) - Step data.
    • tokens: (Array) - List of tokens involved in the step.
      • token: (String) - Token address.
      • index: (BigNumberish) - Index of the token.

Index Calculation

The index represents the encoded data for the addLiquidity function.

For uniV2 the params are token0, token1, amountADesired, amountBDesired and more. amountADesired and amountBDesired are the ones you want to change as those are the unknowns and amount of tokens to add to liquidity.

Address (params tokenA and tokenB) is 32bytes. And encoded data starts with 4 bytes for the function name. So index for amountADesired is 4+32+32=68 and then +32 for the bytes of amountADesired is index start for amountBDesired.

Tools