Skip to content

Commit

Permalink
Fix 1Inch quoting issues (#81)
Browse files Browse the repository at this point in the history
Currently the 1Inch solver returns a ton of 403 errors while quoting.
The reason is that the 1Inch API checks the `tx.origin` for legal
requirements and for quote requests we currently send the zero address.
Since that address obviously can't be the origin of any transaction they
refuse to return quotes for those.

To work around that we set `from` (our settlement contract) as the
`tx.origin` for quote requests. Since the calldata generated for that
will never get used to settle real orders this is okay.
  • Loading branch information
MartinquaXD authored Oct 25, 2024
1 parent 188ac64 commit cd492c5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/infra/dex/oneinch/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,22 @@ impl Query {
return None;
};

// 1Inch checks `origin` for legal reasons.
// If we provide the zero address the API will return status code 403.
// `order.owner` is only zero while quoting and calldata generated
// for quotes will not be used to actually settle orders to it's fine
// to send a different `origin` here.
let origin = match order.owner.is_zero() {
true => self.from_address,
false => order.owner,
};

Some(Self {
from_token_address: order.sell.0,
to_token_address: order.buy.0,
amount: order.amount.get(),
slippage: Slippage::from_domain(slippage),
origin: order.owner,
origin,
..self
})
}
Expand Down

0 comments on commit cd492c5

Please sign in to comment.