1717Nonce ,
1818HexBytes ,
1919)
20- from .types import AddressLike ,UniswapV4_slot0 ,UniswapV4_position_info ,UniswapV4_tick_info ,UniswapV4_PathKey
20+ from .types import AddressLike ,UniswapV4_slot0 ,UniswapV4_position_info ,UniswapV4_tick_info ,UniswapV4_path_key
2121from .token import ERC20Token
2222from .exceptions import InvalidToken ,InsufficientBalance
2323from .util import (
@@ -210,7 +210,7 @@ def get_quote_exact_input(
210210self ,
211211currency :AddressLike ,# input token
212212qty :int ,
213- path :List [UniswapV4_PathKey ],
213+ path :List [UniswapV4_path_key ],
214214 )-> Any :
215215"""
216216 :path is a swap route
@@ -234,7 +234,7 @@ def get_quote_exact_output(
234234self ,
235235currency :AddressLike ,# input token
236236qty :int ,
237- path :List [UniswapV4_PathKey ],
237+ path :List [UniswapV4_path_key ],
238238 )-> Any :
239239"""
240240 :path is a swap route
@@ -384,6 +384,7 @@ def swap(
384384qty :int ,
385385fee :int ,
386386tick_spacing :int ,
387+ hook_data :bytes ,
387388sqrt_price_limit_x96 :int = 0 ,
388389zero_for_one :bool = True ,
389390hooks :Union [AddressLike ,str ,None ]= NOHOOK_ADDRESS ,
@@ -437,6 +438,7 @@ def initialize(
437438fee :int ,
438439tick_spacing :int ,
439440sqrt_price_limit_x96 :int ,
441+ hook_data :bytes ,
440442hooks :Union [AddressLike ,str ,None ]= NOHOOK_ADDRESS ,
441443gas :Optional [Wei ]= None ,
442444max_fee :Optional [Wei ]= None ,
@@ -467,6 +469,7 @@ def initialize(
467469 {
468470"key" :pool_key ,
469471"sqrtPriceX96" :sqrt_price_limit_x96 ,
472+ "hookData" :hook_data ,
470473 }
471474 ),
472475self ._get_tx_params (gas = gas ,max_fee = max_fee ,priority_fee = priority_fee ),
@@ -476,10 +479,12 @@ def donate(
476479self ,
477480currency0 :ERC20Token ,
478481currency1 :ERC20Token ,
479- qty :int ,
482+ qty1 :int ,
483+ qty2 :int ,
480484fee :int ,
481485tick_spacing :int ,
482486sqrt_price_limit_x96 :int ,
487+ hook_data :bytes ,
483488hooks :Union [AddressLike ,str ,None ]= NOHOOK_ADDRESS ,
484489gas :Optional [Wei ]= None ,
485490max_fee :Optional [Wei ]= None ,
@@ -509,13 +514,15 @@ def donate(
509514self .router .functions .donate (
510515 {
511516"key" :pool_key ,
512- "sqrtPriceX96" :sqrt_price_limit_x96 ,
517+ "amount0" :qty1 ,
518+ "amount1" :qty2 ,
519+ "hookData" :hook_data ,
513520 }
514521 ),
515522self ._get_tx_params (gas = gas ,max_fee = max_fee ,priority_fee = priority_fee ),
516523 )
517524
518- def modify_position (
525+ def modify_liquidity (
519526self ,
520527currency0 :ERC20Token ,
521528currency1 :ERC20Token ,
@@ -524,6 +531,8 @@ def modify_position(
524531tick_spacing :int ,
525532tick_upper :int ,
526533tick_lower :int ,
534+ salt :int ,
535+ hook_data :bytes ,
527536hooks :Union [AddressLike ,str ,None ]= NOHOOK_ADDRESS ,
528537gas :Optional [Wei ]= None ,
529538max_fee :Optional [Wei ]= None ,
@@ -550,26 +559,27 @@ def modify_position(
550559"hooks" :hooks ,
551560 }
552561
553- modify_position_params = {
562+ modify_liquidity_params = {
554563"tickLower" :tick_lower ,
555564"tickUpper" :tick_upper ,
556565"liquidityDelta" :qty ,
566+ "salt" :salt ,
557567 }
558568
559569return self ._build_and_send_tx (
560- self .router .functions .modifyPosition (
570+ self .router .functions .modifyLiquidity (
561571 {
562572"key" :pool_key ,
563573"params" :modify_position_params ,
574+ "hookData" :hook_data ,
564575 }
565576 ),
566577self ._get_tx_params (value = Wei (qty ),gas = gas ,max_fee = max_fee ,priority_fee = priority_fee ),
567578 )
568579
569580def settle (
570581self ,
571- currency0 :ERC20Token ,
572- qty :int ,
582+ currency0 :Union [AddressLike ,str ,None ],
573583gas :Optional [Wei ]= None ,
574584max_fee :Optional [Wei ]= None ,
575585priority_fee :Optional [Wei ]= None ,
@@ -589,7 +599,7 @@ def settle(
589599
590600def take (
591601self ,
592- currency0 :ERC20Token ,
602+ currency0 :Union [ AddressLike , str , None ] ,
593603to :AddressLike ,
594604qty :int ,
595605gas :Optional [Wei ]= None ,
@@ -612,6 +622,56 @@ def take(
612622self ._get_tx_params (gas = gas ,max_fee = max_fee ,priority_fee = priority_fee ),
613623 )
614624
625+ def mint (
626+ self ,
627+ currency0 :Union [AddressLike ,str ,None ],
628+ id :int ,
629+ qty :int ,
630+ gas :Optional [Wei ]= None ,
631+ max_fee :Optional [Wei ]= None ,
632+ priority_fee :Optional [Wei ]= None ,
633+ )-> HexBytes :
634+ """
635+ :Called by the user to net out some value owed to the user
636+ :Can also be used as a mechanism for _free_ flash loans
637+ """
638+
639+ return self ._build_and_send_tx (
640+ self .router .functions .mint (
641+ {
642+ "currency " :currency0 ,
643+ "id " :id ,
644+ "amount " :qty ,
645+ }
646+ ),
647+ self ._get_tx_params (gas = gas ,max_fee = max_fee ,priority_fee = priority_fee ),
648+ )
649+
650+ def burn (
651+ self ,
652+ currency0 :Union [AddressLike ,str ,None ],
653+ id :int ,
654+ qty :int ,
655+ gas :Optional [Wei ]= None ,
656+ max_fee :Optional [Wei ]= None ,
657+ priority_fee :Optional [Wei ]= None ,
658+ )-> HexBytes :
659+ """
660+ :Called by the user to net out some value owed to the user
661+ :Can also be used as a mechanism for _free_ flash loans
662+ """
663+
664+ return self ._build_and_send_tx (
665+ self .router .functions .burn (
666+ {
667+ "currency " :currency0 ,
668+ "id " :id ,
669+ "amount " :qty ,
670+ }
671+ ),
672+ self ._get_tx_params (gas = gas ,max_fee = max_fee ,priority_fee = priority_fee ),
673+ )
674+
615675# ------ Wallet balance ------------------------------------------------------------
616676def get_eth_balance (self )-> Wei :
617677"""Get the balance of ETH for your address."""
@@ -715,8 +775,8 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token
715775symbol = _symbol
716776return ERC20Token (symbol ,address ,name ,decimals )
717777
718- def get_pool_id (self ,currency0 :AddressLike ,currency1 :AddressLike ,fee :int ,tickSpacing :int ,hooks :Union [AddressLike ,str ,None ]= NOHOOK_ADDRESS )-> bytes :
719- if int (currency0 )> int (currency1 ):
778+ def get_pool_id (self ,currency0 :str ,currency1 :str ,fee :int ,tickSpacing :int ,hooks :Union [AddressLike ,str ,None ]= NOHOOK_ADDRESS )-> bytes :
779+ if int (currency0 , 16 )> int (currency1 , 16 ):
720780currency0 ,currency1 = currency1 ,currency0
721781pool_id = bytes (self .w3 .solidity_keccak (["address" ,"address" ,"int24" ,"int24" ,"address" ], [(currency0 ,currency1 ,fee ,tickSpacing ,hooks )]))
722782return pool_id