This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def swap_on_uniswap_v3(w3, router_contract, token_in, token_out, amount, wallet_address, private_key, deadline): | |
try: | |
account = w3.eth.account.from_key(private_key) | |
# ใช้ quoteExactInputSingle เพื่อประมาณการ amounts_out | |
quoter_v3 = w3.eth.contract(address=QUOTER_ADDRESS, abi=quoter_abi) | |
quote = quoter_v3.functions.quoteExactInputSingle( | |
token_in, | |
token_out, | |
3000, # 0.3% fee tier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.20; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; | |
import "@uniswap/v3-periphery/contracts/interfaces/IQuoter.sol"; | |
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; | |
contract CrossDexAtomicSwap is Ownable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: Unlicense | |
pragma solidity ^0.8.4; | |
library SafeMath { | |
/** | |
* @dev Returns the addition of two unsigned integers, reverting on | |
* overflow. | |
* | |
* Counterpart to Solidity's `+` operator. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"math/big" | |
"time" | |
"github.com/ethereum/go-ethereum/common" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use web3::types::{H160, U256}; | |
use web3::contract::{Contract, Options}; | |
use std::str::FromStr; | |
use std::time::Duration; | |
use tokio::time; | |
// Define DEX struct | |
struct DEX { | |
name: String, | |
router_address: H160, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from adbkit import ADBTools | |
from kthread_sleep import sleep | |
from mydevice import deviceserial | |
def get_uiautomator_frame(screenshotfolder='c:\\ttscreenshots'): | |
if screenshotfolder: | |
adb.aa_update_screenshot() | |
df = adb.aa_get_all_displayed_items_from_uiautomator( | |
screenshotfolder=screenshotfolder, # screenshots will be saved here | |
max_variation_percent_x=10, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from web3 import Web3 | |
import os | |
from dotenv import load_dotenv | |
from web3.middleware import geth_poa_middleware | |
# from web3.middleware import ( | |
# async_geth_poa_middleware, | |
# ) | |
import asyncio | |
# Load environment variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetchTokenPrice = async () => { | |
const tokenAddress = '0xB96D0f29a0aC9AF4a32835e90EC6531389765089'; | |
const tokenAddress2 = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'; | |
const data1 = await publicClient.readContract({ | |
address: '0x93accdaf2a9bb95d83d28cd19bc00d08be8741f9', | |
abi: pancakePairAbi, | |
functionName: 'getReserves', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import time | |
from web3 import Web3 | |
from web3.middleware import geth_poa_middleware | |
import aiohttp | |
from colorama import Fore, Style, init | |
import ssl | |
import certifi | |
from decimal import Decimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
from web3 import Web3 | |
from web3.middleware import geth_poa_middleware | |
from colorama import Fore, Back, Style, init | |
# Initialize colorama | |
init(autoreset=True) | |
# กำหนดค่าการเชื่อมต่อกับ Polygon network |
NewerOlder