From e6cd3bdfbbc5f247cd3b1df9dc06a3570d9a920f Mon Sep 17 00:00:00 2001 From: sakulstra Date: Mon, 2 Sep 2024 09:51:35 +0200 Subject: [PATCH] feat: add getter for token pairs --- .../contracts/static-a-token/StataTokenFactory.sol | 8 ++++---- .../static-a-token/interfaces/IStataTokenFactory.sol | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/periphery/contracts/static-a-token/StataTokenFactory.sol b/src/periphery/contracts/static-a-token/StataTokenFactory.sol index e7ba0929..a8061ebb 100644 --- a/src/periphery/contracts/static-a-token/StataTokenFactory.sol +++ b/src/periphery/contracts/static-a-token/StataTokenFactory.sol @@ -22,7 +22,7 @@ contract StataTokenFactory is Initializable, IStataTokenFactory { address public immutable STATA_TOKEN_IMPL; mapping(address => address) internal _underlyingToStataToken; - address[] internal _stataTokens; + TokenPair[] internal _tokenPairs; event StataTokenCreated(address indexed stataToken, address indexed underlying); @@ -70,7 +70,7 @@ contract StataTokenFactory is Initializable, IStataTokenFactory { _underlyingToStataToken[underlyings[i]] = stataToken; stataTokens[i] = stataToken; - _stataTokens.push(stataToken); + _tokenPairs.push(TokenPair({stataToken: stataToken, underlying: underlyings[i]})); emit StataTokenCreated(stataToken, underlyings[i]); } else { stataTokens[i] = cachedStataToken; @@ -80,8 +80,8 @@ contract StataTokenFactory is Initializable, IStataTokenFactory { } ///@inheritdoc IStataTokenFactory - function getStataTokens() external view returns (address[] memory) { - return _stataTokens; + function getTokenPairs() external view returns (TokenPair[] memory) { + return _tokenPairs; } ///@inheritdoc IStataTokenFactory diff --git a/src/periphery/contracts/static-a-token/interfaces/IStataTokenFactory.sol b/src/periphery/contracts/static-a-token/interfaces/IStataTokenFactory.sol index 2eaf187b..edd7fe7a 100644 --- a/src/periphery/contracts/static-a-token/interfaces/IStataTokenFactory.sol +++ b/src/periphery/contracts/static-a-token/interfaces/IStataTokenFactory.sol @@ -4,6 +4,11 @@ pragma solidity ^0.8.10; interface IStataTokenFactory { error NotListedUnderlying(address underlying); + struct TokenPair { + address underlying; + address stataToken; + } + /** * @notice Creates new StataTokens * @param underlyings the addresses of the underlyings to create. @@ -12,10 +17,10 @@ interface IStataTokenFactory { function createStataTokens(address[] memory underlyings) external returns (address[] memory); /** - * @notice Returns all StataTokens deployed via this registry. + * @notice Returns all StataTokens deployed via this registry paired with the corresponding underlying. * @return address[] list of StataTokens */ - function getStataTokens() external view returns (address[] memory); + function getTokenPairs() external view returns (TokenPair[] memory); /** * @notice Returns the StataToken for a given underlying.