Skip to content

Instantly share code, notes, and snippets.

View olegpetroveth's full-sized avatar

Oleg Petrov olegpetroveth

View GitHub Profile
@olegpetroveth
olegpetroveth / monitor.py
Last active April 3, 2023 16:37
Mayachain mimir + pool monitoring with OS notification on Linux
# Disclaimers
# 1. Verify the code and make sure you understand it
# 2. Run at your own risk, I take no accountability for information reported
# 3. This is not meant to scale into a complete project, I was just curious learning Python
# 4. Please don't abuse the refresh interval (or if you want, run your own infra)
import requests
import time
import os
@olegpetroveth
olegpetroveth / index.js
Created May 4, 2023 18:55
Mnemonic to private and public keys
const bip39 = require('bip39');
const { hdkey } = require('ethereumjs-wallet');
// Replace the following mnemonic seed phrase with your own
const mnemonic = 'your mnemonic seed phrase here';
// to install
// yarn add bip39 ethereumjs-wallet
// to run
@olegpetroveth
olegpetroveth / TSAggregatorVTHOR.sol
Created June 27, 2023 18:46
Aggregator contract daisy-chaining standard ERC-4626 operations with Thorchain protocol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import {SafeTransferLib} from "../lib/SafeTransferLib.sol";
import {TSAggregator} from "./TSAggregator.sol";
import {IThorchainRouter} from "./interfaces/IThorchainRouter.sol";
import {IUniswapRouterV2} from "./interfaces/IUniswapRouterV2.sol";
import {IERC20} from "./interfaces/IERC20.sol";
import {IERC4626} from "./interfaces/IERC4626.sol";
@olegpetroveth
olegpetroveth / arkeo-testnet-guide.md
Last active September 18, 2023 17:31
Arkeo validator setup from fresh Ubuntu Server 22.04
@olegpetroveth
olegpetroveth / evm-params.js
Created November 15, 2023 18:34
Encode/Decode EVM Params
const Web3 = require('web3');
// encode
const feePercents = [1000]; // 10% fee
const feeRecipients = ["0x9F9A7D3e131eD45225396613E383D59a732f7BeB"];
const encodedFees = Web3.eth.abi.encodeParameters(
['uint256[]', 'address[]'],
[feePercents, feeRecipients]
);
@olegpetroveth
olegpetroveth / TSMemoGenerator.sol
Created November 26, 2023 03:12
Thorswap Memo Generator Contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract TSMemoGenerator {
// Generic memo for swaps and loans
// e.g. SWAP:BNB.BNB:bnb108n64knfm38f0mm23nkreqqmpc7rpcw89sqqw5:1231230/2/6:t:30
function generic(
string memory action, // SWAP
string memory asset, // BNB.BNB
@olegpetroveth
olegpetroveth / TSDistributor.sol
Created November 29, 2023 14:20
Simple contract to help with fee sharing agreements
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import { IERC20 } from './interfaces/IERC20.sol';
import { Owners } from "./Owners.sol";
contract TSDistributor is Owners {
address public walletA;
address public walletB;
uint16 public shareA;
@olegpetroveth
olegpetroveth / TSLendingLoop_V1.sol
Last active February 22, 2024 20:35
Thorchain Lending Looper Aggregator Contract - PoC
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
// I don't recommend anyone deploy or use this contract.
// This is not tested, not reviewed and certainly not audited.
import {Owners} from "../../lib/Owners.sol";
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
import {SafeTransferLib} from "../../lib/SafeTransferLib.sol";
import {IThorchainRouterV4} from "../../interfaces/IThorchainRouterV4.sol";
@olegpetroveth
olegpetroveth / txn_type.ts
Last active March 8, 2024 15:36
Tracker txn_type short list
export enum TransactionType {
SWAP_TC_TO_TC = 'SWAP:TC-TC',
SWAP_ETH_TO_TC = 'SWAP:ETH-TC',
SWAP_TC_TO_ETH = 'SWAP:TC-ETH',
SWAP_ETH_TO_ETH = 'SWAP:ETH-ETH',
SWAP_AVAX_TO_TC = 'SWAP:AVAX-TC',
SWAP_TC_TO_AVAX = 'SWAP:TC-AVAX',
SWAP_AVAX_TO_AVAX = 'SWAP:AVAX-AVAX',
@olegpetroveth
olegpetroveth / swapKitClient.ts
Last active March 22, 2024 02:01
Up to date SwapKit Client example
import type { AssetValue, ConnectWalletParams, SwapKit } from "@swapkit/core";
import type { ThorchainProvider } from "@swapkit/thorchain";
import type { keystoreWallet } from "@swapkit/wallet-keystore";
import { SwapKitApi } from "@swapkit/api";
import { FeeOption } from "@swapkit/core";
import { Chain } from "@swapkit/types";
import { logger } from "@thorswap/logger";
type SupportedWallet = typeof keystoreWallet;