-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtodo
executable file
·82 lines (58 loc) · 2.52 KB
/
todo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Bitstamp needs proxy
Twitter parsing without API, because free plan doesn't work (https://github.com/3asyPe/twitter-automation, Snscrape) and parse new from exchanges
New pairs on Raydium https://github.com/patrulek/rayscan
Use bitquery api https://docs.bitquery.io/docs/usecases/discord-bot/
Defillama и dexscreener - new pairs
Raydium and pump.fun
If there is no symbol by contract check information in coingecko
------------------------------------------------------------------------------------------
Calculate commission:
import { ethers } from "ethers";
async function transactionCost(priorityFeeInGwei: number): Promise<string> {
try {
const gasLimit = 21000;
const provider = new ethers.providers.Web3Provider(window.ethereum);
const feeData = await provider.getFeeData();
if (!feeData.lastBaseFeePerGas) {
throw new Error("Base Fee is not available.");
}
const priorityFeeInWei = ethers.utils.parseUnits(priorityFeeInGwei.toString(), "gwei");
const totalGasPrice = feeData.lastBaseFeePerGas.add(priorityFeeInWei); // BigNumber
const transactionFeeInWei = totalGasPrice.mul(gasLimit); // BigNumber
return ethers.utils.formatEther(transactionFeeInWei);
} catch (error) {
console.error(error);
throw error;
}
}
------------------------------------------------------------------------------------------
chainlink:
from web3 import Web3
CHAINLINK_ABI = [
{
"inputs": [],
"name": "latestRoundData",
"outputs": [
{"internalType": "uint80", "name": "roundId", "type": "uint80"},
{"internalType": "int256", "name": "answer", "type": "int256"},
{"internalType": "uint256", "name": "startedAt", "type": "uint256"},
{"internalType": "uint256", "name": "updatedAt", "type": "uint256"},
{"internalType": "uint80", "name": "answeredInRound", "type": "uint80"},
],
"stateMutability": "view",
"type": "function",
}
]
def get_eth_price(rpc_url: str, contract_address: str) -> float:
try:
w3 = Web3(Web3.HTTPProvider(rpc_url))
if not w3.isConnected():
raise ConnectionError("")
contract = w3.eth.contract(address=Web3.toChecksumAddress(contract_address), abi=CHAINLINK_ABI)
latest_data = contract.functions.latestRoundData().call()
price = latest_data[1]
return float(price) / 10**8
except Exception as e:
print(e)
return None
https://docs.chain.link/data-feeds/price-feeds/addresses?network=ethereum&page=1