Skip to content

Commit 29551f5

Browse files
feat: ci (#13)
* feat: ci * chore: .nvmrc * feat: ci * feat: ci * chore: build stage ci * chore: simplify CI workflow trigger configuration * fix: lint * chore: more conservative linting * fix lint in transactions.ts * fix interface lints * fix more * fmt index.ts * fix errors * complete format --------- Co-authored-by: fishonamos <amosfishon@gmail.com>
1 parent 3be9e68 commit 29551f5

File tree

18 files changed

+241
-172
lines changed

18 files changed

+241
-172
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
quality:
10+
name: Code Quality
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: '.nvmrc'
20+
21+
- name: Setup PNPM
22+
uses: pnpm/action-setup@v2
23+
with:
24+
version: '8.9.0'
25+
26+
- name: Install dependencies
27+
run: pnpm install
28+
29+
- name: Check formatting
30+
run: pnpm format --check
31+
32+
- name: Run linting
33+
run: pnpm lint
34+
35+
- name: Build
36+
run: pnpm build

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.19.1

apps/web/.eslintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
5+
"parserOptions": {
6+
"ecmaVersion": 2020,
7+
"sourceType": "module"
8+
},
9+
"rules": {
10+
"@typescript-eslint/no-explicit-any": "error",
11+
"@typescript-eslint/no-unused-vars": "error"
12+
},
13+
"env": {
14+
"node": true,
15+
"es6": true
16+
}
17+
}

apps/web/src/routes/v1/query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Router } from 'express';
22
import { Request, Response } from 'express';
33
import { config } from '../../config';
44
import Agent from '@atoma-agents/sui-agent/src/agents/SuiAgent';
5-
let suiAgent = new Agent(config.atomaSdkBearerAuth);
5+
const suiAgent = new Agent(config.atomaSdkBearerAuth);
66
const queryRouter: Router = Router();
77

88
// Health check endpoint
@@ -21,7 +21,7 @@ const handleQuery = async (req: Request, res: Response): Promise<void> => {
2121
return;
2222
}
2323
// TODO: Implement query handling with sui-agent
24-
let result = await suiAgent.SuperVisorAgent(query);
24+
const result = await suiAgent.SuperVisorAgent(query);
2525
res.status(200).json(result);
2626
} catch (error) {
2727
console.error('Error handling query:', error);

packages/sui-agent/.eslintrc.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"plugins": ["@typescript-eslint"],
4-
"extends": [
5-
"eslint:recommended",
6-
"plugin:@typescript-eslint/recommended"
7-
],
8-
"parserOptions": {
9-
"ecmaVersion": 2020,
10-
"sourceType": "module"
11-
},
12-
"rules": {}
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
5+
"parserOptions": {
6+
"ecmaVersion": 2020,
7+
"sourceType": "module"
8+
},
9+
"rules": {
10+
"@typescript-eslint/no-explicit-any": "error",
11+
"@typescript-eslint/no-unused-vars": "error"
12+
}
1313
}

