diff --git a/contracts/LpSugar.vy b/contracts/LpSugar.vy index f49bf73..7ea1508 100644 --- a/contracts/LpSugar.vy +++ b/contracts/LpSugar.vy @@ -14,6 +14,7 @@ initializes: lp_shared MAX_TOKENS: public(constant(uint256)) = 2000 MAX_LPS: public(constant(uint256)) = 500 MAX_POSITIONS: public(constant(uint256)) = 200 +MAX_TOKEN_SYMBOL_LEN: public(constant(uint256)) = 30 # Slot0 from CLPool.sol struct Slot: @@ -1073,7 +1074,7 @@ def _safe_decimals(_token: address) -> uint8: @internal @view -def _safe_symbol(_token: address) -> String[30]: +def _safe_symbol(_token: address) -> String[MAX_TOKEN_SYMBOL_LEN]: """ @notice Returns the `ERC20.symbol()` safely (max 30 chars) @param _token The token to call @@ -1092,9 +1093,9 @@ def _safe_symbol(_token: address) -> String[30]: resp_len: uint256 = len(response) # Check response as revert_on_failure is set to False - # And that the symbol size is not more than 10 chars (96 bytes) - if resp_len > 0 and resp_len <= 96: - return abi_decode(response, String[30]) + # And that the symbol size is not some large value (probably spam) + if resp_len > 0 and resp_len <= MAX_TOKEN_SYMBOL_LEN: + return abi_decode(response, String[MAX_TOKEN_SYMBOL_LEN]) return "-???-" diff --git a/env.base b/env.base index f5dfc61..1126d14 100644 --- a/env.base +++ b/env.base @@ -14,7 +14,7 @@ TEST_FACTORY_ADDRESS_8453=0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A TEST_ADDRESS_8453=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac TEST_ALM_ADDRESS_8453=0x892Ff98a46e5bd141E2D12618f4B2Fe6284debac -LP_SUGAR_ADDRESS_8453=0x82dA79111A0C79639B7a4c6dc149283D103f1860 +LP_SUGAR_ADDRESS_8453=0xECd02f59C82D713191b0CD6337c6F3a750a55d72 REWARDS_SUGAR_ADDRESS_8453=0xA44600F4DBA6683d8BD99270B1A6a143fB9F1C3B VE_SUGAR_ADDRESS_8453=0x4c5d3925fe65DFeB5A079485136e4De09cb664A5 RELAY_SUGAR_ADDRESS_8453=0x8932B5FE23C07Df06533F8f09E43e7cca6a24143 diff --git a/tests/test_lp_sugar.py b/tests/test_lp_sugar.py index ff2fd49..719f59b 100644 --- a/tests/test_lp_sugar.py +++ b/tests/test_lp_sugar.py @@ -108,6 +108,22 @@ def test_tokens_long_symbol(sugar_contract, TokenStruct): assert token.symbol == '-???-' +@pytest.mark.skipif(int(CHAIN_ID) not in [8453], reason="Only BASE") +def test_tokens_long_symbol(sugar_contract, TokenStruct): + tokens = list(map( + lambda _p: TokenStruct(*_p), + sugar_contract.tokens(1, 2508, ADDRESS_ZERO, []) + )) + + assert tokens is not None + assert len(tokens) > 1 + + token = tokens[0] + + assert token.symbol is not None + assert token.symbol == '-???-' + + @pytest.mark.skipif(int(CHAIN_ID) not in [10], reason="Only OP") def test_all_long_symbol(sugar_contract, LpStruct): pools = list(map(