diff --git a/contracts/LpSugar.vy b/contracts/LpSugar.vy index 92edd89..317fac0 100644 --- a/contracts/LpSugar.vy +++ b/contracts/LpSugar.vy @@ -68,7 +68,7 @@ struct Position: struct Token: token_address: address - symbol: String[128] + symbol: String[100] decimals: uint8 account_balance: uint256 listed: bool @@ -83,7 +83,7 @@ struct SwapLp: struct Lp: lp: address - symbol: String[128] + symbol: String[100] decimals: uint8 liquidity: uint256 @@ -133,7 +133,7 @@ struct AlmManagedPositionInfo: interface IERC20: def decimals() -> uint8: view - def symbol() -> String[128]: view + def symbol() -> String[100]: view def balanceOf(_account: address) -> uint256: view interface IPool: @@ -148,7 +148,7 @@ interface IPool: def index0() -> uint256: view def index1() -> uint256: view def totalSupply() -> uint256: view - def symbol() -> String[128]: view + def symbol() -> String[100]: view def decimals() -> uint8: view def stable() -> bool: view def balanceOf(_account: address) -> uint256: view @@ -1088,17 +1088,17 @@ def _safe_decimals(_token: address) -> uint8: @internal @view -def _safe_symbol(_token: address) -> String[128]: +def _safe_symbol(_token: address) -> String[100]: """ @notice Returns the `ERC20.symbol()` result safely @param _token The token to call """ - # >=192 input size is required by Vyper's _abi_decode() - response: Bytes[192] = b"" + # Large input size is required by Vyper's _abi_decode() + response: Bytes[2048] = b"" response = raw_call( _token, method_id("symbol()"), - max_outsize=192, + max_outsize=2048, gas=50000, is_delegate_call=False, is_static_call=True, @@ -1106,9 +1106,12 @@ def _safe_symbol(_token: address) -> String[128]: )[1] # Check response as revert_on_failure is set to False - # String size cannot be larger than max_outsize - 64 bytes - if len(response) > 0 and len(response) <= 128: - return abi_decode(response, String[128]) + # ABI decoded string size cannot be larger than Bytes size - 64 bytes + if len(response) > 0: + decoded_symbol: String[1984] = abi_decode(response, String[1984]) + end: uint256 = min(100, len(decoded_symbol)) + truncated_symbol: String[100] = convert(slice(decoded_symbol, 0, end), String[100]) + return truncated_symbol return "-NA-" diff --git a/env.optimism b/env.optimism index 8612cb3..8cf97fd 100644 --- a/env.optimism +++ b/env.optimism @@ -13,7 +13,7 @@ GOVERNOR_10=0x1F82e10D58aEf03DeA2e478029fB0387A1cbE989 TEST_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac TEST_ALM_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac -LP_SUGAR_ADDRESS_10=0x065CA8CD19367A7c9773BC563940a4c0016de0DE +LP_SUGAR_ADDRESS_10=0x54F8968CC76ECB17018E44049FdcC14ff833fa67 REWARDS_SUGAR_ADDRESS_10=0x62CCFB2496f49A80B0184AD720379B529E9152fB VE_SUGAR_ADDRESS_10=0x94f913362b232e31daB49a1aFB775cfd25DaA6a1 RELAY_SUGAR_ADDRESS_10=0xb8307e5842B9aeE75C704183F0355076aa74b4e2 diff --git a/readme.md b/readme.md index 4a6a7ee..a9c7992 100644 --- a/readme.md +++ b/readme.md @@ -37,7 +37,7 @@ Below is the list of datasets we support. > [!NOTE] > `LpSugar.vy` is deployed on: -> Optimism - `0x065CA8CD19367A7c9773BC563940a4c0016de0DE` +> Optimism - `0x54F8968CC76ECB17018E44049FdcC14ff833fa67` > Base - `0x63a73829C74e936C1D2EEbE64164694f16700138` It allows fetching on-chain pools data.