-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated Swing for advanceRoutes endpoint
- Loading branch information
1 parent
789364e
commit b0ca244
Showing
12 changed files
with
360 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ethers, utils, Wallet } from 'ethers'; | ||
import { EnvNames, NetworkNames, Sdk, NETWORK_NAME_TO_CHAIN_ID } from '../../src'; | ||
import { logger } from './common'; | ||
import * as dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
async function main(): Promise<void> { | ||
const wallet = Wallet.createRandom(); | ||
|
||
logger.log('sender wallet', wallet.address); | ||
|
||
const sdk = new Sdk(wallet, { | ||
env: EnvNames.LocalNets, | ||
networkName: NetworkNames.LocalA, | ||
}); | ||
|
||
const { state } = sdk; | ||
|
||
logger.log('key account', state.account); | ||
|
||
const fromChainId: number = NETWORK_NAME_TO_CHAIN_ID[NetworkNames.Mainnet]; | ||
const toChainId: number = NETWORK_NAME_TO_CHAIN_ID[NetworkNames.Bsc]; | ||
|
||
const fromAmount = utils.parseUnits('1', 18); | ||
|
||
const quoteRequestPayload = { | ||
fromChainId: fromChainId, | ||
toChainId: toChainId, | ||
fromTokenAddress: ethers.constants.AddressZero, | ||
toTokenAddress: ethers.constants.AddressZero, | ||
fromAmount: fromAmount, | ||
}; | ||
|
||
const quotes = await sdk.advanceRoutes(quoteRequestPayload); | ||
|
||
logger.log('Advance Routes: ', quotes.items); | ||
} | ||
|
||
main() | ||
.catch(logger.error) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { BigNumber } from 'ethers'; | ||
import { Type } from 'class-transformer'; | ||
import { IsBoolean, IsInt, IsOptional, IsPositive } from 'class-validator'; | ||
import { IsAddress, IsBigNumberish } from './validators'; | ||
|
||
export class GetAdvanceRoutesDto { | ||
@IsOptional() | ||
serviceProvider?: string; | ||
|
||
@IsAddress() | ||
fromTokenAddress: string; | ||
|
||
@IsAddress() | ||
toTokenAddress: string; | ||
|
||
@IsPositive() | ||
@IsInt() | ||
@Type(() => Number) | ||
fromChainId: number | null; | ||
|
||
@IsPositive() | ||
@IsInt() | ||
@Type(() => Number) | ||
toChainId: number; | ||
|
||
@IsBigNumberish() | ||
fromAmount: BigNumber; | ||
|
||
@IsOptional() | ||
@IsAddress() | ||
toAddress?: string; | ||
|
||
@IsOptional() | ||
@IsAddress() | ||
fromAddress?: string; | ||
|
||
@IsOptional() | ||
@IsBoolean() | ||
allowSwitchChain?: boolean; | ||
|
||
@IsOptional() | ||
@IsBoolean() | ||
showZeroUsd?: boolean; | ||
} |
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,56 @@ | ||
import { BigNumber } from 'ethers'; | ||
import { TransformBigNumber } from '../../common/transformers/transform-big-number'; | ||
|
||
export class AdvanceRouteToken { | ||
address: string; | ||
|
||
symbol: string; | ||
|
||
decimals?: number; | ||
|
||
name: string; | ||
} | ||
|
||
export class FeesToken { | ||
address: string; | ||
|
||
symbol: string; | ||
|
||
decimals?: number; | ||
|
||
chain: string; | ||
} | ||
|
||
export class FeesCost { | ||
type: string; | ||
|
||
token: FeesToken; | ||
|
||
@TransformBigNumber() | ||
amount: BigNumber; | ||
|
||
amountUSD?: string; | ||
} | ||
|
||
export class AdvanceRoute { | ||
provider: string; | ||
|
||
fromToken: AdvanceRouteToken; | ||
|
||
toToken: AdvanceRouteToken; | ||
|
||
duration: number; | ||
|
||
gasUSD: string; | ||
|
||
tool: string; | ||
|
||
@TransformBigNumber() | ||
amount: BigNumber; | ||
|
||
amountUSD: string; | ||
|
||
feeCosts?: FeesCost[]; | ||
|
||
gasCosts?: FeesCost[]; | ||
} |
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,5 @@ | ||
import { AdvanceRoute } from './advance-route'; | ||
|
||
export class AdvanceRoutes { | ||
items: AdvanceRoute[]; | ||
} |
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
Oops, something went wrong.