Skip to content

Commit

Permalink
cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
leecchh committed Jul 29, 2024
1 parent a257a01 commit 77b442b
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions sdk/deepbook-v3/examples/useDeepbookClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> => {
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',
Expand All @@ -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!'),
};
};

0 comments on commit 77b442b

Please sign in to comment.