Skip to content

Commit

Permalink
Merge branch 'main' into new-chains-for-old-sdk-version
Browse files Browse the repository at this point in the history
  • Loading branch information
cheshirrrcat committed Mar 1, 2024
2 parents 2dcf08f + a642fff commit 827dcf1
Show file tree
Hide file tree
Showing 58 changed files with 538 additions and 730 deletions.
8 changes: 4 additions & 4 deletions examples/liquidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dotenv/config';

import { ethers } from 'ethers';
import { simpleFetch } from 'simple-typed-fetch';
import { CrossMarginCFD__factory, ERC20__factory } from '@electra.finance/contracts/lib/ethers-v5/index.js';
import { CrossMarginCFD__factory, ERC20__factory } from '@electra.finance/contracts/lib/ethers-v6/index.js';

import type { FuturesTradeInfo } from '../src/index.js';
import { Electra, SupportedChainId, crypt } from '../src/index.js';
Expand Down Expand Up @@ -393,10 +393,10 @@ const testLiquidation = async (instrumentName: string) => {
const allowance = await collateralContract.allowance(walletAddress, address);

const depositAmount = DEPOSIT_AMOUNT + (depositsCount * 10);
const bnAmount = ethers.utils.parseUnits(depositAmount.toString(), decimals);
const bnAmount = ethers.parseUnits(depositAmount.toString(), decimals);
if (allowance.lt(bnAmount)) {
console.log(`${instrumentName}: Approving ${depositAmount} ${collateralAddress} to ${address}`);
await collateralContract.approve(address, ethers.constants.MaxUint256); // Sometimes before approve you need to call approve(0)
await collateralContract.approve(address, ethers.MaxUint256); // Sometimes before approve you need to call approve(0)
await delay(2000);
}

Expand Down Expand Up @@ -450,7 +450,7 @@ const testLiquidation = async (instrumentName: string) => {
console.log(`${instrumentName}: Depositing ${dpAmount} ${collateralAddress} to ${address}`);

await crossMarginCFDContract.depositAsset(
ethers.utils.parseUnits(
ethers.parseUnits(
dpAmount.toString(),
decimals
)
Expand Down
Loading

0 comments on commit 827dcf1

Please sign in to comment.