File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,10 @@ pub enum Error {
241
241
// 43 (0x2b)
242
242
#[ error( "Trying to swap2 between the same pool" ) ]
243
243
SamePool ,
244
+
245
+ // 44 (0x2c)
246
+ #[ error( "Swap sending fee taking overflow" ) ]
247
+ TransferToSenderSub ,
244
248
}
245
249
246
250
impl From < Error > for Vec < u8 > {
Original file line number Diff line number Diff line change @@ -287,9 +287,18 @@ impl Pools {
287
287
) ) ;
288
288
289
289
// transfer tokens
290
- erc20:: take ( from, original_amount , permit2) ?;
290
+ erc20:: take ( from, amount_in , permit2) ?;
291
291
erc20:: transfer_to_sender ( to, amount_out) ?;
292
292
293
+ if original_amount > amount_in {
294
+ erc20:: transfer_to_sender (
295
+ to,
296
+ original_amount
297
+ . checked_sub ( amount_in)
298
+ . ok_or ( Error :: TransferToSenderSub ) ?,
299
+ ) ?;
300
+ }
301
+
293
302
#[ cfg( feature = "log-events" ) ]
294
303
evm:: log ( events:: Swap2 {
295
304
user : msg:: sender ( ) ,
You can’t perform that action at this time.
0 commit comments