-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from rarimo/feature/bsc
Added slippage param, support bsc pancake swap, refactor, fixed swap for input native token
- Loading branch information
Showing
51 changed files
with
1,264 additions
and
383 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ | |
"workspaces": [ | ||
"packages/*" | ||
], | ||
"gitHooks": { | ||
"pre-commit": "yarn lint" | ||
}, | ||
"scripts": { | ||
"build": "yarn workspaces foreach --parallel --topological-dev --verbose run build", | ||
"docs": "typedoc --options typedoc.json", | ||
|
@@ -37,7 +40,8 @@ | |
"prettier": "^2.7.1", | ||
"ts-jest": "^29.0.3", | ||
"typedoc": "^0.23.8", | ||
"typescript": "^4.9.5" | ||
"typescript": "^4.9.5", | ||
"yorkie": "^2.0.0" | ||
}, | ||
"dependenciesMeta": { | ||
"[email protected]": { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { Config } from './types' | ||
|
||
export const DEFAULT_CONFIG: Config = { | ||
V3_TOKEN_LIST: 'https://ipfs.io/ipns/tokens.uniswap.org', | ||
V2_TOKEN_LIST: | ||
'https://raw.githubusercontent.com/traderjoe-xyz/joe-tokenlists/main/src/joe.tokenlist-v2.json', | ||
UNISWAP_V3_TOKEN_LIST_URL: 'https://ipfs.io/ipns/tokens.uniswap.org', | ||
TRADER_JOE_TOKEN_LIST_URL: | ||
'https://raw.githubusercontent.com/traderjoe-xyz/joe-tokenlists/main/mc.tokenlist.json', | ||
PANCAKE_SWAP_TOKEN_LIST_URL: | ||
'https://tokens.pancakeswap.finance/pancakeswap-extended.json', | ||
} |
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 |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import { SwapContractVersion } from '../../enums' | ||
import { SWAP_V2_ABI } from './swap-v2' | ||
import { SWAP_V3_ABI } from './swap-v3' | ||
|
||
export * from './erc-20' | ||
export * from './swap-v2' | ||
export * from './swap-v3' | ||
|
||
export const SWAP_CONTRACT_ABIS = { | ||
[SwapContractVersion.TraderJoe]: SWAP_V2_ABI, | ||
[SwapContractVersion.PancakeSwap]: SWAP_V2_ABI, | ||
[SwapContractVersion.UniswapV3]: SWAP_V3_ABI, | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export const SWAP_V2 = [ | ||
export const SWAP_V2_ABI = [ | ||
{ | ||
inputs: [ | ||
{ | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export const SWAP_V3 = [ | ||
export const SWAP_V3_ABI = [ | ||
{ | ||
inputs: [ | ||
{ | ||
|
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 @@ | ||
export const BUNDLE_SALT_BYTES = 32 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const RARIMO_BRIDGE_FEE = 2.5 | ||
|
||
export const NATIVE_TOKEN_WRAP_SLIPPAGE_MULTIPLIER = 1.02 |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from './chains' | ||
export * from './abi/' | ||
export * from './fee' | ||
export * from './bundle' | ||
export * from './tokens' |
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,57 @@ | ||
import { Token } from '../entities' | ||
import { ChainNames } from '../enums' | ||
import { EVM_CHAINS } from './chains' | ||
|
||
const chapelChain = EVM_CHAINS.find(i => i.name === ChainNames.Chapel)! | ||
const fujiChain = EVM_CHAINS.find(i => i.name === ChainNames.Fuji)! | ||
|
||
export const PANCAKE_SWAP_TESTNET_TOKEN_LIST: Token[] = [ | ||
new Token({ | ||
chain: chapelChain, | ||
address: '0x8BaBbB98678facC7342735486C851ABD7A0d17Ca', | ||
name: 'Ethereum Token', | ||
symbol: 'ETH', | ||
decimals: 18, | ||
logoURI: | ||
'https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/app/images/eth_logo.svg', | ||
}), | ||
new Token({ | ||
chain: chapelChain, | ||
address: '0x8BaBbB98678facC7342735486C851ABD7A0d17Ca', | ||
name: 'Ethereum Token', | ||
symbol: 'ETH', | ||
decimals: 18, | ||
logoURI: | ||
'https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/app/images/eth_logo.svg', | ||
}), | ||
new Token({ | ||
chain: chapelChain, | ||
address: '0xae13d989dac2f0debff460ac112a837c89baa7cd', | ||
name: 'Wrapped Binance Testnet Token', | ||
symbol: 'WBNB', | ||
decimals: 18, | ||
logoURI: | ||
'https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/app/images/bnb.png', | ||
}), | ||
] | ||
|
||
export const TRADER_JOE_SWAP_TESTNET_TOKEN_LIST: Token[] = [ | ||
new Token({ | ||
chain: fujiChain, | ||
address: '0xd00ae08403B9bbb9124bB305C09058E32C39A48c', | ||
decimals: 18, | ||
name: 'Wrapped AVAX', | ||
symbol: 'WAVAX', | ||
logoURI: | ||
'https://raw.githubusercontent.com/traderjoe-xyz/joe-tokenlists/main/logos/0xd00ae08403B9bbb9124bB305C09058E32C39A48c/logo.png', | ||
}), | ||
new Token({ | ||
chain: fujiChain, | ||
address: '0xB6076C93701D6a07266c31066B298AeC6dd65c2d', | ||
decimals: 6, | ||
name: 'USD Coin', | ||
symbol: 'USDC', | ||
logoURI: | ||
'https://raw.githubusercontent.com/traderjoe-xyz/joe-tokenlists/main/logos/0xB6076C93701D6a07266c31066B298AeC6dd65c2d/logo.png', | ||
}), | ||
] |
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,37 @@ | ||
import { BN } from '@distributedlab/utils' | ||
|
||
export class AmountBase { | ||
readonly #value: string | ||
readonly #decimals: number | ||
|
||
protected constructor(value: string, decimals: number) { | ||
this.#value = value | ||
this.#decimals = decimals | ||
} | ||
|
||
get value(): string { | ||
return this.#value | ||
} | ||
|
||
get decimals(): number { | ||
return this.#decimals | ||
} | ||
|
||
toString(): string { | ||
return new BN(this.#value).fromFraction(this.#decimals).toString() | ||
} | ||
} | ||
|
||
export class Amount extends AmountBase { | ||
protected constructor(value: string, decimals: number) { | ||
super(value, decimals) | ||
} | ||
|
||
static fromRaw(value: string, decimals: number): Amount { | ||
return new Amount(value, decimals) | ||
} | ||
|
||
static fromFraction(value: string, decimals: number): Amount { | ||
return new Amount(new BN(value).fromFraction(decimals).toString(), decimals) | ||
} | ||
} |
Oops, something went wrong.