Skip to content

Commit

Permalink
decimals for native asset
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns committed Dec 15, 2023
1 parent dd2c31a commit e475429
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions modules/sor/sor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class SorService {
}

private async getSwap(input: GetSwapsInput, v1Service: SwapService = sorV1BalancerService) {
console.log(`Running SOR for ${input.swapAmount} ${input.tokenIn} > ${input.tokenOut}`);
const v1Start = +new Date();
const swapV1 = await v1Service.getSwapResult(input);
const v1Time = +new Date() - v1Start;
Expand Down Expand Up @@ -144,7 +143,7 @@ export class SorService {
const fp = (a: bigint, d: number) => Number(formatUnits(String(a), d));
const bn = (a: string, d: number) => BigInt(String(parseUnits(a, d)));
const prismaToken = await tokenService.getToken(resultToken, chain);
const decimals = prismaToken!.decimals;
const decimals = prismaToken ? prismaToken.decimals : 18; // most probably native asset
let v2Perf =
version === 'V1'
? 1 - fp(v1ResultAmount, decimals) / fp(v2ResultAmount, decimals) // negative perf means V1 is better
Expand Down

0 comments on commit e475429

Please sign in to comment.