Skip to content

Instantly share code, notes, and snippets.

View Henry-E's full-sized avatar
😃

Henry-E

😃
View GitHub Profile
@Henry-E
Henry-E / closeAuxAccount.ts
Created April 25, 2024 09:46
Close aux token account
import * as anchor from "@coral-xyz/anchor";
import { PublicKey, Transaction, ComputeBudgetProgram } from "@solana/web3.js";
import * as token from "@solana/spl-token";
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
// Assumes your running with `anchor run closeAux --provider.cluster mainnet --provider.wallet ~/.config/solana/your-key.json`
const payer = provider.wallet["payer"];
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QTextEdit, QPushButton
from PyQt6.QtCore import Qt, pyqtSignal
from ib_insync import IB, util
from aiogram import Bot, Dispatcher, types
import asyncio
import threading
# Import logging
import logging
# Setup logging
@Henry-E
Henry-E / gist:df482ea553170c7a27a73296afc205ef
Created January 4, 2022 18:52
Grant for adding Closeable permissioned markets to serum v3
Proposal
A 13,500 token grant for adding closeable markets to serum v3.
This PR will allow permissioned markets to be disabled and to redeem the rent exempt Sol used for the event queue, request queue, bid and ask queues.
It’s been a feature long requested by many in the community building on top and serum and we were very happy to be able to make this PR.
https://github.com/project-serum/serum-dex/pull/191
3,500 tokens will go to Tom, 10,000 will go to Henry
@Henry-E
Henry-E / lib.rs
Created July 12, 2021 14:43
Serum New Order CPI
const BASE: u128 = 1_000_000
// Assumes limit price and coin amount have 6 decimals and the u64 int contains all decimal places
fn new_order(
&self,
side: Side,
limit_price: u64,
coin_amount: u64,
order_type: OrderType,
) -> ProgramResult {
let (price_lots, coin_lots, pc_lot_size) = {
@Henry-E
Henry-E / proxy_transfer.rs
Last active May 4, 2022 00:13
Very hacky PCA CPI
pub fn proxy_transfer(ctx: Context<ProxyTransfer>, amount: u64, nonce: u8) -> ProgramResult {
token::transfer(ctx.accounts.into(), amount)?;
// let seeds = &[TEST_SEED.as_bytes(), &[nonce]];
let seeds: &[&[u8]] = &[ctx.accounts.authority.to_account_info().key.as_ref(), &[nonce]];
let signer = &[&seeds[..]];
// let cpi_ctx = CpiContext::from(&*ctx.accounts).with_signer(signer);
let cpi_ctx = CpiContext::new_with_signer(
ctx.accounts.token_program.clone(),
#!/bin/bash
# make it easier to request interactive jobs
int ()
{
# there's issues with getopts working in functions if OPTIND isn't reset
# every time the function is called
local OPTIND;
# should we use gpu queue, defaults to cpu
// all this code needs to go in the loop which initialises the asteroids
bool isStillCheckingLocation = true;
while(isStillCheckingLocation)
{
asteroidStartLocation = new Vector2 (UnityEngine.Random.Range (0, gameWidth),
UnityEngine.Random.Range (0, gameHeight));
// we need to make sure the asteroids are not spawned too close to the player
if( (asteroidStartLocation.x < gameWidth * 0.4f || asteroidStartLocation.x > gameWidth * 0.6f) &&
(asteroidStartLocation.y < gameHeight * 0.4f || asteroidStartLocation.y > gameHeight * 0.6f) )
isStillCheckingLocation = false;
//initialise this variable
shootingRangeDeg = 5f;
if( atan2 * mathf.Rad2Deb < shootingRangeDeg )
fire();
// outside of the class, below "Using UnityEngine"
using Random = UnityEngine.Random;
// make sure to initialise this properly
fudgeFactor = 30;
// inside the update function
atan2 = Mathf.Atan2 (v_diff.y, v_diff.x);
Quaternion newAngle = Quaternion.Euler (0f, 0f, atan2 * Mathf.Rad2Deg + Random.Range( - fudgeFactor, fudgeFactor) );
// this needs to go into the asteroid's update function.
// It might be prudent to store the gameHeight and gameWidth variables
// in the GameManager script and assign them to variables in this
// script on awake.
// I'm neglecting to add any initialisation here but I'm sure you know what to do
aWidth = GameManager.instance.gameWidth
aHeight = GameManager.instance.gameHeight
// inside the update function