├── .eslintrc.json
├── koii
└── task-template
│ ├── TaskDescription.md
│ ├── babel.config.cjs
│ ├── tests
│ ├── wasm
│ │ ├── zstd.wasm
│ │ └── bincode_js_bg.wasm
│ ├── testTask.js
│ ├── config.js
│ ├── test.webpack.config.js
│ ├── simulateTask.js
│ └── prod-debug.js
│ ├── nodemon.json
│ ├── jest.config.js
│ ├── .gitlab-ci.yml
│ ├── src
│ ├── task
│ │ ├── 0-setup.js
│ │ ├── 5-routes.js
│ │ ├── 2-submission.js
│ │ ├── prediction_results.json
│ │ ├── 3-audit.js
│ │ ├── libs
│ │ │ └── utils.js
│ │ ├── 4-distribution.js
│ │ └── candlestick-plotter.js
│ └── index.js
│ ├── .gitignore
│ ├── .prettierrc
│ ├── .eslintrc.js
│ ├── webpack.config.js
│ ├── docker-compose.yaml
│ ├── package.json
│ ├── Manual K2 Calls.md
│ ├── .env.local.example
│ └── error.txt
├── starknetNethermind
└── my_project
│ ├── .gitignore
│ ├── Scarb.lock
│ ├── snfoundry.toml
│ ├── tests
│ └── test_contract.cairo
│ └── Scarb.toml
├── particle-auth-aa
├── .eslintrc.json
├── public
│ ├── dark.png
│ ├── logo.png
│ ├── iexec.png
│ ├── mobile.png
│ ├── not-found.png
│ ├── trading.png
│ ├── dashboard1.png
│ ├── pulsetrade.png
│ ├── intermediate.png
│ ├── vercel.svg
│ └── next.svg
├── src
│ ├── app
│ │ ├── favicon.png
│ │ ├── chat
│ │ │ └── [chatId]
│ │ │ │ └── layout.tsx
│ │ ├── not-found.tsx
│ │ ├── layout.tsx
│ │ ├── globals.css
│ │ └── trading
│ │ │ └── execute
│ │ │ └── page.tsx
│ ├── components
│ │ ├── MaxWidthWrapper.tsx
│ │ ├── ui
│ │ │ ├── textarea.tsx
│ │ │ ├── input.tsx
│ │ │ ├── progress.tsx
│ │ │ ├── alert.tsx
│ │ │ ├── button.tsx
│ │ │ └── card.tsx
│ │ ├── TxNotification.tsx
│ │ ├── chats
│ │ │ ├── GroupChatHeader.tsx
│ │ │ ├── MessageList.tsx
│ │ │ ├── MessageInput.tsx
│ │ │ └── ChatInitiallizer.tsx
│ │ ├── ai-chat
│ │ │ ├── MessageList.tsx
│ │ │ ├── Welcome.tsx
│ │ │ ├── TradeValues.tsx
│ │ │ └── ChatList.tsx
│ │ └── Links.tsx
│ └── lib
│ │ ├── iexec.ts
│ │ ├── hooks
│ │ ├── useClickOutside.ts
│ │ ├── useChat.ts
│ │ ├── usePersistence.tsx
│ │ ├── useWeb3Mail.ts
│ │ ├── useParticleAuth.ts
│ │ └── useDataProtectioon.ts
│ │ ├── utils
│ │ ├── lib-utils.ts
│ │ └── connectionStore.ts
│ │ ├── services
│ │ └── ai-chat.ts
│ │ ├── mockData.ts
│ │ └── connectkit.tsx
├── next.config.mjs
├── IEXEC.txt
├── postcss.config.mjs
├── global.d.ts
├── contracts
│ └── FILE.txt
├── components.json
├── .gitignore
├── .env.sample
├── tsconfig.json
├── firebase.config.ts
├── README.md
├── package.json
└── tailwind.config.ts
├── .gitattributes
├── public
├── dark.png
├── iexec.png
├── logo.png
├── mobile.png
├── trading.png
├── dashboard1.png
├── not-found.png
├── pulsetrade.png
├── intermediate.png
├── pulsetrade(1).png
├── pulse-trade-logo.png
├── vercel.svg
└── next.svg
├── src
├── app
│ ├── favicon.png
│ ├── chat
│ │ └── [chatId]
│ │ │ └── layout.tsx
│ ├── not-found.tsx
│ ├── layout.tsx
│ ├── globals.css
│ └── trading
│ │ └── execute
│ │ └── page.tsx
├── components
│ ├── MaxWidthWrapper.tsx
│ ├── ui
│ │ ├── textarea.tsx
│ │ ├── input.tsx
│ │ ├── progress.tsx
│ │ ├── alert.tsx
│ │ ├── button.tsx
│ │ └── card.tsx
│ ├── TxNotification.tsx
│ ├── chats
│ │ ├── GroupChatHeader.tsx
│ │ ├── MessageList.tsx
│ │ ├── MessageInput.tsx
│ │ └── ChatInitiallizer.tsx
│ ├── ai-chat
│ │ ├── MessageList.tsx
│ │ ├── Welcome.tsx
│ │ ├── TradeValues.tsx
│ │ └── ChatList.tsx
│ └── Links.tsx
└── lib
│ ├── iexec.ts
│ ├── hooks
│ ├── useClickOutside.ts
│ ├── useChat.ts
│ ├── usePersistence.tsx
│ ├── useWeb3Mail.ts
│ ├── useParticleAuth.ts
│ └── useDataProtectioon.ts
│ ├── utils
│ ├── lib-utils.ts
│ └── connectionStore.tsx
│ ├── services
│ └── ai-chat.ts
│ ├── mockData.ts
│ └── connectkit.tsx
├── tradeLLM
├── README.md
├── .gitignore
├── .env.example
├── render.yaml
├── config
│ └── api-config.js
├── middleware
│ ├── rateLimiter.js
│ ├── errorHandler.js
│ └── requestValidator.js
├── package.json
├── Test Prompts.md
└── utils
│ ├── marketDataValidator.js
│ └── dataTransformer.js
├── IEXEC.txt
├── postcss.config.mjs
├── next-env.d.ts
├── global.d.ts
├── contracts
└── FILE.txt
├── next.config.mjs
├── components.json
├── .env.sample
├── tsconfig.json
├── firebase.config.ts
├── LICENSE
├── package.json
├── tailwind.config.ts
└── .gitignore
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/koii/task-template/TaskDescription.md:
--------------------------------------------------------------------------------
1 | # Task Description Template
2 |
--------------------------------------------------------------------------------
/starknetNethermind/my_project/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .snfoundry_cache/
3 |
--------------------------------------------------------------------------------
/particle-auth-aa/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/koii/task-template/babel.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = { presets: ["@babel/preset-env"] };
2 |
--------------------------------------------------------------------------------
/public/dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/dark.png
--------------------------------------------------------------------------------
/public/iexec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/iexec.png
--------------------------------------------------------------------------------
/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/logo.png
--------------------------------------------------------------------------------
/public/mobile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/mobile.png
--------------------------------------------------------------------------------
/public/trading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/trading.png
--------------------------------------------------------------------------------
/src/app/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/src/app/favicon.png
--------------------------------------------------------------------------------
/tradeLLM/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/tradeLLM/README.md
--------------------------------------------------------------------------------
/public/dashboard1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/dashboard1.png
--------------------------------------------------------------------------------
/public/not-found.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/not-found.png
--------------------------------------------------------------------------------
/public/pulsetrade.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/pulsetrade.png
--------------------------------------------------------------------------------
/public/intermediate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/intermediate.png
--------------------------------------------------------------------------------
/public/pulsetrade(1).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/pulsetrade(1).png
--------------------------------------------------------------------------------
/public/pulse-trade-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/public/pulse-trade-logo.png
--------------------------------------------------------------------------------
/tradeLLM/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .env
3 | .DS_Store
4 | npm-debug.log
5 | yarn-debug.log
6 | yarn-error.log
--------------------------------------------------------------------------------
/particle-auth-aa/public/dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/dark.png
--------------------------------------------------------------------------------
/particle-auth-aa/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/logo.png
--------------------------------------------------------------------------------
/particle-auth-aa/public/iexec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/iexec.png
--------------------------------------------------------------------------------
/particle-auth-aa/public/mobile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/mobile.png
--------------------------------------------------------------------------------
/particle-auth-aa/public/not-found.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/not-found.png
--------------------------------------------------------------------------------
/particle-auth-aa/public/trading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/trading.png
--------------------------------------------------------------------------------
/particle-auth-aa/src/app/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/src/app/favicon.png
--------------------------------------------------------------------------------
/koii/task-template/tests/wasm/zstd.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/koii/task-template/tests/wasm/zstd.wasm
--------------------------------------------------------------------------------
/particle-auth-aa/public/dashboard1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/dashboard1.png
--------------------------------------------------------------------------------
/particle-auth-aa/public/pulsetrade.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/pulsetrade.png
--------------------------------------------------------------------------------
/particle-auth-aa/next.config.mjs:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | export default nextConfig;
5 |
--------------------------------------------------------------------------------
/particle-auth-aa/public/intermediate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/particle-auth-aa/public/intermediate.png
--------------------------------------------------------------------------------
/koii/task-template/tests/wasm/bincode_js_bg.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PatrickKish1/pulsetrade/HEAD/koii/task-template/tests/wasm/bincode_js_bg.wasm
--------------------------------------------------------------------------------
/IEXEC.txt:
--------------------------------------------------------------------------------
1 | address=0x32e4fc3953c45f8fe11daddcbff702ff5a19119236fe6d453d424a25333fc08b
2 |
3 | Your protected data address: 0xB406035C56759Fd85c12A199453d2B6725488bd7
--------------------------------------------------------------------------------
/koii/task-template/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "events": {
3 | "crash": "echo 'Application has crashed' && kill $(ps aux | grep '[n]odemon' | awk '{print $2}')"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/koii/task-template/jest.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | transform: { "^.+\\.jsx?$": "babel-jest" },
3 | transformIgnorePatterns: ["/node_modules/(?!@babel/runtime)"],
4 | };
5 |
--------------------------------------------------------------------------------
/particle-auth-aa/IEXEC.txt:
--------------------------------------------------------------------------------
1 | address=0x32e4fc3953c45f8fe11daddcbff702ff5a19119236fe6d453d424a25333fc08b
2 |
3 | Your protected data address: 0xB406035C56759Fd85c12A199453d2B6725488bd7
--------------------------------------------------------------------------------
/tradeLLM/.env.example:
--------------------------------------------------------------------------------
1 | GROQ_API_KEY='groq-api-key'
2 | POLYGON_API_KEY='polygon.io-api-key'
3 | NODE_ENV='development|production'
4 | ALLOWED_ORIGINS=http://localhost:3000
5 | PORT=3000
--------------------------------------------------------------------------------
/postcss.config.mjs:
--------------------------------------------------------------------------------
1 | /** @type {import('postcss-load-config').Config} */
2 | const config = {
3 | plugins: {
4 | tailwindcss: {},
5 | },
6 | };
7 |
8 | export default config;
9 |
--------------------------------------------------------------------------------
/koii/task-template/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | stages:
2 | - test
3 |
4 | jest_tests:
5 | stage: test
6 | image: node:latest
7 | script:
8 | - npm install
9 | - npm run jest-test
10 |
--------------------------------------------------------------------------------
/particle-auth-aa/postcss.config.mjs:
--------------------------------------------------------------------------------
1 | /** @type {import('postcss-load-config').Config} */
2 | const config = {
3 | plugins: {
4 | tailwindcss: {},
5 | },
6 | };
7 |
8 | export default config;
9 |
--------------------------------------------------------------------------------
/koii/task-template/src/task/0-setup.js:
--------------------------------------------------------------------------------
1 | export async function setup() {
2 | // define any steps that must be executed before the task starts
3 | console.log("PULSE TRADE PREDICTOR RUNNING.....");
4 | }
5 |
--------------------------------------------------------------------------------
/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // NOTE: This file should not be edited
5 | // see https://nextjs.org/docs/basic-features/typescript for more information.
6 |
--------------------------------------------------------------------------------
/global.d.ts:
--------------------------------------------------------------------------------
1 | import { ConnectKitProvider } from "@particle-network/connectkit";
2 | declare global {
3 | interface Window {
4 | ethereum: ConnectKitOptions; // Replace `any` with a more specific type if available
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/particle-auth-aa/global.d.ts:
--------------------------------------------------------------------------------
1 | import { ConnectKitProvider } from "@particle-network/connectkit";
2 | declare global {
3 | interface Window {
4 | ethereum: ConnectKitOptions; // Replace `any` with a more specific type if available
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/koii/task-template/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | build
3 | node_modules
4 | package-lock.json
5 | yarn.lock
6 | migrate.sh
7 | */dev.js
8 | data/*
9 | executables/*
10 | namespace/*
11 | config/*
12 | .env.local
13 | taskStateInfoKeypair.json
14 | localKOIIDB.db
15 | metadata.json
16 | .npmrc
17 | .env*
--------------------------------------------------------------------------------
/koii/task-template/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "printWidth": 80,
3 | "tabWidth": 2,
4 | "useTabs": false,
5 | "semi": true,
6 | "singleQuote": false,
7 | "trailingComma": "all",
8 | "bracketSpacing": true,
9 | "jsxBracketSameLine": false,
10 | "arrowParens": "always",
11 | "endOfLine": "auto"
12 | }
13 |
--------------------------------------------------------------------------------
/koii/task-template/tests/testTask.js:
--------------------------------------------------------------------------------
1 | import { taskRunner } from "@_koii/task-manager";
2 |
3 | import "../src/index.js";
4 | import { namespaceWrapper } from "@_koii/namespace-wrapper";
5 |
6 | async function executeTasks() {
7 | let round = 1;
8 | await taskRunner.task(round);
9 | process.exit(0);
10 | }
11 | executeTasks()
--------------------------------------------------------------------------------
/koii/task-template/.eslintrc.js:
--------------------------------------------------------------------------------
1 | export default {
2 | env: {
3 | browser: true,
4 | commonjs: true,
5 | es2021: true,
6 | node: true,
7 | jest: true,
8 | },
9 | extends: "eslint:recommended",
10 | parserOptions: {
11 | ecmaVersion: 15,
12 | sourceType: "module",
13 | },
14 | rules: {},
15 | ignorePatterns: ["dist/", "node_modules/"],
16 | };
17 |
--------------------------------------------------------------------------------
/contracts/FILE.txt:
--------------------------------------------------------------------------------
1 | PULSE TRADE DEPLOYED ON CITREA
2 | status 0x1 Transaction mined and execution succeed
3 | transaction hash 0x6b0675375172e93d93a2febf9e0c42ad017cf60c211c7a4cac370f2001afe678
4 | block hash 0xc30f5ca54e66f2073a492eb337ec842b58e6698927697054c334b739e28bb29c
5 | block number 3904461
6 | contract address 0xe8da3071c06445ca26475f0fa1161ee5e8956929
7 | from 0xf171b553fe688c45d7dc9eeefe00709fc47b5a69
8 |
--------------------------------------------------------------------------------
/koii/task-template/webpack.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | entry: "./src/index.js",
3 | target: "node",
4 | // When uploading to arweave use the production mode
5 | // mode:"production",
6 | mode: "development",
7 | devtool: "source-map",
8 | optimization: {
9 | usedExports: false,
10 | },
11 | stats: {
12 | moduleTrace: false,
13 | },
14 | node: {
15 | __dirname: true,
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/particle-auth-aa/contracts/FILE.txt:
--------------------------------------------------------------------------------
1 | PULSE TRADE DEPLOYED ON CITREA
2 | status 0x1 Transaction mined and execution succeed
3 | transaction hash 0x6b0675375172e93d93a2febf9e0c42ad017cf60c211c7a4cac370f2001afe678
4 | block hash 0xc30f5ca54e66f2073a492eb337ec842b58e6698927697054c334b739e28bb29c
5 | block number 3904461
6 | contract address 0xe8da3071c06445ca26475f0fa1161ee5e8956929
7 | from 0xf171b553fe688c45d7dc9eeefe00709fc47b5a69
8 |
--------------------------------------------------------------------------------
/next.config.mjs:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const isProd = process.env.NODE_ENV === 'production';
3 | const nextConfig = {
4 | reactStrictMode: true,
5 | images: {
6 | unoptimized: true, // Disable default image optimization
7 | },
8 | assetPrefix: isProd ? '/pulsetrade/' : '',
9 | basePath: isProd ? '/pulsetrade' : '',
10 | output: 'export'
11 | };
12 | export default nextConfig;
13 |
--------------------------------------------------------------------------------
/koii/task-template/tests/config.js:
--------------------------------------------------------------------------------
1 | import "dotenv/config";
2 |
3 | export const TASK_ID =
4 | process.env.TASK_ID || "BXbYKFdXZhQgEaMFbeShaisQBYG1FD4MiSf9gg4n6mVn";
5 | export const WEBPACKED_FILE_PATH =
6 | process.env.WEBPACKED_FILE_PATH || "../dist/main.js";
7 |
8 | const envKeywords = process.env.TEST_KEYWORDS ?? "";
9 |
10 | export const TEST_KEYWORDS = envKeywords
11 | ? envKeywords.split(",")
12 | : ["TEST", "EZ TESTING"];
13 |
--------------------------------------------------------------------------------
/koii/task-template/src/task/5-routes.js:
--------------------------------------------------------------------------------
1 | import { namespaceWrapper, app } from "@_koii/namespace-wrapper";
2 |
3 | export function routes() {
4 | /**
5 | *
6 | * Define all your custom routes here
7 | *
8 | */
9 |
10 | // Example route
11 | app.get("/value", async (_req, res) => {
12 | const value = await namespaceWrapper.storeGet("value");
13 | console.log("value", value);
14 | res.status(200).json({ value: value });
15 | });
16 | }
17 |
--------------------------------------------------------------------------------
/src/components/MaxWidthWrapper.tsx:
--------------------------------------------------------------------------------
1 | import { cn } from "@/lib/utils"
2 | import { ReactNode } from "react"
3 |
4 | const MaxWidthWrapper = ({
5 | className,
6 | children
7 | }:{
8 | className?: string,
9 | children: ReactNode
10 | }) => {
11 | return (
12 |
14 | {children}
15 |
16 | )
17 | }
18 |
19 | export default MaxWidthWrapper
--------------------------------------------------------------------------------
/src/app/chat/[chatId]/layout.tsx:
--------------------------------------------------------------------------------
1 | import { Metadata } from 'next';
2 |
3 | export const metadata: Metadata = {
4 | title: 'Chat',
5 | description: 'Secure Web3 Chat',
6 | };
7 |
8 | export default function ChatLayout({
9 | children,
10 | }: {
11 | children: React.ReactNode;
12 | }) {
13 | return (
14 |
15 |
16 | {children}
17 |
18 |
19 | );
20 | }
21 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/MaxWidthWrapper.tsx:
--------------------------------------------------------------------------------
1 | import { cn } from "@/lib/utils"
2 | import { ReactNode } from "react"
3 |
4 | const MaxWidthWrapper = ({
5 | className,
6 | children
7 | }:{
8 | className?: string,
9 | children: ReactNode
10 | }) => {
11 | return (
12 |
14 | {children}
15 |
16 | )
17 | }
18 |
19 | export default MaxWidthWrapper
--------------------------------------------------------------------------------
/particle-auth-aa/src/app/chat/[chatId]/layout.tsx:
--------------------------------------------------------------------------------
1 | import { Metadata } from 'next';
2 |
3 | export const metadata: Metadata = {
4 | title: 'Chat',
5 | description: 'Secure Web3 Chat',
6 | };
7 |
8 | export default function ChatLayout({
9 | children,
10 | }: {
11 | children: React.ReactNode;
12 | }) {
13 | return (
14 |
15 |
16 | {children}
17 |
18 |
19 | );
20 | }
21 |
--------------------------------------------------------------------------------
/koii/task-template/tests/test.webpack.config.js:
--------------------------------------------------------------------------------
1 | import Dotenv from "dotenv-webpack";
2 |
3 | export default {
4 | entry: "./src/index.js",
5 | target: "node",
6 | // When uploading to arweave use the production mode
7 | // mode:"production",
8 | mode: "development",
9 | devtool: "source-map",
10 | optimization: {
11 | usedExports: false,
12 | },
13 | stats: {
14 | moduleTrace: false,
15 | },
16 | node: {
17 | __dirname: true,
18 | },
19 | plugins: [new Dotenv()],
20 | };
21 |
--------------------------------------------------------------------------------
/components.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://ui.shadcn.com/schema.json",
3 | "style": "new-york",
4 | "rsc": true,
5 | "tsx": true,
6 | "tailwind": {
7 | "config": "tailwind.config.ts",
8 | "css": "src/app/globals.css",
9 | "baseColor": "zinc",
10 | "cssVariables": true,
11 | "prefix": ""
12 | },
13 | "aliases": {
14 | "components": "@/components",
15 | "utils": "@/lib/utils",
16 | "ui": "@/components/ui",
17 | "lib": "@/lib",
18 | "hooks": "@/hooks"
19 | },
20 | "iconLibrary": "lucide"
21 | }
--------------------------------------------------------------------------------
/particle-auth-aa/components.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://ui.shadcn.com/schema.json",
3 | "style": "new-york",
4 | "rsc": true,
5 | "tsx": true,
6 | "tailwind": {
7 | "config": "tailwind.config.ts",
8 | "css": "src/app/globals.css",
9 | "baseColor": "zinc",
10 | "cssVariables": true,
11 | "prefix": ""
12 | },
13 | "aliases": {
14 | "components": "@/components",
15 | "utils": "@/lib/utils",
16 | "ui": "@/components/ui",
17 | "lib": "@/lib",
18 | "hooks": "@/hooks"
19 | },
20 | "iconLibrary": "lucide"
21 | }
--------------------------------------------------------------------------------
/koii/task-template/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: "3.2"
2 | services:
3 | task_node:
4 | image: public.ecr.aws/koii-network/task_node:latest
5 | command: yarn initialize-start
6 | extra_hosts:
7 | - "host.docker.internal:host-gateway"
8 |
9 | ports:
10 | - 30017:30017
11 |
12 | env_file: .env.local
13 |
14 | container_name: task_node
15 |
16 | # network_mode: host
17 | volumes:
18 | - ~/.config/koii:/app/config
19 | - ./data:/app/data
20 | - ./namespace:/app/namespace
21 | - ./dist:/app/executables
22 |
--------------------------------------------------------------------------------
/tradeLLM/render.yaml:
--------------------------------------------------------------------------------
1 | # render.yaml
2 | services:
3 | - type: web
4 | name: tradellm-api
5 | env: node
6 | buildCommand: npm install
7 | startCommand: node server.js
8 | envVars:
9 | - key: PORT
10 | value: 3000
11 | - key: NODE_ENV
12 | value: production
13 | - key: GROQ_API_KEY
14 | sync: false # This will be added manually in Render dashboard
15 | - key: POLYGON_API_KEY
16 | sync: false # This will be added manually in Render dashboard
17 | healthCheckPath: /health
18 | autoDeploy: true
19 |
--------------------------------------------------------------------------------
/particle-auth-aa/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 | .yarn/install-state.gz
8 |
9 | # testing
10 | /coverage
11 |
12 | # next.js
13 | /.next/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env*.local
30 |
31 | # vercel
32 | .vercel
33 |
34 | # typescript
35 | *.tsbuildinfo
36 | next-env.d.ts
37 |
--------------------------------------------------------------------------------
/src/lib/iexec.ts:
--------------------------------------------------------------------------------
1 | // lib/iexec.ts
2 | import { IExec } from 'iexec';
3 |
4 | export const iexec = new IExec({ ethProvider: window.ethereum });
5 |
6 | export const registerOnIExec = async (emailOrWallet: string) => {
7 | try {
8 | // Mock registration (replace with actual Data Protector implementation)
9 | console.log('Registering on iExec:', emailOrWallet);
10 | // Example: await iexec.dataProtector.register(emailOrWallet);
11 | return true;
12 | } catch (error) {
13 | console.error('iExec registration failed:', error);
14 | throw error;
15 | }
16 | };
17 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/iexec.ts:
--------------------------------------------------------------------------------
1 | // lib/iexec.ts
2 | import { IExec } from 'iexec';
3 |
4 | export const iexec = new IExec({ ethProvider: window.ethereum });
5 |
6 | export const registerOnIExec = async (emailOrWallet: string) => {
7 | try {
8 | // Mock registration (replace with actual Data Protector implementation)
9 | console.log('Registering on iExec:', emailOrWallet);
10 | // Example: await iexec.dataProtector.register(emailOrWallet);
11 | return true;
12 | } catch (error) {
13 | console.error('iExec registration failed:', error);
14 | throw error;
15 | }
16 | };
17 |
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/particle-auth-aa/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/starknetNethermind/my_project/Scarb.lock:
--------------------------------------------------------------------------------
1 | # Code generated by scarb DO NOT EDIT.
2 | version = 1
3 |
4 | [[package]]
5 | name = "pulsetrade"
6 | version = "0.1.0"
7 | dependencies = [
8 | "snforge_std",
9 | ]
10 |
11 | [[package]]
12 | name = "snforge_scarb_plugin"
13 | version = "0.34.0"
14 | source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.34.0#d6976d4635cbe69bd199fd502788c469d408ed2d"
15 |
16 | [[package]]
17 | name = "snforge_std"
18 | version = "0.34.0"
19 | source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.34.0#d6976d4635cbe69bd199fd502788c469d408ed2d"
20 | dependencies = [
21 | "snforge_scarb_plugin",
22 | ]
23 |
--------------------------------------------------------------------------------
/koii/task-template/src/task/2-submission.js:
--------------------------------------------------------------------------------
1 | import { namespaceWrapper } from "@_koii/namespace-wrapper";
2 |
3 | export async function submission(roundNumber) {
4 | try {
5 | console.log(`MAKE SUBMISSION FOR ROUND ${roundNumber}`);
6 |
7 | // Get the stored stock symbol
8 | const stockSymbol = await namespaceWrapper.storeGet("value");
9 |
10 | if (!stockSymbol) {
11 | throw new Error("No stock symbol found in storage");
12 | }
13 |
14 | // Return the stock symbol for validation
15 | return stockSymbol;
16 | } catch (error) {
17 | console.error("MAKE SUBMISSION ERROR:", error);
18 | throw error;
19 | }
20 | }
--------------------------------------------------------------------------------
/koii/task-template/src/task/prediction_results.json:
--------------------------------------------------------------------------------
1 | {
2 | "symbol": "AAPL",
3 | "lastPrice": 192.53,
4 | "predictedPrice": 191.58003692388536,
5 | "signals": {
6 | "type": "SELL",
7 | "entry": 192.53,
8 | "prediction": 191.58003692388536,
9 | "stopLoss": 196.38060000000002,
10 | "takeProfit": 186.7541,
11 | "potentialReturn": 0.493410417137403,
12 | "confidence": "LOW"
13 | },
14 | "modelMetrics": {
15 | "lookbackPeriod": 30,
16 | "iterations": 2000,
17 | "learningRate": 0.005,
18 | "hiddenLayers": [
19 | 12,
20 | 12,
21 | 8
22 | ]
23 | },
24 | "timestamp": "2024-12-29T09:02:43.373Z"
25 | }
--------------------------------------------------------------------------------
/.env.sample:
--------------------------------------------------------------------------------
1 | # Particle Project Config, learn more info: https://dashboard.particle.network/
2 | NEXT_PUBLIC_PROJECT_ID=
3 | NEXT_PUBLIC_CLIENT_KEY=
4 | NEXT_PUBLIC_APP_ID=
5 |
6 | # WalletConnect Project Id, learn more info: https://cloud.walletconnect.com/
7 | NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
8 |
9 | NEXT_PUBLIC_FIREBASE_API_KEY=
10 | NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
11 | NEXT_PUBLIC_FIREBASE_PROJECT_ID=
12 | NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
13 | NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
14 | NEXT_PUBLIC_FIREBASE_APP_ID=
15 | NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=
16 |
17 | # Contract Addresses
18 | NEXT_PUBLIC_ETH_CONTRACT_ADDRESS=0xe8da3071c06445ca26475f0fa1161ee5e8956929
--------------------------------------------------------------------------------
/src/lib/hooks/useClickOutside.ts:
--------------------------------------------------------------------------------
1 | import { useEffect, useRef } from "react";
2 |
3 | const useClickOutside = (handler: () => void) => {
4 | const ref = useRef(null);
5 |
6 | useEffect(() => {
7 | const handleClickOutside = (event: MouseEvent) => {
8 | if (ref.current && !ref.current.contains(event.target as Node)) {
9 | handler();
10 | }
11 | };
12 |
13 | document.addEventListener("mousedown", handleClickOutside);
14 |
15 | return () => {
16 | document.removeEventListener("mousedown", handleClickOutside);
17 | };
18 | }, [handler]);
19 |
20 | return ref;
21 | };
22 |
23 | export default useClickOutside;
24 |
--------------------------------------------------------------------------------
/src/lib/utils/lib-utils.ts:
--------------------------------------------------------------------------------
1 |
2 | // Utility function to format the balance to 6 decimal places
3 | // This is more accurate than using .toFixed() because it does not rount it
4 | export const formatBalance = (balanceInEther: string): string => {
5 | const [integerPart, decimalPart] = balanceInEther.split(".");
6 | const truncatedDecimalPart = decimalPart ? decimalPart.slice(0, 6) : "000000";
7 | return `${integerPart}.${truncatedDecimalPart}`;
8 | };
9 |
10 | // Function to truncate addresses for display
11 | export const truncateAddress = (address: string): string => {
12 | return address ? `${address.slice(0, 6)}...${address.slice(address.length - 4)}` : '';
13 | };
--------------------------------------------------------------------------------
/koii/task-template/src/index.js:
--------------------------------------------------------------------------------
1 | import { initializeTaskManager } from "@_koii/task-manager";
2 | // any custom setup logic you need
3 | import { setup } from "./task/0-setup.js";
4 |
5 | // your task, submission, and audit logic
6 | import { task } from "./task/1-task.js";
7 | import { submission } from "./task/2-submission.js";
8 | import { audit } from "./task/3-audit.js";
9 |
10 | // rewards calculation
11 | import { distribution } from "./task/4-distribution.js";
12 |
13 | // custom REST API routes
14 | import { routes } from "./task/5-routes.js";
15 |
16 | initializeTaskManager({
17 | setup,
18 | task,
19 | submission,
20 | audit,
21 | distribution,
22 | routes,
23 | });
24 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/hooks/useClickOutside.ts:
--------------------------------------------------------------------------------
1 | import { useEffect, useRef } from "react";
2 |
3 | const useClickOutside = (handler: () => void) => {
4 | const ref = useRef(null);
5 |
6 | useEffect(() => {
7 | const handleClickOutside = (event: MouseEvent) => {
8 | if (ref.current && !ref.current.contains(event.target as Node)) {
9 | handler();
10 | }
11 | };
12 |
13 | document.addEventListener("mousedown", handleClickOutside);
14 |
15 | return () => {
16 | document.removeEventListener("mousedown", handleClickOutside);
17 | };
18 | }, [handler]);
19 |
20 | return ref;
21 | };
22 |
23 | export default useClickOutside;
24 |
--------------------------------------------------------------------------------
/particle-auth-aa/.env.sample:
--------------------------------------------------------------------------------
1 | # Particle Project Config, learn more info: https://dashboard.particle.network/
2 | NEXT_PUBLIC_PROJECT_ID=
3 | NEXT_PUBLIC_CLIENT_KEY=
4 | NEXT_PUBLIC_APP_ID=
5 |
6 | # WalletConnect Project Id, learn more info: https://cloud.walletconnect.com/
7 | NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
8 |
9 | NEXT_PUBLIC_FIREBASE_API_KEY=
10 | NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
11 | NEXT_PUBLIC_FIREBASE_PROJECT_ID=
12 | NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
13 | NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
14 | NEXT_PUBLIC_FIREBASE_APP_ID=
15 | NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=
16 |
17 | # Contract Addresses
18 | NEXT_PUBLIC_ETH_CONTRACT_ADDRESS=0xe8da3071c06445ca26475f0fa1161ee5e8956929
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/utils/lib-utils.ts:
--------------------------------------------------------------------------------
1 |
2 | // Utility function to format the balance to 6 decimal places
3 | // This is more accurate than using .toFixed() because it does not rount it
4 | export const formatBalance = (balanceInEther: string): string => {
5 | const [integerPart, decimalPart] = balanceInEther.split(".");
6 | const truncatedDecimalPart = decimalPart ? decimalPart.slice(0, 6) : "000000";
7 | return `${integerPart}.${truncatedDecimalPart}`;
8 | };
9 |
10 | // Function to truncate addresses for display
11 | export const truncateAddress = (address: string): string => {
12 | return address ? `${address.slice(0, 6)}...${address.slice(address.length - 4)}` : '';
13 | };
--------------------------------------------------------------------------------
/src/app/not-found.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 | import { Button } from "@/components/ui/button";
3 | import Image from "next/image";
4 | import Link from "next/link";
5 |
6 | export default function NotFound() {
7 | return (
8 |
9 |
10 |
Page Not Found
11 |
The page you are looking for does not exist.
12 |
13 |
14 |
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "lib": ["dom", "dom.iterable", "esnext"],
4 | "allowJs": true,
5 | "skipLibCheck": true,
6 | "strict": true,
7 | "noEmit": true,
8 | "esModuleInterop": true,
9 | "module": "esnext",
10 | "moduleResolution": "bundler",
11 | "resolveJsonModule": true,
12 | "isolatedModules": true,
13 | "jsx": "preserve",
14 | "incremental": true,
15 | "plugins": [
16 | {
17 | "name": "next"
18 | }
19 | ],
20 | "paths": {
21 | "@/*": ["./src/*"]
22 | }
23 | },
24 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "*.mjs" ,"global.d.ts"],
25 | "exclude": ["node_modules"]
26 | }
27 |
--------------------------------------------------------------------------------
/particle-auth-aa/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "lib": ["dom", "dom.iterable", "esnext"],
4 | "allowJs": true,
5 | "skipLibCheck": true,
6 | "strict": true,
7 | "noEmit": true,
8 | "esModuleInterop": true,
9 | "module": "esnext",
10 | "moduleResolution": "bundler",
11 | "resolveJsonModule": true,
12 | "isolatedModules": true,
13 | "jsx": "preserve",
14 | "incremental": true,
15 | "plugins": [
16 | {
17 | "name": "next"
18 | }
19 | ],
20 | "paths": {
21 | "@/*": ["./src/*"]
22 | }
23 | },
24 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "global.d.ts"],
25 | "exclude": ["node_modules"]
26 | }
27 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/app/not-found.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 | import { Button } from "@/components/ui/button";
3 | import Image from "next/image";
4 | import Link from "next/link";
5 |
6 | export default function NotFound() {
7 | return (
8 |
9 |
10 |
Page Not Found
11 |
The page you are looking for does not exist.
12 |
13 |
14 |
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/src/components/ui/textarea.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | const Textarea = React.forwardRef<
6 | HTMLTextAreaElement,
7 | React.ComponentProps<"textarea">
8 | >(({ className, ...props }, ref) => {
9 | return (
10 |
18 | )
19 | })
20 | Textarea.displayName = "Textarea"
21 |
22 | export { Textarea }
23 |
--------------------------------------------------------------------------------
/tradeLLM/config/api-config.js:
--------------------------------------------------------------------------------
1 | require('dotenv').config();
2 |
3 | module.exports = {
4 | yahooFinance: {
5 | apiKey: process.env.YAHOO_FINANCE_API_KEY,
6 | baseUrl: 'https://yfapi.net/v8',
7 | timeout: 30000,
8 | retryAttempts: 3,
9 | retryDelay: 1000,
10 | rateLimit: {
11 | maxRequests: 100,
12 | perTimeWindow: '1m'
13 | }
14 | },
15 | alphaVantage: {
16 | apiKey: process.env.ALPHA_VANTAGE_API_KEY,
17 | baseUrl: 'https://www.alphavantage.co/query',
18 | timeout: 30000,
19 | retryAttempts: 3,
20 | retryDelay: 1000,
21 | rateLimit: {
22 | maxRequests: 5,
23 | perTimeWindow: '1m'
24 | }
25 | },
26 | cache: {
27 | ttl: 10000, // 10 seconds
28 | checkPeriod: 600
29 | }
30 | };
--------------------------------------------------------------------------------
/koii/task-template/src/task/3-audit.js:
--------------------------------------------------------------------------------
1 | import { namespaceWrapper } from "@_koii/namespace-wrapper";
2 |
3 | export async function audit(submission, roundNumber, submitterKey) {
4 | try {
5 | console.log(`AUDIT SUBMISSION FOR ROUND ${roundNumber} from ${submitterKey}`);
6 |
7 | // Verify the submission is a valid stock symbol
8 | if (!submission || typeof submission !== 'string') {
9 | console.error('Invalid submission format');
10 | return false;
11 | }
12 |
13 | // Verify it matches the expected stock symbol (AAPL in this case)
14 | // You can modify this to accept different symbols if needed
15 | return submission === 'AAPL';
16 | } catch (error) {
17 | console.error("AUDIT ERROR:", error);
18 | return false;
19 | }
20 | }
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ui/textarea.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | const Textarea = React.forwardRef<
6 | HTMLTextAreaElement,
7 | React.ComponentProps<"textarea">
8 | >(({ className, ...props }, ref) => {
9 | return (
10 |
18 | )
19 | })
20 | Textarea.displayName = "Textarea"
21 |
22 | export { Textarea }
23 |
--------------------------------------------------------------------------------
/firebase.config.ts:
--------------------------------------------------------------------------------
1 | import { initializeApp } from 'firebase/app';
2 | import { getFirestore } from 'firebase/firestore';
3 | // import { getAnalytics } from 'firebase/analytics';
4 |
5 | // Initialize Firebase
6 | export const firebaseConfig = {
7 | apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
8 | authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
9 | projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
10 | storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
11 | messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
12 | appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
13 | measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
14 | };
15 |
16 | const app = initializeApp(firebaseConfig);
17 | export const db = getFirestore(app);
18 | // export const analytics = getAnalytics(app);
--------------------------------------------------------------------------------
/particle-auth-aa/firebase.config.ts:
--------------------------------------------------------------------------------
1 | import { initializeApp } from 'firebase/app';
2 | import { getFirestore } from 'firebase/firestore';
3 | // import { getAnalytics } from 'firebase/analytics';
4 |
5 | // Initialize Firebase
6 | export const firebaseConfig = {
7 | apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
8 | authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
9 | projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
10 | storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
11 | messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
12 | appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
13 | measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
14 | };
15 |
16 | const app = initializeApp(firebaseConfig);
17 | export const db = getFirestore(app);
18 | // export const analytics = getAnalytics(app);
--------------------------------------------------------------------------------
/src/components/ui/input.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | const Input = React.forwardRef>(
6 | ({ className, type, ...props }, ref) => {
7 | return (
8 |
17 | )
18 | }
19 | )
20 | Input.displayName = "Input"
21 |
22 | export { Input }
23 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ui/input.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | const Input = React.forwardRef>(
6 | ({ className, type, ...props }, ref) => {
7 | return (
8 |
17 | )
18 | }
19 | )
20 | Input.displayName = "Input"
21 |
22 | export { Input }
23 |
--------------------------------------------------------------------------------
/src/app/layout.tsx:
--------------------------------------------------------------------------------
1 | // app/layout.tsx
2 | // 'use client';
3 |
4 | import type { Metadata } from 'next';
5 | import { Inter } from 'next/font/google';
6 | import './globals.css';
7 | import { CombinedProvider } from '@/lib/hooks/usePersistence';
8 |
9 | const inter = Inter({ subsets: ['latin'] });
10 |
11 | export const metadata: Metadata = {
12 | title: 'PULSE TRADE AI',
13 | description: 'Your OP trading platform that super charges your trading experience.',
14 | applicationName: 'Pulse Trade AI Platform',
15 | icons: "/logo.png"
16 | };
17 |
18 |
19 | export default function RootLayout({
20 | children,
21 | }: {
22 | children: React.ReactNode;
23 | }) {
24 | return (
25 |
26 |
27 |
28 | {children}
29 |
30 |
31 |
32 | );
33 | }
--------------------------------------------------------------------------------
/particle-auth-aa/src/app/layout.tsx:
--------------------------------------------------------------------------------
1 | // app/layout.tsx
2 | // 'use client';
3 |
4 | import { CombinedProvider } from "@/lib/hooks/usePersistence";
5 | import type { Metadata } from 'next';
6 | import { Inter } from 'next/font/google';
7 | import './globals.css';
8 |
9 | const inter = Inter({ subsets: ['latin'] });
10 |
11 | export const metadata: Metadata = {
12 | title: 'PULSE TRADE AI',
13 | description: 'Your OP trading platform that super charges your trading experience.',
14 | applicationName: 'Pulse Trade AI Platform',
15 | icons: "/logo.png"
16 | };
17 |
18 |
19 | export default function RootLayout({
20 | children,
21 | }: {
22 | children: React.ReactNode;
23 | }) {
24 | return (
25 |
26 |
27 |
28 | {children}
29 |
30 |
31 |
32 | );
33 | }
--------------------------------------------------------------------------------
/src/components/ui/progress.tsx:
--------------------------------------------------------------------------------
1 | "use client"
2 |
3 | import * as React from "react"
4 | import * as ProgressPrimitive from "@radix-ui/react-progress"
5 |
6 | import { cn } from "@/lib/utils"
7 |
8 | const Progress = React.forwardRef<
9 | React.ElementRef,
10 | React.ComponentPropsWithoutRef
11 | >(({ className, value, ...props }, ref) => (
12 |
20 |
24 |
25 | ))
26 | Progress.displayName = ProgressPrimitive.Root.displayName
27 |
28 | export { Progress }
29 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ui/progress.tsx:
--------------------------------------------------------------------------------
1 | "use client"
2 |
3 | import * as React from "react"
4 | import * as ProgressPrimitive from "@radix-ui/react-progress"
5 |
6 | import { cn } from "@/lib/utils"
7 |
8 | const Progress = React.forwardRef<
9 | React.ElementRef,
10 | React.ComponentPropsWithoutRef
11 | >(({ className, value, ...props }, ref) => (
12 |
20 |
24 |
25 | ))
26 | Progress.displayName = ProgressPrimitive.Root.displayName
27 |
28 | export { Progress }
29 |
--------------------------------------------------------------------------------
/src/components/TxNotification.tsx:
--------------------------------------------------------------------------------
1 | import { truncateAddress } from "@/lib/utils/lib-utils";
2 | import React from "react";
3 |
4 |
5 | interface TransactionLinkProps {
6 | hash: string;
7 | blockExplorerUrl: string;
8 | }
9 |
10 | const TxNotification: React.FC = ({
11 | hash,
12 | blockExplorerUrl,
13 | }) => {
14 | const explorerUrl = `${blockExplorerUrl}/tx/${hash}`;
15 |
16 | return (
17 |
33 | );
34 | };
35 |
36 | export default TxNotification;
37 |
--------------------------------------------------------------------------------
/src/lib/hooks/useChat.ts:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 | import { Chat, ChatMessage } from '../utils';
3 | import { listenToChat, listenToChatMessages } from '../firebase';
4 |
5 | export const useChat = (chatId: string) => {
6 | const [chat, setChat] = useState(null);
7 | const [messages, setMessages] = useState([]);
8 | const [loading, setLoading] = useState(true);
9 | const [error, setError] = useState(null);
10 |
11 | useEffect(() => {
12 | if (!chatId) return;
13 |
14 | const unsubscribeChat = listenToChat(chatId, (chat) => {
15 | setChat(chat);
16 | setLoading(false);
17 | });
18 |
19 | const unsubscribeMessages = listenToChatMessages(chatId, (messages) => {
20 | setMessages(messages);
21 | });
22 |
23 | return () => {
24 | unsubscribeChat();
25 | unsubscribeMessages();
26 | };
27 | }, [chatId]);
28 |
29 | return {
30 | chat,
31 | messages,
32 | loading,
33 | error,
34 | };
35 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/TxNotification.tsx:
--------------------------------------------------------------------------------
1 | import { truncateAddress } from "@/lib/utils/lib-utils";
2 | import React from "react";
3 |
4 |
5 | interface TransactionLinkProps {
6 | hash: string;
7 | blockExplorerUrl: string;
8 | }
9 |
10 | const TxNotification: React.FC = ({
11 | hash,
12 | blockExplorerUrl,
13 | }) => {
14 | const explorerUrl = `${blockExplorerUrl}/tx/${hash}`;
15 |
16 | return (
17 |
33 | );
34 | };
35 |
36 | export default TxNotification;
37 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/hooks/useChat.ts:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 | import { Chat, ChatMessage } from '../utils';
3 | import { listenToChat, listenToChatMessages } from '../firebase';
4 |
5 | export const useChat = (chatId: string) => {
6 | const [chat, setChat] = useState(null);
7 | const [messages, setMessages] = useState([]);
8 | const [loading, setLoading] = useState(true);
9 | const [error, setError] = useState(null);
10 |
11 | useEffect(() => {
12 | if (!chatId) return;
13 |
14 | const unsubscribeChat = listenToChat(chatId, (chat) => {
15 | setChat(chat);
16 | setLoading(false);
17 | });
18 |
19 | const unsubscribeMessages = listenToChatMessages(chatId, (messages) => {
20 | setMessages(messages);
21 | });
22 |
23 | return () => {
24 | unsubscribeChat();
25 | unsubscribeMessages();
26 | };
27 | }, [chatId]);
28 |
29 | return {
30 | chat,
31 | messages,
32 | loading,
33 | error,
34 | };
35 | };
--------------------------------------------------------------------------------
/tradeLLM/middleware/rateLimiter.js:
--------------------------------------------------------------------------------
1 | // middleware/rateLimiter.js
2 | const rateLimit = require('express-rate-limit');
3 |
4 | // Create rate limiter middleware
5 | const createRateLimiter = (options = {}) => {
6 | const defaultOptions = {
7 | windowMs: 15 * 60 * 1000, // 15 minutes
8 | max: 100, // Limit each IP to 100 requests per windowMs
9 | message: 'Too many requests from this IP, please try again later.',
10 | standardHeaders: true,
11 | legacyHeaders: false
12 | };
13 |
14 | return rateLimit({
15 | ...defaultOptions,
16 | ...options
17 | });
18 | };
19 |
20 | // Export middleware instances
21 | module.exports = {
22 | // Standard rate limit for general endpoints
23 | standard: createRateLimiter(),
24 |
25 | // Rate limit for market data endpoints
26 | market: createRateLimiter({
27 | windowMs: 5 * 60 * 1000, // 5 minutes
28 | max: 50 // 50 requests per 5 minutes
29 | }),
30 |
31 | // Rate limit for chat endpoints
32 | chat: createRateLimiter({
33 | windowMs: 1 * 60 * 1000, // 1 minute
34 | max: 10 // 10 requests per minute
35 | })
36 | };
--------------------------------------------------------------------------------
/tradeLLM/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "trading-chat-api",
3 | "version": "1.0.0",
4 | "description": "Trading Chat API powered by Groq",
5 | "main": "server.js",
6 | "scripts": {
7 | "start": "node server.js",
8 | "dev": "nodemon server.js"
9 | },
10 | "dependencies": {
11 | "@langchain/core": "^0.3.23",
12 | "@langchain/groq": "^0.1.2",
13 | "@langchain/langgraph": "^0.2.33",
14 | "axios": "^1.6.2",
15 | "ccxt": "^4.4.40",
16 | "cors": "^2.8.5",
17 | "dotenv": "^16.4.7",
18 | "express": "^4.21.2",
19 | "express-rate-limit": "^7.5.0",
20 | "express-validator": "^7.2.0",
21 | "groq-sdk": "^0.3.3",
22 | "http-errors": "^2.0.0",
23 | "ioredis": "^5.4.1",
24 | "limiter": "^2.1.0",
25 | "node-cache": "^5.1.2",
26 | "rate-limit-redis": "^4.2.0",
27 | "uuid": "^11.0.3",
28 | "yahoo-finance2": "^2.13.2"
29 | },
30 | "devDependencies": {
31 | "nodemon": "^2.0.22"
32 | },
33 | "engines": {
34 | "node": ">=18.0.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/starknetNethermind/my_project/snfoundry.toml:
--------------------------------------------------------------------------------
1 | # Visit https://foundry-rs.github.io/starknet-foundry/appendix/snfoundry-toml.html
2 | # and https://foundry-rs.github.io/starknet-foundry/projects/configuration.html for more information
3 |
4 | # [sncast.default] # Define a profile name
5 | # url = "https://free-rpc.nethermind.io/sepolia-juno/v0_7" # Url of the RPC provider
6 | # accounts-file = "../account-file" # Path to the file with the account data
7 | # account = "mainuser" # Account from `accounts_file` or default account file that will be used for the transactions
8 | # keystore = "~/keystore" # Path to the keystore file
9 | # wait-params = { timeout = 300, retry-interval = 10 } # Wait for submitted transaction parameters
10 | # block-explorer = "StarkScan" # Block explorer service used to display links to transaction details
11 | # show-explorer-links = true # Print links pointing to pages with transaction details in the chosen block explorer
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Soos3D
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/koii/task-template/src/task/libs/utils.js:
--------------------------------------------------------------------------------
1 | // Utility functions for data scaling and transformation
2 | export function minMax(data, featureRange = [0, 1]) {
3 | const min = Math.min(...data);
4 | const max = Math.max(...data);
5 |
6 | const scaler = {
7 | transform: (input) => {
8 | if (Array.isArray(input)) {
9 | return input.map(val =>
10 | ((val - min) / (max - min)) * (featureRange[1] - featureRange[0]) + featureRange[0]
11 | );
12 | }
13 | return ((input - min) / (max - min)) * (featureRange[1] - featureRange[0]) + featureRange[0];
14 | },
15 | inverseTransform: (input) => {
16 | if (Array.isArray(input)) {
17 | return input.map(val =>
18 | ((val - featureRange[0]) / (featureRange[1] - featureRange[0])) * (max - min) + min
19 | );
20 | }
21 | return ((input - featureRange[0]) / (featureRange[1] - featureRange[0])) * (max - min) + min;
22 | }
23 | };
24 |
25 | return {
26 | scaledData: scaler.transform(data),
27 | scaler
28 | };
29 | }
--------------------------------------------------------------------------------
/public/next.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/particle-auth-aa/public/next.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/chats/GroupChatHeader.tsx:
--------------------------------------------------------------------------------
1 | import { Chat, User } from '@/lib/utils';
2 | import React from 'react';
3 |
4 | interface GroupChatHeaderProps {
5 | chat: Chat;
6 | currentUser: User;
7 | }
8 |
9 | export const GroupChatHeader: React.FC = ({
10 | chat,
11 | currentUser,
12 | }) => {
13 | return (
14 |
15 |
16 |
17 |
{chat.name}
18 |
19 | {chat.participants.length} participants
20 |
21 |
22 |
23 |
24 |
Participants:
25 |
26 | {chat.participants.map((participant) => (
27 |
35 | {participant.address.slice(0, 6)}...{participant.address.slice(-4)}
36 | {participant.isWeb3MailEnabled && ' (Web3Mail)'}
37 |
38 | ))}
39 |
40 |
41 |
42 | );
43 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/chats/GroupChatHeader.tsx:
--------------------------------------------------------------------------------
1 | import { Chat, User } from '@/lib/utils';
2 | import React from 'react';
3 |
4 | interface GroupChatHeaderProps {
5 | chat: Chat;
6 | currentUser: User;
7 | }
8 |
9 | export const GroupChatHeader: React.FC = ({
10 | chat,
11 | currentUser,
12 | }) => {
13 | return (
14 |
15 |
16 |
17 |
{chat.name}
18 |
19 | {chat.participants.length} participants
20 |
21 |
22 |
23 |
24 |
Participants:
25 |
26 | {chat.participants.map((participant) => (
27 |
35 | {participant.address.slice(0, 6)}...{participant.address.slice(-4)}
36 | {participant.isWeb3MailEnabled && ' (Web3Mail)'}
37 |
38 | ))}
39 |
40 |
41 |
42 | );
43 | };
--------------------------------------------------------------------------------
/src/lib/utils/connectionStore.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 | import React, { useEffect } from 'react';
3 | import { useAccount } from '@particle-network/connectkit';
4 |
5 | export const WalletPersistenceProvider = ({
6 | children
7 | }: {
8 | children: React.ReactNode
9 | }) => {
10 | const { isConnected, address } = useAccount();
11 | const { setWalletConnected, setWalletAddress } = useWalletStore();
12 | useEffect(() => {
13 | // Sync Particle Network connection state with Zustand store
14 | setWalletConnected(isConnected);
15 | if (isConnected && address) {
16 | setWalletAddress(address);
17 | } else {
18 | setWalletAddress('');
19 | }
20 | }, [isConnected, address, setWalletConnected, setWalletAddress]);
21 | return <>{children}>;
22 | };
23 | import { create } from 'zustand';
24 | import { persist } from 'zustand/middleware';
25 | interface WalletState {
26 | isWalletConnected: boolean;
27 | walletAddress: string;
28 | setWalletConnected: (connected: boolean) => void;
29 | setWalletAddress: (address: string) => void;
30 | }
31 | const useWalletStore = create()(
32 | persist(
33 | (set) => ({
34 | isWalletConnected: false,
35 | walletAddress: '',
36 | setWalletConnected: (connected) => set({ isWalletConnected: connected }),
37 | setWalletAddress: (address) => set({ walletAddress: address }),
38 | }),
39 | {
40 | name: 'wallet-storage',
41 | }
42 | )
43 | );
44 |
45 | export default {useWalletStore};
--------------------------------------------------------------------------------
/tradeLLM/middleware/errorHandler.js:
--------------------------------------------------------------------------------
1 | const createError = require('http-errors');
2 |
3 | const errorHandler = {
4 | // Convert thrown errors to API responses
5 | apiErrorHandler: (err, req, res, next) => {
6 | // Log error for internal tracking
7 | console.error('API Error:', {
8 | error: err,
9 | path: req.path,
10 | method: req.method,
11 | body: req.body,
12 | params: req.params,
13 | query: req.query,
14 | timestamp: new Date().toISOString()
15 | });
16 |
17 | // Handle specific error types
18 | if (err.name === 'ValidationError') {
19 | return res.status(400).json({
20 | error: 'Validation Error',
21 | details: err.details
22 | });
23 | }
24 |
25 | if (err.name === 'RateLimitError') {
26 | return res.status(429).json({
27 | error: 'Rate Limit Exceeded',
28 | message: err.message
29 | });
30 | }
31 |
32 | if (err.name === 'MarketDataError') {
33 | return res.status(503).json({
34 | error: 'Market Data Service Unavailable',
35 | message: err.message
36 | });
37 | }
38 |
39 | // Default error response
40 | res.status(err.status || 500).json({
41 | error: err.message || 'Internal Server Error',
42 | requestId: req.id
43 | });
44 | },
45 |
46 | // Not Found handler
47 | notFoundHandler: (req, res, next) => {
48 | next(createError(404, 'Endpoint not found'));
49 | }
50 | };
51 |
52 | module.exports = errorHandler;
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/utils/connectionStore.ts:
--------------------------------------------------------------------------------
1 | 'use client';
2 | import React, { useEffect } from 'react';
3 | import { useAccount } from '@particle-network/connectkit';
4 | import { useWalletStore } from '../utils/connectionStore';
5 | export const WalletPersistenceProvider = ({
6 | children
7 | }: {
8 | children: React.ReactNode
9 | }) => {
10 | const { isConnected, address } = useAccount();
11 | const { setWalletConnected, setWalletAddress } = useWalletStore();
12 | useEffect(() => {
13 | // Sync Particle Network connection state with Zustand store
14 | setWalletConnected(isConnected);
15 | if (isConnected && address) {
16 | setWalletAddress(address);
17 | } else {
18 | setWalletAddress('');
19 | }
20 | }, [isConnected, address, setWalletConnected, setWalletAddress]);
21 | return <>{children}>;
22 | };
23 | import { create } from 'zustand';
24 | import { persist } from 'zustand/middleware';
25 | interface WalletState {
26 | isWalletConnected: boolean;
27 | walletAddress: string;
28 | setWalletConnected: (connected: boolean) => void;
29 | setWalletAddress: (address: string) => void;
30 | }
31 | export const useWalletStore = create()(
32 | persist(
33 | (set) => ({
34 | isWalletConnected: false,
35 | walletAddress: '',
36 | setWalletConnected: (connected) => set({ isWalletConnected: connected }),
37 | setWalletAddress: (address) => set({ walletAddress: address }),
38 | }),
39 | {
40 | name: 'wallet-storage',
41 | }
42 | )
43 | );
--------------------------------------------------------------------------------
/particle-auth-aa/README.md:
--------------------------------------------------------------------------------
1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2 |
3 | ## Getting Started
4 |
5 | First, run the development server:
6 |
7 | ```bash
8 | npm run dev
9 | # or
10 | yarn dev
11 | # or
12 | pnpm dev
13 | # or
14 | bun dev
15 | ```
16 |
17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18 |
19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20 |
21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
22 |
23 | ## Learn More
24 |
25 | To learn more about Next.js, take a look at the following resources:
26 |
27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29 |
30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
31 |
32 | ## Deploy on Vercel
33 |
34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35 |
36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
37 |
--------------------------------------------------------------------------------
/src/components/chats/MessageList.tsx:
--------------------------------------------------------------------------------
1 | import { ChatMessage } from '@/lib/utils';
2 | import React from 'react';
3 | import MaxWidthWrapper from '../MaxWidthWrapper';
4 |
5 |
6 | interface MessageListProps {
7 | messages: ChatMessage[];
8 | currentUserAddress: string;
9 | }
10 |
11 | export const MessageList: React.FC = ({
12 | messages,
13 | currentUserAddress
14 | }) => {
15 | const messageRef = React.useRef(null);
16 |
17 | React.useEffect(() => {
18 | if (messageRef.current) {
19 | messageRef.current.scrollTop = messageRef.current.scrollHeight;
20 | }
21 | }, [messages]);
22 |
23 | return (
24 |
25 |
29 | {messages.map((message) => (
30 |
36 |
43 |
{message.content}
44 |
45 | {new Date(message.timestamp).toLocaleTimeString()}
46 |
47 |
48 |
49 | ))}
50 |
51 |
52 |
53 | );
54 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/chats/MessageList.tsx:
--------------------------------------------------------------------------------
1 | import { ChatMessage } from '@/lib/utils';
2 | import React from 'react';
3 | import MaxWidthWrapper from '../MaxWidthWrapper';
4 |
5 |
6 | interface MessageListProps {
7 | messages: ChatMessage[];
8 | currentUserAddress: string;
9 | }
10 |
11 | export const MessageList: React.FC = ({
12 | messages,
13 | currentUserAddress
14 | }) => {
15 | const messageRef = React.useRef(null);
16 |
17 | React.useEffect(() => {
18 | if (messageRef.current) {
19 | messageRef.current.scrollTop = messageRef.current.scrollHeight;
20 | }
21 | }, [messages]);
22 |
23 | return (
24 |
25 |
29 | {messages.map((message) => (
30 |
36 |
43 |
{message.content}
44 |
45 | {new Date(message.timestamp).toLocaleTimeString()}
46 |
47 |
48 |
49 | ))}
50 |
51 |
52 |
53 | );
54 | };
--------------------------------------------------------------------------------
/koii/task-template/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pulsetrade",
3 | "version": "3.0.0",
4 | "description": "",
5 | "main": "src/index.js",
6 | "type": "module",
7 | "scripts": {
8 | "test": "node tests/testTask.js",
9 | "simulate": "node tests/simulateTask.js",
10 | "jest-test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
11 | "start": "node index.js",
12 | "prod-debug": "nodemon --ignore 'dist/*' tests/prod-debug.js",
13 | "webpack": "webpack",
14 | "webpack:test": "webpack --config tests/test.webpack.config.js",
15 | "webpack:prod": "webpack --mode production",
16 | "lint": "eslint . --fix",
17 | "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,md}\""
18 | },
19 | "author": "patrickkish",
20 | "license": "ISC",
21 | "dependencies": {
22 | "@_koii/namespace-wrapper": "^1.0.14",
23 | "@_koii/task-manager": "^1.0.1",
24 | "@_koii/web3.js": "^0.1.11",
25 | "@babel/preset-env": "^7.25.7",
26 | "axios": "^1.7.7",
27 | "babel-jest": "^29.7.0",
28 | "brain.js": "^2.0.0-beta.24",
29 | "chalk": "^5.3.0",
30 | "cross-spawn": "^7.0.3",
31 | "d3": "^7.9.0",
32 | "dotenv": "^16.4.7",
33 | "dotenv-webpack": "^8.1.0",
34 | "gpu.js": "^2.16.0",
35 | "mongodb": "^6.12.0",
36 | "nodemon": "^3.1.7",
37 | "onnxjs": "^0.1.8",
38 | "onnxruntime-node": "^1.20.1",
39 | "tail": "^2.2.6"
40 | },
41 | "devDependencies": {
42 | "eslint": "8.4.1",
43 | "globals": "^15.9.0",
44 | "jest": "^29.7.0",
45 | "joi": "^17.9.2",
46 | "prettier": "^3.3.3",
47 | "webpack": "^5.28.0",
48 | "webpack-cli": "^4.5.0"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/components/chats/MessageInput.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { Button } from '@/components/ui/button';
3 | import MaxWidthWrapper from '../MaxWidthWrapper';
4 |
5 | interface MessageInputProps {
6 | onSendMessage: (content: string) => Promise;
7 | isProcessing: boolean;
8 | }
9 |
10 | export const MessageInput: React.FC = ({
11 | onSendMessage,
12 | isProcessing
13 | }) => {
14 | const [message, setMessage] = useState('');
15 |
16 | const handleSubmit = async (e: React.FormEvent) => {
17 | e.preventDefault();
18 | if (!message.trim() || isProcessing) return;
19 |
20 | try {
21 | await onSendMessage(message.trim());
22 | setMessage('');
23 | } catch (error) {
24 | console.error('Error sending message:', error);
25 | }
26 | };
27 |
28 | return (
29 |
30 |
49 |
50 |
51 | );
52 | };
53 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/chats/MessageInput.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { Button } from '@/components/ui/button';
3 | import MaxWidthWrapper from '../MaxWidthWrapper';
4 |
5 | interface MessageInputProps {
6 | onSendMessage: (content: string) => Promise;
7 | isProcessing: boolean;
8 | }
9 |
10 | export const MessageInput: React.FC = ({
11 | onSendMessage,
12 | isProcessing
13 | }) => {
14 | const [message, setMessage] = useState('');
15 |
16 | const handleSubmit = async (e: React.FormEvent) => {
17 | e.preventDefault();
18 | if (!message.trim() || isProcessing) return;
19 |
20 | try {
21 | await onSendMessage(message.trim());
22 | setMessage('');
23 | } catch (error) {
24 | console.error('Error sending message:', error);
25 | }
26 | };
27 |
28 | return (
29 |
30 |
49 |
50 |
51 | );
52 | };
53 |
--------------------------------------------------------------------------------
/particle-auth-aa/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "particle-next-starter",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build",
8 | "start": "next start",
9 | "lint": "next lint"
10 | },
11 | "dependencies": {
12 | "@iexec/dataprotector": "^2.0.0-beta.10",
13 | "@iexec/web3mail": "^1.1.1",
14 | "@particle-network/aa": "^1.5.1",
15 | "@particle-network/auth-core": "^1.5.1",
16 | "@particle-network/auth-core-modal": "^1.5.1",
17 | "@particle-network/authkit": "^2.0.19",
18 | "@particle-network/connectkit": "^2.0.15",
19 | "@radix-ui/react-alert-dialog": "^1.1.3",
20 | "@radix-ui/react-dialog": "^1.1.4",
21 | "@radix-ui/react-dropdown-menu": "^2.1.4",
22 | "@radix-ui/react-progress": "^1.1.1",
23 | "@radix-ui/react-select": "^2.1.4",
24 | "@radix-ui/react-slot": "^1.1.1",
25 | "class-variance-authority": "^0.7.1",
26 | "clsx": "^2.1.1",
27 | "ethers": "^6.13.1",
28 | "firebase": "^11.0.2",
29 | "lucide-react": "^0.468.0",
30 | "next": "14.2.4",
31 | "pino-pretty": "^13.0.0",
32 | "react": "^18",
33 | "react-dom": "^18",
34 | "react-hot-toast": "^2.4.1",
35 | "recharts": "^2.15.0",
36 | "starknet": "^6.11.0",
37 | "tailwind-merge": "^2.5.5",
38 | "tailwindcss-animate": "^1.0.7",
39 | "viem": "^2.21.54",
40 | "web3": "^4.10.0"
41 | },
42 | "devDependencies": {
43 | "@types/node": "^20",
44 | "@types/react": "^18",
45 | "@types/react-dom": "^18",
46 | "eslint": "^8",
47 | "eslint-config-next": "14.2.4",
48 | "postcss": "^8",
49 | "tailwindcss": "^3.4.1",
50 | "typescript": "^5"
51 | },
52 | "overrides": {
53 | "ajv": "^8.17.1"
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tradeLLM/middleware/requestValidator.js:
--------------------------------------------------------------------------------
1 | const { body, param, validationResult } = require('express-validator');
2 | const marketSymbols = require('../config/market-symbols.json');
3 |
4 | const validateSymbol = (symbol) => {
5 | const allSymbols = [
6 | ...marketSymbols.stocks.US.map(s => s.symbol),
7 | ...marketSymbols.forex.map(s => s.symbol),
8 | ...marketSymbols.crypto.map(s => s.symbol),
9 | ...marketSymbols.indices.map(s => s.symbol)
10 | ];
11 |
12 | return allSymbols.includes(symbol);
13 | };
14 |
15 | const validators = {
16 | getQuote: [
17 | param('symbol')
18 | .trim()
19 | .notEmpty()
20 | .withMessage('Symbol is required')
21 | .custom(validateSymbol)
22 | .withMessage('Invalid symbol'),
23 | ],
24 |
25 | chatRequest: [
26 | body('message')
27 | .trim()
28 | .notEmpty()
29 | .withMessage('Message is required')
30 | .isLength({ max: 500 })
31 | .withMessage('Message too long (max 500 characters)'),
32 | ],
33 |
34 | timeframe: [
35 | param('timeframe')
36 | .optional()
37 | .isIn(['1m', '5m', '15m', '30m', '1h', '4h', '1d', '1w'])
38 | .withMessage('Invalid timeframe')
39 | ]
40 | };
41 |
42 | const validate = (validations) => {
43 | return async (req, res, next) => {
44 | await Promise.all(validations.map(validation => validation.run(req)));
45 |
46 | const errors = validationResult(req);
47 | if (errors.isEmpty()) {
48 | return next();
49 | }
50 |
51 | res.status(400).json({
52 | errors: errors.array().map(err => ({
53 | field: err.param,
54 | message: err.msg
55 | }))
56 | });
57 | };
58 | };
59 |
60 | module.exports = {
61 | validators,
62 | validate
63 | };
--------------------------------------------------------------------------------
/starknetNethermind/my_project/tests/test_contract.cairo:
--------------------------------------------------------------------------------
1 | use starknet::ContractAddress;
2 |
3 | use snforge_std::{declare, ContractClassTrait, DeclareResultTrait};
4 |
5 | use my_project::IHelloStarknetSafeDispatcher;
6 | use my_project::IHelloStarknetSafeDispatcherTrait;
7 | use my_project::IHelloStarknetDispatcher;
8 | use my_project::IHelloStarknetDispatcherTrait;
9 |
10 | fn deploy_contract(name: ByteArray) -> ContractAddress {
11 | let contract = declare(name).unwrap().contract_class();
12 | let (contract_address, _) = contract.deploy(@ArrayTrait::new()).unwrap();
13 | contract_address
14 | }
15 |
16 | #[test]
17 | fn test_increase_balance() {
18 | let contract_address = deploy_contract("HelloStarknet");
19 |
20 | let dispatcher = IHelloStarknetDispatcher { contract_address };
21 |
22 | let balance_before = dispatcher.get_balance();
23 | assert(balance_before == 0, 'Invalid balance');
24 |
25 | dispatcher.increase_balance(42);
26 |
27 | let balance_after = dispatcher.get_balance();
28 | assert(balance_after == 42, 'Invalid balance');
29 | }
30 |
31 | #[test]
32 | #[feature("safe_dispatcher")]
33 | fn test_cannot_increase_balance_with_zero_value() {
34 | let contract_address = deploy_contract("HelloStarknet");
35 |
36 | let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address };
37 |
38 | let balance_before = safe_dispatcher.get_balance().unwrap();
39 | assert(balance_before == 0, 'Invalid balance');
40 |
41 | match safe_dispatcher.increase_balance(0) {
42 | Result::Ok(_) => core::panic_with_felt252('Should have panicked'),
43 | Result::Err(panic_data) => {
44 | assert(*panic_data.at(0) == 'Amount cannot be 0', *panic_data.at(0));
45 | }
46 | };
47 | }
48 |
--------------------------------------------------------------------------------
/src/components/ai-chat/MessageList.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useRef } from 'react';
2 | import Image from 'next/image';
3 |
4 | interface Message {
5 | id: string;
6 | content: string;
7 | isAi: boolean;
8 | timestamp: number;
9 | }
10 |
11 | interface MessageListProps {
12 | messages: Message[];
13 | loading?: boolean;
14 | }
15 |
16 | export const MessageList = ({ messages, loading }: MessageListProps) => {
17 | const messagesEndRef = useRef(null);
18 |
19 | const scrollToBottom = () => {
20 | messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
21 | };
22 |
23 | useEffect(() => {
24 | scrollToBottom();
25 | }, [messages]);
26 |
27 | return (
28 |
29 | {messages.map((message) => (
30 |
34 |
39 |
{message.content}
40 |
41 | {new Date(message.timestamp).toLocaleTimeString()}
42 |
43 |
44 |
45 | ))}
46 |
47 | {loading && (
48 |
49 |
56 |
57 | )}
58 |
59 |
60 |
61 | );
62 | };
--------------------------------------------------------------------------------
/src/lib/services/ai-chat.ts:
--------------------------------------------------------------------------------
1 | import { collection, addDoc, updateDoc, doc } from 'firebase/firestore';
2 | import { db } from '../../../firebase.config';
3 |
4 |
5 | interface ChatData {
6 | userId: string;
7 | threadId?: string;
8 | title: string;
9 | lastMessage?: {
10 | content: string;
11 | timestamp: number;
12 | };
13 | }
14 |
15 | export const createNewChat = async (data: ChatData) => {
16 | try {
17 | const chatData = {
18 | ...data,
19 | createdAt: Date.now(),
20 | updatedAt: Date.now()
21 | };
22 |
23 | const chatRef = await addDoc(collection(db, 'ai_chats'), chatData);
24 | return chatRef.id;
25 | } catch (error) {
26 | console.error('Error creating chat:', error);
27 | throw error;
28 | }
29 | };
30 |
31 | export const updateChatThread = async (chatId: string, threadId: string) => {
32 | try {
33 | const chatRef = doc(db, 'ai_chats', chatId);
34 | await updateDoc(chatRef, {
35 | threadId,
36 | updatedAt: Date.now()
37 | });
38 | } catch (error) {
39 | console.error('Error updating chat thread:', error);
40 | throw error;
41 | }
42 | };
43 |
44 | export const addMessage = async (chatId: string, content: string, isAi: boolean) => {
45 | try {
46 | const messageData = {
47 | chatId,
48 | content,
49 | isAi,
50 | timestamp: Date.now()
51 | };
52 |
53 | await addDoc(collection(db, 'ai_chat_messages'), messageData);
54 |
55 | // Update last message in chat
56 | const chatRef = doc(db, 'ai_chats', chatId);
57 | await updateDoc(chatRef, {
58 | lastMessage: {
59 | content,
60 | timestamp: Date.now()
61 | },
62 | updatedAt: Date.now()
63 | });
64 | } catch (error) {
65 | console.error('Error adding message:', error);
66 | throw error;
67 | }
68 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ai-chat/MessageList.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useRef } from 'react';
2 | import Image from 'next/image';
3 |
4 | interface Message {
5 | id: string;
6 | content: string;
7 | isAi: boolean;
8 | timestamp: number;
9 | }
10 |
11 | interface MessageListProps {
12 | messages: Message[];
13 | loading?: boolean;
14 | }
15 |
16 | export const MessageList = ({ messages, loading }: MessageListProps) => {
17 | const messagesEndRef = useRef(null);
18 |
19 | const scrollToBottom = () => {
20 | messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
21 | };
22 |
23 | useEffect(() => {
24 | scrollToBottom();
25 | }, [messages]);
26 |
27 | return (
28 |
29 | {messages.map((message) => (
30 |
34 |
39 |
{message.content}
40 |
41 | {new Date(message.timestamp).toLocaleTimeString()}
42 |
43 |
44 |
45 | ))}
46 |
47 | {loading && (
48 |
49 |
56 |
57 | )}
58 |
59 |
60 |
61 | );
62 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/services/ai-chat.ts:
--------------------------------------------------------------------------------
1 | import { collection, addDoc, updateDoc, doc } from 'firebase/firestore';
2 | import { db } from '../../../firebase.config';
3 |
4 |
5 | interface ChatData {
6 | userId: string;
7 | threadId?: string;
8 | title: string;
9 | lastMessage?: {
10 | content: string;
11 | timestamp: number;
12 | };
13 | }
14 |
15 | export const createNewChat = async (data: ChatData) => {
16 | try {
17 | const chatData = {
18 | ...data,
19 | createdAt: Date.now(),
20 | updatedAt: Date.now()
21 | };
22 |
23 | const chatRef = await addDoc(collection(db, 'ai_chats'), chatData);
24 | return chatRef.id;
25 | } catch (error) {
26 | console.error('Error creating chat:', error);
27 | throw error;
28 | }
29 | };
30 |
31 | export const updateChatThread = async (chatId: string, threadId: string) => {
32 | try {
33 | const chatRef = doc(db, 'ai_chats', chatId);
34 | await updateDoc(chatRef, {
35 | threadId,
36 | updatedAt: Date.now()
37 | });
38 | } catch (error) {
39 | console.error('Error updating chat thread:', error);
40 | throw error;
41 | }
42 | };
43 |
44 | export const addMessage = async (chatId: string, content: string, isAi: boolean) => {
45 | try {
46 | const messageData = {
47 | chatId,
48 | content,
49 | isAi,
50 | timestamp: Date.now()
51 | };
52 |
53 | await addDoc(collection(db, 'ai_chat_messages'), messageData);
54 |
55 | // Update last message in chat
56 | const chatRef = doc(db, 'ai_chats', chatId);
57 | await updateDoc(chatRef, {
58 | lastMessage: {
59 | content,
60 | timestamp: Date.now()
61 | },
62 | updatedAt: Date.now()
63 | });
64 | } catch (error) {
65 | console.error('Error adding message:', error);
66 | throw error;
67 | }
68 | };
--------------------------------------------------------------------------------
/src/components/ui/alert.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 | import { cva, type VariantProps } from "class-variance-authority"
3 |
4 | import { cn } from "@/lib/utils"
5 |
6 | const alertVariants = cva(
7 | "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
8 | {
9 | variants: {
10 | variant: {
11 | default: "bg-background text-foreground",
12 | destructive:
13 | "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
14 | },
15 | },
16 | defaultVariants: {
17 | variant: "default",
18 | },
19 | }
20 | )
21 |
22 | const Alert = React.forwardRef<
23 | HTMLDivElement,
24 | React.HTMLAttributes & VariantProps
25 | >(({ className, variant, ...props }, ref) => (
26 |
32 | ))
33 | Alert.displayName = "Alert"
34 |
35 | const AlertTitle = React.forwardRef<
36 | HTMLParagraphElement,
37 | React.HTMLAttributes
38 | >(({ className, ...props }, ref) => (
39 |
44 | ))
45 | AlertTitle.displayName = "AlertTitle"
46 |
47 | const AlertDescription = React.forwardRef<
48 | HTMLParagraphElement,
49 | React.HTMLAttributes
50 | >(({ className, ...props }, ref) => (
51 |
56 | ))
57 | AlertDescription.displayName = "AlertDescription"
58 |
59 | export { Alert, AlertTitle, AlertDescription }
60 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ui/alert.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 | import { cva, type VariantProps } from "class-variance-authority"
3 |
4 | import { cn } from "@/lib/utils"
5 |
6 | const alertVariants = cva(
7 | "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
8 | {
9 | variants: {
10 | variant: {
11 | default: "bg-background text-foreground",
12 | destructive:
13 | "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
14 | },
15 | },
16 | defaultVariants: {
17 | variant: "default",
18 | },
19 | }
20 | )
21 |
22 | const Alert = React.forwardRef<
23 | HTMLDivElement,
24 | React.HTMLAttributes & VariantProps
25 | >(({ className, variant, ...props }, ref) => (
26 |
32 | ))
33 | Alert.displayName = "Alert"
34 |
35 | const AlertTitle = React.forwardRef<
36 | HTMLParagraphElement,
37 | React.HTMLAttributes
38 | >(({ className, ...props }, ref) => (
39 |
44 | ))
45 | AlertTitle.displayName = "AlertTitle"
46 |
47 | const AlertDescription = React.forwardRef<
48 | HTMLParagraphElement,
49 | React.HTMLAttributes
50 | >(({ className, ...props }, ref) => (
51 |
56 | ))
57 | AlertDescription.displayName = "AlertDescription"
58 |
59 | export { Alert, AlertTitle, AlertDescription }
60 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "homepage": "https://patrickkish1.github.io/pulsetrade",
3 | "name": "pulsetrade",
4 | "version": "0.1.0",
5 | "private": true,
6 | "scripts": {
7 | "dev": "next dev",
8 | "build": "next build",
9 | "start": "next start",
10 | "lint": "next lint",
11 | "predeploy": "npm run build",
12 | "deploy": "gh-pages -d out"
13 | },
14 | "dependencies": {
15 | "@ant-design/icons": "^5.5.2",
16 | "@iexec/dataprotector": "^2.0.0-beta.10",
17 | "@iexec/web3mail": "^1.1.1",
18 | "@particle-network/aa": "^1.5.1",
19 | "@particle-network/auth-core": "^1.5.1",
20 | "@particle-network/auth-core-modal": "^1.5.1",
21 | "@particle-network/authkit": "^2.0.19",
22 | "@particle-network/connectkit": "^2.0.15",
23 | "@radix-ui/react-alert-dialog": "^1.1.3",
24 | "@radix-ui/react-dialog": "^1.1.4",
25 | "@radix-ui/react-dropdown-menu": "^2.1.4",
26 | "@radix-ui/react-progress": "^1.1.1",
27 | "@radix-ui/react-select": "^2.1.4",
28 | "@radix-ui/react-slot": "^1.1.1",
29 | "class-variance-authority": "^0.7.1",
30 | "clsx": "^2.1.1",
31 | "cross-env": "^7.0.3",
32 | "ethers": "^6.13.1",
33 | "firebase": "^11.0.2",
34 | "lucide-react": "^0.468.0",
35 | "next": "14.2.4",
36 | "pino-pretty": "^13.0.0",
37 | "react": "^18",
38 | "react-dom": "^18",
39 | "react-hot-toast": "^2.4.1",
40 | "recharts": "^2.15.0",
41 | "starknet": "^6.11.0",
42 | "tailwind-merge": "^2.5.5",
43 | "tailwindcss-animate": "^1.0.7",
44 | "viem": "^2.21.54",
45 | "web3": "^4.10.0"
46 | },
47 | "devDependencies": {
48 | "@types/node": "^20",
49 | "@types/react": "^18",
50 | "@types/react-dom": "^18",
51 | "eslint": "^8",
52 | "eslint-config-next": "14.2.4",
53 | "gh-pages": "^6.2.0",
54 | "postcss": "^8",
55 | "tailwindcss": "^3.4.1",
56 | "typescript": "^5"
57 | },
58 | "overrides": {
59 | "ajv": "^8.17.1"
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/lib/hooks/usePersistence.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import React from 'react';
4 | import { useAccount } from '@particle-network/connectkit';
5 | import { create } from 'zustand';
6 | import { persist } from 'zustand/middleware';
7 | import { ParticleConnectkit } from '../connectkit';
8 |
9 | // Define the wallet state interface
10 | interface WalletState {
11 | isWalletConnected: boolean;
12 | walletAddress: string;
13 | setWalletConnected: (connected: boolean) => void;
14 | setWalletAddress: (address: string) => void;
15 | }
16 |
17 | // Create persistent store
18 | export const useWalletStore = create()(
19 | persist(
20 | (set) => ({
21 | isWalletConnected: false,
22 | walletAddress: '',
23 | setWalletConnected: (connected) => set({ isWalletConnected: connected }),
24 | setWalletAddress: (address) => set({ walletAddress: address }),
25 | }),
26 | {
27 | name: 'wallet-storage',
28 | }
29 | )
30 | );
31 |
32 | // Create the persistence provider component
33 | export const WalletPersistenceProvider = ({
34 | children
35 | }: {
36 | children: React.ReactNode
37 | }) => {
38 | const { isConnected, address } = useAccount();
39 | const { setWalletConnected, setWalletAddress } = useWalletStore();
40 |
41 | React.useEffect(() => {
42 | // Sync Particle Network connection state with Zustand store
43 | setWalletConnected(isConnected);
44 | if (isConnected && address) {
45 | setWalletAddress(address);
46 | } else {
47 | setWalletAddress('');
48 | }
49 | }, [isConnected, address, setWalletConnected, setWalletAddress]);
50 |
51 | return <>{children}>;
52 | };
53 |
54 | // Combined provider for both Particle and Persistence
55 | export const CombinedProvider = ({ children }: { children: React.ReactNode }) => {
56 | return (
57 |
58 |
59 | {children}
60 |
61 |
62 | );
63 | };
--------------------------------------------------------------------------------
/koii/task-template/Manual K2 Calls.md:
--------------------------------------------------------------------------------
1 | # GUIDE TO CALLS K2 FUNCTIONS MANUALLY
2 |
3 | If you wish to do the development by avoiding the timers then you can do the intended calls to K2 directly using these function calls.
4 |
5 | To disable timers please set the TIMERS flag in task-node ENV to disable
6 |
7 | NOTE : K2 will still have the windows to accept the submission and audit values, so you are expected to make calls in the intended slots of your round time.
8 |
9 | ## Get the task state
10 |
11 | ```js
12 | console.log(await namespaceWrapper.getTaskState());
13 | ```
14 |
15 | ## Get round
16 |
17 | ```js
18 | const round = await namespaceWrapper.getRound();
19 | console.log("ROUND", round);
20 | ```
21 |
22 | ## Call to do the work for the task
23 |
24 | ```js
25 | import { taskRunner } from "@_koii/task-manager";
26 | await taskRunner.task();
27 | ```
28 |
29 | ## Submission to K2
30 |
31 | Preferably you should submit the CID received from IPFS.
32 |
33 | ```js
34 | import { taskRunner } from "@_koii/task-manager";
35 | await taskRunner.submitTask(round - 1);
36 | ```
37 |
38 | ## Audit submissions
39 |
40 | ```js
41 | import { taskRunner } from "@_koii/task-manager";
42 | await taskRunner.auditTask(round - 1);
43 | ```
44 |
45 | ## Upload distribution list to K2
46 |
47 | ```js
48 | import { taskRunner } from "@_koii/task-manager";
49 | await taskRunner.selectAndGenerateDistributionList(10);
50 | ```
51 |
52 | ## Audit distribution list
53 |
54 | ```js
55 | import { taskRunner } from "@_koii/task-manager";
56 | await coreLogic.auditDistribution(round - 2);
57 | ```
58 |
59 | ## Payout trigger
60 |
61 | ```js
62 | const responsePayout = await namespaceWrapper.payoutTrigger();
63 | console.log("RESPONSE TRIGGER", responsePayout);
64 | ```
65 |
66 | ## Logs to be displayed on desktop-node
67 |
68 | ```js
69 | namespaceWrapper.logger("error", "Internet connection lost");
70 | await namespaceWrapper.logger("warn", "Stakes are running low");
71 | await namespaceWrapper.logger("log", "Task is running");
72 | ```
73 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/hooks/usePersistence.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import React from 'react';
4 | import { useAccount } from '@particle-network/connectkit';
5 | import { ParticleConnectkit } from '@/lib/connectkit';
6 | import { create } from 'zustand';
7 | import { persist } from 'zustand/middleware';
8 |
9 | // Define the wallet state interface
10 | interface WalletState {
11 | isWalletConnected: boolean;
12 | walletAddress: string;
13 | setWalletConnected: (connected: boolean) => void;
14 | setWalletAddress: (address: string) => void;
15 | }
16 |
17 | // Create persistent store
18 | export const useWalletStore = create()(
19 | persist(
20 | (set) => ({
21 | isWalletConnected: false,
22 | walletAddress: '',
23 | setWalletConnected: (connected) => set({ isWalletConnected: connected }),
24 | setWalletAddress: (address) => set({ walletAddress: address }),
25 | }),
26 | {
27 | name: 'wallet-storage',
28 | }
29 | )
30 | );
31 |
32 | // Create the persistence provider component
33 | export const WalletPersistenceProvider = ({
34 | children
35 | }: {
36 | children: React.ReactNode
37 | }) => {
38 | const { isConnected, address } = useAccount();
39 | const { setWalletConnected, setWalletAddress } = useWalletStore();
40 |
41 | React.useEffect(() => {
42 | // Sync Particle Network connection state with Zustand store
43 | setWalletConnected(isConnected);
44 | if (isConnected && address) {
45 | setWalletAddress(address);
46 | } else {
47 | setWalletAddress('');
48 | }
49 | }, [isConnected, address, setWalletConnected, setWalletAddress]);
50 |
51 | return <>{children}>;
52 | };
53 |
54 | // Combined provider for both Particle and Persistence
55 | export const CombinedProvider = ({ children }: { children: React.ReactNode }) => {
56 | return (
57 |
58 |
59 | {children}
60 |
61 |
62 | );
63 | };
--------------------------------------------------------------------------------
/src/components/ui/button.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 | import { Slot } from "@radix-ui/react-slot"
3 | import { cva, type VariantProps } from "class-variance-authority"
4 |
5 | import { cn } from "@/lib/utils"
6 |
7 | const buttonVariants = cva(
8 | "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
9 | {
10 | variants: {
11 | variant: {
12 | default:
13 | "bg-primary text-primary-foreground shadow hover:bg-primary/90",
14 | destructive:
15 | "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
16 | outline:
17 | "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
18 | secondary:
19 | "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
20 | ghost: "hover:bg-accent hover:text-accent-foreground",
21 | link: "text-primary underline-offset-4 hover:underline",
22 | },
23 | size: {
24 | default: "h-9 px-4 py-2",
25 | sm: "h-8 rounded-md px-3 text-xs",
26 | lg: "h-10 rounded-md px-8",
27 | icon: "h-9 w-9",
28 | },
29 | },
30 | defaultVariants: {
31 | variant: "default",
32 | size: "default",
33 | },
34 | }
35 | )
36 |
37 | export interface ButtonProps
38 | extends React.ButtonHTMLAttributes,
39 | VariantProps {
40 | asChild?: boolean
41 | }
42 |
43 | const Button = React.forwardRef(
44 | ({ className, variant, size, asChild = false, ...props }, ref) => {
45 | const Comp = asChild ? Slot : "button"
46 | return (
47 |
52 | )
53 | }
54 | )
55 | Button.displayName = "Button"
56 |
57 | export { Button, buttonVariants }
58 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ui/button.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 | import { Slot } from "@radix-ui/react-slot"
3 | import { cva, type VariantProps } from "class-variance-authority"
4 |
5 | import { cn } from "@/lib/utils"
6 |
7 | const buttonVariants = cva(
8 | "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
9 | {
10 | variants: {
11 | variant: {
12 | default:
13 | "bg-primary text-primary-foreground shadow hover:bg-primary/90",
14 | destructive:
15 | "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
16 | outline:
17 | "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
18 | secondary:
19 | "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
20 | ghost: "hover:bg-accent hover:text-accent-foreground",
21 | link: "text-primary underline-offset-4 hover:underline",
22 | },
23 | size: {
24 | default: "h-9 px-4 py-2",
25 | sm: "h-8 rounded-md px-3 text-xs",
26 | lg: "h-10 rounded-md px-8",
27 | icon: "h-9 w-9",
28 | },
29 | },
30 | defaultVariants: {
31 | variant: "default",
32 | size: "default",
33 | },
34 | }
35 | )
36 |
37 | export interface ButtonProps
38 | extends React.ButtonHTMLAttributes,
39 | VariantProps {
40 | asChild?: boolean
41 | }
42 |
43 | const Button = React.forwardRef(
44 | ({ className, variant, size, asChild = false, ...props }, ref) => {
45 | const Comp = asChild ? Slot : "button"
46 | return (
47 |
52 | )
53 | }
54 | )
55 | Button.displayName = "Button"
56 |
57 | export { Button, buttonVariants }
58 |
--------------------------------------------------------------------------------
/src/components/ui/card.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | const Card = React.forwardRef<
6 | HTMLDivElement,
7 | React.HTMLAttributes
8 | >(({ className, ...props }, ref) => (
9 |
17 | ))
18 | Card.displayName = "Card"
19 |
20 | const CardHeader = React.forwardRef<
21 | HTMLDivElement,
22 | React.HTMLAttributes
23 | >(({ className, ...props }, ref) => (
24 |
29 | ))
30 | CardHeader.displayName = "CardHeader"
31 |
32 | const CardTitle = React.forwardRef<
33 | HTMLDivElement,
34 | React.HTMLAttributes
35 | >(({ className, ...props }, ref) => (
36 |
41 | ))
42 | CardTitle.displayName = "CardTitle"
43 |
44 | const CardDescription = React.forwardRef<
45 | HTMLDivElement,
46 | React.HTMLAttributes
47 | >(({ className, ...props }, ref) => (
48 |
53 | ))
54 | CardDescription.displayName = "CardDescription"
55 |
56 | const CardContent = React.forwardRef<
57 | HTMLDivElement,
58 | React.HTMLAttributes
59 | >(({ className, ...props }, ref) => (
60 |
61 | ))
62 | CardContent.displayName = "CardContent"
63 |
64 | const CardFooter = React.forwardRef<
65 | HTMLDivElement,
66 | React.HTMLAttributes
67 | >(({ className, ...props }, ref) => (
68 |
73 | ))
74 | CardFooter.displayName = "CardFooter"
75 |
76 | export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
77 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ui/card.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react"
2 |
3 | import { cn } from "@/lib/utils"
4 |
5 | const Card = React.forwardRef<
6 | HTMLDivElement,
7 | React.HTMLAttributes
8 | >(({ className, ...props }, ref) => (
9 |
17 | ))
18 | Card.displayName = "Card"
19 |
20 | const CardHeader = React.forwardRef<
21 | HTMLDivElement,
22 | React.HTMLAttributes
23 | >(({ className, ...props }, ref) => (
24 |
29 | ))
30 | CardHeader.displayName = "CardHeader"
31 |
32 | const CardTitle = React.forwardRef<
33 | HTMLDivElement,
34 | React.HTMLAttributes
35 | >(({ className, ...props }, ref) => (
36 |
41 | ))
42 | CardTitle.displayName = "CardTitle"
43 |
44 | const CardDescription = React.forwardRef<
45 | HTMLDivElement,
46 | React.HTMLAttributes
47 | >(({ className, ...props }, ref) => (
48 |
53 | ))
54 | CardDescription.displayName = "CardDescription"
55 |
56 | const CardContent = React.forwardRef<
57 | HTMLDivElement,
58 | React.HTMLAttributes
59 | >(({ className, ...props }, ref) => (
60 |
61 | ))
62 | CardContent.displayName = "CardContent"
63 |
64 | const CardFooter = React.forwardRef<
65 | HTMLDivElement,
66 | React.HTMLAttributes
67 | >(({ className, ...props }, ref) => (
68 |
73 | ))
74 | CardFooter.displayName = "CardFooter"
75 |
76 | export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
77 |
--------------------------------------------------------------------------------
/src/lib/hooks/useWeb3Mail.ts:
--------------------------------------------------------------------------------
1 | import { useState } from 'react';
2 | import { IExecWeb3mail } from '@iexec/web3mail';
3 | import { IExecDataProtector } from '@iexec/dataprotector';
4 |
5 | export const useWeb3Mail = () => {
6 | const [loading, setLoading] = useState(false);
7 | const [error, setError] = useState(null);
8 |
9 | const protectEmail = async (email: string) => {
10 | setLoading(true);
11 | setError(null);
12 | try {
13 | const dataProtector = new IExecDataProtector(window.ethereum);
14 | const protectedData = await dataProtector.core.protectData({
15 | data: { email },
16 | name: `Protected email for Web3Mail`,
17 | });
18 | return protectedData.address;
19 | } catch (err: unknown) {
20 | // Type guard to check if err is an Error object
21 | if (err instanceof Error) {
22 | setError(err.message);
23 | } else {
24 | // Fallback for cases where err might not be an Error object
25 | setError('An unknown error occurred');
26 | }
27 | throw err;
28 | } finally {
29 | setLoading(false);
30 | }
31 | };
32 |
33 | const sendWeb3Mail = async (
34 | recipientAddress: string,
35 | subject: string,
36 | content: string
37 | ) => {
38 | setLoading(true);
39 | setError(null);
40 | try {
41 | const web3mail = new IExecWeb3mail(window.ethereum);
42 | const { taskId } = await web3mail.sendEmail({
43 | emailSubject: subject,
44 | emailContent: content,
45 | protectedData: recipientAddress,
46 | contentType: 'text/plain',
47 | senderName: 'Web3 Chat',
48 | workerpoolAddressOrEns: 'prod-v8-learn.main.pools.iexec.eth',
49 | });
50 | return taskId;
51 | } catch (err: unknown) {
52 | // Type guard to check if err is an Error object
53 | if (err instanceof Error) {
54 | setError(err.message);
55 | } else {
56 | // Fallback for cases where err might not be an Error object
57 | setError('An unknown error occurred');
58 | }
59 | throw err;
60 | } finally {
61 | setLoading(false);
62 | }
63 | };
64 |
65 | return {
66 | protectEmail,
67 | sendWeb3Mail,
68 | loading,
69 | error,
70 | };
71 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/hooks/useWeb3Mail.ts:
--------------------------------------------------------------------------------
1 | import { useState } from 'react';
2 | import { IExecWeb3mail } from '@iexec/web3mail';
3 | import { IExecDataProtector } from '@iexec/dataprotector';
4 |
5 | export const useWeb3Mail = () => {
6 | const [loading, setLoading] = useState(false);
7 | const [error, setError] = useState(null);
8 |
9 | const protectEmail = async (email: string) => {
10 | setLoading(true);
11 | setError(null);
12 | try {
13 | const dataProtector = new IExecDataProtector(window.ethereum);
14 | const protectedData = await dataProtector.core.protectData({
15 | data: { email },
16 | name: `Protected email for Web3Mail`,
17 | });
18 | return protectedData.address;
19 | } catch (err: unknown) {
20 | // Type guard to check if err is an Error object
21 | if (err instanceof Error) {
22 | setError(err.message);
23 | } else {
24 | // Fallback for cases where err might not be an Error object
25 | setError('An unknown error occurred');
26 | }
27 | throw err;
28 | } finally {
29 | setLoading(false);
30 | }
31 | };
32 |
33 | const sendWeb3Mail = async (
34 | recipientAddress: string,
35 | subject: string,
36 | content: string
37 | ) => {
38 | setLoading(true);
39 | setError(null);
40 | try {
41 | const web3mail = new IExecWeb3mail(window.ethereum);
42 | const { taskId } = await web3mail.sendEmail({
43 | emailSubject: subject,
44 | emailContent: content,
45 | protectedData: recipientAddress,
46 | contentType: 'text/plain',
47 | senderName: 'Web3 Chat',
48 | workerpoolAddressOrEns: 'prod-v8-learn.main.pools.iexec.eth',
49 | });
50 | return taskId;
51 | } catch (err: unknown) {
52 | // Type guard to check if err is an Error object
53 | if (err instanceof Error) {
54 | setError(err.message);
55 | } else {
56 | // Fallback for cases where err might not be an Error object
57 | setError('An unknown error occurred');
58 | }
59 | throw err;
60 | } finally {
61 | setLoading(false);
62 | }
63 | };
64 |
65 | return {
66 | protectEmail,
67 | sendWeb3Mail,
68 | loading,
69 | error,
70 | };
71 | };
--------------------------------------------------------------------------------
/src/lib/hooks/useParticleAuth.ts:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { useAccount } from '@particle-network/connectkit';
4 | import type { Connector } from '@particle-network/connector-core';
5 | import { type Chain } from 'viem';
6 |
7 | interface ParticleAuthUserInfo {
8 | address: string;
9 | email?: string;
10 | wallets: string[];
11 | socialInfo?: any;
12 | }
13 |
14 | interface ParticleAuthResponse {
15 | email?: string;
16 | wallets?: string[];
17 | social?: any;
18 | }
19 |
20 | interface ParticleConnector extends Connector {
21 | request: (args: { method: string; params?: any[] }) => Promise;
22 | }
23 |
24 | interface ParticleAuthHookReturn {
25 | getUserInfo: () => Promise;
26 | isConnected: boolean;
27 | address: string | undefined;
28 | chainId: number | undefined;
29 | chain: Chain | undefined;
30 | connector: ParticleConnector | undefined;
31 | status: 'connected' | 'connecting' | 'reconnecting' | 'disconnected';
32 | }
33 |
34 | export const useParticleAuth = (): ParticleAuthHookReturn => {
35 | const {
36 | address,
37 | chainId,
38 | connector,
39 | isConnected,
40 | chain,
41 | status
42 | } = useAccount();
43 |
44 | const getUserInfo = async (): Promise => {
45 | if (!isConnected || !address || !connector) return null;
46 |
47 | try {
48 | // Cast connector to ParticleConnector to access typed request method
49 | const particleConnector = connector as ParticleConnector;
50 |
51 | // Get user info from the connector with proper typing
52 | const userInfo = await particleConnector.request({
53 | method: 'particle_auth',
54 | params: []
55 | });
56 |
57 | return {
58 | address: address,
59 | email: userInfo?.email,
60 | wallets: userInfo?.wallets || [address],
61 | socialInfo: userInfo?.social
62 | };
63 | } catch (error) {
64 | console.error('Error getting user info:', error);
65 | // If particle_auth fails, return basic wallet info
66 | return {
67 | address: address,
68 | wallets: [address]
69 | };
70 | }
71 | };
72 |
73 | return {
74 | getUserInfo,
75 | isConnected,
76 | address,
77 | chainId,
78 | chain,
79 | connector: connector as ParticleConnector,
80 | status
81 | };
82 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/hooks/useParticleAuth.ts:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { useAccount } from '@particle-network/connectkit';
4 | import type { Connector } from '@particle-network/connector-core';
5 | import { type Chain } from 'viem';
6 |
7 | interface ParticleAuthUserInfo {
8 | address: string;
9 | email?: string;
10 | wallets: string[];
11 | socialInfo?: any;
12 | }
13 |
14 | interface ParticleAuthResponse {
15 | email?: string;
16 | wallets?: string[];
17 | social?: any;
18 | }
19 |
20 | interface ParticleConnector extends Connector {
21 | request: (args: { method: string; params?: any[] }) => Promise;
22 | }
23 |
24 | interface ParticleAuthHookReturn {
25 | getUserInfo: () => Promise;
26 | isConnected: boolean;
27 | address: string | undefined;
28 | chainId: number | undefined;
29 | chain: Chain | undefined;
30 | connector: ParticleConnector | undefined;
31 | status: 'connected' | 'connecting' | 'reconnecting' | 'disconnected';
32 | }
33 |
34 | export const useParticleAuth = (): ParticleAuthHookReturn => {
35 | const {
36 | address,
37 | chainId,
38 | connector,
39 | isConnected,
40 | chain,
41 | status
42 | } = useAccount();
43 |
44 | const getUserInfo = async (): Promise => {
45 | if (!isConnected || !address || !connector) return null;
46 |
47 | try {
48 | // Cast connector to ParticleConnector to access typed request method
49 | const particleConnector = connector as ParticleConnector;
50 |
51 | // Get user info from the connector with proper typing
52 | const userInfo = await particleConnector.request({
53 | method: 'particle_auth',
54 | params: []
55 | });
56 |
57 | return {
58 | address: address,
59 | email: userInfo?.email,
60 | wallets: userInfo?.wallets || [address],
61 | socialInfo: userInfo?.social
62 | };
63 | } catch (error) {
64 | console.error('Error getting user info:', error);
65 | // If particle_auth fails, return basic wallet info
66 | return {
67 | address: address,
68 | wallets: [address]
69 | };
70 | }
71 | };
72 |
73 | return {
74 | getUserInfo,
75 | isConnected,
76 | address,
77 | chainId,
78 | chain,
79 | connector: connector as ParticleConnector,
80 | status
81 | };
82 | };
--------------------------------------------------------------------------------
/tailwind.config.ts:
--------------------------------------------------------------------------------
1 | import type { Config } from "tailwindcss";
2 |
3 | const config: Config = {
4 | darkMode: ["class"],
5 | content: [
6 | "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
7 | "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
8 | "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
9 | ],
10 | theme: {
11 | extend: {
12 | keyframes: {
13 | 'wave-move-forever': {
14 | '0%': { transform: 'translate3d(-90px,0,0)' },
15 | '100%': { transform: 'translate3d(85px,0,0)' },
16 | },
17 | },
18 | animation: {
19 | 'wave-parallax': 'wave-move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite',
20 | },
21 | backgroundImage: {
22 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
23 | 'gradient-conic': 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))'
24 | },
25 | borderRadius: {
26 | lg: 'var(--radius)',
27 | md: 'calc(var(--radius) - 2px)',
28 | sm: 'calc(var(--radius) - 4px)'
29 | },
30 | colors: {
31 | background: 'hsl(var(--background))',
32 | foreground: 'hsl(var(--foreground))',
33 | card: {
34 | DEFAULT: 'hsl(var(--card))',
35 | foreground: 'hsl(var(--card-foreground))'
36 | },
37 | popover: {
38 | DEFAULT: 'hsl(var(--popover))',
39 | foreground: 'hsl(var(--popover-foreground))'
40 | },
41 | primary: {
42 | DEFAULT: 'hsl(var(--primary))',
43 | foreground: 'hsl(var(--primary-foreground))'
44 | },
45 | secondary: {
46 | DEFAULT: 'hsl(var(--secondary))',
47 | foreground: 'hsl(var(--secondary-foreground))'
48 | },
49 | muted: {
50 | DEFAULT: 'hsl(var(--muted))',
51 | foreground: 'hsl(var(--muted-foreground))'
52 | },
53 | accent: {
54 | DEFAULT: 'hsl(var(--accent))',
55 | foreground: 'hsl(var(--accent-foreground))'
56 | },
57 | destructive: {
58 | DEFAULT: 'hsl(var(--destructive))',
59 | foreground: 'hsl(var(--destructive-foreground))'
60 | },
61 | border: 'hsl(var(--border))',
62 | input: 'hsl(var(--input))',
63 | ring: 'hsl(var(--ring))',
64 | chart: {
65 | '1': 'hsl(var(--chart-1))',
66 | '2': 'hsl(var(--chart-2))',
67 | '3': 'hsl(var(--chart-3))',
68 | '4': 'hsl(var(--chart-4))',
69 | '5': 'hsl(var(--chart-5))'
70 | }
71 | }
72 | }
73 | },
74 | plugins: [require("tailwindcss-animate")],
75 | };
76 | export default config;
77 |
--------------------------------------------------------------------------------
/particle-auth-aa/tailwind.config.ts:
--------------------------------------------------------------------------------
1 | import type { Config } from "tailwindcss";
2 |
3 | const config: Config = {
4 | darkMode: ["class"],
5 | content: [
6 | "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
7 | "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
8 | "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
9 | ],
10 | theme: {
11 | extend: {
12 | keyframes: {
13 | 'wave-move-forever': {
14 | '0%': { transform: 'translate3d(-90px,0,0)' },
15 | '100%': { transform: 'translate3d(85px,0,0)' },
16 | },
17 | },
18 | animation: {
19 | 'wave-parallax': 'wave-move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite',
20 | },
21 | backgroundImage: {
22 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
23 | 'gradient-conic': 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))'
24 | },
25 | borderRadius: {
26 | lg: 'var(--radius)',
27 | md: 'calc(var(--radius) - 2px)',
28 | sm: 'calc(var(--radius) - 4px)'
29 | },
30 | colors: {
31 | background: 'hsl(var(--background))',
32 | foreground: 'hsl(var(--foreground))',
33 | card: {
34 | DEFAULT: 'hsl(var(--card))',
35 | foreground: 'hsl(var(--card-foreground))'
36 | },
37 | popover: {
38 | DEFAULT: 'hsl(var(--popover))',
39 | foreground: 'hsl(var(--popover-foreground))'
40 | },
41 | primary: {
42 | DEFAULT: 'hsl(var(--primary))',
43 | foreground: 'hsl(var(--primary-foreground))'
44 | },
45 | secondary: {
46 | DEFAULT: 'hsl(var(--secondary))',
47 | foreground: 'hsl(var(--secondary-foreground))'
48 | },
49 | muted: {
50 | DEFAULT: 'hsl(var(--muted))',
51 | foreground: 'hsl(var(--muted-foreground))'
52 | },
53 | accent: {
54 | DEFAULT: 'hsl(var(--accent))',
55 | foreground: 'hsl(var(--accent-foreground))'
56 | },
57 | destructive: {
58 | DEFAULT: 'hsl(var(--destructive))',
59 | foreground: 'hsl(var(--destructive-foreground))'
60 | },
61 | border: 'hsl(var(--border))',
62 | input: 'hsl(var(--input))',
63 | ring: 'hsl(var(--ring))',
64 | chart: {
65 | '1': 'hsl(var(--chart-1))',
66 | '2': 'hsl(var(--chart-2))',
67 | '3': 'hsl(var(--chart-3))',
68 | '4': 'hsl(var(--chart-4))',
69 | '5': 'hsl(var(--chart-5))'
70 | }
71 | }
72 | }
73 | },
74 | plugins: [require("tailwindcss-animate")],
75 | };
76 | export default config;
77 |
--------------------------------------------------------------------------------
/starknetNethermind/my_project/Scarb.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pulsetrade"
3 | version = "0.1.0"
4 | edition = "2024_07"
5 |
6 | # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html
7 |
8 | [dependencies]
9 | starknet = "2.9.1"
10 |
11 | [dev-dependencies]
12 | snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.34.0" }
13 | assert_macros = "2.9.1"
14 |
15 | [[target.starknet-contract]]
16 | sierra = true
17 |
18 | [scripts]
19 | test = "snforge test"
20 |
21 | # Visit https://foundry-rs.github.io/starknet-foundry/appendix/scarb-toml.html for more information
22 |
23 | # [tool.snforge] # Define `snforge` tool section
24 | # exit_first = true # Stop tests execution immediately upon the first failure
25 | # fuzzer_runs = 1234 # Number of runs of the random fuzzer
26 | # fuzzer_seed = 1111 # Seed for the random fuzzer
27 |
28 | # [[tool.snforge.fork]] # Used for fork testing
29 | # name = "SOME_NAME" # Fork name
30 | # url = "http://your.rpc.url" # Url of the RPC provider
31 | # block_id.tag = "latest" # Block to fork from (block tag)
32 |
33 | # [[tool.snforge.fork]]
34 | # name = "SOME_SECOND_NAME"
35 | # url = "http://your.second.rpc.url"
36 | # block_id.number = "123" # Block to fork from (block number)
37 |
38 | # [[tool.snforge.fork]]
39 | # name = "SOME_THIRD_NAME"
40 | # url = "http://your.third.rpc.url"
41 | # block_id.hash = "0x123" # Block to fork from (block hash)
42 |
43 | # [profile.dev.cairo] # Configure Cairo compiler
44 | # unstable-add-statements-code-locations-debug-info = true # Should be used if you want to use coverage
45 | # unstable-add-statements-functions-debug-info = true # Should be used if you want to use coverage/profiler
46 | # inlining-strategy = "avoid" # Should be used if you want to use coverage
47 |
48 | # [features] # Used for conditional compilation
49 | # enable_for_tests = [] # Feature name and list of other features that should be enabled with it
50 |
--------------------------------------------------------------------------------
/src/components/ai-chat/Welcome.tsx:
--------------------------------------------------------------------------------
1 | import { Card, CardContent } from '@/components/ui/card';
2 | import { Button } from '@/components/ui/button';
3 | import Image from 'next/image';
4 | import { useState } from 'react';
5 | import { AIInputCard } from './InputCard';
6 |
7 | const chatInstructions = [
8 | "Ask about market analysis and trading insights",
9 | "Get real-time price information using (S:SYMBOL) format",
10 | "Analyze multiple assets by comparing different symbols",
11 | "Request technical analysis with specific indicators",
12 | "Get trade suggestions with stop loss and take profit levels"
13 | ];
14 |
15 | export interface AIWelcomeProps {
16 | onClose: () => void;
17 | onSendMessage: (message: string) => Promise;
18 | }
19 |
20 | export const AIWelcome = ({ onClose, onSendMessage }: AIWelcomeProps) => {
21 | const [showInput, setShowInput] = useState(false);
22 |
23 | const handleStartChat = () => {
24 | setShowInput(true);
25 | onClose();
26 | };
27 |
28 | return (
29 |
30 |
31 |
37 |
38 |
39 |
Welcome to TradeLLM Assistant
40 |
41 | I'm here to help you with market analysis and trading insights.
42 |
43 |
44 |
45 |
46 | How to interact with me:
47 |
48 | {chatInstructions.map((instruction, index) => (
49 | -
50 | •
51 | {instruction}
52 |
53 | ))}
54 |
55 |
56 |
57 |
58 | {!showInput ? (
59 |
65 | ) : (
66 |
72 | )}
73 |
74 | );
75 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ai-chat/Welcome.tsx:
--------------------------------------------------------------------------------
1 | import { Card, CardContent } from '@/components/ui/card';
2 | import { Button } from '@/components/ui/button';
3 | import Image from 'next/image';
4 | import { useState } from 'react';
5 | import { AIInputCard } from './InputCard';
6 |
7 | const chatInstructions = [
8 | "Ask about market analysis and trading insights",
9 | "Get real-time price information using (S:SYMBOL) format",
10 | "Analyze multiple assets by comparing different symbols",
11 | "Request technical analysis with specific indicators",
12 | "Get trade suggestions with stop loss and take profit levels"
13 | ];
14 |
15 | export interface AIWelcomeProps {
16 | onClose: () => void;
17 | onSendMessage: (message: string) => Promise;
18 | }
19 |
20 | export const AIWelcome = ({ onClose, onSendMessage }: AIWelcomeProps) => {
21 | const [showInput, setShowInput] = useState(false);
22 |
23 | const handleStartChat = () => {
24 | setShowInput(true);
25 | onClose();
26 | };
27 |
28 | return (
29 |
30 |
31 |
37 |
38 |
39 |
Welcome to TradeLLM Assistant
40 |
41 | I'm here to help you with market analysis and trading insights.
42 |
43 |
44 |
45 |
46 | How to interact with me:
47 |
48 | {chatInstructions.map((instruction, index) => (
49 | -
50 | •
51 | {instruction}
52 |
53 | ))}
54 |
55 |
56 |
57 |
58 | {!showInput ? (
59 |
65 | ) : (
66 |
72 | )}
73 |
74 | );
75 | };
--------------------------------------------------------------------------------
/koii/task-template/.env.local.example:
--------------------------------------------------------------------------------
1 | ######################################################
2 | ################## DO NOT EDIT BELOW #################
3 | ######################################################
4 | # Location of main wallet Do not change this, it mounts the ~/.config/koii:/app/config if you want to change, update it in the docker-compose.yml
5 | WALLET_LOCATION="/app/config/id.json"
6 | # Node Mode
7 | NODE_MODE="service"
8 | # The nodes address
9 | SERVICE_URL="http://localhost:8080"
10 | # Intial balance for the distribution wallet which will be used to hold the distribution list.
11 | INITIAL_DISTRIBUTION_WALLET_BALANCE= 2
12 | # Global timers which track the round time, submission window and audit window and call those functions
13 | GLOBAL_TIMERS="true"
14 | # HAVE_STATIC_IP is flag to indicate you can run tasks that host APIs
15 | # HAVE_STATIC_IP=true
16 | # To be used when developing your tasks locally and don't want them to be whitelisted by koii team yet
17 | RUN_NON_WHITELISTED_TASKS=true
18 | # The address of the main trusted node
19 | # TRUSTED_SERVICE_URL="https://k2-tasknet.koii.live"
20 | ######################################################
21 | ################ DO NOT EDIT ABOVE ###################
22 | ######################################################
23 |
24 |
25 | ######################################################
26 | ## DO NOT PUT YOUR KEYS ON GITHUB!!!
27 | ## To set up your environment variables:
28 | ## - Copy `.env-local.example` to a new file named `.env-local`.
29 | ## - Fill in the necessary values in `.env-local`.
30 | #######################################################
31 |
32 | # For the purpose of automating the staking wallet creation, the value must be greater
33 | # than the sum of all TASK_STAKES, the wallet will only be created and staking on task
34 | # will be done if it doesn't already exist
35 | INITIAL_STAKING_WALLET_BALANCE=10
36 |
37 | # environment
38 | ENVIRONMENT="development"
39 |
40 | # If you are running a koii-test-validator use http://127.0.0.1:8899 (linux) otherwise use http://host.docker.internal:8899 for Mac and Windows
41 | # Location of K2 node
42 | K2_NODE_URL="https://testnet.koii.live"
43 |
44 | # Tasks to run and their stakes. This is the varaible you can add your Task ID to after
45 | # registering with the crete-task-cli. This variable supports a comma separated list:
46 | # TASKS="id1,id2,id3"
47 | # TASK_STAKES="1,1,1"
48 | TASKS="AXcd6MctmDUQo3XDeBNa4NBAi4tfBYDpt4Adxyai3Do3"
49 | TASK_STAKES=5
50 |
51 | # User can enter as many environment variables as they like below. These can be task
52 | # specific variables that are needed for the task to perform it's job. Some examples:
53 | SCRAPING_URL=""
54 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 | .pnpm-debug.log*
9 |
10 | # Diagnostic reports (https://nodejs.org/api/report.html)
11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12 |
13 | # Runtime data
14 | pids
15 | *.pid
16 | *.seed
17 | *.pid.lock
18 |
19 | # Directory for instrumented libs generated by jscoverage/JSCover
20 | lib-cov
21 |
22 | # Coverage directory used by tools like istanbul
23 | coverage
24 | *.lcov
25 |
26 | # nyc test coverage
27 | .nyc_output
28 |
29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30 | .grunt
31 |
32 | # Bower dependency directory (https://bower.io/)
33 | bower_components
34 |
35 | # node-waf configuration
36 | .lock-wscript
37 |
38 | # Compiled binary addons (https://nodejs.org/api/addons.html)
39 | build/Release
40 |
41 | # Dependency directories
42 | node_modules/
43 | jspm_packages/
44 |
45 | # Snowpack dependency directory (https://snowpack.dev/)
46 | web_modules/
47 |
48 | # TypeScript cache
49 | *.tsbuildinfo
50 |
51 | # Optional npm cache directory
52 | .npm
53 |
54 | # Optional eslint cache
55 | .eslintcache
56 |
57 | # Optional stylelint cache
58 | .stylelintcache
59 |
60 | # Microbundle cache
61 | .rpt2_cache/
62 | .rts2_cache_cjs/
63 | .rts2_cache_es/
64 | .rts2_cache_umd/
65 |
66 | # Optional REPL history
67 | .node_repl_history
68 |
69 | # Output of 'npm pack'
70 | *.tgz
71 |
72 | # Yarn Integrity file
73 | .yarn-integrity
74 |
75 | # dotenv environment variable files
76 | .env
77 | .env.development.local
78 | .env.test.local
79 | .env.production.local
80 | .env.local
81 |
82 | # parcel-bundler cache (https://parceljs.org/)
83 | .cache
84 | .parcel-cache
85 |
86 | # Next.js build output
87 | .next
88 | out
89 |
90 | # Nuxt.js build / generate output
91 | .nuxt
92 | dist
93 |
94 | # Gatsby files
95 | .cache/
96 | # Comment in the public line in if your project uses Gatsby and not Next.js
97 | # https://nextjs.org/blog/next-9-1#public-directory-support
98 | # public
99 |
100 | # vuepress build output
101 | .vuepress/dist
102 |
103 | # vuepress v2.x temp and cache directory
104 | .temp
105 | .cache
106 |
107 | # Docusaurus cache and generated files
108 | .docusaurus
109 |
110 | # Serverless directories
111 | .serverless/
112 |
113 | # FuseBox cache
114 | .fusebox/
115 |
116 | # DynamoDB Local files
117 | .dynamodb/
118 |
119 | # TernJS port file
120 | .tern-port
121 |
122 | # Stores VSCode versions used for testing VSCode extensions
123 | .vscode-test
124 |
125 | # yarn v2
126 | .yarn/cache
127 | .yarn/unplugged
128 | .yarn/build-state.yml
129 | .yarn/install-state.gz
130 | .pnp.*
131 |
--------------------------------------------------------------------------------
/tradeLLM/Test Prompts.md:
--------------------------------------------------------------------------------
1 | Here are a variety of prompts to test the LLM's ability to act as a professional, experienced trader:
2 |
3 | ---
4 |
5 | ### **Technical Analysis**
6 | 1. "Analyze the chart pattern of Tesla (TSLA) and suggest possible support and resistance levels. Explain your reasoning."
7 | 2. "Identify and explain three technical indicators that would signal a potential bullish reversal for Apple (AAPL)."
8 |
9 | ### **Fundamental Analysis**
10 | 3. "Evaluate Amazon's (AMZN) recent earnings report and provide insights on how it might impact its stock price."
11 | 4. "How would a 0.5% interest rate hike by the Federal Reserve impact the equity and forex markets? Provide specific examples."
12 |
13 | ### **Risk Management**
14 | 5. "Explain how a trader could use position sizing to limit risk in a volatile market."
15 | 6. "Design a risk management plan for a $100,000 trading portfolio focusing on forex markets."
16 |
17 | ### **Market News & Interpretation**
18 | 7. "Oil prices have surged by 10% in the past week due to geopolitical tensions. What are the likely impacts on stock indices and currency pairs?"
19 | 8. "If a major tech company announces a groundbreaking AI innovation, how could it influence sector-wide market sentiment?"
20 |
21 | ### **Trading Strategies**
22 | 9. "Describe a swing trading strategy for gold (XAU/USD) in the current market environment."
23 | 10. "Explain how a trader could use a straddle options strategy to profit from an upcoming earnings report."
24 |
25 | ### **Forex and Commodities**
26 | 11. "Analyze the EUR/USD currency pair and suggest a trading plan based on current macroeconomic data."
27 | 12. "What factors influence the price of crude oil, and how can traders anticipate significant price movements?"
28 |
29 | ### **Scenario Analysis**
30 | 13. "Suppose the S&P 500 drops by 3% in a single trading session. What are the possible reasons, and how should a trader react?"
31 | 14. "A major central bank is considering adopting cryptocurrency as legal tender. What could be the short-term and long-term effects on crypto markets?"
32 |
33 | ### **Education and Knowledge Testing**
34 | 15. "What is the difference between market orders and limit orders? Provide examples of when to use each."
35 | 16. "Explain how the Fibonacci retracement tool works and how it is applied in technical trading."
36 |
37 | ### **Ethics and Caution**
38 | 17. "A client asks for advice on an all-in bet on a speculative penny stock. How would you advise them while promoting ethical trading practices?"
39 | 18. "What precautions should new traders take when trading in highly leveraged markets like forex or futures?"
40 |
41 | ---
42 |
43 | These prompts assess various aspects of the LLM's knowledge and its ability to provide comprehensive, responsible, and nuanced trading-related responses.
--------------------------------------------------------------------------------
/src/lib/hooks/useDataProtectioon.ts:
--------------------------------------------------------------------------------
1 | import { useState } from 'react';
2 | import { IExecDataProtector } from '@iexec/dataprotector';
3 | import { checkIsConnected, checkCurrentChain } from '@/lib/utils';
4 |
5 | interface DataProtectionError {
6 | message: string;
7 | code?: string | number;
8 | }
9 |
10 | export const useDataProtection = () => {
11 | const [loading, setLoading] = useState(false);
12 | const [error, setError] = useState(null);
13 | const [protectedData, setProtectedData] = useState('');
14 |
15 | const handleError = (err: unknown): string => {
16 | if (err instanceof Error) {
17 | return err.message;
18 | }
19 | if (typeof err === 'object' && err !== null && 'message' in err) {
20 | return (err as DataProtectionError).message;
21 | }
22 | return 'An unknown error occurred';
23 | };
24 |
25 | const protectUserData = async (userEmail: string) => {
26 | setError(null);
27 | setLoading(true);
28 |
29 | try {
30 | // Check connection and chain as shown in the example
31 | checkIsConnected();
32 | await checkCurrentChain();
33 |
34 | const iExecDataProtector = new IExecDataProtector(window.ethereum);
35 |
36 | // Following the provided example's data protection format
37 | const data = { email: userEmail };
38 | const protectedDataResponse = await iExecDataProtector.core.protectData({
39 | data,
40 | name: `Protected email for ${userEmail}`,
41 | });
42 |
43 | setProtectedData(protectedDataResponse.address);
44 | return protectedDataResponse.address;
45 |
46 | } catch (err: unknown) {
47 | const errorMessage = handleError(err);
48 | setError(errorMessage);
49 | throw new Error(errorMessage);
50 | } finally {
51 | setLoading(false);
52 | }
53 | };
54 |
55 | const grantAccess = async (protectedDataAddress: string, recipientAddress: string) => {
56 | setError(null);
57 | setLoading(true);
58 |
59 | try {
60 | checkIsConnected();
61 | await checkCurrentChain();
62 |
63 | const iExecDataProtector = new IExecDataProtector(window.ethereum);
64 |
65 | await iExecDataProtector.core.grantAccess({
66 | protectedData: protectedDataAddress,
67 | authorizedUser: recipientAddress,
68 | authorizedApp: 'web3mail.apps.iexec.eth',
69 | numberOfAccess: 1,
70 | });
71 |
72 | } catch (err: unknown) {
73 | const errorMessage = handleError(err);
74 | setError(errorMessage);
75 | throw new Error(errorMessage);
76 | } finally {
77 | setLoading(false);
78 | }
79 | };
80 |
81 | return {
82 | protectUserData,
83 | grantAccess,
84 | protectedData,
85 | loading,
86 | error,
87 | };
88 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/hooks/useDataProtectioon.ts:
--------------------------------------------------------------------------------
1 | import { useState } from 'react';
2 | import { IExecDataProtector } from '@iexec/dataprotector';
3 | import { checkIsConnected, checkCurrentChain } from '@/lib/utils';
4 |
5 | interface DataProtectionError {
6 | message: string;
7 | code?: string | number;
8 | }
9 |
10 | export const useDataProtection = () => {
11 | const [loading, setLoading] = useState(false);
12 | const [error, setError] = useState(null);
13 | const [protectedData, setProtectedData] = useState('');
14 |
15 | const handleError = (err: unknown): string => {
16 | if (err instanceof Error) {
17 | return err.message;
18 | }
19 | if (typeof err === 'object' && err !== null && 'message' in err) {
20 | return (err as DataProtectionError).message;
21 | }
22 | return 'An unknown error occurred';
23 | };
24 |
25 | const protectUserData = async (userEmail: string) => {
26 | setError(null);
27 | setLoading(true);
28 |
29 | try {
30 | // Check connection and chain as shown in the example
31 | checkIsConnected();
32 | await checkCurrentChain();
33 |
34 | const iExecDataProtector = new IExecDataProtector(window.ethereum);
35 |
36 | // Following the provided example's data protection format
37 | const data = { email: userEmail };
38 | const protectedDataResponse = await iExecDataProtector.core.protectData({
39 | data,
40 | name: `Protected email for ${userEmail}`,
41 | });
42 |
43 | setProtectedData(protectedDataResponse.address);
44 | return protectedDataResponse.address;
45 |
46 | } catch (err: unknown) {
47 | const errorMessage = handleError(err);
48 | setError(errorMessage);
49 | throw new Error(errorMessage);
50 | } finally {
51 | setLoading(false);
52 | }
53 | };
54 |
55 | const grantAccess = async (protectedDataAddress: string, recipientAddress: string) => {
56 | setError(null);
57 | setLoading(true);
58 |
59 | try {
60 | checkIsConnected();
61 | await checkCurrentChain();
62 |
63 | const iExecDataProtector = new IExecDataProtector(window.ethereum);
64 |
65 | await iExecDataProtector.core.grantAccess({
66 | protectedData: protectedDataAddress,
67 | authorizedUser: recipientAddress,
68 | authorizedApp: 'web3mail.apps.iexec.eth',
69 | numberOfAccess: 1,
70 | });
71 |
72 | } catch (err: unknown) {
73 | const errorMessage = handleError(err);
74 | setError(errorMessage);
75 | throw new Error(errorMessage);
76 | } finally {
77 | setLoading(false);
78 | }
79 | };
80 |
81 | return {
82 | protectUserData,
83 | grantAccess,
84 | protectedData,
85 | loading,
86 | error,
87 | };
88 | };
--------------------------------------------------------------------------------
/koii/task-template/src/task/4-distribution.js:
--------------------------------------------------------------------------------
1 | // Define the percentage by which to slash the stake of submitters who submitted incorrect values
2 | // 0.7 = 70%
3 | const SLASH_PERCENT = 0.7;
4 |
5 | export function distribution(submitters, bounty, roundNumber) {
6 | /**
7 | * Generate the reward list for a given round
8 | * This function should return an object with the public keys of the submitters as keys
9 | * and the reward amount as values
10 | *
11 | * IMPORTANT: If the slashedStake or reward is not an integer, the distribution list will be rejected
12 | * Values are in ROE, or the KPL equivalent (1 Token = 10^9 ROE)
13 | *
14 | */
15 | console.log(`MAKE DISTRIBUTION LIST FOR ROUND ${roundNumber}`);
16 |
17 | // Initialize an empty object to store the final distribution list
18 | const distributionList = {};
19 |
20 | // Initialize an empty array to store the public keys of submitters with correct values
21 | const approvedSubmitters = [];
22 |
23 | // Iterate through the list of submitters and handle each one
24 | for (const submitter of submitters) {
25 | // If the submitter's votes are 0, they do not get any reward
26 | if (submitter.votes === 0) {
27 | distributionList[submitter.publicKey] = 0;
28 |
29 | // If the submitter's votes are negative (submitted incorrect values), slash their stake
30 | } else if (submitter.votes < 0) {
31 | // Slash the submitter's stake by the defined percentage
32 | const slashedStake = Math.floor(submitter.stake * SLASH_PERCENT);
33 | // Add the slashed amount to the distribution list
34 | // since the stake is positive, we use a negative value to indicate a slash
35 | distributionList[submitter.publicKey] = -slashedStake;
36 |
37 | // Log that the submitter's stake has been slashed
38 | console.log("CANDIDATE STAKE SLASHED", submitter.publicKey, slashedStake);
39 |
40 | // If the submitter's votes are positive, add their public key to the approved submitters list
41 | } else {
42 | approvedSubmitters.push(submitter.publicKey);
43 | }
44 | }
45 |
46 | // If no submitters submitted correct values, return the current distribution list
47 | if (approvedSubmitters.length === 0) {
48 | console.log("NO NODES TO REWARD");
49 | return distributionList;
50 | }
51 |
52 | // Calculate the reward for each approved submitter by dividing the bounty per round equally among them
53 | const reward = Math.floor(bounty / approvedSubmitters.length);
54 |
55 | console.log("REWARD PER NODE", reward);
56 |
57 | // Assign the calculated reward to each approved submitter
58 | approvedSubmitters.forEach((candidate) => {
59 | distributionList[candidate] = reward;
60 | });
61 |
62 | // Return the final distribution list
63 | return distributionList;
64 | }
65 |
--------------------------------------------------------------------------------
/src/lib/mockData.ts:
--------------------------------------------------------------------------------
1 | import { addDoc, collection } from 'firebase/firestore';
2 | import { db } from '../../firebase.config';
3 |
4 |
5 | export async function seedMockData(currentUserAddress: string) {
6 | // Mock participants
7 | const mockParticipants = [
8 | {
9 | address: currentUserAddress,
10 | isWeb3MailEnabled: false,
11 | createdAt: Date.now(),
12 | lastSeen: Date.now()
13 | },
14 | {
15 | address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
16 | isWeb3MailEnabled: true,
17 | createdAt: Date.now(),
18 | lastSeen: Date.now()
19 | },
20 | {
21 | address: '0x123d35Cc6634C0532925a3b844Bc454e4438f789',
22 | isWeb3MailEnabled: false,
23 | createdAt: Date.now(),
24 | lastSeen: Date.now()
25 | }
26 | ];
27 |
28 | try {
29 | // Create an individual chat
30 | const individualChat = await addDoc(collection(db, 'chats'), {
31 | participants: [mockParticipants[0], mockParticipants[1]],
32 | type: 'individual',
33 | createdAt: Date.now(),
34 | updatedAt: Date.now(),
35 | unreadCount: {
36 | [mockParticipants[0].address]: 0,
37 | [mockParticipants[1].address]: 0
38 | }
39 | });
40 |
41 | // Create a group chat
42 | const groupChat = await addDoc(collection(db, 'chats'), {
43 | participants: mockParticipants,
44 | type: 'group',
45 | name: 'Test Group Chat',
46 | createdAt: Date.now(),
47 | updatedAt: Date.now(),
48 | unreadCount: {
49 | [mockParticipants[0].address]: 0,
50 | [mockParticipants[1].address]: 0,
51 | [mockParticipants[2].address]: 0
52 | }
53 | });
54 |
55 | // Add mock messages to individual chat
56 | const mockMessages = [
57 | {
58 | chatId: individualChat.id,
59 | content: 'Hey, how are you?',
60 | senderId: currentUserAddress,
61 | timestamp: Date.now() - 100000,
62 | isWeb3Mail: false
63 | },
64 | {
65 | chatId: individualChat.id,
66 | content: `I'm doing great, thanks for asking!`,
67 | senderId: mockParticipants[1].address,
68 | timestamp: Date.now() - 50000,
69 | isWeb3Mail: true
70 | },
71 | {
72 | chatId: individualChat.id,
73 | content: 'Would you like to discuss the new project?',
74 | senderId: currentUserAddress,
75 | timestamp: Date.now(),
76 | isWeb3Mail: false
77 | }
78 | ];
79 |
80 | // Add messages to database
81 | for (const message of mockMessages) {
82 | await addDoc(collection(db, 'messages'), message);
83 | }
84 |
85 | return {
86 | individualChatId: individualChat.id,
87 | groupChatId: groupChat.id
88 | };
89 | } catch (error) {
90 | console.error('Error seeding mock data:', error);
91 | throw error;
92 | }
93 | }
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/mockData.ts:
--------------------------------------------------------------------------------
1 | import { addDoc, collection } from 'firebase/firestore';
2 | import { db } from '../../firebase.config';
3 |
4 |
5 | export async function seedMockData(currentUserAddress: string) {
6 | // Mock participants
7 | const mockParticipants = [
8 | {
9 | address: currentUserAddress,
10 | isWeb3MailEnabled: false,
11 | createdAt: Date.now(),
12 | lastSeen: Date.now()
13 | },
14 | {
15 | address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
16 | isWeb3MailEnabled: true,
17 | createdAt: Date.now(),
18 | lastSeen: Date.now()
19 | },
20 | {
21 | address: '0x123d35Cc6634C0532925a3b844Bc454e4438f789',
22 | isWeb3MailEnabled: false,
23 | createdAt: Date.now(),
24 | lastSeen: Date.now()
25 | }
26 | ];
27 |
28 | try {
29 | // Create an individual chat
30 | const individualChat = await addDoc(collection(db, 'chats'), {
31 | participants: [mockParticipants[0], mockParticipants[1]],
32 | type: 'individual',
33 | createdAt: Date.now(),
34 | updatedAt: Date.now(),
35 | unreadCount: {
36 | [mockParticipants[0].address]: 0,
37 | [mockParticipants[1].address]: 0
38 | }
39 | });
40 |
41 | // Create a group chat
42 | const groupChat = await addDoc(collection(db, 'chats'), {
43 | participants: mockParticipants,
44 | type: 'group',
45 | name: 'Test Group Chat',
46 | createdAt: Date.now(),
47 | updatedAt: Date.now(),
48 | unreadCount: {
49 | [mockParticipants[0].address]: 0,
50 | [mockParticipants[1].address]: 0,
51 | [mockParticipants[2].address]: 0
52 | }
53 | });
54 |
55 | // Add mock messages to individual chat
56 | const mockMessages = [
57 | {
58 | chatId: individualChat.id,
59 | content: 'Hey, how are you?',
60 | senderId: currentUserAddress,
61 | timestamp: Date.now() - 100000,
62 | isWeb3Mail: false
63 | },
64 | {
65 | chatId: individualChat.id,
66 | content: `I'm doing great, thanks for asking!`,
67 | senderId: mockParticipants[1].address,
68 | timestamp: Date.now() - 50000,
69 | isWeb3Mail: true
70 | },
71 | {
72 | chatId: individualChat.id,
73 | content: 'Would you like to discuss the new project?',
74 | senderId: currentUserAddress,
75 | timestamp: Date.now(),
76 | isWeb3Mail: false
77 | }
78 | ];
79 |
80 | // Add messages to database
81 | for (const message of mockMessages) {
82 | await addDoc(collection(db, 'messages'), message);
83 | }
84 |
85 | return {
86 | individualChatId: individualChat.id,
87 | groupChatId: groupChat.id
88 | };
89 | } catch (error) {
90 | console.error('Error seeding mock data:', error);
91 | throw error;
92 | }
93 | }
--------------------------------------------------------------------------------
/koii/task-template/tests/simulateTask.js:
--------------------------------------------------------------------------------
1 | import { taskRunner } from "@_koii/task-manager";
2 |
3 | import "../src/index.js";
4 | import { namespaceWrapper } from "@_koii/namespace-wrapper";
5 |
6 | const numRounds = process.argv[2] || 1;
7 | const roundDelay = process.argv[3] || 5000;
8 | const functionDelay = process.argv[4] || 1000;
9 |
10 | let TASK_TIMES = [];
11 | let SUBMISSION_TIMES = [];
12 | let AUDIT_TIMES = [];
13 |
14 | function sleep(ms) {
15 | return new Promise((resolve) => setTimeout(resolve, ms));
16 | }
17 | await namespaceWrapper.stakeOnChain();
18 | async function executeTasks() {
19 | for (let round = 0; round < numRounds; round++) {
20 | const taskStartTime = Date.now();
21 | await taskRunner.task(round);
22 | const taskEndTime = Date.now();
23 | TASK_TIMES.push(taskEndTime - taskStartTime);
24 | await sleep(functionDelay);
25 |
26 | const taskSubmissionStartTime = Date.now();
27 | await taskRunner.submitTask(round);
28 | const taskSubmissionEndTime = Date.now();
29 | SUBMISSION_TIMES.push(taskSubmissionEndTime - taskSubmissionStartTime);
30 | await sleep(functionDelay);
31 |
32 | const auditStartTime = Date.now();
33 | await taskRunner.auditTask(round);
34 | const auditEndTime = Date.now();
35 | AUDIT_TIMES.push(auditEndTime - auditStartTime);
36 | await sleep(functionDelay);
37 |
38 | await taskRunner.selectAndGenerateDistributionList(round);
39 | await sleep(functionDelay);
40 |
41 | await taskRunner.auditDistribution(round);
42 |
43 | if (round < numRounds - 1) {
44 | await sleep(roundDelay);
45 | }
46 | }
47 | console.log("TIME METRICS BELOW");
48 | function metrics(name, times) {
49 | const average = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
50 | const formatTime = (ms) => (ms / 1000).toFixed(4);
51 | const formatSlot = (ms) => Math.ceil(ms / 408);
52 | const min = Math.min(...times);
53 | const max = Math.max(...times);
54 | const avg = average(times);
55 | const timeMin = formatTime(min);
56 | const timeMax = formatTime(max);
57 | const timeAvg = formatTime(avg);
58 | const slotMin = formatSlot(min);
59 | const slotMax = formatSlot(max);
60 | const slotAvg = formatSlot(avg);
61 |
62 | return {
63 | Metric: `SIMULATED ${name} WINDOW`,
64 | "Avg Time (s)": timeAvg,
65 | "Avg Slots": slotAvg,
66 | "Min Time (s)": timeMin,
67 | "Min Slots": slotMin,
68 | "Max Time (s)": timeMax,
69 | "Max Slots": slotMax,
70 | };
71 | }
72 | const timeMetrics = metrics("TASK", TASK_TIMES);
73 | const submissionMetrics = metrics("SUBMISSION", SUBMISSION_TIMES);
74 | const auditMetrics = metrics("AUDIT", AUDIT_TIMES);
75 |
76 | console.table([timeMetrics, submissionMetrics, auditMetrics]);
77 |
78 | console.log("All tasks executed. Test completed.");
79 | process.exit(0);
80 | }
81 | setTimeout(executeTasks, 1500);
82 |
--------------------------------------------------------------------------------
/tradeLLM/utils/marketDataValidator.js:
--------------------------------------------------------------------------------
1 | class MarketDataValidator {
2 | static validateQuote(quote) {
3 | const requiredFields = [
4 | 'symbol',
5 | 'price',
6 | 'timestamp'
7 | ];
8 |
9 | const numericFields = [
10 | 'price',
11 | 'change',
12 | 'changePercent',
13 | 'volume',
14 | 'high',
15 | 'low',
16 | 'open',
17 | 'close',
18 | ];
19 |
20 | // Check required fields
21 | for (const field of requiredFields) {
22 | if (!quote[field]) {
23 | throw new Error(`Missing required field: ${field}`);
24 | }
25 | }
26 |
27 | // Validate numeric fields
28 | for (const field of numericFields) {
29 | if (quote[field] && (isNaN(quote[field]) || !isFinite(quote[field]))) {
30 | throw new Error(`Invalid numeric value for field: ${field}`);
31 | }
32 | }
33 |
34 | // Validate timestamp
35 | if (!Date.parse(quote.timestamp)) {
36 | throw new Error('Invalid timestamp format');
37 | }
38 |
39 | return true;
40 | }
41 |
42 | static validateOHLCV(data) {
43 | if (!Array.isArray(data)) {
44 | throw new Error('OHLCV data must be an array');
45 | }
46 |
47 | const requiredFields = ['timestamp', 'open', 'high', 'low', 'close', 'volume'];
48 |
49 | data.forEach((candle, index) => {
50 | // Check required fields
51 | for (const field of requiredFields) {
52 | if (!candle[field]) {
53 | throw new Error(`Missing required field ${field} at index ${index}`);
54 | }
55 | }
56 |
57 | // Validate numeric values
58 | if (candle.high < candle.low) {
59 | throw new Error(`Invalid high/low values at index ${index}`);
60 | }
61 |
62 | if (candle.open > candle.high || candle.open < candle.low) {
63 | throw new Error(`Invalid open price at index ${index}`);
64 | }
65 |
66 | if (candle.close > candle.high || candle.close < candle.low) {
67 | throw new Error(`Invalid close price at index ${index}`);
68 | }
69 |
70 | if (candle.volume < 0) {
71 | throw new Error(`Invalid volume at index ${index}`);
72 | }
73 | });
74 |
75 | return true;
76 | }
77 |
78 | static validateTimeRange(startTime, endTime) {
79 | const start = new Date(startTime);
80 | const end = new Date(endTime);
81 |
82 | if (isNaN(start.getTime())) {
83 | throw new Error('Invalid start time');
84 | }
85 |
86 | if (isNaN(end.getTime())) {
87 | throw new Error('Invalid end time');
88 | }
89 |
90 | if (end < start) {
91 | throw new Error('End time must be after start time');
92 | }
93 |
94 | return true;
95 | }
96 | }
97 |
98 | module.exports = MarketDataValidator;
--------------------------------------------------------------------------------
/koii/task-template/error.txt:
--------------------------------------------------------------------------------
1 | error C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@tensorflow\tfjs-node: Command failed.
2 | Exit code: 1
3 | Command: node scripts/install.js
4 | Arguments:
5 | Directory: C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@tensorflow\tfjs-node
6 | Output:
7 | CPU-windows-4.22.0.zip
8 | * Downloading libtensorflow
9 | https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.9.1.zip
10 |
11 | * Building TensorFlow Node.js bindings
12 | node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
13 | node-pre-gyp info it worked if it ends with ok
14 | node-pre-gyp info using node-pre-gyp@1.0.9
15 | node-pre-gyp info using node@22.7.0 | win32 | x64
16 | (node:29192) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
17 | (Use `node --trace-deprecation ...` to show where the warning was created)
18 | node-pre-gyp info check checked for "C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node" (not found)
19 | node-pre-gyp http GET https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.22.0/CPU-windows-4.22.0.zip
20 | node-pre-gyp ERR! install response status 404 Not Found on https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.22.0/CPU-windows-4.22.0.zip
21 | node-pre-gyp WARN Pre-built binaries not installable for @tensorflow/tfjs-node@4.22.0 and node@22.7.0 (node-v127 ABI, unknown) (falling back to source compile with node-gyp)
22 | node-pre-gyp WARN Hit error response status 404 Not Found on https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/4.22.0/CPU-windows-4.22.0.zip
23 | node-pre-gyp ERR! UNCAUGHT EXCEPTION
24 | node-pre-gyp ERR! stack Error: spawn EINVAL
25 | node-pre-gyp ERR! stack at ChildProcess.spawn (node:internal/child_process:421:11)
26 | node-pre-gyp ERR! stack at Object.spawn (node:child_process:761:9)
27 | node-pre-gyp ERR! stack at module.exports.run_gyp (C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:80:18)
28 | node-pre-gyp ERR! stack at build (C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@mapbox\node-pre-gyp\lib\build.js:41:13)
29 | node-pre-gyp ERR! stack at self.commands. [as build] (C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@mapbox\node-pre-gyp\lib\node-pre-gyp.js:86:37)
30 | node-pre-gyp ERR! stack at run (C:\Users\patri\Desktop\HACKERTHON\task-template\node_modules\@mapbox\node-pre-gyp\lib\main.js:81:30)
31 | node-pre-gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:85:11)
32 | node-pre-gyp ERR! System Windows_NT 10.0.26100
33 | node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\patri\\Desktop\\HACKERTHON\\task-template\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
--------------------------------------------------------------------------------
/src/components/Links.tsx:
--------------------------------------------------------------------------------
1 | import Image from "next/image";
2 |
3 | // Link to repository
4 | const repositoryLink = {
5 | href: "https://github.com/soos3d/particle-auth-nextjs-aa",
6 | imgSrc: "/logo.png",
7 | imgAlt: "GitHub Logo",
8 | text: "Check the repository",
9 | };
10 |
11 | // Indicate where the bulk of the code is
12 | const codeText = {
13 | text: "Get started by editing",
14 | code: "src/app/page.tsx",
15 | };
16 |
17 | // Links and descriptions to the particle documentation
18 | const links = [
19 | {
20 | href: "https://developers.particle.network",
21 | title: "Documentation →",
22 | description: "Find in-depth information about AuthCore features and API.",
23 | },
24 | {
25 | href: "https://dashboard.particle.network",
26 | title: "Dashboard →",
27 | description:
28 | "Manage your projects and team, View analytics data, Custom configuration.",
29 | },
30 | {
31 | href: "https://github.com/Particle-Network/particle-web-auth-core",
32 | title: "Examples →",
33 | description: "Discover and deploy boilerplate example AuthCore projects.",
34 | },
35 | {
36 | href: "https://particle.network",
37 | title: "Particle Network →",
38 | description: "The L1 unifying all chains through Universal Accounts.",
39 | },
40 | ];
41 |
42 | // UI component
43 | const LinksGrid = () => {
44 | return (
45 | <>
46 |
63 |
64 | {codeText.text}{" "}
65 |
66 | {codeText.code}
67 |
68 |
69 |
85 |
88 | >
89 | );
90 | };
91 |
92 | export default LinksGrid;
93 |
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/Links.tsx:
--------------------------------------------------------------------------------
1 | import Image from "next/image";
2 |
3 | // Link to repository
4 | const repositoryLink = {
5 | href: "https://github.com/soos3d/particle-auth-nextjs-aa",
6 | imgSrc: "/logo.png",
7 | imgAlt: "GitHub Logo",
8 | text: "Check the repository",
9 | };
10 |
11 | // Indicate where the bulk of the code is
12 | const codeText = {
13 | text: "Get started by editing",
14 | code: "src/app/page.tsx",
15 | };
16 |
17 | // Links and descriptions to the particle documentation
18 | const links = [
19 | {
20 | href: "https://developers.particle.network",
21 | title: "Documentation →",
22 | description: "Find in-depth information about AuthCore features and API.",
23 | },
24 | {
25 | href: "https://dashboard.particle.network",
26 | title: "Dashboard →",
27 | description:
28 | "Manage your projects and team, View analytics data, Custom configuration.",
29 | },
30 | {
31 | href: "https://github.com/Particle-Network/particle-web-auth-core",
32 | title: "Examples →",
33 | description: "Discover and deploy boilerplate example AuthCore projects.",
34 | },
35 | {
36 | href: "https://particle.network",
37 | title: "Particle Network →",
38 | description: "The L1 unifying all chains through Universal Accounts.",
39 | },
40 | ];
41 |
42 | // UI component
43 | const LinksGrid = () => {
44 | return (
45 | <>
46 |
63 |
64 | {codeText.text}{" "}
65 |
66 | {codeText.code}
67 |
68 |
69 |
85 |
88 | >
89 | );
90 | };
91 |
92 | export default LinksGrid;
93 |
--------------------------------------------------------------------------------
/src/components/ai-chat/TradeValues.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 | import { Card, CardContent } from '@/components/ui/card';
3 | import { Button } from '@/components/ui/button';
4 | import { useRouter } from 'next/navigation';
5 |
6 | interface TradeValues {
7 | takeProfit: string;
8 | stopLoss: string;
9 | lotSize: string;
10 | }
11 |
12 | interface TradeValuesCardProps {
13 | values: TradeValues;
14 | onUpdate: (values: TradeValues) => void;
15 | }
16 |
17 | export const TradeValuesCard = ({ values, onUpdate }: TradeValuesCardProps) => {
18 | const router = useRouter();
19 | const [localValues, setLocalValues] = useState(values);
20 |
21 | useEffect(() => {
22 | setLocalValues(values);
23 | }, [values]);
24 |
25 | const handleChange = (field: keyof TradeValues, value: string) => {
26 | const updated = { ...localValues, [field]: value };
27 | setLocalValues(updated);
28 | onUpdate(updated);
29 | };
30 |
31 | const handleExecute = () => {
32 | // Show success notification
33 | alert('Trade executed successfully');
34 | };
35 |
36 | return (
37 |
38 |
39 |
40 |
41 |
42 | handleChange('takeProfit', e.target.value)}
46 | className="border rounded p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
47 | />
48 |
49 |
50 |
51 |
52 | handleChange('stopLoss', e.target.value)}
56 | className="border rounded p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
57 | />
58 |
59 |
60 |
61 |
62 | handleChange('lotSize', e.target.value)}
66 | className="border rounded p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
67 | />
68 |
69 |
70 |
71 |
77 |
84 |
85 |
86 |
87 |
88 | );
89 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ai-chat/TradeValues.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 | import { Card, CardContent } from '@/components/ui/card';
3 | import { Button } from '@/components/ui/button';
4 | import { useRouter } from 'next/navigation';
5 |
6 | interface TradeValues {
7 | takeProfit: string;
8 | stopLoss: string;
9 | lotSize: string;
10 | }
11 |
12 | interface TradeValuesCardProps {
13 | values: TradeValues;
14 | onUpdate: (values: TradeValues) => void;
15 | }
16 |
17 | export const TradeValuesCard = ({ values, onUpdate }: TradeValuesCardProps) => {
18 | const router = useRouter();
19 | const [localValues, setLocalValues] = useState(values);
20 |
21 | useEffect(() => {
22 | setLocalValues(values);
23 | }, [values]);
24 |
25 | const handleChange = (field: keyof TradeValues, value: string) => {
26 | const updated = { ...localValues, [field]: value };
27 | setLocalValues(updated);
28 | onUpdate(updated);
29 | };
30 |
31 | const handleExecute = () => {
32 | // Show success notification
33 | alert('Trade executed successfully');
34 | };
35 |
36 | return (
37 |
38 |
39 |
40 |
41 |
42 | handleChange('takeProfit', e.target.value)}
46 | className="border rounded p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
47 | />
48 |
49 |
50 |
51 |
52 | handleChange('stopLoss', e.target.value)}
56 | className="border rounded p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
57 | />
58 |
59 |
60 |
61 |
62 | handleChange('lotSize', e.target.value)}
66 | className="border rounded p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
67 | />
68 |
69 |
70 |
71 |
77 |
84 |
85 |
86 |
87 |
88 | );
89 | };
--------------------------------------------------------------------------------
/src/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | :root {
6 | --foreground-rgb: 0, 0, 0;
7 | --background-start-rgb: 214, 219, 220;
8 | --background-end-rgb: 255, 255, 255;
9 | }
10 |
11 | @media (prefers-color-scheme: dark) {
12 | :root {
13 | --foreground-rgb: 255, 255, 255;
14 | --background-start-rgb: 0, 0, 0;
15 | --background-end-rgb: 0, 0, 0;
16 | }
17 | }
18 |
19 | @layer utilities {
20 | .text-balance {
21 | text-wrap: balance;
22 | }
23 | }
24 |
25 | @layer base {
26 | :root {
27 | --background: 0 0% 100%;
28 | --foreground: 240 10% 3.9%;
29 | --card: 0 0% 100%;
30 | --card-foreground: 240 10% 3.9%;
31 | --popover: 0 0% 100%;
32 | --popover-foreground: 240 10% 3.9%;
33 | --primary: 240 5.9% 10%;
34 | --primary-foreground: 0 0% 98%;
35 | --secondary: 240 4.8% 95.9%;
36 | --secondary-foreground: 240 5.9% 10%;
37 | --muted: 240 4.8% 95.9%;
38 | --muted-foreground: 240 3.8% 46.1%;
39 | --accent: 240 4.8% 95.9%;
40 | --accent-foreground: 240 5.9% 10%;
41 | --destructive: 0 84.2% 60.2%;
42 | --destructive-foreground: 0 0% 98%;
43 | --border: 240 5.9% 90%;
44 | --input: 240 5.9% 90%;
45 | --ring: 240 10% 3.9%;
46 | --chart-1: 12 76% 61%;
47 | --chart-2: 173 58% 39%;
48 | --chart-3: 197 37% 24%;
49 | --chart-4: 43 74% 66%;
50 | --chart-5: 27 87% 67%;
51 | --radius: 0.5rem;
52 | }
53 | .dark {
54 | --background: 240 10% 3.9%;
55 | --foreground: 0 0% 98%;
56 | --card: 240 10% 3.9%;
57 | --card-foreground: 0 0% 98%;
58 | --popover: 240 10% 3.9%;
59 | --popover-foreground: 0 0% 98%;
60 | --primary: 0 0% 98%;
61 | --primary-foreground: 240 5.9% 10%;
62 | --secondary: 240 3.7% 15.9%;
63 | --secondary-foreground: 0 0% 98%;
64 | --muted: 240 3.7% 15.9%;
65 | --muted-foreground: 240 5% 64.9%;
66 | --accent: 240 3.7% 15.9%;
67 | --accent-foreground: 0 0% 98%;
68 | --destructive: 0 62.8% 30.6%;
69 | --destructive-foreground: 0 0% 98%;
70 | --border: 240 3.7% 15.9%;
71 | --input: 240 3.7% 15.9%;
72 | --ring: 240 4.9% 83.9%;
73 | --chart-1: 220 70% 50%;
74 | --chart-2: 160 60% 45%;
75 | --chart-3: 30 80% 55%;
76 | --chart-4: 280 65% 60%;
77 | --chart-5: 340 75% 55%;
78 | }
79 | }
80 |
81 | @layer base {
82 | * {
83 | @apply border-border;
84 | }
85 | body {
86 | @apply bg-background text-foreground;
87 | }
88 | }
89 |
90 |
91 | /* Width of the scrollbar */
92 | ::-webkit-scrollbar {
93 | width: 8px; /* Adjust the width as needed */
94 | height: 8px;
95 | background: transparent; /* Make the scrollbar background transparent */
96 | }
97 |
98 | /* Track (hidden by making it transparent) */
99 | ::-webkit-scrollbar-track {
100 | background: transparent; /* Completely transparent to hide the track */
101 | }
102 |
103 | /* Thumb (visible part of the scrollbar) */
104 | ::-webkit-scrollbar-thumb {
105 | background: rgba(10, 152, 136, 0.879); /* Your desired thumb color */
106 | border-radius: 5px; /* Rounded corners */
107 | }
108 |
109 | /* p {
110 | background-color: #e1e6e8;
111 | } */
--------------------------------------------------------------------------------
/particle-auth-aa/src/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | :root {
6 | --foreground-rgb: 0, 0, 0;
7 | --background-start-rgb: 214, 219, 220;
8 | --background-end-rgb: 255, 255, 255;
9 | }
10 |
11 | @media (prefers-color-scheme: dark) {
12 | :root {
13 | --foreground-rgb: 255, 255, 255;
14 | --background-start-rgb: 0, 0, 0;
15 | --background-end-rgb: 0, 0, 0;
16 | }
17 | }
18 |
19 | @layer utilities {
20 | .text-balance {
21 | text-wrap: balance;
22 | }
23 | }
24 |
25 | @layer base {
26 | :root {
27 | --background: 0 0% 100%;
28 | --foreground: 240 10% 3.9%;
29 | --card: 0 0% 100%;
30 | --card-foreground: 240 10% 3.9%;
31 | --popover: 0 0% 100%;
32 | --popover-foreground: 240 10% 3.9%;
33 | --primary: 240 5.9% 10%;
34 | --primary-foreground: 0 0% 98%;
35 | --secondary: 240 4.8% 95.9%;
36 | --secondary-foreground: 240 5.9% 10%;
37 | --muted: 240 4.8% 95.9%;
38 | --muted-foreground: 240 3.8% 46.1%;
39 | --accent: 240 4.8% 95.9%;
40 | --accent-foreground: 240 5.9% 10%;
41 | --destructive: 0 84.2% 60.2%;
42 | --destructive-foreground: 0 0% 98%;
43 | --border: 240 5.9% 90%;
44 | --input: 240 5.9% 90%;
45 | --ring: 240 10% 3.9%;
46 | --chart-1: 12 76% 61%;
47 | --chart-2: 173 58% 39%;
48 | --chart-3: 197 37% 24%;
49 | --chart-4: 43 74% 66%;
50 | --chart-5: 27 87% 67%;
51 | --radius: 0.5rem;
52 | }
53 | .dark {
54 | --background: 240 10% 3.9%;
55 | --foreground: 0 0% 98%;
56 | --card: 240 10% 3.9%;
57 | --card-foreground: 0 0% 98%;
58 | --popover: 240 10% 3.9%;
59 | --popover-foreground: 0 0% 98%;
60 | --primary: 0 0% 98%;
61 | --primary-foreground: 240 5.9% 10%;
62 | --secondary: 240 3.7% 15.9%;
63 | --secondary-foreground: 0 0% 98%;
64 | --muted: 240 3.7% 15.9%;
65 | --muted-foreground: 240 5% 64.9%;
66 | --accent: 240 3.7% 15.9%;
67 | --accent-foreground: 0 0% 98%;
68 | --destructive: 0 62.8% 30.6%;
69 | --destructive-foreground: 0 0% 98%;
70 | --border: 240 3.7% 15.9%;
71 | --input: 240 3.7% 15.9%;
72 | --ring: 240 4.9% 83.9%;
73 | --chart-1: 220 70% 50%;
74 | --chart-2: 160 60% 45%;
75 | --chart-3: 30 80% 55%;
76 | --chart-4: 280 65% 60%;
77 | --chart-5: 340 75% 55%;
78 | }
79 | }
80 |
81 | @layer base {
82 | * {
83 | @apply border-border;
84 | }
85 | body {
86 | @apply bg-background text-foreground;
87 | }
88 | }
89 |
90 |
91 | /* Width of the scrollbar */
92 | ::-webkit-scrollbar {
93 | width: 8px; /* Adjust the width as needed */
94 | height: 8px;
95 | background: transparent; /* Make the scrollbar background transparent */
96 | }
97 |
98 | /* Track (hidden by making it transparent) */
99 | ::-webkit-scrollbar-track {
100 | background: transparent; /* Completely transparent to hide the track */
101 | }
102 |
103 | /* Thumb (visible part of the scrollbar) */
104 | ::-webkit-scrollbar-thumb {
105 | background: rgba(10, 152, 136, 0.879); /* Your desired thumb color */
106 | border-radius: 5px; /* Rounded corners */
107 | }
108 |
109 | /* p {
110 | background-color: #e1e6e8;
111 | } */
--------------------------------------------------------------------------------
/src/components/chats/ChatInitiallizer.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from 'react';
2 | import { doc, getDoc, setDoc } from 'firebase/firestore';
3 | import { useParticleAuth } from '@/lib/hooks/useParticleAuth';
4 | import { IExecDataProtector } from '@iexec/dataprotector';
5 | import { useDataProtection } from '@/lib/hooks/useDataProtectioon';
6 | import { db } from '../../../firebase.config';
7 |
8 | export const ChatInitializer = () => {
9 | const { getUserInfo, address, isConnected } = useParticleAuth();
10 | const { loading: protectionLoading, error: protectionError } = useDataProtection();
11 | const [initialized, setInitialized] = useState(false);
12 | const [error, setError] = useState(null);
13 | const [loading, setLoading] = useState(true);
14 |
15 | useEffect(() => {
16 | const initializeUser = async () => {
17 | if (initialized || !address || !isConnected) return;
18 |
19 | try {
20 | setLoading(true);
21 | const userInfo = await getUserInfo();
22 | if (!userInfo) return;
23 |
24 | // Check if user already exists in Firestore
25 | const userDoc = await getDoc(doc(db, 'users', address));
26 |
27 | if (!userDoc.exists()) {
28 | let protectedDataAddress: string | undefined;
29 |
30 | // Only protect email if it exists
31 | if (userInfo.email) {
32 | const dataProtector = new IExecDataProtector(window.ethereum);
33 | try {
34 | const protectedData = await dataProtector.core.protectData({
35 | data: { email: userInfo.email },
36 | name: `Protected email for ${address}`,
37 | });
38 | protectedDataAddress = protectedData.address;
39 | } catch (protectError) {
40 | console.error('Failed to protect email:', protectError);
41 | // Continue without protected email
42 | }
43 | }
44 |
45 | // Store user data in Firestore
46 | await setDoc(doc(db, 'users', address), {
47 | address: address,
48 | email: userInfo.email,
49 | protectedDataAddress,
50 | isWeb3MailEnabled: !!protectedDataAddress,
51 | createdAt: Date.now(),
52 | lastSeen: Date.now(),
53 | socialLoginInfo: userInfo.socialInfo || null
54 | });
55 | } else {
56 | // Update last seen
57 | await setDoc(doc(db, 'users', address), {
58 | lastSeen: Date.now()
59 | }, { merge: true });
60 | }
61 |
62 | setInitialized(true);
63 | } catch (err) {
64 | console.error('Error initializing user:', err);
65 | setError(err instanceof Error ? err.message : 'Failed to initialize user');
66 | } finally {
67 | setLoading(false);
68 | }
69 | };
70 |
71 | initializeUser();
72 | }, [address, isConnected, initialized]);
73 |
74 | if (loading || protectionLoading) {
75 | return Initializing secure chat...
;
76 | }
77 |
78 | if (error || protectionError) {
79 | return (
80 |
81 | Error: {error || protectionError}
82 |
83 | );
84 | }
85 |
86 | return null;
87 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/chats/ChatInitiallizer.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect, useState } from 'react';
2 | import { doc, getDoc, setDoc } from 'firebase/firestore';
3 | import { useParticleAuth } from '@/lib/hooks/useParticleAuth';
4 | import { IExecDataProtector } from '@iexec/dataprotector';
5 | import { useDataProtection } from '@/lib/hooks/useDataProtectioon';
6 | import { db } from '../../../firebase.config';
7 |
8 | export const ChatInitializer = () => {
9 | const { getUserInfo, address, isConnected } = useParticleAuth();
10 | const { loading: protectionLoading, error: protectionError } = useDataProtection();
11 | const [initialized, setInitialized] = useState(false);
12 | const [error, setError] = useState(null);
13 | const [loading, setLoading] = useState(true);
14 |
15 | useEffect(() => {
16 | const initializeUser = async () => {
17 | if (initialized || !address || !isConnected) return;
18 |
19 | try {
20 | setLoading(true);
21 | const userInfo = await getUserInfo();
22 | if (!userInfo) return;
23 |
24 | // Check if user already exists in Firestore
25 | const userDoc = await getDoc(doc(db, 'users', address));
26 |
27 | if (!userDoc.exists()) {
28 | let protectedDataAddress: string | undefined;
29 |
30 | // Only protect email if it exists
31 | if (userInfo.email) {
32 | const dataProtector = new IExecDataProtector(window.ethereum);
33 | try {
34 | const protectedData = await dataProtector.core.protectData({
35 | data: { email: userInfo.email },
36 | name: `Protected email for ${address}`,
37 | });
38 | protectedDataAddress = protectedData.address;
39 | } catch (protectError) {
40 | console.error('Failed to protect email:', protectError);
41 | // Continue without protected email
42 | }
43 | }
44 |
45 | // Store user data in Firestore
46 | await setDoc(doc(db, 'users', address), {
47 | address: address,
48 | email: userInfo.email,
49 | protectedDataAddress,
50 | isWeb3MailEnabled: !!protectedDataAddress,
51 | createdAt: Date.now(),
52 | lastSeen: Date.now(),
53 | socialLoginInfo: userInfo.socialInfo || null
54 | });
55 | } else {
56 | // Update last seen
57 | await setDoc(doc(db, 'users', address), {
58 | lastSeen: Date.now()
59 | }, { merge: true });
60 | }
61 |
62 | setInitialized(true);
63 | } catch (err) {
64 | console.error('Error initializing user:', err);
65 | setError(err instanceof Error ? err.message : 'Failed to initialize user');
66 | } finally {
67 | setLoading(false);
68 | }
69 | };
70 |
71 | initializeUser();
72 | }, [address, isConnected, initialized]);
73 |
74 | if (loading || protectionLoading) {
75 | return Initializing secure chat...
;
76 | }
77 |
78 | if (error || protectionError) {
79 | return (
80 |
81 | Error: {error || protectionError}
82 |
83 | );
84 | }
85 |
86 | return null;
87 | };
--------------------------------------------------------------------------------
/tradeLLM/utils/dataTransformer.js:
--------------------------------------------------------------------------------
1 | class DataTransformer {
2 | static normalizeQuote(quote, source) {
3 | const baseQuote = {
4 | symbol: '',
5 | price: null,
6 | change: null,
7 | changePercent: null,
8 | volume: null,
9 | high: null,
10 | low: null,
11 | open: null,
12 | close: null,
13 | timestamp: null,
14 | source: source
15 | };
16 |
17 | switch (source) {
18 | case 'yahoo':
19 | return {
20 | ...baseQuote,
21 | symbol: quote.symbol,
22 | price: quote.regularMarketPrice,
23 | change: quote.regularMarketChange,
24 | changePercent: quote.regularMarketChangePercent,
25 | volume: quote.regularMarketVolume,
26 | high: quote.regularMarketDayHigh,
27 | low: quote.regularMarketDayLow,
28 | open: quote.regularMarketOpen,
29 | close: quote.regularMarketClose,
30 | timestamp: new Date(quote.regularMarketTime * 1000).toISOString()
31 | };
32 |
33 | case 'alphavantage':
34 | return {
35 | ...baseQuote,
36 | symbol: quote['01. symbol'],
37 | price: parseFloat(quote['06. price']),
38 | change: parseFloat(quote['10. change']),
39 | changePercent: parseFloat(quote['11. change percent'].replace('%', '')),
40 | volume: parseInt(quote['09. volume']),
41 | high: parseFloat(quote['05. high']),
42 | low: parseFloat(quote['04. low']),
43 | open: parseFloat(quote['02. open']),
44 | close: parseFloat(quote['03. close']),
45 | timestamp: quote['07. latest trading day']
46 | };
47 |
48 | default:
49 | throw new Error(`Unknown data source: ${source}`);
50 | }
51 | }
52 |
53 | static normalizeOHLCV(data, source) {
54 | switch (source) {
55 | case 'yahoo':
56 | case 'alphavantage':
57 | return data.map(candle => ({
58 | timestamp: new Date(candle.timestamp).toISOString(),
59 | open: parseFloat(candle.open),
60 | high: parseFloat(candle.high),
61 | low: parseFloat(candle.low),
62 | close: parseFloat(candle.close),
63 | volume: parseInt(candle.volume),
64 | source: source
65 | }));
66 |
67 | default:
68 | throw new Error(`Unknown data source: ${source}`);
69 | }
70 | }
71 |
72 | static calculateMetrics(data) {
73 | if (!data || data.length === 0) return {};
74 |
75 | const prices = data.map(d => d.close);
76 | const returns = prices.slice(1).map((price, i) =>
77 | (price - prices[i]) / prices[i]
78 | );
79 |
80 | return {
81 | mean: returns.reduce((a, b) => a + b, 0) / returns.length,
82 | volatility: Math.sqrt(
83 | returns.reduce((a, b) => a + Math.pow(b - returns.reduce((a, b) => a + b, 0) / returns.length, 2), 0) / returns.length
84 | ) * Math.sqrt(252),
85 | sharpeRatio: (returns.reduce((a, b) => a + b, 0) / returns.length) /
86 | (Math.sqrt(returns.reduce((a, b) => a + Math.pow(b - returns.reduce((a, b) => a + b, 0) / returns.length, 2), 0) / returns.length) || 1)
87 | };
88 | }
89 | }
90 |
91 | module.exports = DataTransformer;
--------------------------------------------------------------------------------
/src/lib/connectkit.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import React from 'react';
4 |
5 | import { ConnectKitProvider, createConfig } from '@particle-network/connectkit';
6 | import { authWalletConnectors } from '@particle-network/connectkit/auth';
7 | import type { Chain } from '@particle-network/connectkit/chains';
8 | // embedded wallet start
9 | import { EntryPosition, wallet } from '@particle-network/connectkit/wallet';
10 | // embedded wallet end
11 | // aa start
12 | import { aa } from '@particle-network/connectkit/aa';
13 | // aa end
14 | // evm start
15 | import { arbitrum, base, lineaSepolia, mainnet, polygon } from '@particle-network/connectkit/chains';
16 | import { evmWalletConnectors } from '@particle-network/connectkit/evm';
17 | // evm end
18 | // solana start
19 | import { solana } from '@particle-network/connectkit/chains';
20 | import { solanaWalletConnectors } from '@particle-network/connectkit/solana';
21 | // solana end
22 |
23 | const projectId = process.env.NEXT_PUBLIC_PROJECT_ID as string;
24 | const clientKey = process.env.NEXT_PUBLIC_CLIENT_KEY as string;
25 | const appId = process.env.NEXT_PUBLIC_APP_ID as string;
26 | const walletConnectProjectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID as string;
27 |
28 | if (!projectId || !clientKey || !appId) {
29 | throw new Error('Please configure the Particle project in .env first!');
30 | }
31 |
32 | const supportChains: Chain[] = [];
33 | // evm start
34 | supportChains.push(mainnet, base, arbitrum, polygon, lineaSepolia);
35 | // evm end
36 | // solana start
37 | supportChains.push(solana);
38 | // solana end
39 |
40 | export const config = createConfig({
41 | projectId,
42 | clientKey,
43 | appId,
44 | appearance: {
45 | mode: 'light',
46 | theme:{
47 | '--pcm-button-font-weight': 'bold',
48 | '--pcm-primary-button-color': '#ffffff',
49 | '--pcm-primary-button-bankground': '#0e3d84',
50 | },
51 | recommendedWallets: [
52 | { walletId: 'metaMask', label: 'Recommended' },
53 | { walletId: 'coinbaseWallet', label: 'Popular' },
54 | { walletId: 'walletConnect', label: 'WalletConnect'},
55 | ],
56 | language: 'en-US',
57 | },
58 | walletConnectors: [
59 | authWalletConnectors(),
60 | // evm start
61 | evmWalletConnectors({
62 | // TODO: replace it with your app metadata.
63 | metadata: {
64 | name: 'PULSE TRADE AI',
65 | icon: typeof window !== 'undefined' ? `${window.location.origin}/logo.png` : '',
66 | description: 'An AI-powered trading platform.',
67 | url: typeof window !== 'undefined' ? window.location.origin : '',
68 | },
69 | walletConnectProjectId: walletConnectProjectId,
70 | }),
71 | // evm end
72 | // solana start
73 | solanaWalletConnectors(),
74 | // solana end
75 | ],
76 | plugins: [
77 | // embedded wallet start
78 | wallet({
79 | visible: true,
80 | entryPosition: EntryPosition.BR,
81 | }),
82 | // embedded wallet end
83 | // aa config start
84 | aa({
85 | name: 'BICONOMY',
86 | version: '2.0.0',
87 | }),
88 | // aa config end
89 | ],
90 | chains: supportChains as unknown as readonly [Chain, ...Chain[]],
91 | });
92 |
93 | // Wrap your application with this component.
94 | export const ParticleConnectkit = ({ children }: React.PropsWithChildren) => {
95 | return {children};
96 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/lib/connectkit.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import React from 'react';
4 |
5 | import { ConnectKitProvider, createConfig } from '@particle-network/connectkit';
6 | import { authWalletConnectors } from '@particle-network/connectkit/auth';
7 | import type { Chain } from '@particle-network/connectkit/chains';
8 | // embedded wallet start
9 | import { EntryPosition, wallet } from '@particle-network/connectkit/wallet';
10 | // embedded wallet end
11 | // aa start
12 | import { aa } from '@particle-network/connectkit/aa';
13 | // aa end
14 | // evm start
15 | import { arbitrum, base, lineaSepolia, mainnet, polygon } from '@particle-network/connectkit/chains';
16 | import { evmWalletConnectors } from '@particle-network/connectkit/evm';
17 | // evm end
18 | // solana start
19 | import { solana } from '@particle-network/connectkit/chains';
20 | import { solanaWalletConnectors } from '@particle-network/connectkit/solana';
21 | // solana end
22 |
23 | const projectId = process.env.NEXT_PUBLIC_PROJECT_ID as string;
24 | const clientKey = process.env.NEXT_PUBLIC_CLIENT_KEY as string;
25 | const appId = process.env.NEXT_PUBLIC_APP_ID as string;
26 | const walletConnectProjectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID as string;
27 |
28 | if (!projectId || !clientKey || !appId) {
29 | throw new Error('Please configure the Particle project in .env first!');
30 | }
31 |
32 | const supportChains: Chain[] = [];
33 | // evm start
34 | supportChains.push(mainnet, base, arbitrum, polygon, lineaSepolia);
35 | // evm end
36 | // solana start
37 | supportChains.push(solana);
38 | // solana end
39 |
40 | export const config = createConfig({
41 | projectId,
42 | clientKey,
43 | appId,
44 | appearance: {
45 | mode: 'light',
46 | theme:{
47 | '--pcm-button-font-weight': 'bold',
48 | '--pcm-primary-button-color': '#ffffff',
49 | '--pcm-primary-button-bankground': '#0e3d84',
50 | },
51 | recommendedWallets: [
52 | { walletId: 'metaMask', label: 'Recommended' },
53 | { walletId: 'coinbaseWallet', label: 'Popular' },
54 | { walletId: 'walletConnect', label: 'WalletConnect'},
55 | ],
56 | language: 'en-US',
57 | },
58 | walletConnectors: [
59 | authWalletConnectors(),
60 | // evm start
61 | evmWalletConnectors({
62 | // TODO: replace it with your app metadata.
63 | metadata: {
64 | name: 'PULSE TRADE AI',
65 | icon: typeof window !== 'undefined' ? `${window.location.origin}/logo.png` : '',
66 | description: 'An AI-powered trading platform.',
67 | url: typeof window !== 'undefined' ? window.location.origin : '',
68 | },
69 | walletConnectProjectId: walletConnectProjectId,
70 | }),
71 | // evm end
72 | // solana start
73 | solanaWalletConnectors(),
74 | // solana end
75 | ],
76 | plugins: [
77 | // embedded wallet start
78 | wallet({
79 | visible: true,
80 | entryPosition: EntryPosition.BR,
81 | }),
82 | // embedded wallet end
83 | // aa config start
84 | aa({
85 | name: 'BICONOMY',
86 | version: '2.0.0',
87 | }),
88 | // aa config end
89 | ],
90 | chains: supportChains as unknown as readonly [Chain, ...Chain[]],
91 | });
92 |
93 | // Wrap your application with this component.
94 | export const ParticleConnectkit = ({ children }: React.PropsWithChildren) => {
95 | return {children};
96 | };
--------------------------------------------------------------------------------
/src/app/trading/execute/page.tsx:
--------------------------------------------------------------------------------
1 | // app/(routes)/trading/execute/page.tsx
2 | "use client";
3 |
4 | import { useState } from 'react';
5 | import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
6 | import { Alert, AlertDescription } from '@/components/ui/alert';
7 | import TradeExecutionForm from '@/components/trading/tradeExecutionForm';
8 | import { useParticleAuth } from '@/lib/hooks/useParticleAuth';
9 | import Header from '@/components/Header';
10 |
11 | interface PriceFeed {
12 | symbol: string;
13 | price: number;
14 | change24h: number;
15 | }
16 |
17 | export default function TradingExecutionPage() {
18 | const { isConnected } = useParticleAuth();
19 | const [priceFeeds, setPriceFeeds] = useState([
20 | { symbol: 'BTC/USD', price: 45000, change24h: 2.5 },
21 | { symbol: 'ETH/USD', price: 2500, change24h: -1.2 }
22 | ]);
23 |
24 | if (!isConnected) {
25 | return (
26 |
27 |
28 |
29 |
30 |
31 | Please connect your wallet to execute trades.
32 |
33 |
34 |
35 |
36 | );
37 | }
38 |
39 | return (
40 |
41 |
Execute Trade
42 |
43 | {/* Price Feeds */}
44 |
45 | {priceFeeds.map(feed => (
46 |
47 |
48 |
49 |
50 |
{feed.symbol}
51 |
52 | ${feed.price.toLocaleString()}
53 |
54 |
55 |
= 0
57 | ? 'bg-green-100 text-green-800'
58 | : 'bg-red-100 text-red-800'
59 | }`}>
60 | {feed.change24h >= 0 ? '+' : ''}{feed.change24h}%
61 |
62 |
63 |
64 |
65 | ))}
66 |
67 |
68 | {/* Trade Execution Form */}
69 |
70 |
71 |
72 | {/* Risk Management Panel */}
73 |
74 |
75 | Risk Management
76 |
77 |
78 |
79 |
80 |
Account Balance
81 |
$50,000
82 |
83 |
84 |
Max Position Size
85 |
$5,000
86 |
87 |
88 |
Risk per Trade
89 |
1%
90 |
91 |
92 |
93 |
94 |
95 |
96 | );
97 | }
--------------------------------------------------------------------------------
/particle-auth-aa/src/app/trading/execute/page.tsx:
--------------------------------------------------------------------------------
1 | // app/(routes)/trading/execute/page.tsx
2 | "use client";
3 |
4 | import { useState } from 'react';
5 | import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
6 | import { Alert, AlertDescription } from '@/components/ui/alert';
7 | import TradeExecutionForm from '@/components/trading/tradeExecutionForm';
8 | import { useParticleAuth } from '@/lib/hooks/useParticleAuth';
9 | import Header from '@/components/Header';
10 |
11 | interface PriceFeed {
12 | symbol: string;
13 | price: number;
14 | change24h: number;
15 | }
16 |
17 | export default function TradingExecutionPage() {
18 | const { isConnected } = useParticleAuth();
19 | const [priceFeeds, setPriceFeeds] = useState([
20 | { symbol: 'BTC/USD', price: 45000, change24h: 2.5 },
21 | { symbol: 'ETH/USD', price: 2500, change24h: -1.2 }
22 | ]);
23 |
24 | if (!isConnected) {
25 | return (
26 |
27 |
28 |
29 |
30 |
31 | Please connect your wallet to execute trades.
32 |
33 |
34 |
35 |
36 | );
37 | }
38 |
39 | return (
40 |
41 |
Execute Trade
42 |
43 | {/* Price Feeds */}
44 |
45 | {priceFeeds.map(feed => (
46 |
47 |
48 |
49 |
50 |
{feed.symbol}
51 |
52 | ${feed.price.toLocaleString()}
53 |
54 |
55 |
= 0
57 | ? 'bg-green-100 text-green-800'
58 | : 'bg-red-100 text-red-800'
59 | }`}>
60 | {feed.change24h >= 0 ? '+' : ''}{feed.change24h}%
61 |
62 |
63 |
64 |
65 | ))}
66 |
67 |
68 | {/* Trade Execution Form */}
69 |
70 |
71 |
72 | {/* Risk Management Panel */}
73 |
74 |
75 | Risk Management
76 |
77 |
78 |
79 |
80 |
Account Balance
81 |
$50,000
82 |
83 |
84 |
Max Position Size
85 |
$5,000
86 |
87 |
88 |
Risk per Trade
89 |
1%
90 |
91 |
92 |
93 |
94 |
95 |
96 | );
97 | }
--------------------------------------------------------------------------------
/src/components/ai-chat/ChatList.tsx:
--------------------------------------------------------------------------------
1 | 'use client'
2 | import { useEffect, useState } from 'react';
3 | import { useRouter } from 'next/navigation';
4 | import { Card, CardContent } from '@/components/ui/card';
5 | import Image from 'next/image';
6 | import { collection, query, where, orderBy, onSnapshot } from 'firebase/firestore';
7 | import { db } from '../../../firebase.config';
8 |
9 |
10 | interface AIChat {
11 | id: string;
12 | userId: string;
13 | threadId: string;
14 | lastMessage: {
15 | content: string;
16 | timestamp: number;
17 | };
18 | title: string;
19 | createdAt: number;
20 | updatedAt: number;
21 | }
22 |
23 | export const AIChatList = ({ userId }: { userId: string }) => {
24 | const [chats, setChats] = useState([]);
25 | const [loading, setLoading] = useState(true);
26 | const router = useRouter();
27 |
28 | useEffect(() => {
29 | const chatsRef = collection(db, 'ai_chats');
30 | const q = query(
31 | chatsRef,
32 | where('userId', '==', userId),
33 | orderBy('updatedAt', 'desc')
34 | );
35 |
36 | const unsubscribe = onSnapshot(
37 | q,
38 | (snapshot) => {
39 | const chatList = snapshot.docs.map(doc => ({
40 | id: doc.id,
41 | ...doc.data()
42 | } as AIChat));
43 | setChats(chatList);
44 | setLoading(false);
45 | },
46 | (error) => {
47 | console.error('Error fetching chats:', error);
48 | setLoading(false);
49 | }
50 | );
51 |
52 | return () => unsubscribe();
53 | }, [userId]);
54 |
55 | const formatTimestamp = (timestamp: number) => {
56 | const date = new Date(timestamp);
57 | const now = new Date();
58 | const diffDays = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24));
59 |
60 | if (diffDays === 0) {
61 | return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
62 | } else if (diffDays === 1) {
63 | return 'Yesterday';
64 | } else {
65 | return date.toLocaleDateString();
66 | }
67 | };
68 |
69 | if (loading) {
70 | return (
71 |
72 |
79 |
80 | );
81 | }
82 |
83 | return (
84 |
85 | {chats.map((chat) => (
86 |
router.push(`/ai-chat/${chat.id}`)}
90 | >
91 |
92 |
93 |
94 |
{chat.title || 'New Chat'}
95 |
96 | {chat.lastMessage?.content}
97 |
98 |
99 |
100 | {formatTimestamp(chat.lastMessage?.timestamp || chat.createdAt)}
101 |
102 |
103 |
104 |
105 | ))}
106 |
107 | {chats.length === 0 && (
108 |
109 |
No chats yet. Start a new conversation!
110 |
111 | )}
112 |
113 | );
114 | };
--------------------------------------------------------------------------------
/particle-auth-aa/src/components/ai-chat/ChatList.tsx:
--------------------------------------------------------------------------------
1 | 'use client'
2 | import { useEffect, useState } from 'react';
3 | import { useRouter } from 'next/navigation';
4 | import { Card, CardContent } from '@/components/ui/card';
5 | import Image from 'next/image';
6 | import { collection, query, where, orderBy, onSnapshot } from 'firebase/firestore';
7 | import { db } from '../../../firebase.config';
8 |
9 |
10 | interface AIChat {
11 | id: string;
12 | userId: string;
13 | threadId: string;
14 | lastMessage: {
15 | content: string;
16 | timestamp: number;
17 | };
18 | title: string;
19 | createdAt: number;
20 | updatedAt: number;
21 | }
22 |
23 | export const AIChatList = ({ userId }: { userId: string }) => {
24 | const [chats, setChats] = useState([]);
25 | const [loading, setLoading] = useState(true);
26 | const router = useRouter();
27 |
28 | useEffect(() => {
29 | const chatsRef = collection(db, 'ai_chats');
30 | const q = query(
31 | chatsRef,
32 | where('userId', '==', userId),
33 | orderBy('updatedAt', 'desc')
34 | );
35 |
36 | const unsubscribe = onSnapshot(
37 | q,
38 | (snapshot) => {
39 | const chatList = snapshot.docs.map(doc => ({
40 | id: doc.id,
41 | ...doc.data()
42 | } as AIChat));
43 | setChats(chatList);
44 | setLoading(false);
45 | },
46 | (error) => {
47 | console.error('Error fetching chats:', error);
48 | setLoading(false);
49 | }
50 | );
51 |
52 | return () => unsubscribe();
53 | }, [userId]);
54 |
55 | const formatTimestamp = (timestamp: number) => {
56 | const date = new Date(timestamp);
57 | const now = new Date();
58 | const diffDays = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24));
59 |
60 | if (diffDays === 0) {
61 | return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
62 | } else if (diffDays === 1) {
63 | return 'Yesterday';
64 | } else {
65 | return date.toLocaleDateString();
66 | }
67 | };
68 |
69 | if (loading) {
70 | return (
71 |
72 |
79 |
80 | );
81 | }
82 |
83 | return (
84 |
85 | {chats.map((chat) => (
86 |
router.push(`/ai-chat/${chat.id}`)}
90 | >
91 |
92 |
93 |
94 |
{chat.title || 'New Chat'}
95 |
96 | {chat.lastMessage?.content}
97 |
98 |
99 |
100 | {formatTimestamp(chat.lastMessage?.timestamp || chat.createdAt)}
101 |
102 |
103 |
104 |
105 | ))}
106 |
107 | {chats.length === 0 && (
108 |
109 |
No chats yet. Start a new conversation!
110 |
111 | )}
112 |
113 | );
114 | };
--------------------------------------------------------------------------------
/koii/task-template/tests/prod-debug.js:
--------------------------------------------------------------------------------
1 | import { spawn } from "cross-spawn";
2 | import fs from "fs";
3 | import "dotenv/config";
4 | import Debugger from "./debugger.js";
5 | import { Tail } from "tail";
6 | import path from "path";
7 | import { fileURLToPath } from "url";
8 | import chalk from "chalk";
9 |
10 | const __filename = fileURLToPath(import.meta.url);
11 | const __dirname = path.dirname(__filename);
12 | const startWatching = async () => {
13 | console.log("Watching for file changes...");
14 | // watch and trigger builds
15 | await build();
16 | };
17 |
18 | /* build and webpack the task */
19 | const build = async () => {
20 | console.log("Building...");
21 | const child = await spawn("npm", ["run", "webpack:test"], {
22 | stdio: "inherit",
23 | });
24 |
25 | await child.on("close", (code) => {
26 | if (code !== 0) {
27 | console.error("Build failed");
28 | } else {
29 | console.log("Build successful");
30 | copyWebpackedFile();
31 | }
32 | return;
33 | });
34 | };
35 |
36 | /* copy the task to the Desktop Node runtime folder */
37 | const copyWebpackedFile = async () => {
38 | const debugConfig = await Debugger.getConfig();
39 | console.log("debugConfig", debugConfig);
40 | const nodeDIR = debugConfig.nodeDir;
41 | const sourcePath = __dirname + "/" + debugConfig.webpackedFilePath;
42 | const desktopNodeExecutablePath = nodeDIR + "/" + debugConfig.destinationPath;
43 | const desktopNodeLogPath = nodeDIR + "/" + debugConfig.logPath;
44 | const keywords = debugConfig.keywords;
45 | const taskID = debugConfig.taskID;
46 |
47 | if (!sourcePath || !desktopNodeExecutablePath) {
48 | console.error("Source path or destination path not specified in .env");
49 | return;
50 | }
51 |
52 | console.log(
53 | `Copying webpacked file from ${sourcePath} to ${desktopNodeExecutablePath}...`,
54 | );
55 |
56 | fs.copyFile(sourcePath, desktopNodeExecutablePath, async (err) => {
57 | if (err) {
58 | console.error("Error copying file:", err);
59 | } else {
60 | console.log("File copied successfully");
61 | tailLogs(desktopNodeLogPath, keywords, taskID);
62 | }
63 | });
64 | };
65 |
66 | /* tail logs */
67 | const tailLogs = async (desktopNodeLogPath, keywords, taskID) => {
68 | console.log("Watchings logs for messages containing ", keywords);
69 |
70 | // Extract the directory path from the full log file path
71 | const dirPath = path.dirname(desktopNodeLogPath);
72 |
73 | // Check if the directory exists, create it if it doesn't
74 | try {
75 | await fs.promises.access(dirPath, fs.constants.F_OK);
76 | } catch (dirErr) {
77 | console.log(
78 | "Unable to find task directory. Please make sure you have the correct task ID set in your .env file, and run the task on the Desktop Node before running prod-debug.",
79 | );
80 | process.exit(1);
81 | }
82 |
83 | // Ensure the log file exists, or create it if it doesn't
84 | try {
85 | await fs.promises.access(desktopNodeLogPath, fs.constants.F_OK);
86 | } catch (err) {
87 | console.log(`Log file not found, creating ${desktopNodeLogPath}`);
88 | await fs.promises.writeFile(desktopNodeLogPath, "", { flag: "a" }); // 'a' flag ensures the file is created if it doesn't exist and not overwritten if it exists
89 | }
90 |
91 | let tail = new Tail(desktopNodeLogPath, "\n", {}, true);
92 |
93 | console.log(
94 | `Now watching logs for messages containing ${keywords.join(", ")}. Please start the task ${taskID} and keep it running on the Desktop Node.`,
95 | );
96 |
97 | tail.on("line", function (data) {
98 | if (keywords.some((keyword) => keyword && data.includes(keyword))) {
99 | console.log(chalk.magenta(data));
100 | } else {
101 | console.log(data);
102 | }
103 | });
104 |
105 | tail.on("error", function (error) {
106 | console.log("ERROR: ", error);
107 | });
108 | };
109 |
110 | startWatching();
111 |
--------------------------------------------------------------------------------
/koii/task-template/src/task/candlestick-plotter.js:
--------------------------------------------------------------------------------
1 | import * as d3 from 'd3';
2 | import * as fs from 'fs';
3 | import StockPredictor from './stock-prediction-model.js';
4 |
5 | class CandlestickPlotter {
6 | constructor(symbol = '^DJI', startDate = '2014-01-30', endDate = '2023-01-29') {
7 | this.symbol = symbol;
8 | this.startDate = startDate;
9 | this.endDate = endDate;
10 | }
11 |
12 | async plotCandlesticks() {
13 | // Create predictor instance
14 | const predictor = new StockPredictor(this.symbol, this.startDate, this.endDate);
15 |
16 | // Run prediction to get data
17 | const predictionResults = await predictor.runPrediction();
18 | const stockData = await predictor.fetchStockData();
19 |
20 | // D3 Candlestick Plotting
21 | const margin = { top: 20, right: 30, bottom: 30, left: 40 };
22 | const width = 960 - margin.left - margin.right;
23 | const height = 500 - margin.top - margin.bottom;
24 |
25 | const svg = d3.select('body').append('svg')
26 | .attr('width', width + margin.left + margin.right)
27 | .attr('height', height + margin.top + margin.bottom)
28 | .append('g')
29 | .attr('transform', `translate(${margin.left},${margin.top})`);
30 |
31 | // X scale
32 | const x = d3.scaleTime()
33 | .domain(d3.extent(stockData, d => new Date(d.date)))
34 | .range([0, width]);
35 |
36 | // Y scale
37 | const y = d3.scaleLinear()
38 | .domain([
39 | d3.min(stockData, d => Math.min(d.low, d.open, d.close, d.high)),
40 | d3.max(stockData, d => Math.max(d.low, d.open, d.close, d.high))
41 | ])
42 | .range([height, 0]);
43 |
44 | // Add X axis
45 | svg.append('g')
46 | .attr('transform', `translate(0,${height})`)
47 | .call(d3.axisBottom(x));
48 |
49 | // Add Y axis
50 | svg.append('g')
51 | .call(d3.axisLeft(y));
52 |
53 | // Candlesticks
54 | svg.selectAll('.candlestick')
55 | .data(stockData)
56 | .enter()
57 | .append('line')
58 | .attr('x1', d => x(new Date(d.date)))
59 | .attr('x2', d => x(new Date(d.date)))
60 | .attr('y1', d => y(d.low))
61 | .attr('y2', d => y(d.high))
62 | .attr('stroke', 'black');
63 |
64 | svg.selectAll('.candle')
65 | .data(stockData)
66 | .enter()
67 | .append('rect')
68 | .attr('x', d => x(new Date(d.date)) - 4)
69 | .attr('y', d => y(Math.max(d.open, d.close)))
70 | .attr('width', 8)
71 | .attr('height', d => Math.abs(y(d.open) - y(d.close)))
72 | .attr('fill', d => d.open > d.close ? 'red' : 'green');
73 |
74 | // Annotate prediction results and signals
75 | const futureAnnotation = svg.append('g')
76 | .attr('transform', `translate(${width}, ${y(predictionResults.futurePrediction)})`);
77 |
78 | futureAnnotation.append('text')
79 | .attr('x', 10)
80 | .attr('y', 0)
81 | .text(`Predicted: $${predictionResults.futurePrediction.toFixed(2)}`)
82 | .attr('fill', 'blue');
83 |
84 | // Optional: Output results to a file
85 | fs.writeFileSync('candlestick_plot_results.json', JSON.stringify({
86 | predictions: predictionResults,
87 | plotData: stockData
88 | }, null, 2));
89 |
90 | console.log('Trading Signals:', predictionResults.signals);
91 | }
92 | }
93 |
94 | // If run directly, create and run plot
95 | if (import.meta.url === `file://${process.argv[1]}`) {
96 | const plotter = new CandlestickPlotter();
97 | plotter.plotCandlesticks().catch(console.error);
98 | }
99 |
100 | export default CandlestickPlotter;
--------------------------------------------------------------------------------