TokenTracker
This commit is contained in:
parent
762e942df9
commit
1031914945
1 changed files with 48 additions and 0 deletions
48
blanktokenTracker.js
Normal file
48
blanktokenTracker.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
const axios = require('axios');
|
||||
const { apiKey, signerUUID, zeroXApiKey } = require('./secrets');
|
||||
|
||||
async function checkTokenPriceChange(contractAddress, percentage) {
|
||||
// Implement token price check using 0x API
|
||||
const response = await axios.get('https://api.0x.org/swap/v1/price', {
|
||||
params: {
|
||||
sellToken: contractAddress,
|
||||
buyToken: 'ETH',
|
||||
sellAmount: 1e18
|
||||
},
|
||||
headers: {
|
||||
'0x-api-key': 'Entering_API_here'
|
||||
}
|
||||
});
|
||||
const price = response.data.price;
|
||||
|
||||
// Compare price change with the specified percentage
|
||||
let previousPrice = null;
|
||||
if (previousPrice !== null) {
|
||||
const priceChange = ((currentPrice - previousPrice) / previousPrice) * 100;
|
||||
previousPrice = currentPrice;
|
||||
return { priceChanged: Math.abs(priceChange) >= percentage };
|
||||
} else {
|
||||
previousPrice = currentPrice;
|
||||
return { priceChanged: false };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// percentage comparison
|
||||
return { priceChanged: true }; // Replace with logic
|
||||
|
||||
async function sendDirectCast(fid, message) {
|
||||
const apiUrl = 'https://api.neynar.com/v2/farcaster/cast';
|
||||
const payload = {
|
||||
signerUUID: 'UUID_Entered_here',
|
||||
text: message,
|
||||
embeds: []
|
||||
};
|
||||
await axios.post(apiUrl, payload, {
|
||||
headers: {
|
||||
apiKey: 'neynar_api_key_here',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { checkTokenPriceChange, sendDirectCast };
|
Loading…
Reference in a new issue