@@ -11,14 +11,14 @@ exchange.**
11
11
12
12
Add this to your Cargo.toml
13
13
14
- ```
14
+ ``` toml
15
15
[dependencies ]
16
- uniswap-sdk-core = "3.3 .0"
16
+ uniswap-sdk-core = " 3.5 .0"
17
17
```
18
18
19
19
And this to your code:
20
20
21
- ```
21
+ ``` rust
22
22
use uniswap_sdk_core :: prelude :: * ;
23
23
```
24
24
@@ -28,48 +28,43 @@ By default, this library does not depend on the standard library (`std`). Howeve
28
28
29
29
## Examples
30
30
31
+ The code below shows an example of how to create a new ` Token ` instance for the DAI token on the Ethereum Mainnet using
32
+ the ` token! ` macro.
33
+
31
34
<details >
32
- <summary >The code below shows an example of how to create a new `Token` instance for the DAI token on the Ethereum Mainnet using
33
- the ` token! ` macro.</summary >
35
+ <summary >Click to expand</summary >
34
36
35
37
``` rust
36
- // The `prelude` module provides a convenient way to import a number of common dependencies at
37
- // once. This can be useful if you are working with multiple parts of the library and want to avoid
38
- // having to import each dependency individually.
39
- // Import necessary preludes and types
38
+ // Import necessary preludes and token macro
40
39
use uniswap_sdk_core :: {prelude :: * , token};
41
40
42
- fn main () {
43
- // Define the chain ID, address, decimals, symbol, and name for the token
44
- const CHAIN_ID : u64 = 1 ; // Ethereum Mainnet
45
- const TOKEN_ADDRESS : & str = " 0x6B175474E89094C44Da98b954EedeAC495271d0F" ; // DAI Token Address
46
- const DECIMALS : u8 = 18 ;
47
- const SYMBOL : & str = " DAI" ;
48
- const NAME : & str = " Dai Stablecoin" ;
49
-
50
- // Use the `token!` macro to create a new `Token` instance
51
- let dai_token = token! (CHAIN_ID , TOKEN_ADDRESS , DECIMALS , SYMBOL , NAME );
52
-
53
- // Example usage of the `Token` methods
54
- println! (" Token Address: {}" , dai_token . address ());
55
- println! (" Is Native: {}" , dai_token . is_native ());
56
-
57
- // Example of comparing two tokens
58
- let another_dai_token = token! (CHAIN_ID , TOKEN_ADDRESS , DECIMALS , SYMBOL , NAME );
59
- println! (" Are the tokens equal? {}" , dai_token . equals (& another_dai_token ));
60
-
61
- // Example of sorting tokens
62
- let another_token = token! (CHAIN_ID , " 0000000000000000000000000000000000000002" , DECIMALS , " ETH" , " Ethereum" );
63
- match dai_token . sorts_before (& another_token ) {
64
- Ok (true ) => println! (" DAI sorts before ETH" ),
65
- Ok (false ) => println! (" DAI does not sort before ETH" ),
66
- Err (e ) => println! (" Error comparing tokens: {:?}" , e ),
67
- }
41
+ // Define the chain ID, address, decimals, symbol, and name for the token
42
+ const CHAIN_ID : u64 = 1 ; // Ethereum Mainnet
43
+ const TOKEN_ADDRESS : & str = " 0x6B175474E89094C44Da98b954EedeAC495271d0F" ; // DAI Token Address
44
+ const DECIMALS : u8 = 18 ;
45
+ const SYMBOL : & str = " DAI" ;
46
+ const NAME : & str = " Dai Stablecoin" ;
47
+
48
+ // Use the `token!` macro to create a new `Token` instance
49
+ let dai_token = token! (CHAIN_ID , TOKEN_ADDRESS , DECIMALS , SYMBOL , NAME );
50
+
51
+ // Example usage of the `Token` methods
52
+ println! (" Token Address: {}" , dai_token . address ());
53
+ println! (" Is Native: {}" , dai_token . is_native ());
54
+
55
+ // Example of comparing two tokens
56
+ let another_dai_token = token! (CHAIN_ID , TOKEN_ADDRESS , DECIMALS , SYMBOL , NAME );
57
+ println! (" Are the tokens equal? {}" , dai_token . equals (& another_dai_token ));
58
+
59
+ // Example of sorting tokens
60
+ let another_token = token! (CHAIN_ID , " 0000000000000000000000000000000000000002" , DECIMALS , " ETH" , " Ethereum" );
61
+ match dai_token . sorts_before ( & another_token ) {
62
+ Ok (true ) => println ! (" DAI sorts before ETH" ),
63
+ Ok (false ) => println ! (" DAI does not sort before ETH" ),
64
+ Err (e ) => println ! (" Error comparing tokens: {:?}" , e ),
68
65
}
69
66
```
70
67
71
- </details >
72
-
73
68
This example demonstrates how to create a ` Token ` instance for DAI on the Ethereum Mainnet using the ` token! ` macro.
74
69
75
70
It then prints the token's address and checks if it's a native token (which it isn't, so it prints false).
@@ -83,14 +78,16 @@ assuming the addresses are correctly set up for this comparison.
83
78
Remember to replace "0x6B175474E89094C44Da98b954EedeAC495271d0F" with the actual address of the DAI token you're working
84
79
with, and adjust the CHAIN_ID if you're working on a different network (e.g., a testnet).
85
80
81
+ </details >
82
+
86
83
## Contribution
87
84
88
85
Contributions are welcome! If you find a bug or have suggestions for improvements, feel free to open an issue or submit
89
86
a pull request on the [ GitHub repository] ( https://github.com/malik672/uniswap-sdk-core-rust ) .
90
87
91
88
## License
92
89
93
- This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
90
+ This project is licensed under the MIT License - see the [ LICENSE] ( ./ LICENSE) file for details.
94
91
95
92
## Acknowledgments
96
93
0 commit comments