{"id":26162501,"url":"https://github.com/balancer/balancer-registry","last_synced_at":"2025-04-14T13:30:28.318Z","repository":{"id":54584030,"uuid":"277599190","full_name":"balancer/balancer-registry","owner":"balancer","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-09T08:44:06.000Z","size":849,"stargazers_count":14,"open_issues_count":0,"forks_count":28,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T02:38:51.592Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/balancer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-06T16:54:16.000Z","updated_at":"2024-02-25T14:51:38.000Z","dependencies_parsed_at":"2022-08-13T20:31:10.800Z","dependency_job_id":null,"html_url":"https://github.com/balancer/balancer-registry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-registry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-registry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-registry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balancer%2Fbalancer-registry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/balancer","download_url":"https://codeload.github.com/balancer/balancer-registry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248888521,"owners_count":21178074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-03-11T13:54:45.083Z","updated_at":"2025-04-14T13:30:28.280Z","avatar_url":"https://github.com/balancer.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Onchain Registry \u0026 Exchange Proxy\n\n### Registry.sol\n\nStores a registry of Balancer Pool addresses for a given token address pair. Pools can be sorted in order of liquidity and queried via view functions.\n\nFork of https://github.com/CryptoManiacsZone/BalancerRegistry\n\n\u003e **Adding Pools To Registry**\n\n`addPoolPair(address pool, address token1, address token2)`\n\nAdds a single pool address for token pair.\n\n`addPools(address[] calldata pools, address token1, address token2)`\n\nAdds an array of pool addresses for token pair.\n\n\u003e **Sorting Pools**\n\n`sortPools(address[] calldata tokens, uint256 lengthLimit)`\n\nSorts pools in order of liquidity. lengthLimit can be used to limit the number of pools sorted.\n\n`sortPoolsWithPurge(address[] calldata tokens, uint256 lengthLimit)`\n\nSorts pools in order of liquidity and removes any pools with \u003c10% of total liquidity.\n\n\u003e **Retrieving Pools**\n\n`getBestPools(address fromToken, address destToken)`\n\nRetrieve array of pool addresses for token pair. Ordered by liquidity if previously sorted. Max of 32 pools returned.\n\n`getBestPoolsWithLimit(address fromToken, address destToken, uint256 limit)`\n\nRetrieve array of pool addresses for token pair. Ordered by liquidity if previously sorted. Max of n pools returned where n=limit.\n\n`getPoolsWithLimit(address fromToken, address destToken, uint256 offset, uint256 limit)`\n\nRetrieve array of pool addresses using an offset starting position.\n\n### ExchangeProxy.sol\n\nThis contract includes swap forwarding proxy logic and on-chain smart order routing functionality.\n\nbatchSwap functions allows users to batch execute swaps recommended by off-chain SOR.\n\nviewSplit functions query the Registry to provide best swap information using on-chain data.\n\nsmartSwap functions combine view and batch functionality to provide complete optimised on-chain swaps.\n\n\u003e **batchSwap functions**\n\n`multihopBatchSwapExactIn(Swap[][] memory swapSequences, TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountIn, uint minTotalAmountOut) public payable`\n\nExecute multi-hop swaps returned from off-chain SOR for swapExactIn trade type.\n\n`multihopBatchSwapExactOut(Swap[][] memory swapSequences, TokenInterface tokenIn, TokenInterface tokenOut, uint maxTotalAmountIn) public payable`\n\nExecute multi-hop swaps returned from off-chain SOR for swapExactOut trade type.\n\n`batchSwapExactIn(Swap[] memory swaps, TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountIn, uint minTotalAmountOut) public payable`\n\nExecute single-hop swaps for swapExactIn trade type. Used for swaps returned from viewSplit function and legacy off-chain SOR.\n\n`batchSwapExactOut(Swap[] memory swaps, TokenInterface tokenIn, TokenInterface tokenOut, uint maxTotalAmountIn) public payable`\n\nExecute single-hop swaps for swapExactOut trade type. Used for swaps returned from viewSplit function and legacy off-chain SOR.\n\n\u003e **viewSplit functions**\n\n`viewSplitExactIn(address tokenIn, address tokenOut, uint swapAmount, uint nPools)`\n\nView function that calculates most optimal swaps (exactIn swap type) across a max of nPools. Returns an array of Swaps and the total amount out for swap.\n\n`viewSplitExactOut(address tokenIn, address tokenOut, uint swapAmount, uint nPools)`\n\nView function that calculates most optimal swaps (exactOut swap type) across a max of nPools. Returns an array of Swaps and the total amount in for swap. (! Please be aware the return parameter \"totalOutput\" in the contract is a misnomer and actually represents totalInput !)\n\n\u003e **smartSwap functions**\n\n`smartSwapExactIn(TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountIn, uint minTotalAmountOut, uint nPools) public payable`\n\nCalculates and executes most optimal swaps across a max of nPools for tokenIn \u003e tokenOut swap with an input token amount = totalAmountIn.\n\n`smartSwapExactOut(TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountOut, uint maxTotalAmountIn, uint nPools) public payable`\n\nCalculates and executes most optimal swaps across a max of nPools for tokenIn \u003e tokenOut swap with a desired output token amount = totalAmountOut.\n\n## Testing\n\nTo run tests:\n\n```\n$ npx buidler node\n$ npx buidler test\n```\n\n## Deploying\n\nDeploy scripts:\n\nAdd .env variable to root and include: INFURA=your_api_key and KEYKOVAN/KEYRINKEBY/KEYMAIN=deploy_key \n\n* Mainnet: `$ npx buidler run --network main  deploy-script-mainnet.js`\n* Kovan: `$ npx buidler run --network kovan deploy-script-kovan.js`\n* Rinkeby: `$ npx buidler run --network rinkeby deploy-script-rinkeby.js`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalancer%2Fbalancer-registry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbalancer%2Fbalancer-registry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalancer%2Fbalancer-registry/lists"}