Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Nov 20, 2024
1 parent 8a43ff7 commit 75477fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
24 changes: 12 additions & 12 deletions src/dex/cables/cables-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ describe('Cables E2E', () => {
const holders = Holders[network];

const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
// [
// {
// name: 'USDC',
// sellAmount: '500000',
// buyAmount: '700000',
// },
// {
// name: 'USDT',
// sellAmount: '600000',
// buyAmount: '850000',
// },
// ],
[
{
name: 'USDC',
sellAmount: '500000',
buyAmount: '700000',
},
{
name: 'USDT',
sellAmount: '600000',
buyAmount: '850000',
},
],
[
{
name: 'WETH',
Expand Down
20 changes: 15 additions & 5 deletions src/dex/cables/cables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import {
OptimalSwapExchange,
SwapSide,
} from '@paraswap/core';
import { AsyncOrSync } from 'ts-essentials';
import { assert, AsyncOrSync } from 'ts-essentials';
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
import { assert } from 'ts-essentials';
import { Network, ETHER_ADDRESS, NULL_ADDRESS } from '../../constants';
import { ETHER_ADDRESS, Network, NULL_ADDRESS } from '../../constants';
import { IDexHelper } from '../../dex-helper';
import {
AdapterExchangeParam,
Expand Down Expand Up @@ -54,7 +53,7 @@ import {
import mainnetRFQAbi from '../../abi/cables/CablesMainnetRFQ.json';
import { Interface } from 'ethers/lib/utils';
import BigNumber from 'bignumber.js';
import { ethers, utils } from 'ethers';
import { ethers } from 'ethers';
import { BI_MAX_UINT256 } from '../../bigint-constants';

export class Cables extends SimpleExchange implements IDex<any> {
Expand Down Expand Up @@ -232,6 +231,16 @@ export class Cables extends SimpleExchange implements IDex<any> {
}
}

// Correction of the srcAmount
// because flag specialDexSupportsInsertFromAmount: false
// is not working for Buy in test
if (isBuy) {
optimalSwapExchange.srcAmount = BigNumber(
(Number(optimalSwapExchange.srcAmount) * 10000) /
(10000 + Number(options.slippageFactor)),
).toFixed(0);
}

return [
{
...optimalSwapExchange,
Expand Down Expand Up @@ -267,7 +276,7 @@ export class Cables extends SimpleExchange implements IDex<any> {
`${this.dexKey}-${this.network}: quoteData undefined`,
);

const swapFunction = 'simpleSwap';
const swapFunction = 'partialSwap';
const swapFunctionParams = [
[
quoteData.nonceAndMeta,
Expand All @@ -280,6 +289,7 @@ export class Cables extends SimpleExchange implements IDex<any> {
quoteData.takerAmount,
],
quoteData.signature,
quoteData.takerAmount,
];

const exchangeData = this.rfqInterface.encodeFunctionData(
Expand Down

0 comments on commit 75477fd

Please sign in to comment.