Skip to content

Commit 680324d

Browse files
feat: initial cut of job versioning, without npx-import usage
1 parent 926fdcd commit 680324d

File tree

19 files changed

+893
-344
lines changed

19 files changed

+893
-344
lines changed

packages/dca-backend/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@
4949
"@lit-protocol/contracts-sdk": "^7.3.0",
5050
"@lit-protocol/lit-node-client": "^7.3.0",
5151
"@lit-protocol/types": "^7.3.0",
52-
"@lit-protocol/vincent-ability-uniswap-swap": "8.0.0",
53-
"@lit-protocol/vincent-app-sdk": "2.2.2",
54-
"@lit-protocol/vincent-contracts-sdk": "^1.0.1",
52+
"@lit-protocol/vincent-app-sdk": "2.2.3",
53+
"@lit-protocol/vincent-contracts-sdk": "^2.0.0",
5554
"@lit-protocol/vincent-scaffold-sdk": "1.1.9-mma",
55+
"@lit-protocol/vincent-ability-erc20-approval": "3.1.0",
56+
"@lit-protocol/vincent-ability-uniswap-swap-v5": "npm:@lit-protocol/vincent-ability-uniswap-swap@5.0.0",
57+
"@lit-protocol/vincent-ability-uniswap-swap-v8": "npm:@lit-protocol/vincent-ability-uniswap-swap@8.0.0",
5658
"@noble/secp256k1": "^2.2.3",
5759
"@sentry/cli": "^2.52.0",
5860
"@sentry/node": "^10.5.0",

packages/dca-backend/src/lib/agenda/jobs/dcaSwapJobManager.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import consola from 'consola';
22
import { Types } from 'mongoose';
33

4-
import * as executeDCASwapJobDef from './executeDCASwap';
54
import { getAgenda } from '../agendaClient';
5+
import { jobName } from './executeDCASwap';
6+
import { JobParams, JobType } from './executeDCASwap/types';
67

78
interface FindSpecificScheduledJobParams {
89
ethAddress: string;
@@ -18,26 +19,22 @@ export async function listJobsByEthAddress({ ethAddress }: { ethAddress: string
1819

1920
return (await agendaClient.jobs({
2021
'data.pkpInfo.ethAddress': ethAddress,
21-
})) as executeDCASwapJobDef.JobType[];
22+
})) as JobType[];
2223
}
2324

24-
export async function findJob(
25-
params: FindSpecificScheduledJobParams
26-
): Promise<executeDCASwapJobDef.JobType>;
27-
export async function findJob(
28-
params: FindSpecificScheduledJobParams
29-
): Promise<executeDCASwapJobDef.JobType | undefined>;
25+
export async function findJob(params: FindSpecificScheduledJobParams): Promise<JobType>;
26+
export async function findJob(params: FindSpecificScheduledJobParams): Promise<JobType | undefined>;
3027
export async function findJob({
3128
ethAddress,
3229
mustExist,
3330
scheduleId,
34-
}: FindSpecificScheduledJobParams): Promise<executeDCASwapJobDef.JobType | undefined> {
31+
}: FindSpecificScheduledJobParams): Promise<JobType | undefined> {
3532
const agendaClient = getAgenda();
3633

3734
const jobs = (await agendaClient.jobs({
3835
_id: new Types.ObjectId(scheduleId),
3936
'data.pkpInfo.ethAddress': ethAddress,
40-
})) as executeDCASwapJobDef.JobType[];
37+
})) as JobType[];
4138

4239
logger.log(`Found ${jobs.length} jobs with ID ${scheduleId}`);
4340
if (mustExist && !jobs.length) {
@@ -51,7 +48,7 @@ export async function editJob({
5148
data,
5249
scheduleId,
5350
}: {
54-
data: Omit<executeDCASwapJobDef.JobParams, 'updatedAt'>;
51+
data: Omit<JobParams, 'updatedAt'>;
5552
scheduleId: string;
5653
}) {
5754
const {
@@ -70,7 +67,7 @@ export async function editJob({
7067

7168
job.attrs.data = { ...data, updatedAt: new Date() };
7269

73-
return (await job.save()) as unknown as executeDCASwapJobDef.JobType;
70+
return (await job.save()) as unknown as JobType;
7471
}
7572

7673
export async function disableJob({
@@ -113,7 +110,7 @@ export async function cancelJob({
113110
}
114111

115112
export async function createJob(
116-
data: Omit<executeDCASwapJobDef.JobParams, 'updatedAt'>,
113+
data: Omit<JobParams, 'updatedAt'>,
117114
options: {
118115
interval?: string;
119116
schedule?: string;
@@ -122,7 +119,7 @@ export async function createJob(
122119
const agenda = getAgenda();
123120

124121
// Create a new job instance
125-
const job = agenda.create<executeDCASwapJobDef.JobParams>(executeDCASwapJobDef.jobName, {
122+
const job = agenda.create<JobParams>(jobName, {
126123
...data,
127124
updatedAt: new Date(),
128125
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const BASE_CHAIN_ID = 8453;
2+
export const BASE_USDC_ADDRESS = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913';
3+
export const BASE_WBTC_ADDRESS = '0x0555E30da8f98308EdB960aa94C0Db47230d2B9c';
4+
export const BASE_UNISWAP_V3_ROUTER = '0x2626664c2603336E57B271c5C0b26F421741e481';

packages/dca-backend/src/lib/agenda/jobs/executeDCASwap/executeDCASwap.ts

Lines changed: 0 additions & 245 deletions
This file was deleted.

0 commit comments

Comments
 (0)