Code Monkey home page Code Monkey logo

1inch-swap's People

Contributors

smye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

1inch-swap's Issues

Contract call?

Hey ! First off thanks so much for making this available --- this is the only example ive been able to find and its the furthest ive ever gotten into integrating 1inch into my contract.

I'm presently trying to call this contract from another contract --- but nothing seems to happen.

I tried removing the is Ownable and the onlyOwner. My other contract appropriately defines

import "./interfaces/SwapProxy.sol";
....
    address internal constant SWAP_PROXY = 0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
    SwapProxy public swappproxy;

    constructor() {
        swappproxy = SwapProxy(SWAP_PROXY);
    }

and i attempt to swappproxy.swap(data);

Nothing happens. I've been debugging with tenderly and it doesnt seem to call the swap proxy contract at all. Curious if you know an obvious answer here. Or if you were aware of anything else i might need to make this work out.
"[ERROR]":"execution reverted"

"state":{
"swapproxy":"0x0000000000000000000000000000000000000000"
"_owner":"0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

Thanks so much !! really hope you can help

Example for 1inchV4 router swap

Hi There,

Nice repo. Could you tell me how you figured out how to decode and encode the data used in the swap?
I'm trying to implement a proxySwap for the v4 router in a similar manner, the calldata is also generated through the 1inch apoi https://etherscan.io/address/0x1111111254fb6c44bac0bed2854e76f90643097d

I have attached 2 comments in the code to clarify my question and situation

  function swap(uint minOut, bytes calldata _data) external onlyOwner {
        (address _c, SwapDescription memory desc, bytes memory _d) = abi.decode(_data[4:], (address, SwapDescription, bytes));
        // How did you know it is _data[4:]? Perhaps this is different for V4 router

        IERC20(desc.srcToken).transferFrom(msg.sender, address(this), desc.amount);
        IERC20(desc.srcToken).approve(AGGREGATION_ROUTER_V4, desc.amount);

        (bool succ, bytes memory _data) = address(AGGREGATION_ROUTER_V4).call(_data);
        if (succ) {
            // We fail on the next line, _data is 0x so it fails
            (uint returnAmount, uint gasLeft) = abi.decode(_data, (uint, uint));
            require(returnAmount >= minOut);
        } else {
            revert();
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.