@@ -85,7 +85,8 @@ contract Escrow is Owned, IEscrow {
8585 mapping (uint => mapping (uint => uint )) public repoSetAdminNonce; // repoId → instanceId → nonce
8686 mapping (address => uint ) public recipientClaimNonce; // recipient → nonce
8787
88- uint public fee;
88+ uint public feeOnFund;
89+ uint public feeOnClaim;
8990 address public feeRecipient;
9091 uint public batchLimit;
9192
@@ -125,14 +126,14 @@ contract Escrow is Owned, IEscrow {
125126 address _owner ,
126127 address _signer ,
127128 address [] memory _whitelistedTokens ,
128- uint _fee ,
129+ uint _feeOnClaim ,
129130 uint _batchLimit
130131 ) Owned (_owner) {
131- require (_fee <= MAX_FEE, Errors.INVALID_FEE);
132+ require (_feeOnClaim <= MAX_FEE, Errors.INVALID_FEE);
132133
133134 signer = _signer;
134135 feeRecipient = _owner;
135- fee = _fee ;
136+ feeOnClaim = _feeOnClaim ;
136137 batchLimit = _batchLimit;
137138 INITIAL_CHAIN_ID = block .chainid ;
138139 INITIAL_DOMAIN_SEPARATOR = _domainSeparator ();
@@ -205,10 +206,17 @@ contract Escrow is Owned, IEscrow {
205206
206207 token.safeTransferFrom (msg .sender , address (this ), amount);
207208
208- accounts[repoId][instanceId].balance[ address (token)] + = amount;
209- fundings[repoId][instanceId][ address (token)][ msg . sender ] += amount ;
209+ uint feeAmount = amount. mulDivUp (feeOnFund, 10_000 ) ;
210+ require (amount > feeAmount, Errors.INVALID_AMOUNT) ;
210211
211- emit FundedRepo (repoId, instanceId, address (token), msg .sender , amount, data);
212+ if (feeAmount > 0 ) token.safeTransfer (feeRecipient, feeAmount);
213+
214+ uint netAmount = amount - feeAmount;
215+
216+ accounts[repoId][instanceId].balance[address (token)] += netAmount;
217+ fundings[repoId][instanceId][address (token)][msg .sender ] += netAmount;
218+
219+ emit FundedRepo (repoId, instanceId, address (token), msg .sender , netAmount, feeAmount, data);
212220 }
213221
214222 /* -------------------------------------------------------------------------- */
@@ -305,8 +313,7 @@ contract Escrow is Owned, IEscrow {
305313 require (distribution.amount > 0 , Errors.INVALID_AMOUNT);
306314 require (whitelistedTokens.contains (address (distribution.token)), Errors.INVALID_TOKEN);
307315
308- // Validate that after fees, recipient will receive at least 1 wei
309- uint feeAmount = distribution.amount.mulDivUp (fee, 10_000 );
316+ uint feeAmount = distribution.amount.mulDivUp (feeOnClaim, 10_000 );
310317 require (distribution.amount > feeAmount, Errors.INVALID_AMOUNT);
311318
312319 distributionId = distributionCount++ ;
@@ -320,7 +327,7 @@ contract Escrow is Owned, IEscrow {
320327 exists: true ,
321328 _type: _type,
322329 payer: _type == DistributionType.Solo ? msg .sender : address (0 ),
323- fee: fee
330+ fee: feeOnClaim
324331 });
325332 }
326333
@@ -486,14 +493,24 @@ contract Escrow is Owned, IEscrow {
486493 emit WhitelistedToken (token);
487494 }
488495
489- function setFee (uint newFee )
496+ function setFeeOnFund (uint newFee )
497+ external
498+ onlyOwner
499+ {
500+ require (newFee <= MAX_FEE, Errors.INVALID_FEE);
501+ uint oldFee = feeOnFund;
502+ feeOnFund = newFee;
503+ emit FeeOnFundSet (oldFee, newFee);
504+ }
505+
506+ function setFeeOnClaim (uint newFee )
490507 external
491508 onlyOwner
492509 {
493510 require (newFee <= MAX_FEE, Errors.INVALID_FEE);
494- uint oldFee = fee ;
495- fee = newFee;
496- emit FeeSet (oldFee, newFee);
511+ uint oldFee = feeOnClaim ;
512+ feeOnClaim = newFee;
513+ emit FeeOnClaimSet (oldFee, newFee);
497514 }
498515
499516 function setFeeRecipient (address newRec )
0 commit comments