-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
11,084 additions
and
6,112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
.yarn/patches/@shapeshiftoss-bitcoinjs-lib-npm-5.2.0-shapeshift.2-e59ff81828.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
diff --git a/src/bufferutils.js b/src/bufferutils.js | ||
index a68fd31ceae3e9c465b09efd7b486fe60f88a965..14ac893566b9a87a3a2d3bd98aa5faacc4306850 100644 | ||
--- a/src/bufferutils.js | ||
+++ b/src/bufferutils.js | ||
@@ -4,12 +4,11 @@ const types = require('./types'); | ||
const typeforce = require('typeforce'); | ||
const varuint = require('varuint-bitcoin'); | ||
// https://github.com/feross/buffer/blob/master/index.js#L1127 | ||
-function verifuint(value, max) { | ||
+function verifuint(value, _max) { | ||
if (typeof value !== 'number') | ||
throw new Error('cannot write a non-number as a number'); | ||
if (value < 0) | ||
throw new Error('specified a negative value for writing an unsigned value'); | ||
- if (value > max) throw new Error('RangeError: value out of range'); | ||
if (Math.floor(value) !== value) | ||
throw new Error('value has a fractional component'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coincap/generated/eip155_1/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_1/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_10/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_137/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_42161/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_43114/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_56/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/caip/src/adapters/coingecko/generated/eip155_8453/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...aip/src/adapters/coingecko/generated/solana_5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/adapter.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/swapper/src/swappers/ChainflipSwapper/ChainflipSwapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { AssetId } from '@shapeshiftoss/caip' | ||
import type { BTCSignTx } from '@shapeshiftoss/hdwallet-core' | ||
import type { Asset } from '@shapeshiftoss/types' | ||
|
||
import type { BuyAssetBySellIdInput, Swapper, UtxoTransactionExecutionProps } from '../../types' | ||
import { executeEvmTransaction, executeSolanaTransaction } from '../../utils' | ||
import { CHAINFLIP_SUPPORTED_CHAIN_IDS } from './constants' | ||
import { isSupportedAssetId } from './utils/helpers' | ||
|
||
export const chainflipSwapper: Swapper = { | ||
executeEvmTransaction, | ||
executeSolanaTransaction, | ||
|
||
executeUtxoTransaction: async ( | ||
txToSign: BTCSignTx, | ||
{ signAndBroadcastTransaction }: UtxoTransactionExecutionProps, | ||
): Promise<string> => { | ||
return await signAndBroadcastTransaction(txToSign) | ||
}, | ||
|
||
filterAssetIdsBySellable: (assets: Asset[]): Promise<AssetId[]> => { | ||
return Promise.resolve( | ||
assets | ||
.filter(asset => CHAINFLIP_SUPPORTED_CHAIN_IDS.sell.includes(asset.chainId)) | ||
.filter(asset => isSupportedAssetId(asset.chainId, asset.assetId)) | ||
.map(asset => asset.assetId), | ||
) | ||
}, | ||
|
||
filterBuyAssetsBySellAssetId: (input: BuyAssetBySellIdInput): Promise<AssetId[]> => { | ||
return Promise.resolve( | ||
input.assets | ||
.filter(asset => CHAINFLIP_SUPPORTED_CHAIN_IDS.buy.includes(asset.chainId)) | ||
.filter(asset => isSupportedAssetId(asset.chainId, asset.assetId)) | ||
.map(asset => asset.assetId), | ||
) | ||
}, | ||
} |
70 changes: 70 additions & 0 deletions
70
packages/swapper/src/swappers/ChainflipSwapper/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
arbitrumAssetId, | ||
type AssetId, | ||
btcAssetId, | ||
type ChainId, | ||
ethAssetId, | ||
flipAssetId, | ||
solAssetId, | ||
usdcAssetId, | ||
usdcOnArbitrumOneAssetId, | ||
usdcOnSolanaAssetId, | ||
usdtAssetId, | ||
} from '@shapeshiftoss/caip' | ||
import type { Asset } from '@shapeshiftoss/types' | ||
import { KnownChainIds } from '@shapeshiftoss/types' | ||
|
||
import type { SupportedChainIds, SwapSource } from '../../types' | ||
import { SwapperName } from '../../types' | ||
import { ChainflipNetwork } from './types' | ||
|
||
export const CHAINFLIP_REGULAR_QUOTE = 'regular' | ||
export const CHAINFLIP_DCA_QUOTE = 'dca' | ||
export const CHAINFLIP_BAAS_COMMISSION = 5 | ||
|
||
export const ChainflipSupportedChainIds = [ | ||
KnownChainIds.EthereumMainnet, | ||
KnownChainIds.ArbitrumMainnet, | ||
KnownChainIds.BitcoinMainnet, | ||
KnownChainIds.SolanaMainnet, | ||
] as const | ||
|
||
export type ChainflipSupportedChainId = (typeof ChainflipSupportedChainIds)[number] | ||
|
||
export const ChainflipSupportedAssetIdsByChainId: Partial<Record<KnownChainIds, AssetId[]>> = { | ||
[KnownChainIds.EthereumMainnet]: [ethAssetId, flipAssetId, usdcAssetId, usdtAssetId], | ||
[KnownChainIds.ArbitrumMainnet]: [arbitrumAssetId, usdcOnArbitrumOneAssetId], | ||
[KnownChainIds.BitcoinMainnet]: [btcAssetId], | ||
[KnownChainIds.SolanaMainnet]: [solAssetId, usdcOnSolanaAssetId], | ||
} | ||
|
||
export const chainIdToChainflipNetwork: Partial<Record<ChainId, ChainflipNetwork>> = { | ||
[KnownChainIds.EthereumMainnet]: ChainflipNetwork.Ethereum, | ||
[KnownChainIds.ArbitrumMainnet]: ChainflipNetwork.Arbitrum, | ||
[KnownChainIds.BitcoinMainnet]: ChainflipNetwork.Bitcoin, | ||
[KnownChainIds.SolanaMainnet]: ChainflipNetwork.Solana, | ||
} | ||
|
||
export const CHAINFLIP_SUPPORTED_CHAIN_IDS: SupportedChainIds = { | ||
sell: ChainflipSupportedChainIds as unknown as ChainId[], | ||
buy: ChainflipSupportedChainIds as unknown as ChainId[], | ||
} | ||
|
||
export const CHAINFLIP_SWAP_SOURCE: SwapSource = SwapperName.Chainflip | ||
export const CHAINFLIP_BOOST_SWAP_SOURCE: SwapSource = `${SwapperName.Chainflip} • Boost` | ||
export const CHAINFLIP_DCA_SWAP_SOURCE: SwapSource = `${SwapperName.Chainflip} • DCA` | ||
export const CHAINFLIP_DCA_BOOST_SWAP_SOURCE: SwapSource = `${SwapperName.Chainflip} • DCA • Boost` | ||
|
||
export const usdcAsset: Asset = { | ||
assetId: 'eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', | ||
chainId: KnownChainIds.EthereumMainnet, | ||
color: '#2373CB', | ||
explorer: 'https://etherscan.io', | ||
explorerAddressLink: 'https://etherscan.io/address/', | ||
explorerTxLink: 'https://etherscan.io/tx/', | ||
icon: 'https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png', | ||
name: 'USDC on Ethereum', | ||
precision: 6, | ||
relatedAssetKey: 'eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', | ||
symbol: 'USDC', | ||
} |
Oops, something went wrong.