edwin-sdk
Version:
SDK for integrating AI agents with DeFi protocols
45 lines (37 loc) • 1.44 kB
text/typescript
import { EdwinPlugin } from '../../core/classes/edwinPlugin';
import { EdwinTool, Chain } from '../../core/types';
import { EOracleService } from './eoracleService';
import { PriceParametersSchema, PriceParameters } from './parameters';
export class EOraclePlugin extends EdwinPlugin {
constructor(apiKey: string) {
super('eoracle', [new EOracleService(apiKey)]);
}
getTools(): Record<string, EdwinTool> {
// Combine public and private tools
return {
...this.getPublicTools(),
...this.getPrivateTools(),
};
}
getPublicTools(): Record<string, EdwinTool> {
const eoracleService = this.toolProviders.find(
provider => provider instanceof EOracleService
) as EOracleService;
return {
eoracleGetPrice: {
name: 'eoracle_get_price',
description: 'Get price information for a given symbol',
schema: PriceParametersSchema.schema,
execute: async (params: PriceParameters) => {
return await eoracleService.getPrice(params.symbol);
},
},
};
}
getPrivateTools(): Record<string, EdwinTool> {
// EOraclePlugin has no private tools
return {};
}
supportsChain = (chain: Chain) => chain.type === 'evm';
}
export const eoracle = (apiKey: string) => new EOraclePlugin(apiKey);