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

Add getMarkets action #137

Closed
wants to merge 3 commits into from
Closed

Add getMarkets action #137

wants to merge 3 commits into from

Conversation

eborrallo
Copy link
Contributor

@eborrallo eborrallo commented Sep 16, 2024

Get Markers functionality to return all the markets active on the protocol satisfying the next type

Array< MarketParams>

The solidity code to populate this array is the next one

 function getMarkets(MgvReader reader) public view returns (MarketWithToken[] memory) {
        (Market[] memory markets,) = reader.openMarkets();
        uint numMarkets = markets.length;
        MarketWithToken[] memory marketsWithToken = new MarketWithToken[](numMarkets);

        for (uint i = 0; i < numMarkets;) {
            IERC20 token0 = IERC20(markets[i].tkn0);
            IERC20 token1 = IERC20(markets[i].tkn1);

            marketsWithToken[i] = MarketWithToken({
                tkn0: Token({
                token: address(token0),
                decimals: token0.decimals(),
                symbol: token0.symbol()
            }),
                tkn1: Token({
                token: address(token1),
                decimals: token1.decimals(),
                symbol: token1.symbol()
            }),
            adr:
                tickSpacing: markets[i].tickSpacing
            });

            unchecked {
                i++;
            }
        }

        return marketsWithToken;
    }

The code was compiled and used as a bytecode

@eborrallo eborrallo requested a review from maxencerb September 16, 2024 18:25
Copy link

changeset-bot bot commented Sep 16, 2024

⚠️ No Changeset found

Latest commit: 7255c1a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

src/actions/market.ts Outdated Show resolved Hide resolved
src/actions/market.ts Outdated Show resolved Hide resolved
src/actions/market.ts Outdated Show resolved Hide resolved
src/actions/market.ts Show resolved Hide resolved
src/types/actions/index.ts Outdated Show resolved Hide resolved
Co-authored-by: Maxence Raballand <[email protected]>
@eborrallo eborrallo force-pushed the getMarkets branch 6 times, most recently from 5e6ad19 to 76e0f30 Compare September 17, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants