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", "name": "@orionprotocol/sdk",
"version": "0.20.25", "version": "0.20.25-rc0",
"description": "Orion Protocol SDK", "description": "Orion Protocol SDK",
"main": "./lib/index.cjs", "main": "./lib/index.cjs",
"module": "./lib/index.js", "module": "./lib/index.js",

View File

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

View File

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