mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
fee parameter should be in exchange decimals
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.20.34-rc-1",
|
||||
"version": "0.20.34-rc-2",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/index.cjs",
|
||||
"module": "./lib/index.js",
|
||||
|
||||
@@ -138,6 +138,7 @@ export async function generateSwapCalldata({
|
||||
flags: 0,
|
||||
};
|
||||
const amountNativeDecimals = await exchangeToNativeDecimals(srcToken, amount, provider);
|
||||
const feeNativeDecimals = await exchangeToNativeDecimals(feeToken, fee, provider)
|
||||
|
||||
path = SafeArray.from(arrayLikePath).map((singleSwap) => {
|
||||
if (singleSwap.assetIn == ethers.ZeroAddress) singleSwap.assetIn = wethAddress;
|
||||
@@ -152,7 +153,7 @@ export async function generateSwapCalldata({
|
||||
amountNativeDecimals,
|
||||
matcher,
|
||||
feeToken,
|
||||
fee,
|
||||
feeNativeDecimals,
|
||||
wethAddress,
|
||||
swapExecutorContractAddress,
|
||||
curveRegistryAddress,
|
||||
@@ -210,7 +211,7 @@ async function processSwaps(
|
||||
));
|
||||
}
|
||||
|
||||
({swapDescription, calls} = payFeeToMatcher(matcher, feeToken, fee, calls, swapDescription));
|
||||
({swapDescription, calls} = await payFeeToMatcher(matcher, feeToken, fee, calls, swapDescription));
|
||||
|
||||
({ swapDescription, calls } = wrapOrUnwrapIfNeeded(
|
||||
amount,
|
||||
@@ -331,14 +332,13 @@ async function processMultiFactorySwaps(
|
||||
return { swapDescription, calls };
|
||||
}
|
||||
|
||||
function payFeeToMatcher(
|
||||
async function payFeeToMatcher(
|
||||
matcher: AddressLike,
|
||||
feeToken: AddressLike,
|
||||
feeAmount: BigNumberish,
|
||||
calls: BytesLike[],
|
||||
swapDescription: LibValidator.SwapDescriptionStruct,
|
||||
) {
|
||||
feeAmount = BigInt(feeAmount)
|
||||
if (feeAmount !== 0n && feeToken === swapDescription.dstToken) {
|
||||
const feePaymentCall = generateFeePaymentCall(matcher, feeToken, feeAmount)
|
||||
calls.push(feePaymentCall)
|
||||
|
||||
Reference in New Issue
Block a user