Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjusting test setup and adding a basic test #172

Merged
merged 6 commits into from
Nov 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
correct places were stricter checking is now in place
  • Loading branch information
sirkitree committed Nov 3, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
HighCrit HighCrit
commit ce0e7157a318a58f1bd31762f80cd6cd7ca5be84
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -25,5 +25,11 @@ jobs:
- name: Run Prettier
run: pnpm run prettier --check .

- name: Create test env file
run: cp core/.env.test.example core/.env.test || cp core/.env.test core/.env.test

- name: Run tests
run: cd core && pnpm test

- name: Build packages
run: pnpm run build
3 changes: 2 additions & 1 deletion core/package.json
Original file line number Diff line number Diff line change
@@ -67,7 +67,8 @@
"ts-node": "10.9.2",
"tslib": "2.8.0",
"typescript": "5.6.3",
"wrangler": "3.84.0"
"wrangler": "3.84.0",
"@types/pdfjs-dist": "^2.10.378"
},
"pnpm": {
"overrides": {
2 changes: 1 addition & 1 deletion core/src/cli/config.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import fs from "fs";
import yaml from "js-yaml";
import path from "path";
import { fileURLToPath } from "url";
import { Action } from "../core/types";
import { Action } from "../core/types.ts";

const ROOT_DIR = path.resolve(fileURLToPath(import.meta.url), "../../../src");

2 changes: 1 addition & 1 deletion core/src/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Readable } from "stream";
import { ImageGenModel } from "./imageGenModels";
import { ImageGenModel } from "./imageGenModels.ts";

/**
* Represents a UUID, which is a universally unique identifier conforming to the UUID standard.
26 changes: 12 additions & 14 deletions core/src/providers/token.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Connection } from "@solana/web3.js";
// import fetch from "cross-fetch";
import { IAgentRuntime, Memory, Provider, State } from "../core/types.ts";
import settings from "../core/settings.ts";
import BigNumber from "bignumber.js";
import { toBN, BN } from '../utils/bignumber.js';
import {
ProcessedTokenData,
TokenSecurityData,
@@ -609,40 +609,38 @@ export class TokenProvider {
): Promise<Array<{ holderAddress: string; balanceUsd: string }>> {
const holdersData = await this.fetchHolderList();

const tokenPriceUsd = new BigNumber(tradeData.price);
const tokenPriceUsd = toBN(tradeData.price);

const highValueHolders = holdersData
.filter((holder) => {
const balanceUsd = new BigNumber(holder.balance).multipliedBy(
const balanceUsd = toBN(holder.balance).multipliedBy(
tokenPriceUsd
);
return balanceUsd.isGreaterThan(5);
})
.map((holder) => ({
holderAddress: holder.address,
balanceUsd: new BigNumber(holder.balance)
.multipliedBy(tokenPriceUsd)
.toFixed(2),
balanceUsd: toBN(holder.balance).multipliedBy(tokenPriceUsd).toFixed(2),
}));

return highValueHolders;
}

async checkRecentTrades(tradeData: TokenTradeData): Promise<boolean> {
return new BigNumber(tradeData.volume_24h_usd).isGreaterThan(0);
return toBN(tradeData.volume_24h_usd).isGreaterThan(0);
}

async countHighSupplyHolders(
securityData: TokenSecurityData
): Promise<number> {
try {
const ownerBalance = new BigNumber(securityData.ownerBalance);
const ownerBalance = toBN(securityData.ownerBalance);
const totalSupply = ownerBalance.plus(securityData.creatorBalance);

const highSupplyHolders = await this.fetchHolderList();
const highSupplyHoldersCount = highSupplyHolders.filter(
(holder) => {
const balance = new BigNumber(holder.balance);
const balance = toBN(holder.balance);
return balance.dividedBy(totalSupply).isGreaterThan(0.02);
}
).length;
@@ -738,8 +736,8 @@ export class TokenProvider {
output += `- Unique Wallets (24h): ${data.tradeData.unique_wallet_24h}\n`;
output += `- Price Change (24h): ${data.tradeData.price_change_24h_percent}%\n`;
output += `- Price Change (12h): ${data.tradeData.price_change_12h_percent}%\n`;
output += `- Volume (24h USD): $${new BigNumber(data.tradeData.volume_24h_usd).toFixed(2)}\n`;
output += `- Current Price: $${new BigNumber(data.tradeData.price).toFixed(2)}\n\n`;
output += `- Volume (24h USD): $${toBN(data.tradeData.volume_24h_usd).toFixed(2)}\n`;
output += `- Current Price: $${toBN(data.tradeData.price).toFixed(2)}\n\n`;

// Holder Distribution Trend
output += `**Holder Distribution Trend:** ${data.holderDistributionTrend}\n\n`;
@@ -771,10 +769,10 @@ export class TokenProvider {
output += `\n**Pair ${index + 1}:**\n`;
output += `- DEX: ${pair.dexId}\n`;
output += `- URL: ${pair.url}\n`;
output += `- Price USD: $${new BigNumber(pair.priceUsd).toFixed(6)}\n`;
output += `- Volume (24h USD): $${new BigNumber(pair.volume.h24).toFixed(2)}\n`;
output += `- Price USD: $${toBN(pair.priceUsd).toFixed(6)}\n`;
output += `- Volume (24h USD): $${toBN(pair.volume.h24).toFixed(2)}\n`;
output += `- Boosts Active: ${pair.boosts && pair.boosts.active}\n`;
output += `- Liquidity USD: $${new BigNumber(pair.liquidity.usd).toFixed(2)}\n`;
output += `- Liquidity USD: $${toBN(pair.liquidity.usd).toFixed(2)}\n`;
});
}
output += `\n`;
4 changes: 2 additions & 2 deletions core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"module": "ESNext",
"lib": ["ESNext", "dom"],
"moduleResolution": "NodeNext",
"moduleResolution": "Bundler",
"outDir": "./dist",
"rootDir": "./src",
"strict": false,