-
Notifications
You must be signed in to change notification settings - Fork 60
Feat: basic gmx agent #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JustUzair
wants to merge
37
commits into
next
Choose a base branch
from
feat-uzair/gmx-agent
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
107e5f6
feat: added gmx agent config
JustUzair 6805ca0
feat: partial agent setup for copilotkit route.ts
JustUzair e972289
feat: init langgraph project and setup basic agent
JustUzair 6d5682d
feat: added GMX Order Type Schem; added public and wallet client; addβ¦
JustUzair cfa6623
fix: added constants file export
JustUzair 50dc116
feat: added workflow context; updated constants ;updated .env.example
JustUzair 0828e43
feat: added gmx agent context
JustUzair a48c934
feat: added command codes to hire and fire agent
JustUzair 4bb98f8
feat: added hire and fire node to the graph; configured graph in langβ¦
JustUzair f84e3d3
fix: fixed agent config
JustUzair f6e9513
fix: fixed edges in the graph; fixed bugs in the agent context file
JustUzair d3590e9
feat: added bootstrap node to show initial state after hiring
JustUzair 01b54e5
feat: added polling; open positionl hold position; close position nodes
JustUzair 5627e6a
fix: removed boilerplate state
JustUzair d88bad4
feat: added onchain-actions client to create long and short position tx
JustUzair de7667d
fix: moved the gmx agent to a separate port to prevent clashes
JustUzair 8aa41e9
feat: added boostrap context caching
JustUzair 4c71bcc
feat: added gmx actions, telemetry and states
JustUzair e42ff35
feat: registered gmx agent to a separate port to prevent clashes
JustUzair eac0f53
todo: remove open close and hold commands and use decision engine insβ¦
JustUzair 847f575
feat: added conditional bootstrapping to commands in case of missing β¦
JustUzair 7460930
partial-feat: added helper scripts to create gmx order calldatas (dueβ¦
JustUzair fe11f8e
feat: added summarize node
JustUzair a00e6d7
fix: updated create-delegation-calldata script to work with zod; addeβ¦
JustUzair 92391b7
fix: removed open, close and hold position nodes and moved the logic β¦
JustUzair 84b45ce
modify: modified context, types and constants
JustUzair 21ed263
feat: added decision evaluation and calldata creation to open positioβ¦
JustUzair ce44116
fix: removed unwanted states and commands from runCommand node
JustUzair 34fab36
fix: error handling for polling node, code cleanup
JustUzair 891840b
fix: fixed agent context types and properties
JustUzair 33afdf9
fix: minor bug fixes
JustUzair 9a9ba21
feat: added close position logic
JustUzair ee7702b
feat: added execution logic for agent after polling and decision
JustUzair 6bde6b3
feat: added standalone scripts to mock approval and token transfers fβ¦
JustUzair 4c82e06
feat: added required constants for approval and intermediate transferβ¦
JustUzair 02dba87
fix: fixed logic bugs to construct correct calldata for opening/closiβ¦
JustUzair cefd684
feat: added tx telemetry for the on-chain executions by agent
JustUzair File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sample Output:
[GMX-Perp][2026-01-08T14:35:14.413Z] Initialized LangGraph workflow context { agent-gmx:dev: mode: 'debug', agent-gmx:dev: pollIntervalMs: 30000, agent-gmx:dev: streamLimit: -1, agent-gmx:dev: delegationsBypassActive: false agent-gmx:dev: } agent-gmx:dev: Inside Poll Command Node agent-gmx:dev: [GMX-Perp][2026-01-08T14:35:14.418Z] Poll Decision: { agent-gmx:dev: kind: 'open-position', agent-gmx:dev: marketAddress: '0x70d95587d40A2caf56bd97485aB3Eec10Bee6336', agent-gmx:dev: direction: 0, agent-gmx:dev: sizeUsd: '10', agent-gmx:dev: leverage: '2', agent-gmx:dev: collateralAmount: '5', agent-gmx:dev: collateralToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', agent-gmx:dev: reason: 'No open GMX position detected; opening demo long' agent-gmx:dev: } agent-gmx:dev: ============================================== agent-gmx:dev: Order Type: MarketIncrease agent-gmx:dev: Direction: Long agent-gmx:dev: Decrease Swap Type : N/A agent-gmx:dev: Market: 0x70d95587d40A2caf56bd97485aB3Eec10Bee6336 agent-gmx:dev: Collateral Token: 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 agent-gmx:dev: Collateral Amount: 5000000 agent-gmx:dev: Size Delta USD: 10000000000000000000000000000000 agent-gmx:dev: Acceptable Price: 3100000000000000000000000000000000 agent-gmx:dev: Execution Fee: 1000000000000000 ETH agent-gmx:dev: Swap Path Length: 0 agent-gmx:dev: ============================================== agent-gmx:dev: agent-gmx:dev: sendWnt Calldata: agent-gmx:dev: Function: sendWnt agent-gmx:dev: Receiver: 0x31eF83a530Fde1B38EE9A18093A333D8Bbbc40D5 agent-gmx:dev: Amount: 1000000000000000 ETH agent-gmx:dev: ============================================== agent-gmx:dev: agent-gmx:dev: sendTokens Calldata: agent-gmx:dev: Function: sendTokens agent-gmx:dev: Token: 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 agent-gmx:dev: Receiver: 0x31eF83a530Fde1B38EE9A18093A333D8Bbbc40D5 agent-gmx:dev: Amount: 5000000 agent-gmx:dev: ============================================== agent-gmx:dev: agent-gmx:dev: createOrder Calldata: agent-gmx:dev: Function: createOrder agent-gmx:dev: Order Type: MarketIncrease agent-gmx:dev: Decrease Swap Type: N/A agent-gmx:dev: Is Long: true agent-gmx:dev: Should Unwrap: false agent-gmx:dev: Trigger Price: 0 agent-gmx:dev: Min Output: 0 agent-gmx:dev: [GMX-Perp][2026-01-08T14:35:14.424Z] Market Long Calldata { agent-gmx:dev: sendWntCalldata: '0x7d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000038d7ea4c68000', agent-gmx:dev: sendTokensCalldata: '0xe6d66ac8000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000000000004c4b40', agent-gmx:dev: createOrderCalldata: '0xf59c48eb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000007e37be2022c0914b268000000000000000000000000000000000000000000000000000000000000000004c4b40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098d7803aea152ff1009f0000000000000000000000000000000000000000000000000000000000038d7ea4c6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000003fcc61a10abdb7fae57af4cb0db19188088c696400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee6336000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', agent-gmx:dev: multicallCalldata: '0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000447d39aaf100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064e6d66ac8000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000031ef83a530fde1b38ee9a18093a333d8bbbc40d500000000000000000000000000000000000000000000000000000000004c4b40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000344f59c48eb00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000007e37be2022c0914b268000000000000000000000000000000000000000000000000000000000000000004c4b40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098d7803aea152ff1009f0000000000000000000000000000000000000000000000000000000000038d7ea4c6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000003fcc61a10abdb7fae57af4cb0db19188088c696400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee6336000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', agent-gmx:dev: orderTypeName: 'MarketIncrease' agent-gmx:dev: } agent-gmx:dev: [GMX-Perp][2026-01-08T14:35:14.427Z] Inside Summarize Node. agent-gmx:dev: [GMX-Perp][2026-01-08T14:35:14.427Z] GMX workflow completed... agent-gmx:dev: info: β Background run succeeded agent-gmx:dev: info: β [1] { agent-gmx:dev: info: β [2] run_id: '72b25f52-528c-49ba-ae88-9618689a8ddb', agent-gmx:dev: info: β [3] run_attempt: 1, agent-gmx:dev: info: β [4] run_created_at: 2026-01-08T14:35:14.389Z, agent-gmx:dev: info: β [5] run_started_at: 2026-01-08T14:35:14.403Z, agent-gmx:dev: info: β [6] run_ended_at: 2026-01-08T14:35:14.429Z, agent-gmx:dev: info: β [7] run_exec_ms: 26 agent-gmx:dev: info: β [8] } agent-gmx:dev: info: βͺ <-- GET /threads/c0d649d0-8c61-459c-963d-3526cf4b53bb/state agent-gmx:dev: info: βͺ --> GET /threads/c0d649d0-8c61-459c-963d-3526cf4b53bb/state 200 1ms web:dev: POST /api/copilotkit 200 in 24.8s