Comments (5)
Never mind, I messed up some things myself. This example also works for v4!
Hey!
Glad you got it working 🙂
Will just leave what I think are the answers to your question below just in case anyone else finds them in the same situation:
-
_data[4:]
is for removing the function selector from the calldata returned by the 1inch API. The function selector determines what function is called -
V4 adds an extra return value
spentAmount
on the swap function:function swap( IAggregationExecutor caller, SwapDescription calldata desc, bytes calldata data ) external payable returns ( uint256 returnAmount, uint256 spentAmount, uint256 gasLeft ) {
So replace
(uint returnAmount, uint gasLeft) = abi.decode(_data, (uint, uint));
with
(uint returnAmount, uint spentAmount, uint gasLeft) = abi.decode(_data, (uint, uint, uint));
from 1inch-swap.
Never mind, I messed up some things myself. This example also works for v4!
from 1inch-swap.
- V4 adds an extra return value
spentAmount
on the swap function:function swap( IAggregationExecutor caller, SwapDescription calldata desc, bytes calldata data ) external payable returns ( uint256 returnAmount, uint256 spentAmount, uint256 gasLeft ) {
This is true for Ethereum but it seems 1inch has not updated this on Polygon and binance smart chain.
There, the old return parameters are still used
from 1inch-swap.
Never mind, I messed up some things myself. This example also works for v4!
Hey!
Glad you got it working 🙂
Will just leave what I think are the answers to your question below just in case anyone else finds them in the same situation:
_data[4:]
is for removing the function selector from the calldata returned by the 1inch API. The function selector determines what function is calledV4 adds an extra return value
spentAmount
on the swap function:function swap( IAggregationExecutor caller, SwapDescription calldata desc, bytes calldata data ) external payable returns ( uint256 returnAmount, uint256 spentAmount, uint256 gasLeft ) {So replace
(uint returnAmount, uint gasLeft) = abi.decode(_data, (uint, uint));with
(uint returnAmount, uint spentAmount, uint gasLeft) = abi.decode(_data, (uint, uint, uint));
Hey @smye, you assume the return type for swap()
on V4 with extra spentAmount
at positional arg. number 2. But 1inch docs for V4 says prototype is still the old V3 prototype. Can you confirm which is correct?
from 1inch-swap.
Never mind, I messed up some things myself. This example also works for v4!
Hey!
Glad you got it working 🙂
Will just leave what I think are the answers to your question below just in case anyone else finds them in the same situation:
_data[4:]
is for removing the function selector from the calldata returned by the 1inch API. The function selector determines what function is calledV4 adds an extra return value
spentAmount
on the swap function:function swap( IAggregationExecutor caller, SwapDescription calldata desc, bytes calldata data ) external payable returns ( uint256 returnAmount, uint256 spentAmount, uint256 gasLeft ) {So replace
(uint returnAmount, uint gasLeft) = abi.decode(_data, (uint, uint));with
(uint returnAmount, uint spentAmount, uint gasLeft) = abi.decode(_data, (uint, uint, uint));Hey @smye, you assume the return type for
swap()
on V4 with extraspentAmount
at positional arg. number 2. But 1inch docs for V4 says prototype is still the old V3 prototype. Can you confirm which is correct?
Nevermind, found it -- https://etherscan.io/address/0x1111111254fb6c44bac0bed2854e76f90643097d#code#L2319
Doc hasn't been updated.
from 1inch-swap.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 1inch-swap.