Skip to content

Commit

Permalink
fix: do not add excessive parameters in TwapData (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Dec 3, 2024
1 parent 698faf1 commit a8f7e96
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/composable/orderTypes/Twap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,18 @@ export function transformDataToStruct(data: TwapData): TwapStruct {
* @returns {TwapStruct} A formatted struct as expected by the smart contract.
*/
export function transformStructToData(struct: TwapStruct): TwapData {
const { n: numberOfParts, partSellAmount, minPartLimit, t: timeBetweenParts, t0: startEpoch, span, ...rest } = struct
const {
n: numberOfParts,
partSellAmount,
minPartLimit,
t: timeBetweenParts,
t0: startEpoch,
span,
sellToken,
buyToken,
receiver,
appData,
} = struct

const durationOfPart: DurationOfPart = span.isZero()
? { durationType: DurationType.AUTO }
Expand All @@ -595,6 +606,9 @@ export function transformStructToData(struct: TwapStruct): TwapData {
numberOfParts,
timeBetweenParts,
durationOfPart,
...rest,
sellToken,
buyToken,
receiver,
appData,
}
}

0 comments on commit a8f7e96

Please sign in to comment.