Files
tycho-protocol-sdk/evm/out/ISwapAdapter.sol/ISwapAdapter.json
2025-09-16 11:31:19 +02:00

1 line
22 KiB
JSON

{"abi":[{"type":"function","name":"getCapabilities","inputs":[{"name":"poolId","type":"bytes32","internalType":"bytes32"},{"name":"sellToken","type":"address","internalType":"address"},{"name":"buyToken","type":"address","internalType":"address"}],"outputs":[{"name":"capabilities","type":"uint8[]","internalType":"enum ISwapAdapterTypes.Capability[]"}],"stateMutability":"nonpayable"},{"type":"function","name":"getLimits","inputs":[{"name":"poolId","type":"bytes32","internalType":"bytes32"},{"name":"sellToken","type":"address","internalType":"address"},{"name":"buyToken","type":"address","internalType":"address"}],"outputs":[{"name":"limits","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"nonpayable"},{"type":"function","name":"getPoolIds","inputs":[{"name":"offset","type":"uint256","internalType":"uint256"},{"name":"limit","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"ids","type":"bytes32[]","internalType":"bytes32[]"}],"stateMutability":"nonpayable"},{"type":"function","name":"getTokens","inputs":[{"name":"poolId","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"tokens","type":"address[]","internalType":"address[]"}],"stateMutability":"nonpayable"},{"type":"function","name":"price","inputs":[{"name":"poolId","type":"bytes32","internalType":"bytes32"},{"name":"sellToken","type":"address","internalType":"address"},{"name":"buyToken","type":"address","internalType":"address"},{"name":"specifiedAmounts","type":"uint256[]","internalType":"uint256[]"}],"outputs":[{"name":"prices","type":"tuple[]","internalType":"struct ISwapAdapterTypes.Fraction[]","components":[{"name":"numerator","type":"uint256","internalType":"uint256"},{"name":"denominator","type":"uint256","internalType":"uint256"}]}],"stateMutability":"nonpayable"},{"type":"function","name":"swap","inputs":[{"name":"poolId","type":"bytes32","internalType":"bytes32"},{"name":"sellToken","type":"address","internalType":"address"},{"name":"buyToken","type":"address","internalType":"address"},{"name":"side","type":"uint8","internalType":"enum ISwapAdapterTypes.OrderSide"},{"name":"specifiedAmount","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"trade","type":"tuple","internalType":"struct ISwapAdapterTypes.Trade","components":[{"name":"calculatedAmount","type":"uint256","internalType":"uint256"},{"name":"gasUsed","type":"uint256","internalType":"uint256"},{"name":"price","type":"tuple","internalType":"struct ISwapAdapterTypes.Fraction","components":[{"name":"numerator","type":"uint256","internalType":"uint256"},{"name":"denominator","type":"uint256","internalType":"uint256"}]}]}],"stateMutability":"nonpayable"},{"type":"error","name":"LimitExceeded","inputs":[{"name":"limit","type":"uint256","internalType":"uint256"}]},{"type":"error","name":"NotImplemented","inputs":[{"name":"reason","type":"string","internalType":"string"}]},{"type":"error","name":"Unavailable","inputs":[{"name":"reason","type":"string","internalType":"string"}]}],"bytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"deployedBytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"methodIdentifiers":{"getCapabilities(bytes32,address,address)":"48bd7dfd","getLimits(bytes32,address,address)":"a9270fbe","getPoolIds(uint256,uint256)":"23eeca01","getTokens(bytes32)":"ecbbc033","price(bytes32,address,address,uint256[])":"aad6e488","swap(bytes32,address,address,uint8,uint256)":"8307c655"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.27+commit.40a35a09\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"limit\",\"type\":\"uint256\"}],\"name\":\"LimitExceeded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"NotImplemented\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"reason\",\"type\":\"string\"}],\"name\":\"Unavailable\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"sellToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"buyToken\",\"type\":\"address\"}],\"name\":\"getCapabilities\",\"outputs\":[{\"internalType\":\"enum ISwapAdapterTypes.Capability[]\",\"name\":\"capabilities\",\"type\":\"uint8[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"sellToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"buyToken\",\"type\":\"address\"}],\"name\":\"getLimits\",\"outputs\":[{\"internalType\":\"uint256[]\",\"name\":\"limits\",\"type\":\"uint256[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"offset\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"limit\",\"type\":\"uint256\"}],\"name\":\"getPoolIds\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"ids\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"}],\"name\":\"getTokens\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"tokens\",\"type\":\"address[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"sellToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"buyToken\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"specifiedAmounts\",\"type\":\"uint256[]\"}],\"name\":\"price\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"}],\"internalType\":\"struct ISwapAdapterTypes.Fraction[]\",\"name\":\"prices\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"poolId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"sellToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"buyToken\",\"type\":\"address\"},{\"internalType\":\"enum ISwapAdapterTypes.OrderSide\",\"name\":\"side\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"specifiedAmount\",\"type\":\"uint256\"}],\"name\":\"swap\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"calculatedAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasUsed\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"numerator\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"denominator\",\"type\":\"uint256\"}],\"internalType\":\"struct ISwapAdapterTypes.Fraction\",\"name\":\"price\",\"type\":\"tuple\"}],\"internalType\":\"struct ISwapAdapterTypes.Trade\",\"name\":\"trade\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implement this interface to support Propeller routing through your pools. Before implementing the interface we need to introduce some function for a given pool. The main one, the swap(x) function, implements a sell order of a specified token. The gas function simply returns the estimated gas cost given a specified amount x. Last but not least, the price function is the derivative of the swap function. It represents the best possible price a user can get from a pool after swapping x of the specified token. During calls to swap and getLimits, the caller can be assumed to have the required sell or buy token balance as well as unlimited approvals to this contract.\",\"errors\":{\"LimitExceeded(uint256)\":[{\"details\":\"The LimitExceeded error is thrown when a limit has been exceeded. E.g. the specified amount can't be traded safely.\"}],\"NotImplemented(string)\":[{\"details\":\"The NotImplemented error is thrown when a function is not implemented.\"}],\"Unavailable(string)\":[{\"details\":\"The Unavailable error is thrown when a pool or swap is not available for unexpected reason. E.g. it was paused due to a bug.\"}]},\"kind\":\"dev\",\"methods\":{\"getCapabilities(bytes32,address,address)\":{\"params\":{\"poolId\":\"The ID of the trading pool.\"},\"returns\":{\"capabilities\":\"An array of Capability.\"}},\"getLimits(bytes32,address,address)\":{\"details\":\"Retrieve the maximum limits of a token that can be traded. The limit is reached when the change in the received amounts is zero or close to zero or when the swap fails because of the pools restrictions. Overestimate if in doubt rather than underestimate. The swap function should not error with `LimitExceeded` if called with amounts below the limit.\",\"params\":{\"buyToken\":\"The token being bought.\",\"poolId\":\"The ID of the trading pool.\",\"sellToken\":\"The token being sold.\"},\"returns\":{\"limits\":\"An array of size two indicating the limit amount for the sell token (maximum the pool is willing to buy in sell token) as well as the limit amount of the buy token (maximum the pool is willing to sell in buy token).\"}},\"getPoolIds(uint256,uint256)\":{\"details\":\"Mainly used for testing. It is alright to not return all available pools here. Nevertheless, this is useful to test against the substreams implementation. If implemented, it saves time writing custom tests.\",\"params\":{\"limit\":\"The maximum number of pool IDs to retrieve.\",\"offset\":\"The starting index from which to retrieve pool IDs.\"},\"returns\":{\"ids\":\"An array of pool IDs.\"}},\"getTokens(bytes32)\":{\"details\":\"Mainly used for testing as this is redundant with the required substreams implementation.\",\"params\":{\"poolId\":\"The ID of the trading pool.\"},\"returns\":{\"tokens\":\"An array of address contracts.\"}},\"price(bytes32,address,address,uint256[])\":{\"details\":\"The returned prices should include all dex fees. In case the fee is dynamic on the amount traded, the returned price is expected to include the minimum fee. Note that the returned price should be the marginal price which is distinct from the executed price `swap(amount_in) / amount_in`! The marginal price is defined as the price to trade an arbitrarily small (almost zero) amount after the trade of (amount). E.g. the marginal price of a uniswap v2 pool at amount=0 is `reserve0/reserve1`. Ideally this method should be implemented, although it is optional as the price function can be numerically derived from the swap function. In case it is not available, it should be flagged via capabilities and calling it should revert using the `NotImplemented` error. The method needs to be implemented as view as this is usually more efficient and can be run in parallel.\",\"params\":{\"buyToken\":\"The token being bought.\",\"poolId\":\"The ID of the trading pool.\",\"sellToken\":\"The token being sold.\",\"specifiedAmounts\":\"Amounts to calculate marginal prices at.\"},\"returns\":{\"prices\":\"array of prices as fractions corresponding to the provided amounts.\"}},\"swap(bytes32,address,address,uint8,uint256)\":{\"details\":\"This function should be state modifying, meaning it should actually execute the swap and change the state of the EVM accordingly. Please include a gas usage estimate for each amount. This can be achieved e.g. by using the `gasleft()` function. The return type `Trade` has an attribute called price which should contain the value of `price(specifiedAmount)`. As this is optional, defined via `Capability.PriceFunction`, it is valid to return a Fraction(0, 0) value for this price. In that case the price will be estimated numerically.\",\"params\":{\"buyToken\":\"The token being bought.\",\"poolId\":\"The ID of the trading pool.\",\"sellToken\":\"The token being sold.\",\"side\":\"The side of the trade (Sell or Buy).\",\"specifiedAmount\":\"The amount to be traded.\"},\"returns\":{\"trade\":\"Trade struct representing the executed trade.\"}}},\"title\":\"ISwapAdapter\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getCapabilities(bytes32,address,address)\":{\"notice\":\"Retrieves the capabilities of the selected pool.\"},\"getLimits(bytes32,address,address)\":{\"notice\":\"Retrieves the limits for each token.\"},\"getPoolIds(uint256,uint256)\":{\"notice\":\"Retrieves a range of pool IDs.\"},\"getTokens(bytes32)\":{\"notice\":\"Retrieves the tokens in the selected pool.\"},\"price(bytes32,address,address,uint256[])\":{\"notice\":\"Calculates marginal prices for specified amounts (optional).\"},\"swap(bytes32,address,address,uint8,uint256)\":{\"notice\":\"Simulates swapping tokens on a given pool.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/interfaces/ISwapAdapter.sol\":\"ISwapAdapter\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/\",\":balancer-v2/interfaces/=lib/balancer-v2-monorepo/pkg/interfaces/contracts/\",\":ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/\",\":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/\",\":forge-std/=lib/forge-std/src/\",\":openzeppelin-contracts/=lib/openzeppelin-contracts/\"],\"viaIR\":true},\"sources\":{\"src/interfaces/ISwapAdapter.sol\":{\"keccak256\":\"0xb7af70bac27e53573dfb145ec715203ca28ab8795f512b8ec84c33b5d812d702\",\"license\":\"AGPL-3.0-or-later\",\"urls\":[\"bzz-raw://ad7d3672672ef08abd6c7c04d3426d6f0bed4ebb34c5e4d70926da145cdfbd87\",\"dweb:/ipfs/QmS99C7MRYB9Lkph2f3XLJfjFmX4u2aC6Tm5n886pMSk1C\"]},\"src/interfaces/ISwapAdapterTypes.sol\":{\"keccak256\":\"0xf5637c8fca78253bd88d94d8173d8de4487146f82e462df42f428142ee951778\",\"license\":\"AGPL-3.0-or-later\",\"urls\":[\"bzz-raw://f2c3ab44f87f9c945f52052196537e057292e45d4011830c73a9495e60cdbf4c\",\"dweb:/ipfs/QmePvUFDNHpH2b5Y4kRBXgSrA55RrZgjdUXwV5GLNX5o5h\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.27+commit.40a35a09"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"}],"type":"error","name":"LimitExceeded"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"type":"error","name":"NotImplemented"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"type":"error","name":"Unavailable"},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"address","name":"buyToken","type":"address"}],"stateMutability":"nonpayable","type":"function","name":"getCapabilities","outputs":[{"internalType":"enum ISwapAdapterTypes.Capability[]","name":"capabilities","type":"uint8[]"}]},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"address","name":"buyToken","type":"address"}],"stateMutability":"nonpayable","type":"function","name":"getLimits","outputs":[{"internalType":"uint256[]","name":"limits","type":"uint256[]"}]},{"inputs":[{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"stateMutability":"nonpayable","type":"function","name":"getPoolIds","outputs":[{"internalType":"bytes32[]","name":"ids","type":"bytes32[]"}]},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function","name":"getTokens","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}]},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"address","name":"buyToken","type":"address"},{"internalType":"uint256[]","name":"specifiedAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function","name":"price","outputs":[{"internalType":"struct ISwapAdapterTypes.Fraction[]","name":"prices","type":"tuple[]","components":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}]}]},{"inputs":[{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"address","name":"buyToken","type":"address"},{"internalType":"enum ISwapAdapterTypes.OrderSide","name":"side","type":"uint8"},{"internalType":"uint256","name":"specifiedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function","name":"swap","outputs":[{"internalType":"struct ISwapAdapterTypes.Trade","name":"trade","type":"tuple","components":[{"internalType":"uint256","name":"calculatedAmount","type":"uint256"},{"internalType":"uint256","name":"gasUsed","type":"uint256"},{"internalType":"struct ISwapAdapterTypes.Fraction","name":"price","type":"tuple","components":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}]}]}]}],"devdoc":{"kind":"dev","methods":{"getCapabilities(bytes32,address,address)":{"params":{"poolId":"The ID of the trading pool."},"returns":{"capabilities":"An array of Capability."}},"getLimits(bytes32,address,address)":{"details":"Retrieve the maximum limits of a token that can be traded. The limit is reached when the change in the received amounts is zero or close to zero or when the swap fails because of the pools restrictions. Overestimate if in doubt rather than underestimate. The swap function should not error with `LimitExceeded` if called with amounts below the limit.","params":{"buyToken":"The token being bought.","poolId":"The ID of the trading pool.","sellToken":"The token being sold."},"returns":{"limits":"An array of size two indicating the limit amount for the sell token (maximum the pool is willing to buy in sell token) as well as the limit amount of the buy token (maximum the pool is willing to sell in buy token)."}},"getPoolIds(uint256,uint256)":{"details":"Mainly used for testing. It is alright to not return all available pools here. Nevertheless, this is useful to test against the substreams implementation. If implemented, it saves time writing custom tests.","params":{"limit":"The maximum number of pool IDs to retrieve.","offset":"The starting index from which to retrieve pool IDs."},"returns":{"ids":"An array of pool IDs."}},"getTokens(bytes32)":{"details":"Mainly used for testing as this is redundant with the required substreams implementation.","params":{"poolId":"The ID of the trading pool."},"returns":{"tokens":"An array of address contracts."}},"price(bytes32,address,address,uint256[])":{"details":"The returned prices should include all dex fees. In case the fee is dynamic on the amount traded, the returned price is expected to include the minimum fee. Note that the returned price should be the marginal price which is distinct from the executed price `swap(amount_in) / amount_in`! The marginal price is defined as the price to trade an arbitrarily small (almost zero) amount after the trade of (amount). E.g. the marginal price of a uniswap v2 pool at amount=0 is `reserve0/reserve1`. Ideally this method should be implemented, although it is optional as the price function can be numerically derived from the swap function. In case it is not available, it should be flagged via capabilities and calling it should revert using the `NotImplemented` error. The method needs to be implemented as view as this is usually more efficient and can be run in parallel.","params":{"buyToken":"The token being bought.","poolId":"The ID of the trading pool.","sellToken":"The token being sold.","specifiedAmounts":"Amounts to calculate marginal prices at."},"returns":{"prices":"array of prices as fractions corresponding to the provided amounts."}},"swap(bytes32,address,address,uint8,uint256)":{"details":"This function should be state modifying, meaning it should actually execute the swap and change the state of the EVM accordingly. Please include a gas usage estimate for each amount. This can be achieved e.g. by using the `gasleft()` function. The return type `Trade` has an attribute called price which should contain the value of `price(specifiedAmount)`. As this is optional, defined via `Capability.PriceFunction`, it is valid to return a Fraction(0, 0) value for this price. In that case the price will be estimated numerically.","params":{"buyToken":"The token being bought.","poolId":"The ID of the trading pool.","sellToken":"The token being sold.","side":"The side of the trade (Sell or Buy).","specifiedAmount":"The amount to be traded."},"returns":{"trade":"Trade struct representing the executed trade."}}},"version":1},"userdoc":{"kind":"user","methods":{"getCapabilities(bytes32,address,address)":{"notice":"Retrieves the capabilities of the selected pool."},"getLimits(bytes32,address,address)":{"notice":"Retrieves the limits for each token."},"getPoolIds(uint256,uint256)":{"notice":"Retrieves a range of pool IDs."},"getTokens(bytes32)":{"notice":"Retrieves the tokens in the selected pool."},"price(bytes32,address,address,uint256[])":{"notice":"Calculates marginal prices for specified amounts (optional)."},"swap(bytes32,address,address,uint8,uint256)":{"notice":"Simulates swapping tokens on a given pool."}},"version":1}},"settings":{"remappings":["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","balancer-v2/interfaces/=lib/balancer-v2-monorepo/pkg/interfaces/contracts/","ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","forge-std/=lib/forge-std/src/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"src/interfaces/ISwapAdapter.sol":"ISwapAdapter"},"evmVersion":"cancun","libraries":{},"viaIR":true},"sources":{"src/interfaces/ISwapAdapter.sol":{"keccak256":"0xb7af70bac27e53573dfb145ec715203ca28ab8795f512b8ec84c33b5d812d702","urls":["bzz-raw://ad7d3672672ef08abd6c7c04d3426d6f0bed4ebb34c5e4d70926da145cdfbd87","dweb:/ipfs/QmS99C7MRYB9Lkph2f3XLJfjFmX4u2aC6Tm5n886pMSk1C"],"license":"AGPL-3.0-or-later"},"src/interfaces/ISwapAdapterTypes.sol":{"keccak256":"0xf5637c8fca78253bd88d94d8173d8de4487146f82e462df42f428142ee951778","urls":["bzz-raw://f2c3ab44f87f9c945f52052196537e057292e45d4011830c73a9495e60cdbf4c","dweb:/ipfs/QmePvUFDNHpH2b5Y4kRBXgSrA55RrZgjdUXwV5GLNX5o5h"],"license":"AGPL-3.0-or-later"}},"version":1},"id":53}