Skip to content

Commit

Permalink
fix: symbol string size
Browse files Browse the repository at this point in the history
  • Loading branch information
ethzoomer authored Nov 18, 2024
1 parent 4b5827c commit eeff98a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions contracts/LpSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct Position:

struct Token:
token_address: address
symbol: String[100]
symbol: String[128]
decimals: uint8
account_balance: uint256
listed: bool
Expand All @@ -83,7 +83,7 @@ struct SwapLp:

struct Lp:
lp: address
symbol: String[100]
symbol: String[128]
decimals: uint8
liquidity: uint256

Expand Down Expand Up @@ -133,7 +133,7 @@ struct AlmManagedPositionInfo:

interface IERC20:
def decimals() -> uint8: view
def symbol() -> String[100]: view
def symbol() -> String[128]: view
def balanceOf(_account: address) -> uint256: view

interface IPool:
Expand All @@ -148,7 +148,7 @@ interface IPool:
def index0() -> uint256: view
def index1() -> uint256: view
def totalSupply() -> uint256: view
def symbol() -> String[100]: view
def symbol() -> String[128]: view
def decimals() -> uint8: view
def stable() -> bool: view
def balanceOf(_account: address) -> uint256: view
Expand Down Expand Up @@ -465,7 +465,7 @@ def _v2_lp(_data: address[4], _token0: address, _token1: address) -> Lp:

return Lp({
lp: _data[1],
symbol: staticcall pool.symbol(),
symbol: self._safe_symbol(_data[1]),
decimals: decimals,
liquidity: pool_liquidity,

Expand Down Expand Up @@ -1088,7 +1088,7 @@ def _safe_decimals(_token: address) -> uint8:

@internal
@view
def _safe_symbol(_token: address) -> String[100]:
def _safe_symbol(_token: address) -> String[128]:
"""
@notice Returns the `ERC20.symbol()` result safely
@param _token The token to call
Expand All @@ -1106,8 +1106,9 @@ def _safe_symbol(_token: address) -> String[100]:
)[1]

# Check response as revert_on_failure is set to False
if len(response) > 0:
return abi_decode(response, String[100])
# String size cannot be larger than max_outsize - 64 bytes
if len(response) > 0 and len(response) <= 128:
return abi_decode(response, String[128])

return "-NA-"

Expand Down
2 changes: 1 addition & 1 deletion env.optimism
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GOVERNOR_10=0x1F82e10D58aEf03DeA2e478029fB0387A1cbE989
TEST_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac
TEST_ALM_ADDRESS_10=0x892ff98a46e5bd141e2d12618f4b2fe6284debac

LP_SUGAR_ADDRESS_10=0x5B3B370C85c8816cBB4BCE5f647dCa3e06c421d7
LP_SUGAR_ADDRESS_10=0x065CA8CD19367A7c9773BC563940a4c0016de0DE
REWARDS_SUGAR_ADDRESS_10=0x62CCFB2496f49A80B0184AD720379B529E9152fB
VE_SUGAR_ADDRESS_10=0x94f913362b232e31daB49a1aFB775cfd25DaA6a1
RELAY_SUGAR_ADDRESS_10=0xb8307e5842B9aeE75C704183F0355076aa74b4e2
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Below is the list of datasets we support.

> [!NOTE]
> `LpSugar.vy` is deployed on:
> Optimism - `0x35F233BE126d7D08aB2D65E647E8c379b1FACF39`
> Optimism - `0x065CA8CD19367A7c9773BC563940a4c0016de0DE`
> Base - `0x63a73829C74e936C1D2EEbE64164694f16700138`
It allows fetching on-chain pools data.
Expand Down

0 comments on commit eeff98a

Please sign in to comment.