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