Skip to content

Instantly share code, notes, and snippets.

View jasbanza's full-sized avatar
👨‍🔬
experimenting

Jason jasbanza

👨‍🔬
experimenting
View GitHub Profile
@jasbanza
jasbanza / walletbalance.md
Created November 22, 2024 13:12
Get user wallet balance at specific height
curl -X GET -H "Content-Type: application/json" -H "x-cosmos-block-height: 17463916" https://rest.cosmos.directory/agoric/cosmos/bank/v1beta1/balances/agoric1u9upew4ndxy5x8hm7kna52t037x26v8f6tm4cc
@jasbanza
jasbanza / TWAP.md
Created February 12, 2024 16:44
Twap thoughts

Estimating Price Impact in the ATOM/OSMO Pool #1399

Problem Scenario

We aim to estimate the price impact in the ATOM/OSMO pool #1399 based on USD price.

Possible Method

We plan to utilize the Time-Weighted Average Price (TWAP) module and USDC (or similar stablecoin) pools as references.

@jasbanza
jasbanza / base64_decode_keyAndValue.js
Created October 18, 2023 13:55
decode base64 nested key and value properties from nested objects and multidimensional arrays
function decodeBase64(obj) {
for (let key in obj) {
try{
if (typeof obj[key] === 'object' && obj[key] !== null) {
// If the property is an object or array, recursively decode its properties
decodeBase64(obj[key]);
} else if (key === 'key' || key === 'value') {
// If the property is "key" or "value", decode its base64 value
obj[key] = atob(obj[key]);
}
@jasbanza
jasbanza / suggestSwapAmountForNewPosition.js
Last active October 9, 2023 17:10
Suggest Swap Amount for new CL Position
// paste into web browser console
const POOL_ID = 1220;
const WALLET_ADDRESS = "YOUR OSMO ADDRESS";
const REST_ENDPOINT = `https://lcd.osmosis.zone/`;
const ACCEPTABLE_TOKEN_RATIO_THRESHOLD = 0.01;
(async () => {
@jasbanza
jasbanza / findOptimalSwap.js
Last active October 5, 2023 11:22
Find optimal swap input token amount, without price lookups
const BigNumber = require('bignumber.js');
/**
* Calculate the optimal token input amount for a swap operation within specified constraints.
*
* @param {Object} options - The options for the swap estimate.
* @param {string} options.poolId - The ID of the liquidity pool.
* @param {number} options.tokenInAmount - The initial token input amount to be optimized.
* @param {string} options.tokenInDenom - The denomination of the input token.
* @param {string} options.tokenOutDenom - The denomination of the output token.
@jasbanza
jasbanza / Showcase.md
Last active October 17, 2023 20:08
Showcase
@jasbanza
jasbanza / RefreshImports.js
Last active September 15, 2023 14:21
Script for google sheets to reload cells with the IMPORT* formula.
/**
* Go through all sheets in a spreadsheet, identify and remove all spreadsheet
* import functions, then replace them a while later. This causes a "refresh"
* of the "import" functions. For periodic refresh of these formulas, set this
* function up as a time-based trigger.
*
* Caution: Formula changes made to the spreadsheet by other scripts or users
* during the refresh period COULD BE OVERWRITTEN.
*
* From: https://stackoverflow.com/a/33875957/1677912
@jasbanza
jasbanza / gist:b2b5518da31a9b0a3969b08e5ce1af13
Created September 11, 2023 17:51
osmosisd CLI - CL create position
osmosisd tx concentratedliquidity create-position 1081 "[-100]" 100 1500000000ibc/4ABBEF4C8926DDDB320AE5188CFD63267ABBCEFC0583E4AE05D6E5AA2401DDAB,1500000000ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858 0 0 --from secondary --chain-id osmosis-1 -b block --keyring-backend os --fees 10000uosmo --gas 527420
@jasbanza
jasbanza / gist:4f7aca74b16f5f59e5ed8d43158865e9
Created September 7, 2023 17:40
Concentrated Liquidity Info
Official blogpost: https://osmosis.zone/blog/supercharged-liquidity-and-osmo-2-0-a-revolution-in-decentralized-market-making
A tweet outlining it: https://twitter.com/Flowslikeosmo/status/1668634416204365827
Official Docs:
https://docs.osmosis.zone/osmosis-core/modules/concentrated-liquidity/
How incentives work: https://commonwealth.im/osmosis/discussion/11641-supercharged-incentives-model
Migration: https://commonwealth.im/osmosis/discussion/11640-supercharged-liquidity-pools-rollout
@jasbanza
jasbanza / script.js
Last active August 8, 2023 15:41
script to update API calls in google sheets.
/**
* Go through all sheets in a spreadsheet, identify and remove all spreadsheet
* import functions, then replace them a while later. This causes a "refresh"
* of the "import" functions. For periodic refresh of these formulas, set this
* function up as a time-based trigger.
*
* Caution: Formula changes made to the spreadsheet by other scripts or users
* during the refresh period COULD BE OVERWRITTEN.
*
* From: https://stackoverflow.com/a/33875957/1677912