From 77b442b01ba3e71e0760218b2a766cf55a7ee5a6 Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Mon, 29 Jul 2024 14:53:16 +0100 Subject: [PATCH] cron job --- sdk/deepbook-v3/examples/useDeepbookClient.ts | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/sdk/deepbook-v3/examples/useDeepbookClient.ts b/sdk/deepbook-v3/examples/useDeepbookClient.ts index 9085d5a237f931..2dbc24cbd28e59 100644 --- a/sdk/deepbook-v3/examples/useDeepbookClient.ts +++ b/sdk/deepbook-v3/examples/useDeepbookClient.ts @@ -5,22 +5,23 @@ import { config } from 'dotenv'; import { DeepBookMarketMaker } from './deepbookMarketMaker.js'; -// Load private key from .env file config(); -(async () => { +export const handler = async (event: any = {}): Promise => { + console.log('Received event:', event); // Use the event parameter to avoid the warning + const privateKey = process.env.PRIVATE_KEY; if (!privateKey) { throw new Error('Private key not found'); } - // Initialize with balance managers if created const balanceManagers = { MANAGER_1: { - address: '', + address: '0x6149bfe6808f0d6a9db1c766552b7ae1df477f5885493436214ed4228e842393', tradeCap: '', }, }; + const mmClient = new DeepBookMarketMaker( privateKey, 'testnet', @@ -30,18 +31,15 @@ config(); const tx = new Transaction(); - // Read only call - console.log(await mmClient.checkManagerBalance('MANAGER_1', 'SUI')); - console.log(await mmClient.getLevel2Range('SUI_DBUSDC', 0.1, 100, true)); - // Balance manager contract call - mmClient.balanceManager.depositIntoManager('MANAGER_1', 'SUI', 10)(tx); + mmClient.deepBook.addDeepPricePoint('SUI_DBUSDC', 'DEEP_DBUSDC')(tx); - // Example PTB call - mmClient.placeLimitOrderExample(tx); - mmClient.flashLoanExample(tx); - - let res = await mmClient.signAndExecute(tx); + const res = await mmClient.signAndExecute(tx); console.dir(res, { depth: null }); -})(); + + return { + statusCode: 200, + body: JSON.stringify('Execution successful!'), + }; +};