Comments (3)
Hello @Thekthekthek !
I would really appreciate, already love your code btw, but I would love to understand it better and use it better :) good job bro
Thank you !! :)
I understand that some parts of this code may be a bit puzzling as this library is intended for developers already comfortable with not only all the blockchain basics and web3.py, but also with previous Uniswap routers. So, going through all these concepts would be out of scope here.
But, if you just need a code sample, maybe the integration tests will help ?
Having said that, I plan to write a tutorial on how to do a swap with this lib and uniswap-smart-path (though not sure when as I'm super busy). So, considering your request, I'll try to make it a bit more accessible.
from uniswap-universal-router-decoder.
Hello @Thekthekthek !
I've written this tutorial
Hopefully it will give you a better understanding on how to use the UR codec! :)
from uniswap-universal-router-decoder.
I would love to see a sample of transaction for a swap, for example :
"""
from uniswap_universal_router_decoder import FunctionRecipient, RouterCodec
codec = RouterCodec()
Permit signature
data, signable_message = codec.create_permit2_signable_message( "0x...", amount, # max = 2**160 - 1 (I don't get how to do this part for example) expiration, (same thing) nonce, # Permit2 nonce (same thing) spender, # UR deadline, (same thing) 1, # chain id )
Then you need to sign the message:
signed_message = acc.sign_message(signable_message) # where acc is your LocalAccount
Permit + v2 swap encoding
path = [token_in_address, token_out_address] encoded_data = ( codec .encode .chain() .permit2_permit(data, signed_message) ----Same goes for code below---- .v2_swap_exact_in(FunctionRecipient.SENDER, Wei(10**18), Wei(0), path)
.build(deadline)
)
Then in your transaction dict:
transaction["data"] = encoded_data
you can now sign and send the transaction to the UR
"""
I would really appreciate, already love your code btw, but I would love to understand it better and use it better :) good job bro
How you can get Nonce of Permit2 auto?
from uniswap-universal-router-decoder.
Related Issues (20)
- Decoding transactions that contain both a V2 and V3 swap HOT 3
- sell fail HOT 8
- Hope you can give a sell token model HOT 9
- js version HOT 1
- Could you provide code for bsc chain? HOT 9
- I don't know what is wrong HOT 11
- Add the support for `PAY_PORTION` and `SWEEP` command HOT 2
- Decoding issues HOT 1
- Decoding uniswap v3 Router with 2 swaps HOT 2
- The SDK fails to decode input data when there is too many commands. HOT 1
- Not working HOT 8
- Is it possible to have the F flag set to 1 so transaction continues on partial reverts ?
- Broken Amounts on a tx with multiple swaps HOT 3
- permit2_sign not work on bsc HOT 7
- Replace deprecated eth_account function HOT 1
- Fetch Permit2 allowance, expiration and nonce HOT 1
- how to get the result of a Transaction
- Quick Uniswap version detection
- Add support for other EVMs HOT 1
- Can swap V3 only on Base. V2 Fails HOT 2
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 uniswap-universal-router-decoder.