From 9536b760ae4bded2bbfeb23d832c669919e0d822 Mon Sep 17 00:00:00 2001 From: 0xKermo Date: Mon, 21 Aug 2023 14:24:20 +0300 Subject: [PATCH] update examples --- README.md | 8 ++++++-- examples/src/buildTransaction.ts | 5 +++-- examples/src/route.ts | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 14888d7..3eafd45 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,12 @@ import { BigNumber } from "@ethersproject/bignumber"; import { parseUnits } from "ethers"; const router = new FibrousRouter(); + const tokenInAddress = tokens["eth"].address; const tokenOutAddress = tokens["usdc"].address; const tokenInDecimals = tokens["eth"].decimals; -const inputAmount = parseUnits("1", tokenInDecimals); +const inputAmount = BigNumber.from(parseUnits("1", tokenInDecimals)); + const route = await fibrous.getBestRoute( inputAmount, // amount tokenInAddress, // token input @@ -58,10 +60,12 @@ import { BigNumber } from "@ethersproject/bignumber"; import { parseUnits } from "ethers"; const fibrous = new FibrousRouter(); + const tokenInAddress = tokens["eth"].address; const tokenOutAddress = tokens["usdc"].address; const tokenInDecimals = tokens["eth"].decimals; -const inputAmount = parseUnits("1", tokenInDecimals); +const inputAmount = BigNumber.from(parseUnits("1", tokenInDecimals)); + // Build route options const tokens = await fibrous.supportedTokens(); // Get a route using the getBestRoute method diff --git a/examples/src/buildTransaction.ts b/examples/src/buildTransaction.ts index 1299c41..a3812fa 100644 --- a/examples/src/buildTransaction.ts +++ b/examples/src/buildTransaction.ts @@ -1,4 +1,5 @@ -import { Router as FibrousRouter } from "fibrous-router-sdk"; +import { BigNumber } from "@ethersproject/bignumber"; +import { Router as FibrousRouter } from "../../src/router/router"; import { parseUnits } from "ethers"; import { randomBytes } from "node:crypto"; @@ -14,7 +15,7 @@ async function main() { const tokenInAddress = tokens["eth"].address; const tokenOutAddress = tokens["usdc"].address; const tokenInDecimals = tokens["eth"].decimals; - const inputAmount = parseUnits("1", tokenInDecimals); + const inputAmount = BigNumber.from(parseUnits("1", tokenInDecimals)); // Get a route using the getBestRoute method const bestRoute = await fibrous.getBestRoute( inputAmount, diff --git a/examples/src/route.ts b/examples/src/route.ts index 52d40fb..8045508 100644 --- a/examples/src/route.ts +++ b/examples/src/route.ts @@ -1,5 +1,6 @@ import { Router as FibrousRouter } from "fibrous-router-sdk"; import { parseUnits } from "ethers"; +import { BigNumber } from "@ethersproject/bignumber"; async function main() { // Create a new router instance const fibrous = new FibrousRouter(); @@ -10,7 +11,7 @@ async function main() { const tokenInAddress = tokens["eth"].address; const tokenOutAddress = tokens["usdc"].address; const tokenInDecimals = tokens["eth"].decimals; - const inputAmount = parseUnits("1", tokenInDecimals); + const inputAmount = BigNumber.from(parseUnits("1", tokenInDecimals)); // Converting 1 ETH to USDC const route = await fibrous.getBestRoute( inputAmount,