You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- All non-global query configurations have been moved to the request-level params ([PR](https://github.com/1inch/1inch-sdk/pull/6))
6
+
- RPC providers for all chains will now be defined/set at SDK startup
7
+
- Query parameters now use concrete types instead of pointers ([PR](https://github.com/1inch/1inch-sdk/pull/16))
8
+
- Limit orders created within the SDK now support auto-expiration ([PR](https://github.com/1inch/1inch-sdk/pull/23))
9
+
- Permit1 properly supported for limit orders when possible (fallback to Approval if Permit1 does not work) ([commit](https://github.com/1inch/1inch-sdk/commit/f2e79e5f0e81503bfeeff076e41455e86e5a5120))
10
+
- When creating a limit order, integrators can error out when an approval is needed. This is useful for integrators who want all onchain actions to be performed manually by their users ([PR](https://github.com/1inch/1inch-sdk/pull/26))
11
+
12
+
### Optimizations and Bug Fixes:
13
+
- Tenderly forks are cleaned up automatically at the beginning of each test run ([PR](https://github.com/1inch/1inch-sdk/pull/6))
14
+
- Validation pattern for swagger-generated input params is now fully handled on all endpoints ([PR](https://github.com/1inch/1inch-sdk/pull/8))
This SDK will be open for contributions from the community. Contribution guidelines will be added soon!
2
+
3
+
4
+
### Versioning
5
+
6
+
This library is currently in the developer preview phase (versions 0.x.x). There will be significant changes to the design of this library leading up to a 1.0.0 release. You can expect the API calls, library structure, etc. to break between each release. Once the library version reaches 1.0.0 and beyond, it will follow traditional semver conventions.
7
+
8
+
### Project structure
9
+
10
+
This SDK is powered by a [client struct](https://github.com/1inch/1inch-sdk/blob/main/golang/client/client.go) that contains instances of all Services used to talk to the 1inch APIs
11
+
12
+
Each Service maps 1-to-1 with the underlying Dev Portal REST API. See [SwapService](https://github.com/1inch/1inch-sdk/blob/main/golang/client/swap.go) as an example. Under each function, you will find the matching REST API path)
13
+
14
+
Each Service uses various types and functions to do its job that are kept separate from the main service file. These can be found in the accompanying folder within the client directory (see the [swap](https://github.com/1inch/1inch-sdk/tree/main/golang/client/swap) package)
15
+
16
+
### Type generation
17
+
18
+
Type generation is done using the `generate_types.sh` script. To add a new swagger file or update an existing one, place the swagger file in `swagger-static` and run the script. It will generate the types file and place it in the appropriately-named sub-folder inside the `client` directory
19
+
20
+
### Swagger file formatting
21
+
For consistency, Swagger files should be formatted with `prettier`
22
+
23
+
This can be installed globally using npm:
24
+
25
+
`npm install -g prettier`
26
+
27
+
If using GoLand, you can set up this action to run automatically using File Watchers:
28
+
29
+
1. Go to Settings or Preferences > Tools > File Watchers.
30
+
2. Click the + button to add a new watcher.
31
+
3. For `File type`, choose JSON.
32
+
4. For `Scope`, choose Project Files.
33
+
5. For `Program`, provide the path to the `prettier`. This can be gotten by running `which prettier`.
34
+
6. For `Arguments`, use `--write $FilePath$`.
35
+
7. For `Output paths to refresh`, use `$FilePath$`.
36
+
8. Ensure the Auto-save edited files to trigger the watcher option is checked
First and foremost, it is important to note that when using the SDK libraries for the 1inch aggregator or limit order protocols, you will be creating *real* transaction data that can and will be executed onchain. Always be deliberate when calling [CreateOrder](https://github.com/1inch/1inch-sdk/blob/main/golang/client/orderbook.go), [SwapTokens](https://github.com/1inch/1inch-sdk/blob/main/golang/client/swap_actions.go), or [GetSwapData](https://github.com/1inch/1inch-sdk/blob/main/golang/client/swap.go). When filling out the parameters for these functions, make sure you understand concepts like [slippage](https://medium.com/onomy-protocol/what-is-slippage-in-defi-62a0d068feb3) and [MEV](https://chain.link/education-hub/maximal-extractable-value-mev), as well as the difference between [USDC](https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) having 6 digits of precision on Ethereum and [DAI](https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f) having 18!
3
+
The SDK requires a minimum version of Go `1.21`.
4
4
5
-
This SDK is young and there will be many use cases that have not been handled yet, so please try it and give us feedback!
5
+
Check out the [release notes](https://github.com/1inch/1inch-sdk/blob/main/golang/CHANGELOG.md) for information about the latest bug fixes, updates, and features added to the SDK.
6
6
7
-
## Overview
7
+
This is a Go SDK to simplify interactions with the 1inch Dev Portal APIs. When complete, it will support all endpoints tracked by our official docs [here](https://portal.1inch.dev/documentation/authentication). See the [Current Functionality](#current-functionality) section for an up-to-date view of the SDK functionality.
8
8
9
-
This is a Go SDK to simplify interactions with the 1inch Dev Portal APIs. When complete, it will support all endpoints tracked by our official docs [here](https://portal.1inch.dev/documentation/authentication). See the `Current Functionality` section for an up-to-date view of the SDK functionality.
9
+
Beyond mirroring the Developer Portal APIs, this SDK also supports token approvals, permit signature generation, and the execution of 1inch swaps onchain for EOA wallets.
10
10
11
-
Beyond mirroring the Developer Portal APIs, this SDK also supports token approvals, permit signature generation, and the execution of 1inch swaps onchain for EOA wallets.
11
+
Jump To:
12
+
*[Supported APIs](#supported-apis)
13
+
*[Getting Started](#getting-started)
14
+
*[Getting Help](#getting-help)
15
+
*[Development](#development)
12
16
13
-
## Current Functionality
14
-
15
-
**Supported APIs**
17
+
## Supported APIs
16
18
17
19
*Swap API*
18
-
- All endpoints supported
19
-
- Ethereum, Polygon, and Arbitrum tested (but should support all 1inch-supported chains)
20
-
- Swaps can be executed onchain from within the SDK using `Permit1` when supported and `Approve` in all other cases
This library is currently in the developer preview phase (versions 0.x.x). There will be significant changes to the design of this library leading up to a 1.0.0 release. You can expect the API calls, library structure, etc. to break between each release. Once the library version reaches 1.0.0 and beyond, it will follow traditional semver conventions.
29
+
To get started working with the SDK, set up your project for Go modules and retrieve the SDK dependencies with `go get`. This example shows how you can use the SDK to make an API request using the SDK's Swap API service:
29
30
30
-
## Using the SDK in your project
31
+
###### Initialize Project
32
+
```
33
+
mkdir ~/hello1inch
34
+
cd ~/hello1inch
35
+
go mod init hello1inch
36
+
```
31
37
32
-
The SDK can be used by first creating a config object, calling the constructor, then accessing the service for the API of interest. For now, the web3 provider and chain are set at the client level, but this will be moved to the request parameters in the future.
38
+
###### Add SDK Dependencies
39
+
```
40
+
go get github.com/1inch/1inch-sdk/golang
41
+
```
33
42
34
-
**Note**: The 1inch Dev Portal Token can be generated at https://portal.1inch.dev
35
-
Additionally,
36
-
documentation for all API calls can be found at https://portal.1inch.dev/documentation
43
+
###### Write Code
44
+
In your preferred editor add the following content to `main.go`
37
45
38
-
Here is a simple program using the SDK that will generate swap data using the 1inch Aggregator:
46
+
**Note**: The 1inch Dev Portal Token can be generated at https://portal.1inch.dev
log.Fatalf("Failed to marshal swap data: %v", err)
107
+
}
100
108
109
+
fmt.Printf("%s\n", string(swapDataRawIndented))
110
+
}
101
111
```
102
112
103
-
More example programs using the SDK can be found in the [examples directory](https://github.com/1inch/1inch-sdk/blob/main/golang/examples)
104
-
105
-
## Tips
106
-
- It is recommended to use private/personal RPC endpoints when using this SDK. Public RPCs tend to have either slow response times, strict rate limits, or both!
107
-
108
-
## Project structure
113
+
###### Compile and Execute
114
+
```sh
115
+
go run .
116
+
```
109
117
110
-
This SDK is powered by a [client struct](https://github.com/1inch/1inch-sdk/blob/main/golang/client/client.go) that contains instances of all Services used to talk to the 1inch APIs
118
+
Documentation for all API calls can be found at https://portal.1inch.dev/documentation
111
119
112
-
Each Service is simply a struct that contains all endpoints from a given 1inch API (see [SwapService](https://github.com/1inch/1inch-sdk/blob/main/golang/client/swap.go))
120
+
More example programs using the SDK can be found in the [examples directory](https://github.com/1inch/1inch-sdk/blob/main/golang/client/examples)
113
121
114
-
Each Service uses various types and functions to do its job that are kept separate from the main service file. These can be found in the accompanying folder within the client directory (see the [swap](https://github.com/1inch/1inch-sdk/tree/main/golang/client/swap) package)
122
+
## Getting Help
115
123
116
-
## Issues/Suggestions
124
+
If you have questions, want to discuss the tool, or have found a bug, please open an [issue](https://github.com/1inch/1inch-sdk/issues) here on GitHub
117
125
118
-
For any problems you have with the SDK or suggestions for improvements, please create an [issue](https://github.com/1inch/1inch-sdk/issues) here on GitHub
119
126
120
127
## Development
121
128
122
-
### Type generation
123
-
124
-
Type generation is done using the `generate_types.sh` script. To add a new swagger file or update an existing one, place the swagger file in `swagger-static` and run the script. It will generate the types file and place it in the appropriately-named sub-folder inside the `client` directory
125
-
126
-
### Swagger file formatting
127
-
For consistency, Swagger files should be formatted with `prettier`
128
-
129
-
This can be installed globally using npm:
130
-
131
-
`npm install -g prettier`
132
-
133
-
If using GoLand, you can set up this action to run automatically using File Watchers:
134
-
135
-
1. Go to Settings or Preferences > Tools > File Watchers.
136
-
2. Click the + button to add a new watcher.
137
-
3. For `File type`, choose JSON.
138
-
4. For `Scope`, choose Project Files.
139
-
5. For `Program`, provide the path to the `prettier`. This can be gotten by running `which prettier`.
140
-
6. For `Arguments`, use `--write $FilePath$`.
141
-
7. For `Output paths to refresh`, use `$FilePath$`.
142
-
8. Ensure the Auto-save edited files to trigger the watcher option is checked
129
+
Please see our [SDK Developer Guide](https://github.com/1inch/1inch-sdk/blob/main/golang/DEVELOPMENT.md) if you would like to contribute
0 commit comments