Automate asset consolidation
You can automate asset consolidation from your deposit wallet addresses at fixed intervals.
Set up a CRON job in your codebase for the Consolidate wallet assets API. You can set the time interval of 15 minutes for best results. Avoid lengthy intervals to prevent extended consolidation cycles.
The following is an example code snippet of a CRON job in a Unix-like system for running the API for token “dai” in the deposit wallet with walletId “12345” that runs every 15 mins:
const cron = require('node-cron');
const axios = require('axios');
// Define the API endpoint and request body
const API_ENDPOINT = 'https://api-sdk.lmnl.dev/api/wallet/consolidate-transaction';
const REQUEST_BODY = {
wallet: {
coin: "eth",
walletId: 12345,
allToken: true,
tokenOptions: {
tokenName: "dai",
tokenAddress: "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60"
}
},
transactions: {
consolidateOptions: {
targetAddress: "0x7f17be241f88530da74f035e8b74125ffedea98d"
}
}
};
// Set up the CRON job to run every 15 minutes
cron.schedule('*/15 * * * *', async () => {
try {
const response = await axios.post(API_ENDPOINT, REQUEST_BODY);
console.log('API called successfully:', response.data);
} catch (error) {
console.error('Error calling the API:', error);
}
});
console.log('CRON job started. API will be called every 15 minutes.');
Updated 29 days ago