{"id":21481569,"url":"https://github.com/afa7789/gouniswapsample","last_synced_at":"2026-04-15T09:31:12.603Z","repository":{"id":107080943,"uuid":"493343327","full_name":"afa7789/GoUniswapSample","owner":"afa7789","description":"Golang get Reserves from Uniswap, simple usage of smart contract in golang.","archived":false,"fork":false,"pushed_at":"2022-06-08T14:56:20.000Z","size":219,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T19:09:08.885Z","etag":null,"topics":["dapp","ethereum","example","golang"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afa7789.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-17T17:08:23.000Z","updated_at":"2022-06-08T14:45:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"3860c600-17eb-48d5-a115-032bd20fb41a","html_url":"https://github.com/afa7789/GoUniswapSample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/afa7789/GoUniswapSample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa7789%2FGoUniswapSample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa7789%2FGoUniswapSample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa7789%2FGoUniswapSample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa7789%2FGoUniswapSample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afa7789","download_url":"https://codeload.github.com/afa7789/GoUniswapSample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa7789%2FGoUniswapSample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31834494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T07:17:56.427Z","status":"ssl_error","status_checked_at":"2026-04-15T07:17:30.007Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dapp","ethereum","example","golang"],"created_at":"2024-11-23T12:26:48.225Z","updated_at":"2026-04-15T09:31:12.568Z","avatar_url":"https://github.com/afa7789.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"![banner image of a bazer on newsprint style](/resources/bazar11_4.png)\n# GGRFU - Golang get Reserves from Uniswap ( Mock swap ) \nThis is a simple repo, trying out the GETH interface to talk to Ethereum EVM.\n\n## Challenge\nCreate a simple service in Golang(preferred) or Typescript that interacts(just reads) with UniswapV2 on Ethereum.   \n\nThere should be 2 inputs:\n\n- An Ethereum address of a Uniswap V2 pair(for e.g \"0xd3d2e2692501a5c9ca623199d38826e513033a17\")\n- An amount\n\nThe program should fetch from the chain the liquidity(reserves) of the pair's tokens and calculate(offchain) the price of the first(base/from) asset in the pool with respect to the second(quote/to), using Uniswap's formula x * y =k.\nIt should output a message that includes the token names of the pair along with the input/output amounts(e.g \"2 ETH \u003c-\u003e 808.121 UNI\")\n\n__Links:__\n\n- Pairs link: https://v2.info.uniswap.org/pairs\n- You can check the pairs' ABI/contract [here](https://etherscan.io/address/0xd3d2e2692501a5c9ca623199d38826e513033a17#code). It should be identical for every pair.\n- You can cross-check the final result [here](https://app.uniswap.org/#/swap?chain=mainnet).\n- Some extra reading on how Uniswap V2 works: https://docs.uniswap.org/protocol/V2/concepts/protocol-overview/how-uniswap-works\n\n__More about Uniswap:__\n\nhttps://docs.uniswap.org/protocol/V2/reference/smart-contracts/pair\n\n### Running it\n\n#### Prerequisites\n\n    - Install [GoLang](https://golang.org/dl/)\n    - Install [Docker](https://www.docker.com/community-edition)\n\n#### Setting up and running it.\n\n```bash\n    git clone github.com/afa7789/GGRFU \u0026\u0026 cd GGRFU\n    go mod tidy\n    cp .env.example .env\n    # add your infura or other WSS to it\n    #  run this to compile the contract\n    make compile\n    # run  it\n    make run\n```\n### Output\n\nI used this pair: __0xbb2b8038a1640196fbe3e38816f3e67cba72d940__\n\ntimestamp: 1652804597\n\n```BASH\nThe Challenge\nWrapped BTC reserve:     WBTC 350.2066285; token decimals:8;\nWrapped Ether reserve:   WETH 5117.883978; token decimals:18;\n-----\nk: 179231689313875619843013296611368;\n-----\nAmount to simulate swap: WETH 0.0001;\nnew reserve0 = 35020663536;\nold reserve0 = 35020662852;\namount out = 0.00000684;\n```\n\nCompare to the value in the uniswap interface at same timestamp:\n\n![uniswap printscreen of swap with same value](/resources/swap.png)\n\n## Tree\n\n```sh\n.\n├── contract\n│   ├── IUniswapV2Pair.sol\n│   └── output # directory where the abi gen is gonna output the abi and bin of the contract.\n├── go.mod\n├── go.sum\n├── internal\n│   └── mycontract # you will not find the contract here when you download the repo, because you gotta run make compile to generate the go file\n│       └── IUniswapV2Pair.go\n├── LICENSE\n├── main.go\n├── Makefile\n├── README.md\n└── .env.example # copy this to add your keys.\n```\n\n\nUniswapModule | 0x9ac91386b4c6300d600c54882145d8eabdd1b5fd\n\nThe Contract Address 0x9ac91386b4c6300d600c54882145d8eabdd1b5fd \n\nSushiSwapModule | 0xbf1e8e287579afad68cc82fc801c3c07b8c5ae59\n\nCurveModule | 0xbfd0d27fb6a6d3f509143c31a390a53069760ca7\n\nEIP173ProxyWithReceive | 0x8a71704f0f8891f92417faf840568ecee0be0918\n\nSlingshot | 0x71727089c52efc4ad7c3fb6565c865463418d7af\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafa7789%2Fgouniswapsample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafa7789%2Fgouniswapsample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafa7789%2Fgouniswapsample/lists"}