Add final transfer from executor in any case

This commit is contained in:
lomonoshka
2023-10-30 20:24:58 +04:00
parent 43e0fa0abe
commit 4d9f09bc21
2 changed files with 7 additions and 3 deletions

View File

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

View File

@@ -131,7 +131,7 @@ export async function generateSwapCalldata({
));
}
calls = wrapOrUnwrapIfNeeded(amountNativeDecimals, swapDescription, calls);
calls = await wrapOrUnwrapIfNeeded(amountNativeDecimals, swapDescription, calls);
const calldata = generateCalls(calls);
return { swapDescription, calldata };
}
@@ -247,7 +247,7 @@ async function processMultiFactorySwaps(
return { swapDescription, calls };
}
function wrapOrUnwrapIfNeeded(amount: BigNumberish, swapDescription: LibValidator.SwapDescriptionStruct, calls: BytesLike[]): BytesLike[] {
async function wrapOrUnwrapIfNeeded(amount: BigNumberish, swapDescription: LibValidator.SwapDescriptionStruct, calls: BytesLike[]): Promise<BytesLike[]> {
if (swapDescription.srcToken === ZeroAddress) {
const wrapCall = generateWrapAndTransferCall(swapDescription.dstReceiver, { value: amount });
calls = ([wrapCall] as BytesLike[]).concat(calls);
@@ -256,6 +256,10 @@ function wrapOrUnwrapIfNeeded(amount: BigNumberish, swapDescription: LibValidato
let unwrapCall = generateUnwrapAndTransferCall(swapDescription.dstReceiver, 0);
unwrapCall = pathCallWithBalance(unwrapCall, swapDescription.dstToken);
calls.push(unwrapCall);
} else {
let transferCall = await generateTransferCall(swapDescription.dstToken, swapDescription.dstReceiver, 0);
transferCall = pathCallWithBalance(transferCall, swapDescription.dstToken);
calls.push(transferCall);
}
return calls;
}