-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update app name to bot and init services
- Loading branch information
Showing
31 changed files
with
10,383 additions
and
13,705 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,6 @@ testem.log | |
.DS_Store | ||
Thumbs.db | ||
|
||
.nx/cache | ||
.nx/cache | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'ddca', | ||
displayName: 'bot', | ||
preset: '../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
'^.+\\.[tj]s$': [ | ||
'ts-jest', | ||
{ tsconfig: '<rootDir>/tsconfig.spec.json' }, | ||
], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/apps/ddca', | ||
coverageDirectory: '../../coverage/apps/bot', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Strategy } from '@jupjup/constants' | ||
import { parseUSDC } from '@jupjup/utils' | ||
|
||
export type AppConfig = { | ||
tradingStrategy: Strategy | ||
startingFundsUSDC: string | ||
} | ||
|
||
export const DEFAULT_CONFIG: AppConfig = { | ||
tradingStrategy: Strategy.DDCA, | ||
startingFundsUSDC: parseUSDC(10).result, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Module } from '@nestjs/common' | ||
import { ConfigModule } from '@nestjs/config' | ||
import { ScheduleModule } from '@nestjs/schedule' | ||
|
||
import { AppService } from './app.service' | ||
import { TradingModule } from '../trading/trading.module' | ||
|
||
@Module({ | ||
imports: [ | ||
ConfigModule.forRoot({ isGlobal: true }), | ||
ScheduleModule.forRoot(), | ||
TradingModule, | ||
], | ||
controllers: [], | ||
providers: [AppService], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Injectable } from '@nestjs/common' | ||
|
||
@Injectable() | ||
export class AppService {} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { TradingController } from './trading.controller' | ||
|
||
describe('TradingController', () => { | ||
let controller: TradingController | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [TradingController], | ||
}).compile() | ||
|
||
controller = module.get<TradingController>(TradingController) | ||
}) | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Controller } from '@nestjs/common' | ||
|
||
@Controller('trading') | ||
export class TradingController {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common' | ||
import { ConfigModule } from '@nestjs/config' | ||
|
||
import { TradingService } from './trading.service' | ||
import { TradingController } from './trading.controller' | ||
|
||
@Module({ | ||
controllers: [TradingController], | ||
providers: [TradingService], | ||
}) | ||
export class TradingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { ConfigModule } from '@nestjs/config' | ||
import { ScheduleModule } from '@nestjs/schedule' | ||
|
||
import { TradingService } from './trading.service' | ||
|
||
describe('TradingService', () => { | ||
let service: TradingService | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [TradingService], | ||
imports: [ | ||
ConfigModule.forRoot({ isGlobal: true }), | ||
ScheduleModule.forRoot(), | ||
], | ||
}).compile() | ||
|
||
service = module.get<TradingService>(TradingService) | ||
}) | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable, Logger } from '@nestjs/common' | ||
import { ConfigService } from '@nestjs/config' | ||
|
||
import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js' | ||
import { Wallet } from '@coral-xyz/anchor' | ||
import bs58 from 'bs58' | ||
|
||
type RouteMap = Record<string, string[]> | ||
|
||
@Injectable() | ||
export class TradingService { | ||
wallet: Wallet | ||
|
||
constructor(private configService: ConfigService) { | ||
// this is set in the monorepo root | ||
const pk = this.configService.get('NX_SOLANA_PK') || '' | ||
|
||
this.wallet = new Wallet(Keypair.fromSecretKey(bs58.decode(pk))) | ||
|
||
const address = this.wallet.publicKey | ||
|
||
Logger.log( | ||
`Wallet at address ${address.toString()} loaded successfully!`, | ||
) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './lib/utils' | ||
export * from './lib/spl' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { parseUSDC } from './spl' | ||
|
||
describe('parseUSDC', () => { | ||
it('should correctly parse a whole number amount', () => { | ||
expect(parseUSDC(10).result).toBe('10000000') | ||
}) | ||
|
||
it('should correctly parse floats', () => { | ||
expect(parseUSDC(10.5).result).toBe('10500000') | ||
}) | ||
|
||
it('should correctly handle zero', () => { | ||
expect(parseUSDC(0).result).toBe('0') | ||
}) | ||
|
||
it('should handle very large numbers', () => { | ||
expect(parseUSDC(123456789.123456).result).toBe('123456789123456') | ||
}) | ||
|
||
it('should throw an error for negative numbers', () => { | ||
expect(parseUSDC(-1).error).toBe('Invalid input') | ||
}) | ||
|
||
it('should throw an error for non-numeric inputs', () => { | ||
// @ts-ignore | ||
expect(parseUSDC('abc').error).toBe('Invalid input') | ||
// @ts-ignore | ||
expect(parseUSDC(undefined).error).toBe('Invalid input') | ||
}) | ||
}) |
Oops, something went wrong.