From 2d47d9fe7fd33cb5b0495ed1013cb6f5e5f8297c Mon Sep 17 00:00:00 2001 From: OjusWiZard Date: Tue, 19 Sep 2023 03:11:35 +0530 Subject: [PATCH 1/2] fix: remove hardcoded chainlink rate age (#1171) Signed-off-by: OjusWiZard --- packages/payment-processor/src/payment/settings.ts | 2 ++ packages/payment-processor/src/payment/swap-any-to-erc20.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/payment-processor/src/payment/settings.ts b/packages/payment-processor/src/payment/settings.ts index f50589b3de..d8e658d097 100644 --- a/packages/payment-processor/src/payment/settings.ts +++ b/packages/payment-processor/src/payment/settings.ts @@ -24,6 +24,8 @@ export interface ISwapSettings { * ['0xPaymentCurrency', '0xIntermediate1', ..., '0xRequestCurrency'] */ path: string[]; + /** maximum time in seconds of how old chainlink rate can be used, default is zero for infinitely old */ + maxRateAge?: number; } export interface IConversionSettings { diff --git a/packages/payment-processor/src/payment/swap-any-to-erc20.ts b/packages/payment-processor/src/payment/swap-any-to-erc20.ts index e53d3278df..52c0f8b428 100644 --- a/packages/payment-processor/src/payment/swap-any-to-erc20.ts +++ b/packages/payment-processor/src/payment/swap-any-to-erc20.ts @@ -167,6 +167,6 @@ export function encodeSwapToPayAnyToErc20Request( feeToPay, // _requestFeeAmount: BigNumberish, feeAddress || constants.AddressZero, // _feeAddress: string, Math.round(swapSettings.deadline / 1000), // _uniswapDeadline: BigNumberish, - 0, // _chainlinkMaxRateTimespan: BigNumberish, + swapSettings.maxRateAge || 0, // _chainlinkMaxRateTimespan: BigNumberish, ]); } From 382e14c0e06987c01754355742e179b86a02f48a Mon Sep 17 00:00:00 2001 From: OjusWiZard Date: Tue, 19 Sep 2023 21:25:29 +0530 Subject: [PATCH 2/2] fix: move `maxRateAge` to `IConversionSettings` (#1171) Signed-off-by: OjusWiZard --- packages/payment-processor/src/payment/settings.ts | 4 ++-- packages/payment-processor/src/payment/swap-any-to-erc20.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/payment-processor/src/payment/settings.ts b/packages/payment-processor/src/payment/settings.ts index d8e658d097..8dac067680 100644 --- a/packages/payment-processor/src/payment/settings.ts +++ b/packages/payment-processor/src/payment/settings.ts @@ -24,8 +24,6 @@ export interface ISwapSettings { * ['0xPaymentCurrency', '0xIntermediate1', ..., '0xRequestCurrency'] */ path: string[]; - /** maximum time in seconds of how old chainlink rate can be used, default is zero for infinitely old */ - maxRateAge?: number; } export interface IConversionSettings { @@ -35,6 +33,8 @@ export interface IConversionSettings { maxToSpend?: BigNumberish; /** a currency manager to access currencies property, like decimals */ currencyManager?: ICurrencyManager; + /** maximum time in seconds of how old chainlink rate can be used, default is zero for infinitely old */ + maxRateAge?: number; } /** diff --git a/packages/payment-processor/src/payment/swap-any-to-erc20.ts b/packages/payment-processor/src/payment/swap-any-to-erc20.ts index 52c0f8b428..5b69b4989a 100644 --- a/packages/payment-processor/src/payment/swap-any-to-erc20.ts +++ b/packages/payment-processor/src/payment/swap-any-to-erc20.ts @@ -167,6 +167,6 @@ export function encodeSwapToPayAnyToErc20Request( feeToPay, // _requestFeeAmount: BigNumberish, feeAddress || constants.AddressZero, // _feeAddress: string, Math.round(swapSettings.deadline / 1000), // _uniswapDeadline: BigNumberish, - swapSettings.maxRateAge || 0, // _chainlinkMaxRateTimespan: BigNumberish, + conversionSettings.maxRateAge ?? 0, // _chainlinkMaxRateTimespan: BigNumberish, ]); }