@@ -13,7 +13,10 @@ import { normalizeConfig } from '../utils/ism.js';
1313
1414import { EvmTokenFeeModule } from './EvmTokenFeeModule.js' ;
1515import { BPS , HALF_AMOUNT , MAX_FEE } from './EvmTokenFeeReader.hardhat-test.js' ;
16- import { TokenFeeReaderParams } from './EvmTokenFeeReader.js' ;
16+ import {
17+ EvmTokenFeeReader ,
18+ TokenFeeReaderParams ,
19+ } from './EvmTokenFeeReader.js' ;
1720import {
1821 LinearFeeConfig ,
1922 ResolvedTokenFeeConfigInput ,
@@ -70,7 +73,11 @@ describe('EvmTokenFeeModule', () => {
7073 } ) ;
7174 const onchainConfig = await module . read ( ) ;
7275 expect ( normalizeConfig ( onchainConfig ) ) . to . deep . equal (
73- normalizeConfig ( { ...config , maxFee : MAX_FEE , halfAmount : HALF_AMOUNT } ) ,
76+ normalizeConfig ( {
77+ ...config ,
78+ maxFee : MAX_FEE ,
79+ halfAmount : HALF_AMOUNT ,
80+ } ) ,
7481 ) ;
7582 } ) ;
7683
@@ -172,7 +179,7 @@ describe('EvmTokenFeeModule', () => {
172179 chain : test4Chain ,
173180 config,
174181 } ) ;
175- const updatedConfig = { ...config , bps : BPS + 1n } ;
182+ const updatedConfig = { ...config , bps : BPS + 1 } ;
176183 await expectTxsAndUpdate ( module , updatedConfig , 0 ) ;
177184 const onchainConfig = await module . read ( ) ;
178185 assert (
@@ -202,7 +209,7 @@ describe('EvmTokenFeeModule', () => {
202209 feeContracts : {
203210 [ test4Chain ] : {
204211 ...feeContracts [ test4Chain ] ,
205- bps : BPS + 1n ,
212+ bps : BPS + 1 ,
206213 } ,
207214 } ,
208215 } ;
@@ -254,7 +261,10 @@ describe('EvmTokenFeeModule', () => {
254261 ...routingFeeConfig ,
255262 owner : newOwner ,
256263 feeContracts : {
257- [ test4Chain ] : { ...feeContracts [ test4Chain ] , owner : newOwner } ,
264+ [ test4Chain ] : {
265+ ...feeContracts [ test4Chain ] ,
266+ owner : newOwner ,
267+ } ,
258268 } ,
259269 } ,
260270 2 ,
@@ -297,7 +307,7 @@ describe('EvmTokenFeeModule', () => {
297307 feeContracts : {
298308 [ test4Chain ] : {
299309 ...feeContracts [ test4Chain ] ,
300- bps : BPS + 1n ,
310+ bps : BPS + 1 ,
301311 } ,
302312 } ,
303313 } ;
@@ -373,7 +383,7 @@ describe('EvmTokenFeeModule', () => {
373383 type : TokenFeeType . LinearFee ,
374384 owner : signer . address ,
375385 token : zeroSupplyToken . address ,
376- bps : 8n ,
386+ bps : 8 ,
377387 } ;
378388
379389 const expandedConfig = await EvmTokenFeeModule . expandConfig ( {
@@ -386,16 +396,16 @@ describe('EvmTokenFeeModule', () => {
386396 expandedConfig . type === TokenFeeType . LinearFee ,
387397 `Must be ${ TokenFeeType . LinearFee } ` ,
388398 ) ;
389- const linearConfig = expandedConfig as LinearFeeConfig ;
390- expect ( linearConfig . maxFee > 0n ) . to . be . true ;
391- expect ( linearConfig . halfAmount > 0n ) . to . be . true ;
392- expect ( linearConfig . bps ) . to . equal ( 8n ) ;
399+
400+ expect ( expandedConfig . maxFee > 0n ) . to . be . true ;
401+ expect ( expandedConfig . halfAmount > 0n ) . to . be . true ;
402+ expect ( expandedConfig . bps ) . to . equal ( 8 ) ;
393403
394404 const roundTripBps = convertToBps (
395- linearConfig . maxFee ,
396- linearConfig . halfAmount ,
405+ expandedConfig . maxFee ,
406+ expandedConfig . halfAmount ,
397407 ) ;
398- expect ( roundTripBps ) . to . equal ( 8n ) ;
408+ expect ( roundTripBps ) . to . equal ( 8 ) ;
399409 } ) ;
400410
401411 it ( 'should expand nested RoutingFee config for zero-supply token' , async ( ) => {
@@ -412,7 +422,7 @@ describe('EvmTokenFeeModule', () => {
412422 type : TokenFeeType . LinearFee ,
413423 owner : signer . address ,
414424 token : zeroSupplyToken . address ,
415- bps : 8n ,
425+ bps : 8 ,
416426 } ,
417427 } ,
418428 } ;
@@ -438,7 +448,7 @@ describe('EvmTokenFeeModule', () => {
438448 const linearFee = nestedFee as LinearFeeConfig ;
439449 expect ( linearFee . maxFee > 0n ) . to . be . true ;
440450 expect ( linearFee . halfAmount > 0n ) . to . be . true ;
441- expect ( linearFee . bps ) . to . equal ( 8n ) ;
451+ expect ( linearFee . bps ) . to . equal ( 8 ) ;
442452 } ) ;
443453
444454 it ( 'should expand config with explicit maxFee/halfAmount (no bps) and preserve values' , async ( ) => {
@@ -466,11 +476,10 @@ describe('EvmTokenFeeModule', () => {
466476 expandedConfig . type === TokenFeeType . LinearFee ,
467477 `Must be ${ TokenFeeType . LinearFee } ` ,
468478 ) ;
469- const linearConfig = expandedConfig as LinearFeeConfig ;
470479
471- expect ( linearConfig . maxFee ) . to . equal ( explicitMaxFee ) ;
472- expect ( linearConfig . halfAmount ) . to . equal ( explicitHalfAmount ) ;
473- expect ( linearConfig . bps ) . to . equal ( expectedBps ) ;
480+ expect ( expandedConfig . maxFee ) . to . equal ( explicitMaxFee ) ;
481+ expect ( expandedConfig . halfAmount ) . to . equal ( explicitHalfAmount ) ;
482+ expect ( expandedConfig . bps ) . to . equal ( expectedBps ) ;
474483 } ) ;
475484
476485 it ( 'should expand nested RoutingFee with explicit maxFee/halfAmount in child LinearFee' , async ( ) => {
@@ -525,7 +534,7 @@ describe('EvmTokenFeeModule', () => {
525534 [ test4Chain ] : {
526535 type : TokenFeeType . LinearFee ,
527536 owner : signer . address ,
528- bps : 8n ,
537+ bps : 8 ,
529538 } ,
530539 } ,
531540 } as ResolvedTokenFeeConfigInput ;
@@ -545,5 +554,32 @@ describe('EvmTokenFeeModule', () => {
545554 assert ( nestedFee , 'Nested fee must exist' ) ;
546555 expect ( nestedFee . token ) . to . equal ( token . address ) ;
547556 } ) ;
557+
558+ it ( 'should expand config with fractional bps (1.5)' , async ( ) => {
559+ const reader = new EvmTokenFeeReader ( multiProvider , test4Chain ) ;
560+ const expected = reader . convertFromBps ( 1.5 ) ;
561+
562+ const inputConfig : ResolvedTokenFeeConfigInput = {
563+ type : TokenFeeType . LinearFee ,
564+ owner : signer . address ,
565+ token : token . address ,
566+ bps : 1.5 ,
567+ } ;
568+
569+ const expandedConfig = await EvmTokenFeeModule . expandConfig ( {
570+ config : inputConfig ,
571+ multiProvider,
572+ chainName : test4Chain ,
573+ } ) ;
574+
575+ assert (
576+ expandedConfig . type === TokenFeeType . LinearFee ,
577+ `Must be ${ TokenFeeType . LinearFee } ` ,
578+ ) ;
579+
580+ expect ( expandedConfig . maxFee ) . to . equal ( expected . maxFee ) ;
581+ expect ( expandedConfig . halfAmount ) . to . equal ( expected . halfAmount ) ;
582+ expect ( expandedConfig . bps ) . to . equal ( 1.5 ) ;
583+ } ) ;
548584 } ) ;
549585} ) ;
0 commit comments