Skip to content

Instantly share code, notes, and snippets.

View earthchie's full-sized avatar

Thanarat Kuawattanaphan earthchie

View GitHub Profile
@earthchie
earthchie / getPrice.js
Created May 13, 2021 15:12
Simple API to get a exchange rate from PancakeSwap V2 Router
const express = require('express');
const { ethers } = require('ethers');
const app = express();
const port = 3000;
const provider = new ethers.providers.JsonRpcProvider('https://bsc-dataseed.binance.org/');
const contract = {
factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73', // PancakeSwap V2 factory
router: '0x10ED43C718714eb63d5aA57B78B54704E256024E', // PancakeSwap V2 router
/******************************\
!!! คำเตือน โปรดระวัง !!!
การใช้บอท มีความเสี่ยงที่จะถูกแบนได้
แนะนำให้สร้างบัญชีใหม่มาบอทโดยเฉพาะ
\******************************/
class TLMBot {
constructor(minWaitTime = 5000, maxWaitTime = 15000) {
this.minWaitTime = minWaitTime;
this.maxWaitTime = maxWaitTime;
@earthchie
earthchie / ExchangeRate.js
Created March 9, 2021 10:58
get Satang and Bitkub Exchange rate
async function getExchangeRate(pair, start, end) {
return {
Satang: await getSatangExchangeRate(pair, start, end),
Bitkub: await getBitkubExchangeRate(pair, start, end)
}
}
async function getSatangExchangeRate(pair, start, end) {
start = start.getTime() - 86399999;
end = end.getTime() + 86400000;
/**
* @file agm_voting.sol
* @author DomeCloud co., ltd.
*/
pragma solidity ^0.5.0;
contract Ballot {
struct vote{
@earthchie
earthchie / Satang_Pro_API.md
Created September 4, 2019 12:31
Satang.Pro API

API

PromptPay Deposit QR code

Request

POST https://api.tdax.com/api/qr-deposits/
Authorization:  TDAX-API <Api-Key>
Signature: <Your-Signed-Request-Signature>
@earthchie
earthchie / saveExcel.js
Created October 31, 2017 07:19
saveExcel function
function saveExcel(data, filename){
var datenum = function (v, date1904) {
if(date1904) v+=1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
},
sheet_from_array_of_arrays = function (data, opts) {
var ws = {};
var range = {s: {c:10000000, r:10000000}, e: {c:0, r:0 }};
var ajax = {
x: [],
abortAll: function() {
var i;
for (i in ajax.x) {
if (Object.prototype.hasOwnProperty.call(ajax.x, i)) {
ajax.x[i].abort();
}
}