Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature-kk-desktop-migrate' into…
Browse files Browse the repository at this point in the history
… feature-kk-desktop-migrate
  • Loading branch information
BitHighlander committed Feb 25, 2025
2 parents 6586ee9 + 34ebf39 commit 4f61007
Show file tree
Hide file tree
Showing 160 changed files with 326 additions and 2,474 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/caip/src/adapters/coingecko/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
} from '../../constants'
import * as adapters from './generated'

export { fetchData as fetchCoingeckoData, parseData as parseCoingeckoData } from './utils'

// https://api.coingecko.com/api/v3/asset_platforms
export enum CoingeckoAssetPlatform {
Ethereum = 'ethereum',
Expand Down
11 changes: 0 additions & 11 deletions packages/chain-adapters/src/cosmossdk/thorchain/types.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/chain-adapters/src/solana/SolanaChainAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ import {
import { isToken2022AccountInfo } from './types'
import { microLamportsToLamports } from './utils'

export const svmChainIds = [KnownChainIds.SolanaMainnet] as const

// Maximum compute units allowed for a single solana transaction
const MAX_COMPUTE_UNITS = 1400000

Expand Down
18 changes: 12 additions & 6 deletions packages/swapper/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
export * from './types'
export * from './utils'
export * from './constants'
export * from './swapper'
export * from './thorchain-utils'
export * from './cowswap-utils'
export * from './safe-utils'
export * from './swapper'
export * from './swappers/ArbitrumBridgeSwapper'
export * from './swappers/ChainflipSwapper'
export * from './swappers/CowSwapper'
export * from './swappers/JupiterSwapper'
export { isArbitrumBridgeTradeQuoteOrRate } from './swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote'
export { isNativeEvmAsset } from './swappers/utils/helpers/helpers'
export * from './swappers/LifiSwapper'
export * from './swappers/PortalsSwapper'
export * from './swappers/ThorchainSwapper'
export * from './swappers/utils/helpers/helpers'
export * from './thorchain-utils'
export * from './types'
export * from './utils'

export * as testData from './swappers/utils/test-data'
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { v4 as uuid } from 'uuid'
import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants'
import type {
GetEvmTradeQuoteInputBase,
GetEvmTradeQuoteInputWithWallet,
SingleHopTradeQuoteSteps,
SwapErrorRight,
SwapperDeps,
Expand All @@ -15,11 +16,7 @@ import type {
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { makeSwapErrorRight } from '../../../utils'
import type {
ArbitrumBridgeTradeQuote,
ArbitrumBridgeTradeRate,
GetEvmTradeQuoteInputWithWallet,
} from '../types'
import type { ArbitrumBridgeTradeQuote, ArbitrumBridgeTradeRate } from '../types'
import type { FetchArbitrumBridgeQuoteInput } from '../utils/fetchArbitrumBridgeSwap'
import { fetchArbitrumBridgeQuote } from '../utils/fetchArbitrumBridgeSwap'
import { assertValidTrade } from '../utils/helpers'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { ethChainId } from '@shapeshiftoss/caip'
import type { HDWallet } from '@shapeshiftoss/hdwallet-core'
import type { Result } from '@sniptt/monads'
import { Err, Ok } from '@sniptt/monads'
import { v4 as uuid } from 'uuid'

import { getDefaultSlippageDecimalPercentageForSwapper } from '../../../constants'
import type {
GetEvmTradeQuoteInputBase,
GetEvmTradeRateInput,
SingleHopTradeRateSteps,
SwapErrorRight,
Expand All @@ -18,10 +16,6 @@ import type { ArbitrumBridgeTradeRate } from '../types'
import { fetchArbitrumBridgePrice } from '../utils/fetchArbitrumBridgeSwap'
import { assertValidTrade } from '../utils/helpers'

export type GetEvmTradeQuoteInputWithWallet = Omit<GetEvmTradeQuoteInputBase, 'supportsEIP1559'> & {
wallet: HDWallet
}

export async function getTradeRate(
input: GetEvmTradeRateInput,
{ assertGetEvmChainAdapter }: SwapperDeps,
Expand Down
2 changes: 2 additions & 0 deletions packages/swapper/src/swappers/ArbitrumBridgeSwapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './endpoints'
export * from './getTradeQuote/getTradeQuote'
8 changes: 1 addition & 7 deletions packages/swapper/src/swappers/ArbitrumBridgeSwapper/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { HDWallet } from '@shapeshiftoss/hdwallet-core'

import type { GetEvmTradeQuoteInputBase, TradeQuote, TradeRate } from '../../types'
import type { TradeQuote, TradeRate } from '../../types'

export enum BRIDGE_TYPE {
ETH_DEPOSIT = 'ETH Deposit',
Expand All @@ -9,10 +7,6 @@ export enum BRIDGE_TYPE {
ERC20_WITHDRAWAL = 'ERC20 Withdrawal',
}

export type GetEvmTradeQuoteInputWithWallet = Omit<GetEvmTradeQuoteInputBase, 'supportsEIP1559'> & {
wallet: HDWallet
}

type ArbitrumBridgeSpecificMetadata = {
direction: 'deposit' | 'withdrawal'
}
Expand Down
2 changes: 2 additions & 0 deletions packages/swapper/src/swappers/ChainflipSwapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './types'
export * from './constants'
4 changes: 2 additions & 2 deletions packages/swapper/src/swappers/JupiterSwapper/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ASSOCIATED_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@coral-xyz/anchor/dist/
import type { Instruction, QuoteResponse, SwapInstructionsResponse } from '@jup-ag/api'
import type { ChainId } from '@shapeshiftoss/caip'
import { fromAssetId, solAssetId, wrappedSolAssetId } from '@shapeshiftoss/caip'
import type { ChainAdapter } from '@shapeshiftoss/chain-adapters/src/solana'
import type { solana } from '@shapeshiftoss/chain-adapters'
import type { Asset, KnownChainIds } from '@shapeshiftoss/types'
import { bnOrZero } from '@shapeshiftoss/utils'
import type { Result } from '@sniptt/monads'
Expand Down Expand Up @@ -53,7 +53,7 @@ type CreateInstructionsParams = {
affiliateBps: string
buyAsset: Asset
sellAsset: any
adapter: ChainAdapter
adapter: solana.ChainAdapter
jupiterUrl: string
}

Expand Down
3 changes: 3 additions & 0 deletions packages/swapper/src/swappers/LifiSwapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './LifiSwapper'
export * from './constants'
export * from './utils/types'
3 changes: 0 additions & 3 deletions packages/swapper/src/swappers/LifiSwapper/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { KnownChainIds } from '@shapeshiftoss/types'

import type { SupportedChainIds } from '../../../types'

export const MIN_CROSS_CHAIN_AMOUNT_THRESHOLD_USD_HUMAN = 20 // arbitrary amount deemed by lifi devs to meet minimum amount across all brdiges
export const MIN_SAME_CHAIN_AMOUNT_THRESHOLD_USD_HUMAN = '0.01' // Same chain bridges can be of any amount, since fees are paid explicitly as miner fees in one chain
export const SELECTED_ROUTE_INDEX = 0 // default to first route - this is the highest ranking according to the query we send
export const DEFAULT_LIFI_TOKEN_ADDRESS = '0x0000000000000000000000000000000000000000'
export const L1_GAS_ORACLE_ADDRESS = '0x420000000000000000000000000000000000000f' // optimism & base
export const L1_FEE_CHAIN_IDS = [KnownChainIds.OptimismMainnet, KnownChainIds.BaseMainnet]
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions packages/swapper/src/swappers/LifiSwapper/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ export interface LifiTradeRate extends TradeRate {
selectedLifiRoute?: Route
lifiTools?: LifiTools
}

export type LifiTool = {
key: string
name: string
logoURI: string
}
1 change: 1 addition & 0 deletions packages/swapper/src/swappers/PortalsSwapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './constants'
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
UtxoTransactionExecutionProps,
} from '../../types'
import { executeEvmTransaction } from '../../utils'
import { buySupportedChainIds, sellSupportedChainIds } from './constants'
import { thorchainBuySupportedChainIds, thorchainSellSupportedChainIds } from './constants'
import type { ThornodePoolResponse } from './types'
import { poolAssetIdToAssetId } from './utils/poolAssetHelpers/poolAssetHelpers'
import { thorService } from './utils/thorService'
Expand Down Expand Up @@ -45,8 +45,8 @@ const getSupportedAssets = async (

allTokens.forEach(assetId => {
const chainId = fromAssetId(assetId).chainId
sellSupportedChainIds[chainId] && supportedSellAssetIds.push(assetId)
buySupportedChainIds[chainId] && supportedBuyAssetIds.push(assetId)
thorchainSellSupportedChainIds[chainId] && supportedSellAssetIds.push(assetId)
thorchainBuySupportedChainIds[chainId] && supportedBuyAssetIds.push(assetId)
})

return { supportedSellAssetIds, supportedBuyAssetIds }
Expand Down
8 changes: 4 additions & 4 deletions packages/swapper/src/swappers/ThorchainSwapper/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SwapperName } from '../../types'

export const THOR_PRECISION = 8

export const sellSupportedChainIds: Record<ChainId, boolean> = {
export const thorchainSellSupportedChainIds: Record<ChainId, boolean> = {
[KnownChainIds.EthereumMainnet]: true,
[KnownChainIds.BitcoinMainnet]: true,
[KnownChainIds.DogecoinMainnet]: true,
Expand All @@ -21,7 +21,7 @@ export const sellSupportedChainIds: Record<ChainId, boolean> = {
[KnownChainIds.BaseMainnet]: true,
}

export const buySupportedChainIds: Record<ChainId, boolean> = {
export const thorchainBuySupportedChainIds: Record<ChainId, boolean> = {
[KnownChainIds.EthereumMainnet]: true,
[KnownChainIds.BitcoinMainnet]: true,
[KnownChainIds.DogecoinMainnet]: true,
Expand All @@ -35,8 +35,8 @@ export const buySupportedChainIds: Record<ChainId, boolean> = {
}

export const THORCHAIN_SUPPORTED_CHAIN_IDS: SupportedChainIds = {
sell: Object.keys(sellSupportedChainIds),
buy: Object.keys(buySupportedChainIds),
sell: Object.keys(thorchainSellSupportedChainIds),
buy: Object.keys(thorchainBuySupportedChainIds),
}

export const THORCHAIN_STREAM_SWAP_SOURCE: SwapSource = `${SwapperName.Thorchain} • Streaming`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Err } from '@sniptt/monads'
import type { CommonTradeQuoteInput, SwapErrorRight, SwapperDeps, TradeQuote } from '../../../types'
import { TradeQuoteError } from '../../../types'
import { makeSwapErrorRight } from '../../../utils'
import { buySupportedChainIds, sellSupportedChainIds } from '../constants'
import { thorchainBuySupportedChainIds, thorchainSellSupportedChainIds } from '../constants'
import type { ThornodePoolResponse, ThorTradeQuote } from '../types'
import { getL1Quote } from '../utils/getL1quote'
import { getL1ToLongtailQuote } from '../utils/getL1ToLongtailQuote'
Expand All @@ -26,7 +26,10 @@ export const getThorTradeQuote = async (
deps.config.REACT_APP_FEATURE_THORCHAINSWAP_L1_TO_LONGTAIL
const { sellAsset, buyAsset } = input

if (!sellSupportedChainIds[sellAsset.chainId] || !buySupportedChainIds[buyAsset.chainId]) {
if (
!thorchainSellSupportedChainIds[sellAsset.chainId] ||
!thorchainBuySupportedChainIds[buyAsset.chainId]
) {
return Err(
makeSwapErrorRight({
message: 'Unsupported chain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Err } from '@sniptt/monads'
import type { GetTradeRateInput, SwapErrorRight, SwapperDeps, TradeRate } from '../../../types'
import { TradeQuoteError } from '../../../types'
import { makeSwapErrorRight } from '../../../utils'
import { buySupportedChainIds, sellSupportedChainIds } from '../constants'
import { thorchainBuySupportedChainIds, thorchainSellSupportedChainIds } from '../constants'
import type { ThornodePoolResponse, ThorTradeRate } from '../types'
import { getL1Rate } from '../utils/getL1Rate'
import { getL1ToLongtailRate } from '../utils/getL1ToLongtailRate'
Expand All @@ -26,7 +26,10 @@ export const getThorTradeRate = async (
deps.config.REACT_APP_FEATURE_THORCHAINSWAP_L1_TO_LONGTAIL
const { sellAsset, buyAsset } = input

if (!sellSupportedChainIds[sellAsset.chainId] || !buySupportedChainIds[buyAsset.chainId]) {
if (
!thorchainSellSupportedChainIds[sellAsset.chainId] ||
!thorchainBuySupportedChainIds[buyAsset.chainId]
) {
return Err(
makeSwapErrorRight({
message: 'Unsupported chain',
Expand Down
8 changes: 8 additions & 0 deletions packages/swapper/src/swappers/ThorchainSwapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './constants'
export * from './getThorTradeQuote/getTradeQuote'
export * from './getThorTradeRate/getTradeRate'
export * from './types'
export * from './utils/thorService'
export * from './utils/poolAssetHelpers/poolAssetHelpers'
export * from './utils/longTailHelpers'
export * from './utils/isRune/isRune'
14 changes: 0 additions & 14 deletions packages/swapper/src/swappers/ThorchainSwapper/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,6 @@ export type ThorUtxoSupportedChainId =
| KnownChainIds.LitecoinMainnet
| KnownChainIds.BitcoinCashMainnet

export type ThorEvmSupportedChainId =
| KnownChainIds.EthereumMainnet
| KnownChainIds.AvalancheMainnet
| KnownChainIds.BnbSmartChainMainnet

export type ThorCosmosSdkSupportedChainId =
| KnownChainIds.ThorchainMainnet
| KnownChainIds.CosmosMainnet

export type ThorChainId =
| ThorCosmosSdkSupportedChainId
| ThorEvmSupportedChainId
| ThorUtxoSupportedChainId

type ThorNodeCoinSchema = {
asset: string
amount: string
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { CHAIN_REFERENCE } from '@shapeshiftoss/caip'
import { Token } from '@uniswap/sdk-core'

export const THOR_MINIMUM_PADDING = 1.2
export const THOR_EVM_GAS_LIMIT = '100000' // for sends of eth / erc20 into thorchain router
export const THORCHAIN_FIXED_PRECISION = 8 // limit values are precision 8 regardless of the chain
export const THORCHAIN_AFFILIATE_NAME = 'ss'
export const MEMO_PART_DELIMITER = ':'
export const POOL_PART_DELIMITER = '.'
export const LIMIT_PART_DELIMITER = '/'
export const DEFAULT_STREAMING_NUM_SWAPS = 0 // let network decide, see https://dev.thorchain.org/thorchain-dev/concepts/streaming-swaps
export const DEFAULT_STREAMING_INTERVAL = 10 // TODO: calc this based on pool depth https://dev.thorchain.org/thorchain-dev/concepts/streaming-swaps

export const WETH_TOKEN = new Token(
Number(CHAIN_REFERENCE.EthereumMainnet),
Expand Down
Loading

0 comments on commit 4f61007

Please sign in to comment.