Skip to content

Instantly share code, notes, and snippets.

View svanas's full-sized avatar

Stefan svanas

View GitHub Profile
@svanas
svanas / Unit1.pas
Last active October 2, 2023 10:59
QuikNode
var client: IWeb3 := TWeb3.Create('https://<your-node-name>.discover.quiknode.pro/<your-token>/');
web3.eth.blockNumber(client, procedure(num: BigInteger; err: IError)
begin
TThread.Synchronize(nil, procedure
begin
if Assigned(err) then
MessageDlg(err.Message, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0)
else
MessageDlg(num.ToString, TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], 0);
end);
@svanas
svanas / Unit1.pas
Last active December 18, 2023 12:10
Listen on Blocknative's mempool WebSocket API
uses
// Delphi
System.Classes,
System.JSON,
System.UITypes,
// FireMonkey
FMX.Controls,
FMX.Controls.Presentation,
FMX.Dialogs,
FMX.Forms,
@svanas
svanas / ETH-XXX-2.sh
Last active January 20, 2022 09:47
Use the Nefertiti crypto bot and trade on all the ETH-XXX market pairs with a single click.
# Trade on all the ETH-XXX market pairs.
# Written by Stefan van As <svanas AT runbox DOT com>
# Example: ./ETH-XXX-2.sh --exchange=Bittrex --price=0.05 --pushover-app-key=X --pushover-user-key=X
for i in "$@"
do
case $i in
--exchange=*)
EXCHANGE="${i#*=}"
shift # past argument=value
@svanas
svanas / Unit1.pas
Last active May 31, 2023 17:16
Swap 100 USDC for WETH on Ethereum
const client: IWeb3 = TWeb3.Create(
web3.eth.infura.endpoint(web3.Ethereum, INFURA_PROJECT_ID).Value
);
web3.eth.balancer.v2.swap(
client,
owner,
TSwapKind.GivenIn,
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH
@svanas
svanas / Unit1.pas
Last active May 31, 2023 17:13
Listen to swaps between two tokens on Balancer
const client: IWeb3 = TWeb3.Create(
web3.eth.infura.endpoint(web3.Ethereum, INFURA_PROJECT_ID).Value
);
const task = web3.eth.balancer.v2.listen(
client,
procedure(
blockNo : BigInteger;
poolId : TBytes32;
tokenIn : TAddress;