gigadex-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.4
2
+ Name: gigadex-sdk
3
+ Version: 0.1.0
4
+ Summary: Reusable Python SDK for GigaDex GraphQL, ABIs, contracts, and CL math.
5
+ Project-URL: Homepage, https://github.com/1220moritz/gigadex-sdk
6
+ Project-URL: Repository, https://github.com/1220moritz/gigadex-sdk
7
+ Project-URL: Issues, https://github.com/1220moritz/gigadex-sdk/issues
8
+ Author: GigaDex SDK Contributors
9
+ License: MIT
10
+ Keywords: defi,gigadex,robinhood-chain,sdk,web3
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: httpx>=0.27.0
22
+ Requires-Dist: pydantic>=2.8.0
23
+ Requires-Dist: web3>=7.16.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.2.0; extra == 'dev'
26
+ Requires-Dist: ruff>=0.5.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # gigadex-sdk
30
+
31
+ The community Python SDK for building on [GigaDex](https://www.gigadex.fi/) on Robinhood Chain.
32
+
33
+ `gigadex-sdk` gives Python developers a small, typed foundation for reading GigaDex data, working with concentrated-liquidity prices and ticks, loading verified contract ABIs, and preparing Web3 integrations.
34
+
35
+ It is useful for:
36
+
37
+ - liquidity keepers and range-management bots
38
+ - portfolio dashboards
39
+ - analytics and reporting scripts
40
+ - research notebooks
41
+ - trading and automation tools
42
+
43
+ > This SDK is community maintained. Review all transactions yourself before sending funds on-chain.
44
+
45
+ ## Features
46
+
47
+ - **GigaDex GraphQL client** for tokens, pools, positions, and portfolio state.
48
+ - **Typed Pydantic models** for safer application code.
49
+ - **Concentrated-liquidity math** for ticks, prices, ranges, and tick-spacing alignment.
50
+ - **Packaged ABI loading** for common GigaDex/Web3 contract interactions.
51
+ - **Web3 helpers** for contracts, chain validation, gas checks, signing, and sending transactions.
52
+ - **Modern Python packaging** with `uv`, `pyproject.toml`, and Python 3.11+ support.
53
+
54
+ ## Installation
55
+
56
+ With `uv`:
57
+
58
+ ```bash
59
+ uv add gigadex-sdk
60
+ ```
61
+
62
+ With `pip`:
63
+
64
+ ```bash
65
+ pip install gigadex-sdk
66
+ ```
67
+
68
+ ## Quick start
69
+
70
+ ### Fetch portfolio data
71
+
72
+ ```python
73
+ from gigadex_sdk.graphql_client import GigaDexGraphQLClient
74
+
75
+ GRAPHQL_URL = "https://edge.gigadex.fi/v1/graphql"
76
+ CHAIN_ID = 4663
77
+ ACCOUNT = "0x2d438b5f9dbb11fb406a92fd97476f4cdc9947d1"
78
+
79
+ client = GigaDexGraphQLClient(GRAPHQL_URL)
80
+ portfolio = client.fetch_portfolio(chain_id=CHAIN_ID, account=ACCOUNT)
81
+
82
+ for position in portfolio.positions:
83
+ print(position.token_id, position.pool, position.tick_lower, position.tick_upper)
84
+ ```
85
+
86
+ ### Work with concentrated-liquidity ticks
87
+
88
+ ```python
89
+ from decimal import Decimal
90
+
91
+ from gigadex_sdk.math import percentage_range_ticks, range_width_percent
92
+
93
+ current_tick = -200_000
94
+ tick_spacing = 10
95
+
96
+ tick_lower, tick_upper = percentage_range_ticks(
97
+ current_tick=current_tick,
98
+ percent_each_side=Decimal("5"),
99
+ tick_spacing=tick_spacing,
100
+ )
101
+
102
+ lower_pct, upper_pct = range_width_percent(tick_lower, tick_upper, current_tick)
103
+
104
+ print(tick_lower, tick_upper)
105
+ print(f"range: -{lower_pct:.2f}% / +{upper_pct:.2f}%")
106
+ ```
107
+
108
+ ### Load packaged ABIs
109
+
110
+ ```python
111
+ from gigadex_sdk.abis import ERC20_ABI, POSITION_MANAGER_ABI
112
+
113
+ print(len(ERC20_ABI))
114
+ print(len(POSITION_MANAGER_ABI))
115
+ ```
116
+
117
+ ### Create a Web3 contract
118
+
119
+ ```python
120
+ from gigadex_sdk.abis import ERC20_ABI
121
+ from gigadex_sdk.chain import ChainClient
122
+
123
+ # ChainClient expects a small settings object with rpc_url, chain_id,
124
+ # account/private-key settings, and gas controls. See README-DEV.md for
125
+ # development details and examples.
126
+ token = chain_client.contract("0xTokenAddress", ERC20_ABI)
127
+ ```
128
+
129
+ ## Common constants
130
+
131
+ ```python
132
+ GIGADEX_GRAPHQL_URL = "https://edge.gigadex.fi/v1/graphql"
133
+ ROBINHOOD_CHAIN_ID = 4663
134
+ ```
135
+
136
+ ## Project status
137
+
138
+ `gigadex-sdk` is early software. The current focus is reliable read access, reusable data models, concentrated-liquidity math, and safe building blocks for bot authors.
139
+
140
+ On-chain write helpers are intentionally low-level. Applications should add their own policy layer for slippage, gas limits, simulation, private-key handling, retries, alerts, and human review.
141
+
142
+ ## Contributing
143
+
144
+ Contributions are welcome. For development setup, test commands, release steps, and PyPI publishing notes, see [`README-DEV.md`](README-DEV.md).
145
+
146
+ ## License
147
+
148
+ MIT
149
+
@@ -0,0 +1,219 @@
1
+ # gigadex-sdk contributor guide
2
+
3
+ This guide is for contributors and maintainers working on the `gigadex-sdk` codebase.
4
+
5
+ For installation and normal SDK usage, see [`README.md`](README.md).
6
+
7
+ ## What this project is
8
+
9
+ `gigadex-sdk` is the community Python SDK for GigaDex on Robinhood Chain. It should stay small, typed, reusable, and safe to build on.
10
+
11
+ The SDK provides building blocks, not complete trading strategies. Applications that use it should decide their own policy for slippage, transaction simulation, gas limits, retries, alerts, and private-key management.
12
+
13
+ ## Development setup
14
+
15
+ Requirements:
16
+
17
+ - Python 3.11+
18
+ - [`uv`](https://docs.astral.sh/uv/)
19
+
20
+ Install the project with development dependencies:
21
+
22
+ ```bash
23
+ uv sync --extra dev
24
+ ```
25
+
26
+ Run commands through `uv`:
27
+
28
+ ```bash
29
+ uv run pytest
30
+ uv run ruff check .
31
+ ```
32
+
33
+ ## Project structure
34
+
35
+ ```text
36
+ src/gigadex_sdk/
37
+ __init__.py package metadata, including __version__
38
+ abis.py ABI loading helpers and public ABI constants
39
+ chain.py Web3 chain/client helpers
40
+ graphql_client.py GigaDex GraphQL queries and client methods
41
+ math.py concentrated-liquidity tick/price/range math
42
+ models.py Pydantic models for GraphQL/API data
43
+ abis/*.json ABI JSON files packaged into wheels
44
+
45
+ abis/*.json local ABI source/override files for development
46
+ tests/ pytest tests
47
+ .github/workflows/ CI and publishing workflows
48
+ pyproject.toml package metadata, dependencies, build config, tool config
49
+ README.md user-facing documentation
50
+ README-DEV.md contributor-facing documentation
51
+ ```
52
+
53
+ ## Design principles
54
+
55
+ ### Keep the SDK focused
56
+
57
+ Good SDK features are reusable across many tools:
58
+
59
+ - GraphQL access
60
+ - typed data models
61
+ - ABI loading
62
+ - Web3 connection helpers
63
+ - CL tick/price math
64
+ - transaction-building primitives
65
+
66
+ Avoid putting app-specific behavior directly into the SDK, such as:
67
+
68
+ - one-off trading strategies
69
+ - keeper-specific scheduling loops
70
+ - notification integrations
71
+ - hardcoded wallet addresses
72
+ - hidden transaction policies
73
+
74
+ Those belong in applications built on top of the SDK.
75
+
76
+ ### Prefer explicit safety
77
+
78
+ The SDK may be used by bots that handle real funds. Code should make risky behavior visible and configurable.
79
+
80
+ Best practices:
81
+
82
+ - Always validate chain IDs before sending transactions.
83
+ - Do not silently bypass gas caps.
84
+ - Do not embed private keys in examples, tests, or docs.
85
+ - Do not hide transaction side effects behind innocent-looking helper names.
86
+ - Prefer explicit arguments for recipient, deadline, slippage, gas policy, and value.
87
+ - Keep write helpers composable so applications can dry-run, simulate, or require review.
88
+
89
+ ### Keep public APIs typed and boring
90
+
91
+ - Use clear function and method names.
92
+ - Prefer small functions over large multi-purpose helpers.
93
+ - Use Pydantic models for external API data.
94
+ - Avoid returning unstructured dictionaries from public APIs when a model is practical.
95
+ - Keep exceptions understandable for bot authors and CLI tools.
96
+
97
+ ## Working with GraphQL
98
+
99
+ GraphQL code lives in `src/gigadex_sdk/graphql_client.py`.
100
+
101
+ Guidelines:
102
+
103
+ - Keep query strings close to the client method that uses them.
104
+ - Validate returned data through models from `models.py`.
105
+ - Paginate when the endpoint supports pagination.
106
+ - Keep default request headers reasonable and transparent.
107
+ - Avoid making network calls at import time.
108
+
109
+ When adding a new query:
110
+
111
+ 1. Add or update Pydantic models in `models.py`.
112
+ 2. Add the query and client method in `graphql_client.py`.
113
+ 3. Add tests for parsing/model behavior where possible.
114
+ 4. Document the common usage in `README.md` if it is user-facing.
115
+
116
+ ## Working with ABIs
117
+
118
+ ABI loading is designed for both local development and installed packages:
119
+
120
+ 1. Local development can use the top-level `abis/` folder.
121
+ 2. Installed wheels load packaged JSON files from `src/gigadex_sdk/abis/`.
122
+ 3. `abis.py` exposes public constants such as `ERC20_ABI` and `POSITION_MANAGER_ABI`.
123
+
124
+ When updating ABI JSON files, keep both ABI locations in sync:
125
+
126
+ ```bash
127
+ cp abis/*.json src/gigadex_sdk/abis/
128
+ ```
129
+
130
+ Then validate that tests and packaging still work:
131
+
132
+ ```bash
133
+ uv run pytest
134
+ uv build
135
+ ```
136
+
137
+ ## Working with CL math
138
+
139
+ Concentrated-liquidity math lives in `src/gigadex_sdk/math.py`.
140
+
141
+ Guidelines:
142
+
143
+ - Use `Decimal` for price/range calculations where precision matters.
144
+ - Keep tick-alignment behavior deterministic.
145
+ - Add tests for edge cases: negative ticks, exact tick-spacing boundaries, tiny ranges, and invalid inputs.
146
+ - Avoid introducing float-only APIs for values that users may rely on for money decisions.
147
+
148
+ ## Working with Web3 helpers
149
+
150
+ Web3 helpers live in `src/gigadex_sdk/chain.py`.
151
+
152
+ Guidelines:
153
+
154
+ - Keep chain validation strict.
155
+ - Keep signing and sending explicit.
156
+ - Do not automatically approve tokens or send transactions as a side effect of read methods.
157
+ - Let applications decide retry policy and receipt-waiting behavior.
158
+ - Keep settings interfaces minimal so apps can use their own config systems.
159
+
160
+ ## Testing
161
+
162
+ Run the test suite:
163
+
164
+ ```bash
165
+ uv run pytest
166
+ ```
167
+
168
+ Run linting:
169
+
170
+ ```bash
171
+ uv run ruff check .
172
+ ```
173
+
174
+ Build the package:
175
+
176
+ ```bash
177
+ uv build
178
+ ```
179
+
180
+ Before opening a pull request, run all checks:
181
+
182
+ ```bash
183
+ uv run ruff check .
184
+ uv run pytest
185
+ uv build
186
+ ```
187
+
188
+ ## Pull request checklist
189
+
190
+ Before submitting a PR:
191
+
192
+ - [ ] The change is reusable SDK functionality, not app-specific behavior.
193
+ - [ ] Public functions/classes have clear names and type hints.
194
+ - [ ] External data is validated with models where practical.
195
+ - [ ] Risky on-chain behavior is explicit and documented.
196
+ - [ ] Tests were added or updated for behavior changes.
197
+ - [ ] `uv run ruff check .` passes.
198
+ - [ ] `uv run pytest` passes.
199
+ - [ ] `uv build` passes if packaging, ABIs, or metadata changed.
200
+ - [ ] User-facing docs were updated in `README.md` if needed.
201
+
202
+ ## Versioning and releases
203
+
204
+ Version numbers are stored in:
205
+
206
+ - `pyproject.toml`
207
+ - `src/gigadex_sdk/__init__.py`
208
+
209
+ When preparing a release, keep both versions in sync and run the full validation suite before tagging.
210
+
211
+ Publishing is handled by the GitHub Actions workflow in `.github/workflows/publish.yml` for version tags matching `v*`.
212
+
213
+ ## Documentation style
214
+
215
+ - `README.md` is for normal users. Keep it practical and friendly.
216
+ - `README-DEV.md` is for contributors and maintainers.
217
+ - Avoid putting secrets, private keys, or personal operational details in documentation.
218
+ - Prefer copy-pasteable examples that are safe by default.
219
+ - Mention when examples are read-only versus transaction-sending.
@@ -0,0 +1,121 @@
1
+ # gigadex-sdk
2
+
3
+ The community Python SDK for building on [GigaDex](https://www.gigadex.fi/) on Robinhood Chain.
4
+
5
+ `gigadex-sdk` gives Python developers a small, typed foundation for reading GigaDex data, working with concentrated-liquidity prices and ticks, loading verified contract ABIs, and preparing Web3 integrations.
6
+
7
+ It is useful for:
8
+
9
+ - liquidity keepers and range-management bots
10
+ - portfolio dashboards
11
+ - analytics and reporting scripts
12
+ - research notebooks
13
+ - trading and automation tools
14
+
15
+ > This SDK is community maintained. Review all transactions yourself before sending funds on-chain.
16
+
17
+ ## Features
18
+
19
+ - **GigaDex GraphQL client** for tokens, pools, positions, and portfolio state.
20
+ - **Typed Pydantic models** for safer application code.
21
+ - **Concentrated-liquidity math** for ticks, prices, ranges, and tick-spacing alignment.
22
+ - **Packaged ABI loading** for common GigaDex/Web3 contract interactions.
23
+ - **Web3 helpers** for contracts, chain validation, gas checks, signing, and sending transactions.
24
+ - **Modern Python packaging** with `uv`, `pyproject.toml`, and Python 3.11+ support.
25
+
26
+ ## Installation
27
+
28
+ With `uv`:
29
+
30
+ ```bash
31
+ uv add gigadex-sdk
32
+ ```
33
+
34
+ With `pip`:
35
+
36
+ ```bash
37
+ pip install gigadex-sdk
38
+ ```
39
+
40
+ ## Quick start
41
+
42
+ ### Fetch portfolio data
43
+
44
+ ```python
45
+ from gigadex_sdk.graphql_client import GigaDexGraphQLClient
46
+
47
+ GRAPHQL_URL = "https://edge.gigadex.fi/v1/graphql"
48
+ CHAIN_ID = 4663
49
+ ACCOUNT = "0x2d438b5f9dbb11fb406a92fd97476f4cdc9947d1"
50
+
51
+ client = GigaDexGraphQLClient(GRAPHQL_URL)
52
+ portfolio = client.fetch_portfolio(chain_id=CHAIN_ID, account=ACCOUNT)
53
+
54
+ for position in portfolio.positions:
55
+ print(position.token_id, position.pool, position.tick_lower, position.tick_upper)
56
+ ```
57
+
58
+ ### Work with concentrated-liquidity ticks
59
+
60
+ ```python
61
+ from decimal import Decimal
62
+
63
+ from gigadex_sdk.math import percentage_range_ticks, range_width_percent
64
+
65
+ current_tick = -200_000
66
+ tick_spacing = 10
67
+
68
+ tick_lower, tick_upper = percentage_range_ticks(
69
+ current_tick=current_tick,
70
+ percent_each_side=Decimal("5"),
71
+ tick_spacing=tick_spacing,
72
+ )
73
+
74
+ lower_pct, upper_pct = range_width_percent(tick_lower, tick_upper, current_tick)
75
+
76
+ print(tick_lower, tick_upper)
77
+ print(f"range: -{lower_pct:.2f}% / +{upper_pct:.2f}%")
78
+ ```
79
+
80
+ ### Load packaged ABIs
81
+
82
+ ```python
83
+ from gigadex_sdk.abis import ERC20_ABI, POSITION_MANAGER_ABI
84
+
85
+ print(len(ERC20_ABI))
86
+ print(len(POSITION_MANAGER_ABI))
87
+ ```
88
+
89
+ ### Create a Web3 contract
90
+
91
+ ```python
92
+ from gigadex_sdk.abis import ERC20_ABI
93
+ from gigadex_sdk.chain import ChainClient
94
+
95
+ # ChainClient expects a small settings object with rpc_url, chain_id,
96
+ # account/private-key settings, and gas controls. See README-DEV.md for
97
+ # development details and examples.
98
+ token = chain_client.contract("0xTokenAddress", ERC20_ABI)
99
+ ```
100
+
101
+ ## Common constants
102
+
103
+ ```python
104
+ GIGADEX_GRAPHQL_URL = "https://edge.gigadex.fi/v1/graphql"
105
+ ROBINHOOD_CHAIN_ID = 4663
106
+ ```
107
+
108
+ ## Project status
109
+
110
+ `gigadex-sdk` is early software. The current focus is reliable read access, reusable data models, concentrated-liquidity math, and safe building blocks for bot authors.
111
+
112
+ On-chain write helpers are intentionally low-level. Applications should add their own policy layer for slippage, gas limits, simulation, private-key handling, retries, alerts, and human review.
113
+
114
+ ## Contributing
115
+
116
+ Contributions are welcome. For development setup, test commands, release steps, and PyPI publishing notes, see [`README-DEV.md`](README-DEV.md).
117
+
118
+ ## License
119
+
120
+ MIT
121
+
@@ -0,0 +1,12 @@
1
+ # ABI files
2
+
3
+ The keeper loads ABIs from this folder first and falls back to built-in minimal fragments if a file is missing.
4
+
5
+ Files:
6
+
7
+ - `position_manager.json` — GigaDex `0xA79F5775b0B49E51202c48DDF03F380FaA96f641` / NonfungiblePositionManager-compatible ABI.
8
+ - `erc20.json` — generic ERC-20 ABI used for token balances and approvals.
9
+ - `multicall.json` — generic `multicall(bytes[])` ABI.
10
+ - `cl_pool.json` — generic concentrated-liquidity pool ABI fragments for validation/introspection.
11
+
12
+ For another deployment, paste verified explorer ABIs into the same filenames. The project is pool-agnostic: runtime pool/token addresses come from GraphQL and `POSITION_TOKEN_ID`, not from WETH/USDG-specific code.
@@ -0,0 +1,131 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "slot0",
5
+ "stateMutability": "view",
6
+ "inputs": [],
7
+ "outputs": [
8
+ {
9
+ "name": "sqrtPriceX96",
10
+ "type": "uint160"
11
+ },
12
+ {
13
+ "name": "tick",
14
+ "type": "int24"
15
+ },
16
+ {
17
+ "name": "observationIndex",
18
+ "type": "uint16"
19
+ },
20
+ {
21
+ "name": "observationCardinality",
22
+ "type": "uint16"
23
+ },
24
+ {
25
+ "name": "observationCardinalityNext",
26
+ "type": "uint16"
27
+ },
28
+ {
29
+ "name": "feeProtocol",
30
+ "type": "uint32"
31
+ },
32
+ {
33
+ "name": "unlocked",
34
+ "type": "bool"
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "type": "function",
40
+ "name": "liquidity",
41
+ "stateMutability": "view",
42
+ "inputs": [],
43
+ "outputs": [
44
+ {
45
+ "name": "",
46
+ "type": "uint128"
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ "type": "function",
52
+ "name": "token0",
53
+ "stateMutability": "view",
54
+ "inputs": [],
55
+ "outputs": [
56
+ {
57
+ "name": "",
58
+ "type": "address"
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "type": "function",
64
+ "name": "token1",
65
+ "stateMutability": "view",
66
+ "inputs": [],
67
+ "outputs": [
68
+ {
69
+ "name": "",
70
+ "type": "address"
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "type": "function",
76
+ "name": "fee",
77
+ "stateMutability": "view",
78
+ "inputs": [],
79
+ "outputs": [
80
+ {
81
+ "name": "",
82
+ "type": "uint24"
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "type": "function",
88
+ "name": "tickSpacing",
89
+ "stateMutability": "view",
90
+ "inputs": [],
91
+ "outputs": [
92
+ {
93
+ "name": "",
94
+ "type": "int24"
95
+ }
96
+ ]
97
+ },
98
+ {
99
+ "type": "function",
100
+ "name": "positions",
101
+ "stateMutability": "view",
102
+ "inputs": [
103
+ {
104
+ "name": "key",
105
+ "type": "bytes32"
106
+ }
107
+ ],
108
+ "outputs": [
109
+ {
110
+ "name": "liquidity",
111
+ "type": "uint128"
112
+ },
113
+ {
114
+ "name": "feeGrowthInside0LastX128",
115
+ "type": "uint256"
116
+ },
117
+ {
118
+ "name": "feeGrowthInside1LastX128",
119
+ "type": "uint256"
120
+ },
121
+ {
122
+ "name": "tokensOwed0",
123
+ "type": "uint128"
124
+ },
125
+ {
126
+ "name": "tokensOwed1",
127
+ "type": "uint128"
128
+ }
129
+ ]
130
+ }
131
+ ]