Skip to content

Commit 4ad3bda

Browse files
authored
Fix WETH for CowSwap Oracle (Gnosis Chain) (#501)
- CowSwap oracle in Gnosis Chain is supposed to use Wrapped XDAI for getting the price, not Wrapped Ether
1 parent 7272185 commit 4ad3bda

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

gnosis/protocol/gnosis_protocol_api.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ def weth_address(self) -> ChecksumAddress:
7171
"""
7272
:return: Wrapped ether checksummed address
7373
"""
74-
if self.network == EthereumNetwork.MAINNET:
75-
return ChecksumAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
76-
elif self.network == EthereumNetwork.RINKEBY:
77-
return ChecksumAddress("0xc778417E063141139Fce010982780140Aa0cD5Ab")
78-
else: # XDAI
79-
return ChecksumAddress("0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1")
74+
if self.network == EthereumNetwork.GNOSIS: # WXDAI
75+
return ChecksumAddress("0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")
76+
if self.network == EthereumNetwork.GOERLI: # Goerli WETH9
77+
return ChecksumAddress("0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6")
78+
79+
# Mainnet WETH9
80+
return ChecksumAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
8081

8182
def get_quote(
8283
self, order: Order, from_address: ChecksumAddress
@@ -129,9 +130,10 @@ def place_order(
129130
from_address = Account.from_key(private_key).address
130131
if not order.feeAmount:
131132
fee_amount = self.get_fee(order, from_address)
132-
if "errorType" in fee_amount: # ErrorResponse
133+
if isinstance(fee_amount, int):
134+
order.feeAmount = fee_amount
135+
elif "errorType" in fee_amount: # ErrorResponse
133136
return fee_amount
134-
order.feeAmount = fee_amount
135137

136138
signable_hash = eip712_encode_hash(
137139
order.get_eip712_structured_data(

gnosis/protocol/tests/test_gnosis_protocol_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ def test_place_order(self):
153153
if type(order_id) is dict:
154154
if order_id["errorType"] == "NoLiquidity":
155155
pytest.xfail("NoLiquidity Error")
156+
elif order_id["errorType"] == "InsufficientBalance":
157+
pytest.xfail("InsufficientBalance")
156158

157159
self.assertEqual(order_id[:2], "0x")
158160
self.assertEqual(len(order_id), 114)

0 commit comments

Comments
 (0)