packages/sui-agent/src/@types/interface.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ export interface IntentAgentResponse {
44
response: null | string;
55
needs_additional_info: boolean;
66
additional_info_required: null | string[];
7-
tool_arguments: any[];
7+
tool_arguments: (string | number | boolean | bigint)[];
88
}
99
export interface toolResponse {
1010
success: boolean;
1111
selected_tool: null | string;
1212
response: null | string;
1313
needs_additional_info: boolean;
1414
additional_info_required: null | string[];
15-
tool_arguments: any[];
15+
tool_arguments: (string | number | boolean | bigint)[];
1616
}
1717
export interface ToolParameter {
1818
name: string;
@@ -24,7 +24,9 @@ export interface Tool {
2424
name: string;
2525
description: string;
2626
parameters: ToolParameter[];
27-
process: (...args: any[]) => Promise<string> | string;
27+
process: (
28+
...args: (string | number | boolean | bigint)[]
29+
) => Promise<string> | string;
2830
}
2931
export declare const COIN_SYNONYMS: Record<string, string>;
3032
export declare const COIN_ADDRESSES: {

packages/sui-agent/src/@types/interface.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ export interface IntentAgentResponse {
55
response: null | string; // Response message from the operation
66
needs_additional_info: boolean; // Indicates if more information is needed
77
additional_info_required: null | string[]; // List of additional information fields needed
8-
tool_arguments: any[]; // Arguments passed to the tool
8+
tool_arguments: (string | number | boolean | bigint)[]; // Arguments passed to the tool
99
}
1010

11+
export type ToolArgument = string | number | boolean | bigint;
12+
1113
// Response interface for tool operations (similar to IntentAgentResponse)
1214
export interface toolResponse {
1315
success: boolean;
1416
selected_tool: null | string;
1517
response: null | string;
1618
needs_additional_info: boolean;
1719
additional_info_required: null | string[];
18-
tool_arguments: any[];
20+
tool_arguments: (string | number | boolean | bigint)[];
1921
}
2022

2123
// Defines the structure for tool parameters
@@ -31,7 +33,9 @@ export interface Tool {
3133
name: string; // Name of the tool
3234
description: string; // Description of what the tool does
3335
parameters: ToolParameter[]; // List of parameters the tool accepts
34-
process: (...args: any[]) => Promise<string> | string; // Function to execute the tool
36+
process: (
37+
...args: (string | number | boolean | bigint)[]
38+
) => Promise<string> | string; // Function to execute the tool
3539
}
3640

3741
// Mapping of different coin names/variants to their standardized symbol

packages/sui-agent/src/agents/SuiAgent.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class Agents {
4242
* @param query - Original user query
4343
* @returns Processed response after decision making
4444
*/
45-
async DecisionMakingAgent(intentResponse: any, query: string) {
45+
async DecisionMakingAgent(
46+
intentResponse: IntentAgentResponse,
47+
query: string,
48+
) {
4649
return await this.utils.processQuery(query);
4750
}
4851

packages/sui-agent/src/tools/aftermath/PoolTool.ts

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import { Aftermath } from 'aftermath-ts-sdk';
1+
import { Aftermath, Pool } from 'aftermath-ts-sdk';
22
import { PoolInfo } from '../../@types/interface';
33
import { handleError } from '../../utils';
44

55
// Initialize Aftermath SDK for mainnet
66
const af = new Aftermath('MAINNET');
77
const pools = af.Pools();
88

9-
// Type definitions for pool operations
10-
type RankingMetric = 'apr' | 'tvl' | 'fees' | 'volume';
11-
type SortOrder = 'asc' | 'desc';
12-
139
/**
1410
* Processes raw pool data into standardized format
1511
* @param pool - Raw pool data from Aftermath
1612
* @param poolId - Unique identifier for the pool
1713
* @returns Standardized pool information
1814
*/
19-
async function processPool(pool: any, poolId: string): Promise<PoolInfo> {
15+
async function processPool(pool: Pool, poolId: string): Promise<PoolInfo> {
2016
try {
2117
const metrics = await pools.getPoolsStats({ poolIds: [poolId] });
2218
const poolMetrics = metrics[0];
@@ -54,7 +50,10 @@ async function processPool(pool: any, poolId: string): Promise<PoolInfo> {
5450
* @param poolId - Unique identifier for the pool
5551
* @returns JSON string containing pool details or error information
5652
*/
57-
export async function getPool(poolId: string): Promise<string> {
53+
export async function getPool(
54+
...args: (string | number | bigint | boolean)[]
55+
): Promise<string> {
56+
const poolId = args[0] as string;
5857
try {
5958
const pool = await pools.getPool({ objectId: poolId });
6059
if (!pool) {
@@ -132,10 +131,9 @@ export async function getAllPools(): Promise<string> {
132131
* @returns JSON string containing event information
133132
*/
134133
export async function getPoolEvents(
135-
poolId: string,
136-
eventType: 'deposit' | 'withdraw',
137-
limit = 10,
134+
...args: (string | number | bigint | boolean)[]
138135
): Promise<string> {
136+
const [poolId, eventType, limit] = args as [string, string, number];
139137
try {
140138
const pool = await pools.getPool({ objectId: poolId });
141139
if (!pool) {
@@ -171,29 +169,6 @@ export async function getPoolEvents(
171169
}
172170
}
173171

174-
/**
175-
* Calculates pool APR based on volume and TVL
176-
* @param pool - Pool data containing volume and TVL information
177-
* @returns Calculated APR as a percentage
178-
*/
179-
export function calculatePoolApr(pool: any): number {
180-
try {
181-
// Convert values from base units
182-
const volume24h = Number(pool.pool.volume24h || 0) / 1e9;
183-
const tvl = Number(pool.pool.lpCoinSupply || 0) / 1e9;
184-
if (tvl === 0) return 0;
185-
186-
// Calculate annual revenue and APR
187-
const feeRate = Number(pool.pool.flatness || 0) / 1e9;
188-
const feeRevenue24h = volume24h * feeRate;
189-
const annualRevenue = feeRevenue24h * 365;
190-
return (annualRevenue / tvl) * 100;
191-
} catch (error) {
192-
console.error('Error calculating pool APR:', error);
193-
return 0;
194-
}
195-
}
196-
197172
/**
198173
* Gets ranked pools by specified metric
199174
* @param metric - Metric to rank by (apr, tvl, fees, volume)
@@ -202,10 +177,9 @@ export function calculatePoolApr(pool: any): number {
202177
* @returns JSON string containing ranked pool information
203178
*/
204179
export async function getRankedPools(
205-
metric: RankingMetric = 'tvl',
206-
limit = 10,
207-
order: SortOrder = 'desc',
180+
...args: (string | number | bigint | boolean)[]
208181
): Promise<string> {
182+
const [metric, limit, order] = args as [string, number, string];
209183
try {
210184
// Fetch and process all pools
211185
const allPools = await pools.getAllPools();
@@ -299,10 +273,9 @@ export async function getRankedPools(
299273
* @returns JSON string containing filtered pool information
300274
*/
301275
export async function getFilteredPools(
302-
minTvl?: number,
303-
minApr?: number,
304-
tokens?: string[],
276+
...args: (string | number | bigint | boolean)[]
305277
): Promise<string> {
278+
const [minTvl, minApr, tokens] = args as [number, number, string[]];
306279
try {
307280
// Fetch and process all pools
308281
const allPools = await pools.getAllPools();

packages/sui-agent/src/tools/aftermath/PoolTransactionTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface RankedPool {
3838
function convertAftermathTransaction(tx: unknown): AftermathTransaction {
3939
const rawTx = tx as {
4040
target: string;
41-
arguments: any[];
41+
arguments: (string | number | boolean | bigint)[];
4242
typeArguments: string[];
4343
};
4444

0 commit comments

Comments
 (0)