Giter Club home page Giter Club logo

Comments (3)

Elnaril avatar Elnaril commented on August 14, 2024

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.

Elnaril avatar Elnaril commented on August 14, 2024

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.

uname0x96 avatar uname0x96 commented on August 14, 2024

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)

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.