Skip to content

Instantly share code, notes, and snippets.

@monokh
monokh / uniswap-sdk-v2-get-price.js
Last active March 21, 2023 09:47
Uniswap V2 SDK Get Price
const { Token, WETH9, CurrencyAmount, TradeType } = require('@uniswap/sdk-core')
const { Route, Trade, Pair } = require('@uniswap/v2-sdk')
const ethers = require('ethers')
;(async () => {
const CHAIN_ID = 1
const daiAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'
const tokenA = WETH9[CHAIN_ID]
const tokenB = new Token(CHAIN_ID, daiAddress, 18, 'DAI', 'DAI')
const pairAddress = Pair.getAddress(tokenA, tokenB)
@inexorabletash
inexorabletash / @ IndexedDB Full Text Search (Proof of Concept).md
Last active March 19, 2024 13:08
IndexedDB Full Text Search (Proof of Concept)

This demonstrates the implementation of full text search for documents in Indexed DB.

  • Word-breaking and stemming is used to create a list of terms for each document.
  • Document records are annotated with the list of terms when added to the database.
  • A multi-entry index on the list of terms is populated.
  • A query is similarly processed into a list of terms.
  • A join over the terms is implemented using multiple cursors on the index.

The necessity of annotating records with the word list to populate the index is a limitation of the current Indexed DB API. A feature request to support custom