Skip to content

Instantly share code, notes, and snippets.

View codewithgun's full-sized avatar
💭
meow?

kampung-tech codewithgun

💭
meow?
  • Littleroot Town
View GitHub Profile
import DLMM, { StrategyType } from "@meteora-ag/dlmm";
import { clusterApiUrl, Connection, Keypair, PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import fs from "fs";
import os from "os";
const privateKeyFilepath = `${os.homedir()}/.config/solana/mainnet.json`;
const rawPrivateKey = fs.readFileSync(privateKeyFilepath, "utf-8");
const payer = Keypair.fromSecretKey(new Uint8Array(JSON.parse(rawPrivateKey)));
@codewithgun
codewithgun / vault_details.ts
Last active August 1, 2025 16:09
Fetch meteora vault details
import VaultImpl from "@meteora-ag/vault-sdk";
import { Mint, unpackMint } from "@solana/spl-token";
import { clusterApiUrl, Connection, PublicKey } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("mainnet-beta"), "confirmed");
const keeperBaseUrl = "https://merv2-api.meteora.ag";
const lendingProgramIdsToName = new Map<string, string>([
["MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA", "MarginFi"],
import AmmImpl, { MAINNET_POOL } from "@mercurial-finance/dynamic-amm-sdk";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import { Wallet, AnchorProvider } from "@project-serum/anchor";
import { TokenListProvider } from "@solana/spl-token-registry";
import Decimal from "decimal.js";
interface JupPriceResponse {
data: {
[address: string]: {
id: String;
@codewithgun
codewithgun / main.rs
Last active April 22, 2024 04:53
DLMM account subscribe and decode
use std::env;
use anchor_client::anchor_lang::AccountDeserialize;
use anyhow::Result;
use base64::Engine;
use futures::{SinkExt, StreamExt};
use lb_clmm::state::position::PositionV2;
use serde_json::{json, Value};
use tokio_tungstenite::{connect_async, tungstenite::Message};
@codewithgun
codewithgun / README.md
Created March 2, 2024 17:15 — forked from progrium/README.md
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • In general, binaries built just for x86 architecture will automatically be run in x86 mode
  • You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
  • You can force command-line apps by prefixing with arch -x86_64, for example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

function test_getFeeAmount() public {
// Configuration was copied from BTC.b/USDC pair
bytes32 params;
uint16 binStep = 10;
params = params.setStaticFeeParameters(10000, 30, 600, 5000, 40000, 1000, 350000);
// Set volatility accumulator to the max
params = params.setVolatilityAccumulator(350000);
// 5900000000000000 => 0.59%
@codewithgun
codewithgun / example-typeorm-jest.test.ts
Created September 19, 2021 09:59 — forked from Ciantic/example-typeorm-jest.test.ts
Example of testing TypeOrm with Jest and Sqlite in-memory database
import { createConnection, getConnection, Entity, getRepository } from "typeorm";
import { PrimaryGeneratedColumn, Column } from "typeorm";
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn()
id?: number;
@Column()
name?: string;
{
"printWidth": 180,
"tabWidth": null,
"useTabs": true,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always"
}
@codewithgun
codewithgun / nodejs-tcp-example.js
Created July 18, 2021 16:43 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@codewithgun
codewithgun / postgres.md
Last active May 17, 2021 18:24
How to configure postgres to receive external/remote request

Unable to connect Postgresql from client

There was several reasons causes client unable to connect to Postgres database.

First, run sudo systemctl status postgresql to check whether the database is running.

If the output shows status: active, it shows that the database is up and running. The problems might due to authentication, listening port, or firewall.

In Postgres, there was few type of authentication methods. However, most of the time, the authentication will be password authentication or local socket authentication.