test md

统一返回结果格式

  • code:返回错误码、200为正常返回
  • msg:错误信息
  • data:返回的数据

具体:

{
	code : 200,
	msg : "Success",
	data : {
		
	}
}

请求方式

  • POST
  • 通过 body传参
  • network 通过url 传入,其实就是网络id,eth 传入1

协议名称(name)

  • compound-v2
  • aave-v2
  • aave-v3
  • lidosteth

操作名称(method)

  • deposit : 存款/质押

  • withraw:赎回/提现

  • claim: 领取奖励

参数描述

报价
Url:

/v1/defi/quote?nework=1

参数:
ApiWrapperQuoteParam
字段名称描述字段类型是否非空备注
name协议名称: 参照协议名称列表stringcompound-v2、aave-v2、aave-v3、lido-steth
method协议,参照stringdeposit、withdraw、claim
args协议对应的参数:参考给wrapper的abi文档string[]没有:直接传[] 空数组
srcTokens输入Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]没有:直接传[] 空数组
srcDecimals输入Tokens 的精度number[]没有:直接传[] 空数组
srcAmounts输入Token的数量string[]没有:直接传[] 空数组
destTokens输出Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]没有:直接传[] 空数组
destDecimals输出Tokens 的精度number[]没有:直接传[] 空数组
feeTokens手续费 Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]直接传空数组[] ,报价后会有值
feeAmounts手续费数量string[]直接传空数组[] ,报价后会有值
ApiQuoteParams
字段名称描述字段类型是否非空备注
partnerFee手续费: 和swap 类似string如果不收手续费就只为0
wrappers协议ApiWrapperQuoteParam[]至少要传入一个
返回结果:
ApiWrapperQuoteResult
字段名称描述字段类型是否非空备注
name协议名称: 参照协议名称列表string根据输入返回
method协议,参照string根据输入返回
args协议对应的参数:参考给wrapper的abi文档string[]根据输入返回
srcTokens输入Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]根据输入返回
srcDecimals输入Tokens 的精度number[]根据输入返回
srcAmounts输入Token的数量string[]根据输入返回
destTokens输出Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]根据输入返回
destDecimals输出 Tokens 的精度number[]根据输入返回
destAmounts输出Token的数量string[]根据报价返回结果
feeType手续费类型number0:无,1:从输入收取,2:从输出收取
directUser是否原路返回资金boolean是否输出token是直接到用户的地址还是可以经过jeton原路返回给用户
feeTokens手续费 Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]直接传空数组[] ,报价后会有值
feeAmounts手续费数量string[]直接传空数组[] ,报价后会有值
data辅助信息json目前就返回个{} 空对象
ApiQuoteResult
字段名称描述字段类型是否非空备注
allowanceTarget授权合约string和swap一样
contractAddressjetonRouterStringjeton入口合约地址
partnerFee手续费: 和swap 类似string和传入的参数一样,用于计算手续费
srcTokens输入Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]会根据计算得出
srcDecimals输入Tokens 的精度number[]会根据计算得出
srcAmounts输入Token的数量string[]会根据计算得出
destTokens输出Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]会根据计算得出
destDecimals输出 Tokens 的精度number[]会根据计算得出
destAmounts输出Token的数量string[]会根据计算得出
results协议报价的结果ApiWrapperQuoteResult[]会根据计算得出

例如:以aave-v3 存入 eth 为例子

请求地址: /v1/defi/quote?network=1

入参:

 {
  "partnerFee": "2147565568030",
  "wrappers": [
    {
      "name": "aave-v3",
      "method": "withdraw",
      "args": [
        "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
        "0"
      ],
      "srcTokens": [
        "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8"
      ],
      "srcDecimals": [
        18
      ],
      "srcAmounts": [
        "997008973080757726"
      ],
      "destTokens": [
        "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
      ],
      "destDecimals": [
        18
      ],
      "feeTokens": [],
      "feeAmounts": []
    }
  ]
}

出参:

