Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
.env
.env
.turbo
4 changes: 2 additions & 2 deletions __tests__/getOrderBookDepth.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import type { IAgentRuntime, Memory, State, Content } from '@elizaos/core';
import { getOrderBookDepthAction } from '../src/actions/getOrderBookDepth';
import { initializeClobClient, type BookParams } from '../src/utils/clobClient';
import { initializeClobClient } from '../src/utils/clobClient';
import { callLLMWithTimeout } from '../src/utils/llmHelpers';
import type { OrderBook } from '../src/types';

Expand Down Expand Up @@ -182,7 +182,7 @@ describe('getOrderBookDepthAction', () => {
expect(result.text).toContain('Total Ask Levels: 4');
expect((result.data as any)?.orderBooks).toEqual(mockMultipleOrderBooks);

const expectedParams: BookParams[] = [{ token_id: '123456' }, { token_id: '789012' }];
const expectedParams = [{ token_id: '123456' }, { token_id: '789012' }];
expect(mockClobClient.getOrderBooks).toHaveBeenCalledWith(expectedParams);
});

Expand Down
46 changes: 39 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plugin-polymarket",
"name": "@elizaos/plugin-polymarket",
"description": "ElizaOS plugin for Polymarket prediction markets",
"version": "0.1.0",
"version": "1.0.0",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down Expand Up @@ -29,9 +29,9 @@
"dist"
],
"dependencies": {
"@elizaos/cli": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-sql": "workspace:*",
"@elizaos/cli": "^1.5.9-alpha.1",
"@elizaos/core": "^1.5.9-alpha.1",
"@elizaos/plugin-sql": "^1.5.9-alpha.1",
"@polymarket/clob-client": "^4.16.0",
"ethers": "^6.13.1",
"node-fetch": "^3.0.0",
Expand Down Expand Up @@ -65,7 +65,39 @@
"platform": "node",
"agentConfig": {
"pluginType": "elizaos:plugin:1.0.0",
"pluginParameters": {}
"pluginParameters": {
"CLOB_API_URL": {
"type": "string",
"description": "Base URL for the Polymarket CLOB API endpoint.",
"required": false,
"default": "https://clob.polymarket.com",
"sensitive": false
},
"WALLET_PRIVATE_KEY": {
"type": "string",
"description": "Private key of the wallet used for signing transactions and authentication.",
"required": false,
"sensitive": true
},
"PRIVATE_KEY": {
"type": "string",
"description": "Alternative private key for authentication (fallback if WALLET_PRIVATE_KEY not set).",
"required": false,
"sensitive": true
},
"CLOB_API_KEY": {
"type": "string",
"description": "API key for authenticating requests to the Polymarket CLOB API.",
"required": false,
"sensitive": true
},
"POLYMARKET_PRIVATE_KEY": {
"type": "string",
"description": "Polymarket-specific private key for advanced trading operations.",
"required": false,
"sensitive": true
}
}
},
"npmPackage": "plugin-polymarket"
}
}
23 changes: 0 additions & 23 deletions packages/registry/index.json

This file was deleted.

31 changes: 0 additions & 31 deletions packages/registry/packages/@elizaos/plugin-polymarket/0.1.0.json

This file was deleted.

50 changes: 35 additions & 15 deletions src/actions/checkOrderScoring.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
type Action,
type Content,
type ActionResult,
type HandlerCallback,
type IAgentRuntime,
type Memory,
Expand Down Expand Up @@ -76,7 +76,7 @@ export const checkOrderScoringAction: Action = {
state?: State,
options?: { [key: string]: unknown },
callback?: HandlerCallback
): Promise<Content> => {
): Promise<ActionResult> => {
logger.info('[checkOrderScoringAction] Handler called!');

let llmResult: { orderIds?: string[]; error?: string } = {};
Expand Down Expand Up @@ -110,13 +110,21 @@ export const checkOrderScoringAction: Action = {
} else {
const errorMessage = 'Please specify one or more Order IDs to check scoring status.';
logger.error(`[checkOrderScoringAction] Order ID extraction failed. Text: "${text}"`);
const errorContent: Content = {
const errorResult: ActionResult = {
text: `❌ **Error**: ${errorMessage}`,
actions: ['CHECK_ORDER_SCORING'],
data: { error: errorMessage },
values: {
success: false,
error: true,
},
data: {
actionName: 'CHECK_ORDER_SCORING',
error: errorMessage,
},
success: false,
error: new Error(errorMessage),
};
if (callback) await callback(errorContent);
throw new Error(errorMessage);
if (callback) await callback({ text: errorResult.text, data: errorResult.data });
return errorResult;
}
logger.info(
`[checkOrderScoringAction] Regex extracted Order IDs: ${JSON.stringify(llmResult.orderIds)}`
Expand Down Expand Up @@ -145,35 +153,47 @@ export const checkOrderScoringAction: Action = {
responseText += 'Could not retrieve scoring status or no valid order IDs provided.';
}

const responseContent: Content = {
const responseResult: ActionResult = {
text: responseText,
actions: ['CHECK_ORDER_SCORING'],
values: {
success: true,
orderIds: orderIdsToScore,
scoringResponse,
},
data: {
actionName: 'CHECK_ORDER_SCORING',
request: apiParams,
response: scoringResponse,
timestamp: new Date().toISOString(),
},
success: true,
};

if (callback) await callback(responseContent);
return responseContent;
if (callback) await callback({ text: responseResult.text, data: responseResult.data });
return responseResult;
} catch (error) {
logger.error(
`[checkOrderScoringAction] Error checking order scoring for IDs ${orderIdsToScore.join(', ')}:`,
error
);
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred.';
const errorContent: Content = {
const errorResult: ActionResult = {
text: `❌ **Error checking order scoring**: ${errorMessage}`,
actions: ['CHECK_ORDER_SCORING'],
values: {
success: false,
error: true,
},
data: {
actionName: 'CHECK_ORDER_SCORING',
error: errorMessage,
orderIds: orderIdsToScore,
timestamp: new Date().toISOString(),
},
success: false,
error: error instanceof Error ? error : new Error(String(error)),
};
if (callback) await callback(errorContent);
throw error;
if (callback) await callback({ text: errorResult.text, data: errorResult.data });
return errorResult;
}
},

Expand Down
Loading