Skip to content

Commit 43f0fa8

Browse files
committed
Fix lint
1 parent a43d60e commit 43f0fa8

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/zilswap-v2/ZilSwapV2.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export class ZilSwapV2 {
358358
const t0State = await this.fetchContractInit(token0Contract)
359359
const t1State = await this.fetchContractInit(token1Contract)
360360

361-
const pair = `${t0State.find((i: Value) => i.vname == 'symbol').value}-${t1State.find((i: Value) => i.vname == 'symbol').value}`
361+
const pair = `${t0State.find((i: Value) => i.vname === 'symbol').value}-${t1State.find((i: Value) => i.vname === 'symbol').value}`
362362
const name = `ZilSwap V2 ${pair} LP Token`
363363
const symbol = `${pair}.ZWAPv2LP`
364364

@@ -390,7 +390,7 @@ export class ZilSwapV2 {
390390
// Check logged in
391391
this.checkAppLoadedWithUser()
392392

393-
let poolHash = this.getHash(pool)
393+
const poolHash = this.getHash(pool)
394394

395395
const contract: Contract = this.contract
396396
const args: any = [
@@ -1845,9 +1845,9 @@ export class ZilSwapV2 {
18451845
return tokenPath;
18461846
}
18471847

1848-
public findSwapPathIn(swapPath: [Pool, boolean][], tokenInHash: string, tokenOutHash: string, tokenAmountIn: BigNumber, poolStepsLeft: number): { swapPath: [Pool, boolean][] | null, expectedAmount: BigNumber } {
1848+
public findSwapPathIn(path: [Pool, boolean][], tokenInHash: string, tokenOutHash: string, tokenAmountIn: BigNumber, poolStepsLeft: number): { swapPath: [Pool, boolean][] | null, expectedAmount: BigNumber } {
18491849
const { pools } = this.getAppState();
1850-
const poolsPath = swapPath.map(s => s[0]);
1850+
const poolsPath = path.map(s => s[0]);
18511851

18521852
const optionPools = Object.values(pools).filter((pool) => {
18531853
if (poolsPath.includes(pool)) return false;
@@ -1857,7 +1857,7 @@ export class ZilSwapV2 {
18571857
let bestPath: [Pool, boolean][] | null = null;
18581858
for (const pool of optionPools) {
18591859
const isSameOrder = pool.contractState.token0 === tokenInHash;
1860-
const newPath = swapPath.concat([[pool, isSameOrder]]);
1860+
const newPath = path.concat([[pool, isSameOrder]]);
18611861
const [poolTokenIn, poolTokenOut] = isSameOrder ? [pool.contractState.token0, pool.contractState.token1] : [pool.contractState.token1, pool.contractState.token0];
18621862
const foundEndPool = poolTokenOut === tokenOutHash;
18631863

@@ -1886,9 +1886,9 @@ export class ZilSwapV2 {
18861886
return { swapPath: bestPath, expectedAmount: bestAmount };
18871887
}
18881888

1889-
public findSwapPathOut(swapPath: [Pool, boolean][], tokenInHash: string, tokenOutHash: string, tokenAmountOut: BigNumber, poolStepsLeft: number): { swapPath: [Pool, boolean][] | null, expectedAmount: BigNumber } {
1889+
public findSwapPathOut(path: [Pool, boolean][], tokenInHash: string, tokenOutHash: string, tokenAmountOut: BigNumber, poolStepsLeft: number): { swapPath: [Pool, boolean][] | null, expectedAmount: BigNumber } {
18901890
const { pools } = this.getAppState();
1891-
const poolsPath = swapPath.map(s => s[0]);
1891+
const poolsPath = path.map(s => s[0]);
18921892

18931893
const optionPools = Object.values(pools).filter((pool) => {
18941894
if (poolsPath.includes(pool)) return false;
@@ -1898,7 +1898,7 @@ export class ZilSwapV2 {
18981898
let bestPath: [Pool, boolean][] | null = null;
18991899
for (const pool of optionPools) {
19001900
const isSameOrder = pool.contractState.token1 === tokenOutHash;
1901-
const newPath: [Pool, boolean][] = [[pool, isSameOrder], ...swapPath];
1901+
const newPath: [Pool, boolean][] = [[pool, isSameOrder], ...path];
19021902
const [poolTokenIn, poolTokenOut] = isSameOrder ? [pool.contractState.token0, pool.contractState.token1] : [pool.contractState.token1, pool.contractState.token0];
19031903
const foundStartPool = poolTokenIn !== tokenInHash;
19041904

@@ -1980,8 +1980,8 @@ export class ZilSwapV2 {
19801980
}
19811981

19821982
/**
1983-
* Gets the contract with the given address that can be called by the default account.
1984-
*/
1983+
* Gets the contract with the given address that can be called by the default account.
1984+
*/
19851985
public getContract(address: string): Contract {
19861986
return (this.walletProvider || this.zilliqa).contracts.at(address)
19871987
}
@@ -2282,7 +2282,7 @@ export class ZilSwapV2 {
22822282
// get_amount_in
22832283
let numerator = new BigNumber(reserveIn).multipliedBy(amountOut)
22842284
let denominator = new BigNumber(reserveOut).minus(amountOut)
2285-
let amountIn = numerator.dividedToIntegerBy(denominator).plus(1)
2285+
const amountIn = numerator.dividedToIntegerBy(denominator).plus(1)
22862286
numerator = amountIn.multipliedBy(PRECISION)
22872287
denominator = new BigNumber(PRECISION).minus(feeInPrecision)
22882288
return numerator.plus(denominator.minus(1)).dividedToIntegerBy(denominator)
@@ -2457,7 +2457,7 @@ export class ZilSwapV2 {
24572457

24582458
// Update whole app state when routerState changes
24592459
if (byStr20Address === this.contractHash) {
2460-
for (const event of item.event_logs) {
2460+
for (const _ of item.event_logs) {
24612461
this.updateAppState()
24622462
}
24632463
}

src/zilswap-v2/test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getContract, network } from './utils'
66
import { ObservedTx, TxReceipt, TxStatus, ZilSwapV2 } from './ZilSwapV2'
77
dotenv.config()
88

9-
const init_liquidity = 10000
9+
const initLiquidity = 10000
1010
const amountIn = 10
1111
const amountInMax = 100
1212
const amountOut = 10
@@ -51,8 +51,8 @@ const getvReserverBounds = (poolHash: string): { vReserveMin: string, vReserveMa
5151
const pools = zilswap.getPools()
5252
const pool = pools[poolHash]
5353

54-
let vReserveA = parseInt(pool.contractState.v_reserve0)
55-
let vReserveB = parseInt(pool.contractState.v_reserve1)
54+
const vReserveA = parseInt(pool.contractState.v_reserve0, 10)
55+
const vReserveB = parseInt(pool.contractState.v_reserve1, 10)
5656

5757
let vReserveMin, vReserveMax;
5858
if (vReserveA === 0 && vReserveB === 0) {
@@ -104,13 +104,13 @@ const test = async () => {
104104
}
105105

106106
// add liquidity
107-
tx = await zilswap.addLiquidity(swthHash, hunyHash, pool1Hash, new BigNumber(init_liquidity).toString(), new BigNumber(init_liquidity).toString(), '0', '0', getvReserverBounds(pool1Hash).vReserveMin, getvReserverBounds(pool1Hash).vReserveMax)
107+
tx = await zilswap.addLiquidity(swthHash, hunyHash, pool1Hash, new BigNumber(initLiquidity).toString(), new BigNumber(initLiquidity).toString(), '0', '0', getvReserverBounds(pool1Hash).vReserveMin, getvReserverBounds(pool1Hash).vReserveMax)
108108
console.log(`\ntx hash: ${tx.hash}\n`)
109109
await waitForTx()
110-
tx = await zilswap.addLiquidityZIL(swthHash, pool2Hash, new BigNumber(init_liquidity).toString(), new BigNumber(init_liquidity).toString(), '0', '0', getvReserverBounds(pool2Hash).vReserveMin, getvReserverBounds(pool2Hash).vReserveMax)
110+
tx = await zilswap.addLiquidityZIL(swthHash, pool2Hash, new BigNumber(initLiquidity).toString(), new BigNumber(initLiquidity).toString(), '0', '0', getvReserverBounds(pool2Hash).vReserveMin, getvReserverBounds(pool2Hash).vReserveMax)
111111
console.log(`\ntx hash: ${tx.hash}\n`)
112112
await waitForTx()
113-
tx = await zilswap.addLiquidityZIL(hunyHash, pool3Hash, new BigNumber(init_liquidity).toString(), new BigNumber(init_liquidity).toString(), '0', '0', getvReserverBounds(pool3Hash).vReserveMin, getvReserverBounds(pool3Hash).vReserveMax)
113+
tx = await zilswap.addLiquidityZIL(hunyHash, pool3Hash, new BigNumber(initLiquidity).toString(), new BigNumber(initLiquidity).toString(), '0', '0', getvReserverBounds(pool3Hash).vReserveMin, getvReserverBounds(pool3Hash).vReserveMax)
114114
console.log(`\ntx hash: ${tx.hash}\n`)
115115
await waitForTx()
116116

src/zilswap-v2/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ export const SHORT_ALPHA = 370301795963710
1515
export const LONG_ALPHA = 185168039996296
1616

1717
const getNetwork = (): Network => {
18-
const network: string = (process.env.NETWORK || '').toLowerCase()
19-
switch (network) {
18+
const net: string = (process.env.NETWORK || '').toLowerCase()
19+
switch (net) {
2020
case 'mainnet':
2121
return Network.MainNet
2222
case 'testnet':
2323
return Network.TestNet
2424
// case 'localhost':
25-
// return Network.LocalHost
25+
// return Network.LocalHost
2626
default:
2727
return Network.TestNet
2828
}
2929
}
3030

31-
const getRPC = (network: Network): string => {
32-
return APIS[network]
31+
const getRPC = (net: Network): string => {
32+
return APIS[net]
3333
}
3434

3535
export const network = getNetwork()
36-
export const rpc = getRPC(network)
36+
export const rpc = getRPC()
3737
export const zilliqa = new Zilliqa(rpc)
3838

3939
export const param = (vname: string, type: string, value: string) => {
@@ -377,7 +377,7 @@ export async function deployZilswapV2Pool(privateKey: string, { router, token0,
377377
const t0State = await token0.getInit()
378378
const t1State = await token1.getInit()
379379

380-
const pair = `${t0State.find((i: Value) => i.vname == 'symbol').value}-${t1State.find((i: Value) => i.vname == 'symbol').value}`
380+
const pair = `${t0State.find((i: Value) => i.vname === 'symbol').value}-${t1State.find((i: Value) => i.vname === 'symbol').value}`
381381
if (!name) name = `ZilSwap V2 ${pair} LP Token`
382382
if (!symbol) symbol = `ZWAPv2LP.${pair}`
383383
}

0 commit comments

Comments
 (0)