{
	code : 200,
	msg : "Success",
	data : {
    "allowanceTarget": "0x49149a233de6E4cD6835971506F47EE5862289c1",
    "contractAddress": "0x4CF4dd3f71B67a7622ac250f8b10d266Dc5aEbcE",
    "partnerFee": "2147565568030",
    "srcAmounts": [
      "997008973080757726"
    ],
    "srcDecimals": [
      18
    ],
    "srcTokens": [
      "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8"
    ],
    "destAmounts": [
      "994017946161515453"
    ],
    "destDecimals": [
      18
    ],
    "destTokens": [
      "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
    ],
    "results": [
      {
        "name": "aave-v3",
        "method": "withdraw",
        "args": [
          "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
          "997008973080757726"
        ],
        "srcTokens": [
          "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8"
        ],
        "srcDecimals": [
          18
        ],
        "srcAmounts": [
          "997008973080757726"
        ],
        "destTokens": [
          "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
        ],
        "destDecimals": [
          18
        ],
        "feeTokens": [
          "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
        ],
        "feeAmounts": [
          "2991026919242273"
        ],
        "destAmounts": [
          "994017946161515453"
        ],
        "data": {},
        "directUser": false,
        "feeType": 2
      }
    ]
  }
}

2.编码
Url:

/v1/defi/encode?network=1

参数:
ApiPermitData
字段名称描述字段类型是否非空备注
token要授权的token地址stringErc20 地址
permitpermit 授权编码数据string
ApiWrapperEncodeParam
说明:与报价结果ApiWrapperQuoteResult保持一致,这个对象和ApiWrapperQuoteResult 的定义是一样的)
字段名称描述字段类型是否非空备注
name协议名称: 参照协议名称列表stringcompound-v2、aave-v2、aave-v3、lido-steth
method协议,参照stringdeposit、withdraw、claim
args协议对应的参数:参考给wrapper的abi文档string[]没有:直接传[] 空数组
srcTokens输入Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]没有:直接传[] 空数组
srcDecimals输入Tokens 的精度number[]没有:直接传[] 空数组
srcAmounts输入Token的数量string[]没有:直接传[] 空数组
destTokens输出Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]没有:直接传[] 空数组
destDecimals输出Tokens 的精度number[]没有:直接传[] 空数组
feeTokens手续费 Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]直接传空数组[] ,报价后会有值
feeAmounts手续费数量string[]直接传空数组[] ,报价后会有值
ApiEncodeParams
字段名称描述字段类型是否非空备注
userAddress用户地址string操作用户,eoa 或者relayer用户
referrerAddress渠道地址string渠道地址
permitspermit 授权列表ApiPermitData[]没有数据请传入空的列表 []
beneficiary资产接受地址string如果不设置就是userAddress
partnerFee手续费: 和swap 类似string与报价结果保持一致
srcTokens输入Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]与报价结果保持一致
srcDecimals输入Tokens 的精度number[]与报价结果保持一致
srcAmounts输入Token的数量string[]与报价结果保持一致
destTokens输出Tokens(ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)string[]与报价结果保持一致
destDecimals输出 Tokens 的精度number[]与报价结果保持一致
destAmounts输出Token的数量string[]与报价结果保持一致
wapperParams协议ApiWrapperQuoteParam[]至少要传入一个
返回结果:
ApiEncodeResult
字段名称描述字段类型是否非空备注
from发起用户string如果eoa用户,那么就是用户自己,如果是relayer, 那么就是relayer
to交互的合约地址string
value交易的eth 金额string
data编码数据string

以lido 存入 eth 为例子

请求地址: /v1/defi/encode?network=1

body:

{
  "partnerFee": "2147565568030",
  "srcTokens": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
  ],
  "srcDecimals": [
    18
  ],
  "srcAmounts": [
    "1000000000000000000"
  ],
  "destTokens": [
    "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
  ],
  "destDecimals": [
    18
  ],
  "destAmounts": [
    "996999002991026918"
  ],
  "wapperParams": [
    {
      "name": "lidosteth",
      "method": "deposit",
      "args": [
        "997008973080757726"
      ],
      "srcTokens": [
        "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
      ],
      "srcDecimals": [
        18
      ],
      "srcAmounts": [
        "1000000000000000000"
      ],
      "destTokens": [
        "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
      ],
      "destDecimals": [
        18
      ],
      "feeTokens": [
        "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
      ],
      "feeAmounts": [
        "2991026919242273"
      ],
      "destAmounts": [
        "996999002991026918"
      ],
      "data": {
        
      },
      "directUser": false,
      "feeType": 1
    }
  ],
  "userAddress": "0xb6CcdceC81C531124eE6D565cd0231dd764ae192",
  "referrerAddress": "0x4EFc83725CF33cDa2ad47fBe2cC30B3836647E27",
  "permits": [
    
  ]
}

