ProjectOpenSea / seaport-js

A TypeScript library to interface with the Seaport marketplace.
MIT License
252 stars 181 forks source link

Incorrect tip amount scaling (only native currency) in partial fill scenario when using fulfillOrders #564

Closed naveen-imtb closed 3 months ago

naveen-imtb commented 4 months ago

Component

API

Have you ensured that all of these are up to date?

What version of seaport-js are you on?

4.0.1

What function is the bug in?

fulfillOrders

Operating System

macOS (Apple Silicon)

Describe the bug

Tip amounts in native currency are incorrectly scaled when performing a partial fill resulting in a much lower fee amount being charged than intended.

The most recent SDK version(4.0.1) includes a fix intended to address the issue where tip amounts were not at all scaled to the proportion of the order being filled in a partial fill scenario when using fulfillOrders. Unfortunately that fix has introduced a new bug where tip amounts are being incorrectly scaled (scaled to a much lower value than required) because the tip amounts sent to the Seaport contract are the scaled down values when they should infact reflect the original full order view.

Scenario:

Expected Actual
Cost of tokens 2 ETH (2 * 1 ETH) 2 ETH (2 * 1 ETH)
Fees 0.04 ETH (2 * 0.02 ETH) 0.008 ETH (2 * 0.004 ETH)
Total 2.04 ETH 2.008 ETH

Note: This issue affects only partial fill scenarios using native currency which are executed by calling fulfillOrders and only seen in v4.0.1 of the SDK.

naveen-imtb commented 4 months ago

PR to address this.