Skip to content

Instantly share code, notes, and snippets.

View Aminechakr's full-sized avatar
🎯
Focusing

Amine Aminechakr

🎯
Focusing
View GitHub Profile
@Aminechakr
Aminechakr / README.md
Created March 13, 2023 09:48
Scoring NodeJs Express API program

This program uses the Express framework to define an API with two endpoints: a POST endpoint to input the endpoint parameters (/endpoint) and a GET endpoint to retrieve the results (/endpoint).

The /endpoint POST endpoint expects a JSON body with three properties: url, name, and score. When a POST request is received, the endpoint parameters are added to the endpoints array.

The /endpoint GET endpoint makes requests to each of the endpoints in the endpoints array and returns a JSON object with the scores for each endpoint. The makeRequests function is called to make the requests and accumulate the scores. If any errors occur during the requests, they are logged to the console.

The startRequests function starts making requests on a fixed interval (in this case, every hour) using the setIntervalAsync function from the set-interval-async library. The interval variable is used to store a reference to the interval so it can be cleared later.

The setTimeout function is used to set a timer for 1 hour after the s

#!/usr/bin/env python
import boto3
sess = boto3.Session(
region_name="us-west-2",
)
ec2 = sess.resource('ec2')
const { ethers } = require("ethers");
const provider = new ethers.providers.JsonRpcProvider("http://0.0.0.0:8545");
// https://info.uniswap.org/pair/0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc
const uniswapUsdtWethExchange = "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc";
// this ABI object works for both Uniswap and SushiSwap
const uniswapAbi = [
"event Swap(address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to)",
];