Skip to content

Commit

Permalink
v13.13.1: remove specific whirlpoolConfig filter
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Dec 10, 2024
1 parent 760a280 commit f524c36
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 111 deletions.
20 changes: 8 additions & 12 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Blockchains from '@depay/web3-blockchains';
import { BN, struct, publicKey, u128, u64 as u64$1, seq, u8, u16, i32, bool, i128, PublicKey, Buffer, Keypair, SystemProgram, TransactionInstruction } from '@depay/solana-web3.js';
import Decimal from 'decimal.js';

function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
constructor({
blockchain,
tokenIn,
Expand All @@ -31,10 +31,10 @@ function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[
this.decimalsOut = decimalsOut;
this.path = path;
this.pools = pools;
this.amountIn = _optionalChain$6([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$6([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$6([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$6([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.amountIn = _optionalChain$5([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$5([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$5([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$5([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.exchange = exchange;
this.getPrep = getPrep;
this.getTransaction = getTransaction;
Expand Down Expand Up @@ -432,7 +432,7 @@ class Exchange {
}
}

function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// Replaces 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE with the wrapped token and implies wrapping.
//
Expand Down Expand Up @@ -551,9 +551,9 @@ const findPath$5 = async ({ blockchain, exchange, tokenIn, tokenOut }) => {

// Add WRAPPED to route path if things start or end with NATIVE
// because that actually reflects how things are routed in reality:
if(_optionalChain$5([path, 'optionalAccess', _ => _.length]) && path[0] == Blockchains[blockchain].currency.address) {
if(_optionalChain$4([path, 'optionalAccess', _ => _.length]) && path[0] == Blockchains[blockchain].currency.address) {
path.splice(1, 0, Blockchains[blockchain].wrapped.address);
} else if(_optionalChain$5([path, 'optionalAccess', _2 => _2.length]) && path[path.length-1] == Blockchains[blockchain].currency.address) {
} else if(_optionalChain$4([path, 'optionalAccess', _2 => _2.length]) && path[path.length-1] == Blockchains[blockchain].currency.address) {
path.splice(path.length-1, 0, Blockchains[blockchain].wrapped.address);
}

Expand Down Expand Up @@ -1927,17 +1927,13 @@ const getPrice = async ({
}
};

function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// This method is cached and is only to be used to generally existing pools every 24h
// Do not use for price calulations, fetch accounts for pools individually in order to calculate price
let getAccounts = async (base, quote) => {
if(quote === Blockchains.solana.wrapped.address) { return [] } // WSOL is base not QUOTE!
let whirlpoolsConfig = _optionalChain$4([(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : undefined), 'optionalAccess', _ => _._whirlpoolsConfig]) || '2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ';
let accounts = await request(`solana://whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc/getProgramAccounts`, {
params: { filters: [
{ dataSize: WHIRLPOOL_LAYOUT.span },
{ memcmp: { offset: 8, bytes: whirlpoolsConfig }},
{ memcmp: { offset: 101, bytes: base }}, // tokenMintA
{ memcmp: { offset: 181, bytes: quote }} // tokenMintB
]},
Expand Down
14 changes: 5 additions & 9 deletions dist/esm/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Blockchains from '@depay/web3-blockchains';
import { BN, struct, publicKey, u128, u64 as u64$1, seq, u8, u16, i32, bool, i128, PublicKey, Buffer, Keypair, SystemProgram, TransactionInstruction } from '@depay/solana-web3.js';
import Decimal from 'decimal.js';

function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
constructor({
blockchain,
tokenIn,
Expand All @@ -31,10 +31,10 @@ function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[
this.decimalsOut = decimalsOut;
this.path = path;
this.pools = pools;
this.amountIn = _optionalChain$2([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$2([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$2([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$2([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.amountIn = _optionalChain$1([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$1([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$1([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$1([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.exchange = exchange;
this.getPrep = getPrep;
this.getTransaction = getTransaction;
Expand Down Expand Up @@ -1570,17 +1570,13 @@ const getPrice = async ({
}
};

function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// This method is cached and is only to be used to generally existing pools every 24h
// Do not use for price calulations, fetch accounts for pools individually in order to calculate price
let getAccounts = async (base, quote) => {
if(quote === Blockchains.solana.wrapped.address) { return [] } // WSOL is base not QUOTE!
let whirlpoolsConfig = _optionalChain$1([(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : undefined), 'optionalAccess', _ => _._whirlpoolsConfig]) || '2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ';
let accounts = await request(`solana://whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc/getProgramAccounts`, {
params: { filters: [
{ dataSize: WHIRLPOOL_LAYOUT.span },
{ memcmp: { offset: 8, bytes: whirlpoolsConfig }},
{ memcmp: { offset: 101, bytes: base }}, // tokenMintA
{ memcmp: { offset: 181, bytes: quote }} // tokenMintB
]},
Expand Down
20 changes: 8 additions & 12 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
var Blockchains__default = /*#__PURE__*/_interopDefaultLegacy(Blockchains);
var Decimal__default = /*#__PURE__*/_interopDefaultLegacy(Decimal);

function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
constructor({
blockchain,
tokenIn,
Expand All @@ -36,10 +36,10 @@
this.decimalsOut = decimalsOut;
this.path = path;
this.pools = pools;
this.amountIn = _optionalChain$6([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$6([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$6([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$6([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.amountIn = _optionalChain$5([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$5([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$5([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$5([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.exchange = exchange;
this.getPrep = getPrep;
this.getTransaction = getTransaction;
Expand Down Expand Up @@ -437,7 +437,7 @@
}
}

function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// Replaces 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE with the wrapped token and implies wrapping.
//
Expand Down Expand Up @@ -556,9 +556,9 @@

// Add WRAPPED to route path if things start or end with NATIVE
// because that actually reflects how things are routed in reality:
if(_optionalChain$5([path, 'optionalAccess', _ => _.length]) && path[0] == Blockchains__default['default'][blockchain].currency.address) {
if(_optionalChain$4([path, 'optionalAccess', _ => _.length]) && path[0] == Blockchains__default['default'][blockchain].currency.address) {
path.splice(1, 0, Blockchains__default['default'][blockchain].wrapped.address);
} else if(_optionalChain$5([path, 'optionalAccess', _2 => _2.length]) && path[path.length-1] == Blockchains__default['default'][blockchain].currency.address) {
} else if(_optionalChain$4([path, 'optionalAccess', _2 => _2.length]) && path[path.length-1] == Blockchains__default['default'][blockchain].currency.address) {
path.splice(path.length-1, 0, Blockchains__default['default'][blockchain].wrapped.address);
}

Expand Down Expand Up @@ -1932,17 +1932,13 @@
}
};

function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// This method is cached and is only to be used to generally existing pools every 24h
// Do not use for price calulations, fetch accounts for pools individually in order to calculate price
let getAccounts = async (base, quote) => {
if(quote === Blockchains__default['default'].solana.wrapped.address) { return [] } // WSOL is base not QUOTE!
let whirlpoolsConfig = _optionalChain$4([(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : undefined), 'optionalAccess', _ => _._whirlpoolsConfig]) || '2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ';
let accounts = await web3Client.request(`solana://whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc/getProgramAccounts`, {
params: { filters: [
{ dataSize: WHIRLPOOL_LAYOUT.span },
{ memcmp: { offset: 8, bytes: whirlpoolsConfig }},
{ memcmp: { offset: 101, bytes: base }}, // tokenMintA
{ memcmp: { offset: 181, bytes: quote }} // tokenMintB
]},
Expand Down
14 changes: 5 additions & 9 deletions dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
var Blockchains__default = /*#__PURE__*/_interopDefaultLegacy(Blockchains);
var Decimal__default = /*#__PURE__*/_interopDefaultLegacy(Decimal);

function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }class Route {
constructor({
blockchain,
tokenIn,
Expand All @@ -36,10 +36,10 @@
this.decimalsOut = decimalsOut;
this.path = path;
this.pools = pools;
this.amountIn = _optionalChain$2([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$2([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$2([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$2([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.amountIn = _optionalChain$1([amountIn, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
this.amountOutMin = _optionalChain$1([amountOutMin, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
this.amountOut = _optionalChain$1([amountOut, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
this.amountInMax = _optionalChain$1([amountInMax, 'optionalAccess', _7 => _7.toString, 'call', _8 => _8()]);
this.exchange = exchange;
this.getPrep = getPrep;
this.getTransaction = getTransaction;
Expand Down Expand Up @@ -1575,17 +1575,13 @@
}
};

function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

// This method is cached and is only to be used to generally existing pools every 24h
// Do not use for price calulations, fetch accounts for pools individually in order to calculate price
let getAccounts = async (base, quote) => {
if(quote === Blockchains__default['default'].solana.wrapped.address) { return [] } // WSOL is base not QUOTE!
let whirlpoolsConfig = _optionalChain$1([(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : undefined), 'optionalAccess', _ => _._whirlpoolsConfig]) || '2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ';
let accounts = await web3ClientSolana.request(`solana://whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc/getProgramAccounts`, {
params: { filters: [
{ dataSize: WHIRLPOOL_LAYOUT.span },
{ memcmp: { offset: 8, bytes: whirlpoolsConfig }},
{ memcmp: { offset: 101, bytes: base }}, // tokenMintA
{ memcmp: { offset: 181, bytes: quote }} // tokenMintB
]},
Expand Down
Loading

0 comments on commit f524c36

Please sign in to comment.