shapeshift / web

ShapeShift Web
https://app.shapeshift.com
MIT License
157 stars 180 forks source link

Dynamically adjust memo length for L1ToLongtail according to the data length limits of any chains #6784

Open NeOMakinG opened 2 weeks ago

NeOMakinG commented 2 weeks ago

Overview

As far as we know:

Map the byte size

We need to select the actual size:

If we can't meet any of these conditions, just return an error so it's safer, and this chain should be added to this mapping, it has probably been forgotten while supporting it.

This way we will support any chains limits in an holistic way.

Final Asset Address length

THORChain allow to use only X number of characters, and it will fuzzy search in the 1inch token list:

We need to find a way to reduce the final asset address length (eg: https://gitlab.com/thorchain/thornode/-/blob/v1.131.0/common/tokenlist/ethtokens/eth_mainnet_latest.json), as far as we know, 2-3-4 chars are not enough and are colliding with multiple addresses, we have some solutions:

minAmountOut of the final asset

We need to implement a dynamic adjustment of the final asset's minAmountOut in the memo.

Reduce the length of the minAmountOut value depending on the actual memo length overflow, be careful that the value should be acceptable and the 2 last numbers of the memo are the exponents as specified in the THORChain aggregator code.

Examples:

Please make sure the precision is good enough, even if it's already another security.

References and additional details

You will be able to find a lot of details in https://github.com/shapeshift/web/pull/6731

THORChain memo length documentation: https://dev.thorchain.org/concepts/memo-length-reduction.html THORChain aggregator memo informations: https://dev.thorchain.org/aggregators/memos.html

Our @gomesalexandre 🐐 did a wonderful out of date POC for the minAmountOut logic: https://github.com/shapeshift/web/pull/6772/files

Acceptance Criteria

Need By Date

No response

Screenshots/Mockups

No response

Estimated effort

No response