Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong estimation of fees for hooks #5076

Open
anxolin opened this issue Nov 7, 2024 · 0 comments
Open

Wrong estimation of fees for hooks #5076

anxolin opened this issue Nov 7, 2024 · 0 comments
Labels
Bug Something isn't working Hooks store

Comments

@anxolin
Copy link
Contributor

anxolin commented Nov 7, 2024

Description
I'm observing that SWAPs for hook is not estimating fees correctly.

Facts

In this screenshot you can see the fee for a HOOKS SWAP of 201 COW to xDAI.
Screenshot at Nov 07 16-57-07

In this second screenshot, you can see a NORMAL SWAP of 201 COW to xDAI.
Screenshot at Nov 07 16-56-51

Both fees are the same, however, our hook specified a gas limit of 23,100.

HOOKS REQUEST:

{
    "sellToken": "0x177127622c4a00f3d409b75571e12cb3c8973d3c",
    "buyToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    "from": "0x79063d9173C09887d536924E2F6eADbaBAc099f5",
    "receiver": "0x79063d9173C09887d536924E2F6eADbaBAc099f5",
    "appData": "{\"appCode\":\"CoW Swap\",\"environment\":\"pr\",\"metadata\":{\"hooks\":{\"pre\":[{\"callData\":\"0x\",\"dappId\":\"c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586\",\"gasLimit\":\"23100\",\"target\":\"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14\"}]},\"orderClass\":{\"orderClass\":\"market\"},\"partnerFee\":{\"bps\":10,\"recipient\":\"0x6b3214fD11dc91De14718DeE98Ef59bCbFcfB432\"},\"quote\":{\"slippageBips\":200,\"smartSlippage\":true}},\"version\":\"1.3.0\"}",
    "appDataHash": "0x73ab84e42e0f0c6251e26b30f55f8612bf28246a33a385c37f8b1309334027d7",
    "partiallyFillable": false,
    "priceQuality": "optimal",
    "validFor": 1800,
    "kind": "sell",
    "sellAmountBeforeFee": "201000000000000000000"
}

HOOKS RESPONSE:

{
    "quote": {
        "sellToken": "0x177127622c4a00f3d409b75571e12cb3c8973d3c",
        "buyToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "receiver": "0x79063d9173c09887d536924e2f6eadbabac099f5",
        "sellAmount": "200999289982025513046",
        "buyAmount": "110854925167667579123",
        "validTo": 1731000394,
        "appData": "{\"appCode\":\"CoW Swap\",\"environment\":\"pr\",\"metadata\":{\"hooks\":{\"pre\":[{\"callData\":\"0x\",\"dappId\":\"c768665aa144bcf18c14eea0249b6322050e5daeba046d7e94df743a2e504586\",\"gasLimit\":\"23100\",\"target\":\"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14\"}]},\"orderClass\":{\"orderClass\":\"market\"},\"partnerFee\":{\"bps\":10,\"recipient\":\"0x6b3214fD11dc91De14718DeE98Ef59bCbFcfB432\"},\"quote\":{\"slippageBips\":200,\"smartSlippage\":true}},\"version\":\"1.3.0\"}",
        "appDataHash": "0x73ab84e42e0f0c6251e26b30f55f8612bf28246a33a385c37f8b1309334027d7",
        "feeAmount": "710017974486954",
        "kind": "sell",
        "partiallyFillable": false,
        "sellTokenBalance": "erc20",
        "buyTokenBalance": "erc20",
        "signingScheme": "eip712"
    },
    "from": "0x79063d9173c09887d536924e2f6eadbabac099f5",
    "expiration": "2024-11-07T16:58:34.236950099Z",
    "id": 243207,
    "verified": true
}

SWAP REQUEST:

{
  "sellToken": "0x177127622c4a00f3d409b75571e12cb3c8973d3c",
  "buyToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  "from": "0x79063d9173C09887d536924E2F6eADbaBAc099f5",
  "receiver": "0x79063d9173C09887d536924E2F6eADbaBAc099f5",
  "appData": "{\"appCode\":\"CoW Swap\",\"environment\":\"pr\",\"metadata\":{\"orderClass\":{\"orderClass\":\"market\"},\"partnerFee\":{\"bps\":10,\"recipient\":\"0x6b3214fD11dc91De14718DeE98Ef59bCbFcfB432\"},\"quote\":{\"slippageBips\":200,\"smartSlippage\":true}},\"version\":\"1.3.0\"}",
  "appDataHash": "0xfd826d6bc0b9dd6a2d64df2e7825de5936dd1c529b17fea04ec5c0c3add57c59",
  "partiallyFillable": false,
  "priceQuality": "optimal",
  "validFor": 1800,
  "kind": "sell",
  "sellAmountBeforeFee": "201000000000000000000"
}

SWAP RESPONSE

{
    "quote": {
        "sellToken": "0x177127622c4a00f3d409b75571e12cb3c8973d3c",
        "buyToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "receiver": "0x79063d9173c09887d536924e2f6eadbabac099f5",
        "sellAmount": "200999362564111871644",
        "buyAmount": "110854965198066455234",
        "validTo": 1731000388,
        "appData": "{\"appCode\":\"CoW Swap\",\"environment\":\"pr\",\"metadata\":{\"orderClass\":{\"orderClass\":\"market\"},\"partnerFee\":{\"bps\":10,\"recipient\":\"0x6b3214fD11dc91De14718DeE98Ef59bCbFcfB432\"},\"quote\":{\"slippageBips\":200,\"smartSlippage\":true}},\"version\":\"1.3.0\"}",
        "appDataHash": "0xfd826d6bc0b9dd6a2d64df2e7825de5936dd1c529b17fea04ec5c0c3add57c59",
        "feeAmount": "637435888128356",
        "kind": "sell",
        "partiallyFillable": false,
        "sellTokenBalance": "erc20",
        "buyTokenBalance": "erc20",
        "signingScheme": "eip712"
    },
    "from": "0x79063d9173c09887d536924e2f6eadbabac099f5",
    "expiration": "2024-11-07T16:58:28.760894338Z",
    "id": 243206,
    "verified": true
}

Conclusion

We are underestimating the fee for hooks, but I think I think is likely a FE issue. I can see above how the fee for the SWAP is 0.0006374358881 COW and the fee for the HOOKS SWAP is 0.0007100179745 COW

@elena-zh elena-zh added Bug Something isn't working Hooks store labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Hooks store
Projects
None yet
Development

No branches or pull requests

2 participants