-
Notifications
You must be signed in to change notification settings - Fork 2
Migration local storage vers smart contract #2
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
base: main
Are you sure you want to change the base?
Conversation
…ion; [ADD] Add .env.example and new docker-compose.dev.yml for development; [UPDATE] Update backend Dockerfile and package.json for new dependencies; [ADD] Implement Turbos DEX and Flash Loan adapters; [ADD] User data service and API routes for user data management; [UPDATE] Enhance simulator and transaction builder for network flexibility
…c parameters; [ADD] Implement Turbos-specific fields for testnet in BlockCard; [UPDATE] Modify strategy building logic to accommodate network variations.
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.
Pull request overview
This pull request migrates user data storage from localStorage to on-chain smart contract storage and adds comprehensive network support (mainnet/testnet/devnet). It introduces a new user data management system with blockchain-based persistence, automatic protocol routing for different networks, enhanced error handling, and API documentation via Swagger.
Changes:
- Migration from localStorage to on-chain storage using
UserDataStoragesmart contract - Network-aware protocol routing (e.g., NAVI → TURBOS on testnet where NAVI is unavailable)
- New API endpoints for user data management with Swagger documentation
- Enhanced error handling with clear distinction between configuration and funding errors
- Support for new protocols (TURBOS, perpetual trading)
Reviewed changes
Copilot reviewed 34 out of 37 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/src/hooks/useUserData.ts |
New hook for managing on-chain user data (strategies, execution history) |
frontend/src/app/app/sections/BuilderSection/utils/strategyBuilder.ts |
Network-aware strategy building with TURBOS support on testnet |
frontend/src/app/app/sections/BuilderSection/index.tsx |
Network context integration |
frontend/src/app/app/sections/BuilderSection/components/Canvas.tsx |
Network prop threading |
frontend/src/app/app/sections/BuilderSection/components/BlockCard.tsx |
Turbos-specific UI fields for testnet |
frontend/pnpm-lock.yaml |
Dependency updates |
frontend/docker-compose*.yml |
New Docker configuration files |
docker-compose.yml |
Root Docker compose removed (migrated to subdirectories) |
backend/src/types/strategy.ts |
Extended types for TURBOS and perpetual trading |
backend/src/services/UserDataService.ts |
Smart contract interaction service for user data |
backend/src/services/SuiClientService.ts |
Singleton SuiClient service |
backend/src/core/transaction-builder.ts |
Network-aware protocol routing |
backend/src/core/simulator.ts |
Enhanced error messages with configuration vs funding distinction |
backend/src/config/swagger.ts |
Swagger documentation configuration |
backend/src/config/admin.ts |
Admin configuration exports |
backend/src/config/addresses.ts |
Network-based address configuration |
backend/src/api/server.ts |
Swagger UI integration and new userdata routes |
backend/src/api/routes/userdata.ts |
API endpoints for user data management |
backend/src/api/routes/swagger-annotations.ts |
Swagger API documentation |
backend/src/api/routes/simulation.ts |
Network parameter support |
backend/src/api/routes/build.ts |
Network-aware transaction building |
backend/src/adapters/perp/* |
New perpetual trading adapter structure |
backend/src/adapters/flashloan/navi-adapter.ts |
Network-aware configuration |
backend/src/adapters/dex/cetus-adapter.ts |
Network-aware initialization |
backend/package.json |
Swagger dependencies added |
backend/move/Move.lock |
Move compiler version and package ID updates |
backend/docker-compose*.yml |
New Docker configuration files |
backend/Dockerfile |
Port correction |
Files not reviewed (1)
- backend/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const params = node.params as TurbosSwapParams; | ||
|
|
||
| // Get Turbos config (will throw if not on testnet) | ||
| const turbosConfig = this.getTurbosConfig(); |
Copilot
AI
Jan 13, 2026
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.
Unused variable turbosConfig.
| const turbosConfig = this.getTurbosConfig(); | |
| this.getTurbosConfig(); |
|
|
||
| // Determine which coin type is the input | ||
| const inputCoinType = user_a2b ? params.coin_type_a : params.coin_type_b; | ||
| const outputCoinType = user_a2b ? params.coin_type_b : params.coin_type_a; |
Copilot
AI
Jan 13, 2026
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.
Unused variable outputCoinType.
| const outputCoinType = user_a2b ? params.coin_type_b : params.coin_type_a; |
|
|
||
| async preOpenPosition(node: PerpOpenNode): Promise<PerpEstimate> { | ||
| const params = node.params; | ||
| const config = this.getConfig(); |
Copilot
AI
Jan 13, 2026
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.
Unused variable config.
| } | ||
|
|
||
| openPosition(tx: Transaction, node: PerpOpenNode, collateral: any, estimate: PerpEstimate): any { | ||
| const params = node.params; |
Copilot
AI
Jan 13, 2026
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.
Unused variable params.
|
|
||
| openPosition(tx: Transaction, node: PerpOpenNode, collateral: any, estimate: PerpEstimate): any { | ||
| const params = node.params; | ||
| const config = this.getConfig(); |
Copilot
AI
Jan 13, 2026
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.
Unused variable config.
| } | ||
|
|
||
| closePosition(tx: Transaction, node: PerpCloseNode, position: any, estimate: PerpEstimate): any { | ||
| const params = node.params; |
Copilot
AI
Jan 13, 2026
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.
Unused variable params.
| const params = node.params; |
|
|
||
| closePosition(tx: Transaction, node: PerpCloseNode, position: any, estimate: PerpEstimate): any { | ||
| const params = node.params; | ||
| const config = this.getConfig(); |
Copilot
AI
Jan 13, 2026
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.
Unused variable config.
| @@ -0,0 +1,362 @@ | |||
| import { SuiClient } from '@mysten/sui/client'; | |||
| import { Transaction } from '@mysten/sui/transactions'; | |||
| import { getAdminSigner, PACKAGE_ID } from '../config/admin'; | |||
Copilot
AI
Jan 13, 2026
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.
Unused import getAdminSigner.
| import { getAdminSigner, PACKAGE_ID } from '../config/admin'; | |
| import { PACKAGE_ID } from '../config/admin'; |
| let needsParamAdaptation = false; | ||
|
|
||
| // Auto-redirect: Navi → Turbos on testnet | ||
| if (this.network === "testnet" && protocol === "NAVI") { | ||
| targetProtocol = "TURBOS"; | ||
| needsParamAdaptation = true; |
Copilot
AI
Jan 13, 2026
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.
The value assigned to needsParamAdaptation here is unused.
| let needsParamAdaptation = false; | |
| // Auto-redirect: Navi → Turbos on testnet | |
| if (this.network === "testnet" && protocol === "NAVI") { | |
| targetProtocol = "TURBOS"; | |
| needsParamAdaptation = true; | |
| // Auto-redirect: Navi → Turbos on testnet | |
| if (this.network === "testnet" && protocol === "NAVI") { | |
| targetProtocol = "TURBOS"; |
|
Avant de merge la pr :
|
Description
Please provide a detailed description of what was done in this PR.
switch from local storage to
Changes include
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it.
Checklist
Additional comments
Please post additional comments in this section if you have them, otherwise delete it.