fix: fix bug with curve calldata generation while in crossfactory

This commit is contained in:
lomonoshka
2023-11-29 20:03:47 +04:00
parent 51907c17e5
commit ff8729a1d3
3 changed files with 12 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.25",
"version": "0.20.25-rc0",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -4,7 +4,7 @@ import {
ERC20__factory,
} from "@orionprotocol/contracts/lib/ethers-v6/index.js";
import { MaxUint256, type BigNumberish, type JsonRpcProvider } from "ethers";
import { addCallParams } from "./utils.js";
import { addCallParams, pathCallWithBalance } from "./utils.js";
import type { SingleSwap } from "../../../types.js";
import { generateApproveCall } from "./erc20.js";
import type { BytesLike } from "ethers";
@@ -15,7 +15,8 @@ export async function generateCurveStableSwapCall(
swap: SingleSwap,
provider: JsonRpcProvider,
swapExecutorContractAddress: string,
curveRegistry: string
curveRegistry: string,
pathWithBalance = false
) {
const executorInterface = SwapExecutor__factory.createInterface();
const registry = CurveRegistry__factory.connect(curveRegistry, provider);
@@ -38,7 +39,11 @@ export async function generateCurveStableSwapCall(
"curveSwapStableAmountIn",
[pool, assetOut, i, j, to, amount]
);
calls.push(addCallParams(calldata))
calldata = addCallParams(calldata)
if (pathWithBalance) {
calldata = pathCallWithBalance(calldata, swap.assetIn)
}
calls.push(calldata)
return calls
}

View File

@@ -251,13 +251,14 @@ async function processMultiFactorySwaps(
break;
}
case 'Curve': {
const curveCalls = await generateCurveStableSwapCall(
let curveCalls = await generateCurveStableSwapCall(
amount,
swapExecutorContractAddress,
swap,
provider,
swapExecutorContractAddress,
curveRegistryAddress
curveRegistryAddress,
true
);
calls.push(...curveCalls);
break;