add curveAdapter
This commit is contained in:
@@ -10,6 +10,8 @@ module.exports = {
|
||||
DODOCalleeHelper: "0xe3B40F8D8346d428EAB28d9Fd672b784d921cfBD",
|
||||
DODOV1PmmHelper: "0x4EE6398898F7FC3e648b3f6bA458310ac29cD352",
|
||||
DODOV2RouteHelper: "0xd72b354BD39f8F11D0cA07bD5724896Bb1a42707",
|
||||
CurveSample: "",
|
||||
|
||||
|
||||
//Template
|
||||
CloneFactory: "0x1ddD02f6d31C1eF04cFA0a1AA811406B5B2884E7",
|
||||
@@ -44,6 +46,8 @@ module.exports = {
|
||||
DODOV1Adapter: "0xd5a7E197bacE1F3B26E2760321d6ce06Ad07281a",
|
||||
DODOV2Adapter: "0x8aB2D334cE64B50BE9Ab04184f7ccBa2A6bb6391",
|
||||
UniAdapter: "0x17eBC315760Bb47384224A5f3BF829222fbD3Aa7",
|
||||
CurveAdapter: "",
|
||||
|
||||
|
||||
//Proxy
|
||||
DODOV2Proxy: "0xeCEaDe494FD5F913Fd937C5CAc4577236395Dc32",
|
||||
|
||||
@@ -10,6 +10,8 @@ module.exports = {
|
||||
DODOCalleeHelper: "0x2673E5333620bb22BD1bFB3af9Fc7012008E3b4B",
|
||||
DODOV1PmmHelper: "0x2BBD66fC4898242BDBD2583BBe1d76E8b8f71445",
|
||||
DODOV2RouteHelper: "0xC1CCE4C003B10052f168072A4c3c02051053d957",
|
||||
CurveSample: "",
|
||||
|
||||
|
||||
//Template
|
||||
CloneFactory: "0x03E2427859119E497EB856a166F616a2Ce5f8c88",
|
||||
@@ -48,6 +50,8 @@ module.exports = {
|
||||
DODOV1Adapter: "0x8E4842d0570c85Ba3805A9508Dce7C6A458359d0",
|
||||
DODOV2Adapter: "0x165BA87e882208100672b6C56f477eE42502c820",
|
||||
UniAdapter: "0xE223AcD7CBAFabCFfcAfeC5e69877424c4760aC2",
|
||||
CurveAdapter: "",
|
||||
|
||||
|
||||
//Proxy
|
||||
DODOV2Proxy: "",
|
||||
|
||||
@@ -10,6 +10,7 @@ module.exports = {
|
||||
DODOCalleeHelper: "0x45a7E2E9D780613E047f7e78a9d3902ff854B522",
|
||||
DODOV1PmmHelper: "0x6373ceB657C83C91088d328622573FB766064Ac4",
|
||||
DODOV2RouteHelper: "0x0672952Fab6BD1336C57AE09E49DB6D3e78B1896",
|
||||
CurveSample: "0x5381382257C761DAc6F1509B1BA1B70dDaa6862a",
|
||||
|
||||
//Template
|
||||
CloneFactory: "0x5e5a7b76462e4bdf83aa98795644281bdba80b88",
|
||||
@@ -46,6 +47,7 @@ module.exports = {
|
||||
DODOV1Adapter: "0x91E1c84BA8786B1FaE2570202F0126C0b88F6Ec7",
|
||||
DODOV2Adapter: "0xe6AafA1c45D9d0C64686c1f1D17B9fe9c7DAB05b",
|
||||
UniAdapter: "0x50D148D0908C602A56884B8628A36470a875EEb2",
|
||||
CurveAdapter: "0x12e599006a5F19819cde6FABceBbd8586688C8ac",
|
||||
|
||||
//Proxy
|
||||
DODOV2Proxy: "",
|
||||
|
||||
@@ -10,6 +10,8 @@ module.exports = {
|
||||
DODOCalleeHelper: "0x684D9d0768761fF0659B9f55D98F57648302ed14",
|
||||
DODOV1PmmHelper: "0xFB973C79C665C0AC69E74C67be90D4C7A6f23c59",
|
||||
DODOV2RouteHelper: "0x67166F14E9aCf43A822BE147eA59CdDd01A7C00d",
|
||||
CurveSample: "0xDfb423413f9Aa62Dd8e86a73d6e89918b4C22dd8",
|
||||
|
||||
|
||||
//Template
|
||||
CloneFactory: "0x5dCEAe50CF8C3B885430E0E79226C513Db0318f2",
|
||||
@@ -45,6 +47,8 @@ module.exports = {
|
||||
DODOV1Adapter: "0x99d69565EdA438E3ebAA0627A407968ABD0f755b",
|
||||
DODOV2Adapter: "0x14F7B8Fb0c1447DdE7bcf92a8d9BB058c8A5FE64",
|
||||
UniAdapter: "0xa95cE97a04f61efb201c08da41e4bBF7E7106770",
|
||||
CurveAdapter: "0x9Fc4588D38ebC0E73D8d2BCF2DA34Ae8E4bac61d",
|
||||
|
||||
|
||||
//Proxy
|
||||
DODOV2Proxy: "0xAc7cC7d2374492De2D1ce21e2FEcA26EB0d113e7",
|
||||
|
||||
@@ -10,6 +10,8 @@ module.exports = {
|
||||
DODOCalleeHelper: "0x261F6cF4dF0e5c1432739cDAFD9299150FEd3dFc",
|
||||
DODOV1PmmHelper: "0x18DFdE99F578A0735410797e949E8D3e2AFCB9D2",
|
||||
DODOV2RouteHelper: "0x324c747885a88EA6f8115C46E0605C828ed527D3",
|
||||
CurveSample: "",
|
||||
|
||||
|
||||
//Template
|
||||
CloneFactory: "0x729f7f44bf64Ce814716b6261e267DbE6cdf021c",
|
||||
@@ -44,6 +46,8 @@ module.exports = {
|
||||
DODOV1Adapter: "0xDBFaF391C37339c903503495395Ad7D6B096E192",
|
||||
DODOV2Adapter: "0x6C30bE15d88462B788DEa7c6A860a2CCAF7B2670",
|
||||
UniAdapter: "0xe373DF144a70BCCc10190f97bEDE647D1eD6cfc8",
|
||||
CurveAdapter: "",
|
||||
|
||||
|
||||
//Proxy
|
||||
DODOV2Proxy: "0x45894C062E6f4E58B257e0826675355305dfef0d",
|
||||
|
||||
@@ -10,6 +10,8 @@ module.exports = {
|
||||
DODOCalleeHelper: "0x3CD6D7F5fF977bf8069548eA1F9441b061162b42",
|
||||
DODOV1PmmHelper: "0xDfaf9584F5d229A9DBE5978523317820A8897C5A",
|
||||
DODOV2RouteHelper: "0x9B64c81ba54eA51e1f6B7fefb3cfF8AA6F1e2A09",
|
||||
CurveSample: "",
|
||||
|
||||
|
||||
//Template
|
||||
CloneFactory: "0x2BBD66fC4898242BDBD2583BBe1d76E8b8f71445",
|
||||
@@ -45,6 +47,8 @@ module.exports = {
|
||||
DODOV1Adapter: "0xbe9a66e49503e84ae59a4d0545365AABedf33b40",
|
||||
DODOV2Adapter: "0xa356867fDCEa8e71AEaF87805808803806231FdC",
|
||||
UniAdapter: "0xc6962a577A3Be5311f9f9Ab9B8b6A69a25bBc817",
|
||||
CurveAdapter: "",
|
||||
|
||||
|
||||
//Proxy
|
||||
DODOV2Proxy: "0x6B4Fa0bc61Eddc928e0Df9c7f01e407BfcD3e5EF",
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
Copyright 2021 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
@@ -14,20 +12,24 @@ import {SafeMath} from "../../lib/SafeMath.sol";
|
||||
import {UniversalERC20} from "../lib/UniversalERC20.sol";
|
||||
import {SafeERC20} from "../../lib/SafeERC20.sol";
|
||||
|
||||
// for two tokens
|
||||
contract CurveUnderlyingAdapter is IDODOAdapter {
|
||||
// for two tokens; to adapter like dodo V1
|
||||
contract CurveAdapter is IDODOAdapter {
|
||||
using SafeMath for uint;
|
||||
using UniversalERC20 for IERC20;
|
||||
|
||||
function _curveSwap(address to, address pool, bytes memory moreInfo) internal {
|
||||
(address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (address, address, int128, int128));
|
||||
require(fromToken == ICurve(pool).underlying_coins(i), 'CurveAdapter: WRONG_TOKEN');
|
||||
require(toToken == ICurve(pool).underlying_coins(j), 'CurveAdapter: WRONG_TOKEN');
|
||||
(bool noLending, address fromToken, address toToken, int128 i, int128 j) = abi.decode(moreInfo, (bool, address, address, int128, int128));
|
||||
uint256 sellAmount = IERC20(fromToken).balanceOf(address(this));
|
||||
|
||||
// approve
|
||||
IERC20(fromToken).approve(pool, sellAmount);
|
||||
IERC20(fromToken).universalApproveMax(pool, sellAmount);
|
||||
// swap
|
||||
ICurve(pool).exchange_underlying(i, j, sellAmount, 0);
|
||||
if(noLending) {
|
||||
ICurve(pool).exchange(i, j, sellAmount, 0);
|
||||
} else {
|
||||
ICurve(pool).exchange_underlying(i, j, sellAmount, 0);
|
||||
}
|
||||
|
||||
if(to != address(this)) {
|
||||
SafeERC20.safeTransfer(IERC20(toToken), to, IERC20(toToken).balanceOf(address(this)));
|
||||
}
|
||||
@@ -163,7 +163,7 @@ contract DODONFTProxy is ReentrancyGuard, InitializableOwnable {
|
||||
_deposit(msg.sender, fragment, IFragment(fragment)._QUOTE_(), curRequireQuote, flag == 1);
|
||||
IFragment(fragment).buyout(msg.sender);
|
||||
|
||||
IDODONFTRegistry(_NFT_REGISTY_).removeRegistry(fragment);
|
||||
// IDODONFTRegistry(_NFT_REGISTY_).removeRegistry(fragment);
|
||||
|
||||
// refund dust eth
|
||||
if (flag == 1 && msg.value > curRequireQuote) msg.sender.transfer(msg.value - curRequireQuote);
|
||||
|
||||
37
contracts/SmartRoute/sampler/CurveSample.sol
Normal file
37
contracts/SmartRoute/sampler/CurveSample.sol
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
|
||||
Copyright 2021 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../intf/ICurve.sol";
|
||||
|
||||
contract CurveSampler {
|
||||
|
||||
function sampleFromCurve(
|
||||
address curveAddress,
|
||||
int128 fromTokenIdx,
|
||||
int128 toTokenIdx,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
uint256 buyAmount = ICurve(curveAddress).get_dy_underlying(fromTokenIdx, toTokenIdx, takerTokenAmounts[i]);
|
||||
makerTokenAmounts[i] = buyAmount;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return makerTokenAmounts;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user