Skip to content

Commit

Permalink
Add Yoshi Exchange support (Fantom) [TKR-270] (#473)
Browse files Browse the repository at this point in the history
* Resolve conflicts

* Update CHANGELOG.json
  • Loading branch information
kyu-c authored May 18, 2022
1 parent 6774d2f commit fedb531
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{
"note": "Add GMX and Platypus on Avalanche and Enable KyberDMM on bsc",
"pr": 478
},
{
"note": "Add Yoshi Exchange support in Fantom",
"pr": 473
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
UNISWAPV2_ROUTER_BY_CHAIN_ID,
WAULTSWAP_ROUTER_BY_CHAIN_ID,
XSIGMA_MAINNET_INFOS,
YOSHI_ROUTER_BY_CHAIN_ID,
} from './constants';
import { CurveInfo, ERC20BridgeSource, PlatypusInfo } from './types';

Expand Down Expand Up @@ -565,7 +566,8 @@ export function uniswapV2LikeRouterAddress(
| ERC20BridgeSource.MorpheusSwap
| ERC20BridgeSource.SpookySwap
| ERC20BridgeSource.SpiritSwap
| ERC20BridgeSource.BiSwap,
| ERC20BridgeSource.BiSwap
| ERC20BridgeSource.Yoshi,
): string {
switch (source) {
case ERC20BridgeSource.UniswapV2:
Expand Down Expand Up @@ -616,6 +618,8 @@ export function uniswapV2LikeRouterAddress(
return SPIRITSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.BiSwap:
return BISWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.Yoshi:
return YOSHI_ROUTER_BY_CHAIN_ID[chainId];
default:
throw new Error(`Unknown UniswapV2 like source ${source}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.SpookySwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.Yoshi,
]),
[ChainId.Celo]: new SourceFilters([
ERC20BridgeSource.UbeSwap,
Expand Down Expand Up @@ -344,6 +345,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.SpookySwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.Yoshi,
]),
[ChainId.Celo]: new SourceFilters([
ERC20BridgeSource.UbeSwap,
Expand Down Expand Up @@ -2405,6 +2407,13 @@ export const PLATYPUS_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);

export const YOSHI_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.Fantom]: '0xe4a4642b19c4d0cba965673cd51422b1eda0a78d',
},
NULL_ADDRESS,
);

export const VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID = valueByChainId<ERC20BridgeSource[]>(
{
[ChainId.Mainnet]: [
Expand Down Expand Up @@ -2621,6 +2630,7 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
[ERC20BridgeSource.MorpheusSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.SpiritSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.SpookySwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.Yoshi]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.Beethovenx]: () => 100e3,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'SpookySwap');
case ERC20BridgeSource.MorpheusSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'MorpheusSwap');
case ERC20BridgeSource.Yoshi:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'Yoshi');
case ERC20BridgeSource.AaveV2:
return encodeBridgeSourceId(BridgeProtocol.AaveV2, 'AaveV2');
case ERC20BridgeSource.Compound:
Expand Down Expand Up @@ -299,6 +301,7 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
case ERC20BridgeSource.SpookySwap:
case ERC20BridgeSource.MorpheusSwap:
case ERC20BridgeSource.BiSwap:
case ERC20BridgeSource.Yoshi:
const uniswapV2FillData = (order as OptimizedMarketBridgeOrder<UniswapV2FillData>).fillData;
bridgeData = encoder.encode([uniswapV2FillData.router, uniswapV2FillData.tokenAddressPath]);
break;
Expand Down Expand Up @@ -526,6 +529,7 @@ export const BRIDGE_ENCODERS: {
[ERC20BridgeSource.SpookySwap]: routerAddressPathEncoder,
[ERC20BridgeSource.MorpheusSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.BiSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.Yoshi]: routerAddressPathEncoder,
// Avalanche
[ERC20BridgeSource.GMX]: gmxAddressPathEncoder,
[ERC20BridgeSource.Platypus]: platypusAddressPathEncoder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ export class SamplerOperations {
case ERC20BridgeSource.UbeSwap:
case ERC20BridgeSource.SpiritSwap:
case ERC20BridgeSource.SpookySwap:
case ERC20BridgeSource.Yoshi:
case ERC20BridgeSource.MorpheusSwap:
case ERC20BridgeSource.BiSwap:
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
Expand Down Expand Up @@ -1792,6 +1793,7 @@ export class SamplerOperations {
case ERC20BridgeSource.UbeSwap:
case ERC20BridgeSource.SpiritSwap:
case ERC20BridgeSource.SpookySwap:
case ERC20BridgeSource.Yoshi:
case ERC20BridgeSource.MorpheusSwap:
case ERC20BridgeSource.BiSwap:
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export enum ERC20BridgeSource {
SpookySwap = 'SpookySwap',
Beethovenx = 'Beethovenx',
MorpheusSwap = 'MorpheusSwap',
Yoshi = 'Yoshi',
Geist = 'Geist',
}
export type SourcesWithPoolsCache =
Expand Down

0 comments on commit fedb531

Please sign in to comment.