smye / 1inch-swap Goto Github PK
View Code? Open in Web Editor NEWA minimal example showing how to integrate 1inch in your smart contract using Brownie
A minimal example showing how to integrate 1inch in your smart contract using Brownie
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
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();
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.