Skip to content

Commit

Permalink
feat: add allowed lifi bridges (#174)
Browse files Browse the repository at this point in the history
* feat: add allowed lifi bridges
  • Loading branch information
0xSulpiride authored Sep 26, 2022
1 parent 57273d4 commit 1237da3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "etherspot",
"version": "1.36.7",
"version": "1.36.8",
"description": "Etherspot SDK",
"keywords": [
"ether",
Expand Down
5 changes: 4 additions & 1 deletion src/sdk/dto/get-exchange-cross-chain-quote.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BigNumber } from 'ethers';
import { Type } from 'class-transformer';
import { IsInt, IsOptional, IsPositive } from 'class-validator';
import { IsAddress, IsBigNumberish } from './validators';
import { CrossChainServiceProvider } from '..';
import { CrossChainServiceProvider, LiFiBridge } from '..';

export class GetExchangeCrossChainQuoteDto {
@IsAddress()
Expand All @@ -26,4 +26,7 @@ export class GetExchangeCrossChainQuoteDto {

@IsOptional()
serviceProvider?: CrossChainServiceProvider;

@IsOptional()
lifiBridges?: LiFiBridge[];
}
14 changes: 14 additions & 0 deletions src/sdk/exchange/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ export enum CrossChainServiceProvider {
LiFi = 'LiFi',
Connext = 'Connext',
}

export enum LiFiBridge {
across = 'across',
arbitrum = 'arbitrum',
avalanche = 'avalanche',
cbridge = 'cbridge',
connext = 'connext',
hop = 'hop',
hyphen = 'hyphen',
multichain = 'multichain',
optimism = 'optimism',
polygon = 'polygon',
stargate = 'stargate'
}
6 changes: 5 additions & 1 deletion src/sdk/exchange/exchange.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {

import { PaginatedTokens } from '../assets';
import { GetCrossChainBridgeTokenListDto, GetCrossChainBridgeRouteDto, GetCrossChainBridgeSupportedChainsDto } from '../dto';
import { CrossChainServiceProvider } from './constants';
import { CrossChainServiceProvider, LiFiBridge } from './constants';

export class ExchangeService extends Service {
async getExchangeSupportedAssets(page: number = null, limit: number = null, ChainId: number): Promise<PaginatedTokens> {
Expand Down Expand Up @@ -66,6 +66,7 @@ export class ExchangeService extends Service {
toChainId: number,
fromAmount: BigNumber,
serviceProvider?: CrossChainServiceProvider,
lifiBridges?: LiFiBridge[]
): Promise<BridgingQuotes> {
const { apiService, accountService } = this.services;

Expand All @@ -83,6 +84,7 @@ export class ExchangeService extends Service {
$fromChainId: Int
$toChainId: Int
$serviceProvider: CrossChainServiceProvider
$lifiBridges: [LiFiBridge!]
) {
result: getCrossChainQuotes(
account: $account
Expand All @@ -92,6 +94,7 @@ export class ExchangeService extends Service {
fromChainId: $fromChainId
toChainId: $toChainId
serviceProvider: $serviceProvider
lifiBridges: $lifiBridges
) {
items {
provider
Expand Down Expand Up @@ -156,6 +159,7 @@ export class ExchangeService extends Service {
toChainId,
fromAmount,
serviceProvider,
lifiBridges
},
models: {
result: BridgingQuotes,
Expand Down
3 changes: 2 additions & 1 deletion src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ export class Sdk {
* @return Promise<MutliChainQuotes>
*/
async getCrossChainQuotes(dto: GetExchangeCrossChainQuoteDto): Promise<BridgingQuotes> {
const { fromChainId, toChainId, fromTokenAddress, toTokenAddress, fromAmount, serviceProvider } = await validateDto(
const { fromChainId, toChainId, fromTokenAddress, toTokenAddress, fromAmount, serviceProvider, lifiBridges } = await validateDto(
dto,
GetExchangeCrossChainQuoteDto,
{
Expand All @@ -1367,6 +1367,7 @@ export class Sdk {
toChainId,
BigNumber.from(fromAmount),
serviceProvider,
lifiBridges
);
}

Expand Down

0 comments on commit 1237da3

Please sign in to comment.