Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getter for token pairs #15

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/periphery/contracts/static-a-token/StataTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down