返回结果

{
  code : 200,
  msg : "Success",
  data: {
        "from": "0xb6CcdceC81C531124eE6D565cd0231dd764ae192",
        "to": "0x4CF4dd3f71B67a7622ac250f8b10d266Dc5aEbcE",
        "value": "1000000000000000000",
        "data": "0xb42e09a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000004efc83725cf33cda2ad47fbe2cc30b3836647e27000000000000000000000000b6ccdcec81c531124ee6d565cd0231dd764ae192000000000000000000000000000000000000000000000000000001f404e2001e000000000000000000000000000000000000000000000000000000006485d08631500bb62ff34093887ae46e8eb2a33900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe8400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000dd60d4f96b2e2e6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000fae849108f2a63abe3bab17e21be077d07e7a9a200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000024b6b55f250000000000000000000000000000000000000000000000000dd61660ee5b05de00000000000000000000000000000000000000000000000000000000"
      }
}
Args (报价)
compound-v2

deposit

{
  "name": "compound-v2",
  "method": "deposit",
  "args": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",// ETH, 要 srcTokens[0]保持一致
    "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",// cEth, 要 destTokens[0] 保持一致
    "0" //这个参数在报价的是填入0,报价完成后结果里面自动讲 srcAmounts[0] 填入
  ],
  "srcTokens": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
  ],
  "srcDecimals": [
    18
  ],
  "srcAmounts": [
  	"1000000000000000000"
  ],
  "destTokens": [
    "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"
  ],
  "destDecimals": [
    8
  ]
}

withdraw

{
  "name": "compound-v2",
  "method": "withdraw",
  "args": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",// destTokens[0] 保持一致
    "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",// srcTokens[0] 保持一致
    "0" //cToken的数量,报价的时候填入0,报价后会自动填入(从 srcAmounts[0] 取)
  ],
  "srcTokens": [
    "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5"
  ],
  "srcDecimals": [
    8
  ],
  "srcAmounts": [
    "4963958952"
  ],
  "destTokens": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
  ],
  "destDecimals": [
    18
  ]
}

claim

{
  "name": "compound-v2",
  "method": "claim",
  "args": [
    "0x25f6E3Ed064Fc771AF0f22a8D24a1FB176ec5c53" //给那个用户领取收益,必须手动指定
  ],
  "srcTokens": [],
  "srcDecimals": [],
  "srcAmounts": [],
  "destTokens": [
    "0xc00e94Cb662C3520282E6f5717214004A7f26888" //补贴token的地址 comp
  ],
  "destDecimals": [
    18
  ]
}
aave-v2

deposit

{
  "name": "aave-v2",
  "method": "deposit",
  "args": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", //请与srcToken[0] 保持一致
    "0" //请填写 0,报价服务会自动给 用srcAmounts[0]来进行填充
  ],
  "srcTokens": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" //ETH
  ],
  "srcDecimals": [
    18
  ],
  "srcAmounts": [
    "1000000000000000000"
  ],
  "destTokens": [
    "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e" //AToken
  ],
  "destDecimals": [
    18
  ]
}

withdraw

{
  "name": "aave-v2",
  "method": "withdraw",
  "args": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",//ETH 务必与destTokens[0] 保持一致
    "0",//请填写0,报价服务会自动用srcAmounts[0] 进行填充
  ],
  "srcTokens": [
    "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e"
  ],
  "srcDecimals": [
    8
  ],
  "srcAmounts": [
  	"1000000000000000000"
  ],
  "destTokens": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
  ],
  "destDecimals": [
    18
  ]
}
aave-v3(与v2版本相同)
lidosteth

deposit

{
  "name": "lidosteth",
  "method": "deposit",
  "args": [
    "0" //要存入的eth数量,请填入0,报价会自动用 srcAmounts[0] 进行填充
  ],
  "srcTokens": [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" //eth
  ],
  "srcDecimals": [
    18
  ],
  "srcAmounts": [
    "1000000000000000000"
  ],
  "destTokens": [
    "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84" //lido
  ],
  "destDecimals": [
    18
  ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值