NoFeeSwap: A Zero-Spread Automated Market Making Protocol | Ramtin Madani - NoFeeSwap
Ethereum Denver·Thu, Oct 9, 2025, 12:00 AM
This presentation explores a range of novel, gas-efficient EVM tools pertaining to AMMs, including liquidity distribution functions, secure and efficient custom curve constructions, root-finding methods, and calculus on-chain (the computation of integrals and derivatives). It also covers advanced EVM strategies for handling memory, calldata, and storage. As part of the NoFeeSwap protocol, a comprehensive suite of Solidity libraries is introduced to support these functionalities. NoFeeSwap is an AMM protocol offering several unique advantages. Notably, it eliminates the spread between buy and sell marginal prices while ensuring liquidity growth for LPs after each swap. NoFeeSwap features concentrate liquidity along with inherent compounding. A wide variety of innovative customizations is offered to ensure utmost flexibility for LP strategies. 🚀 Get Ready for ETHDenver 2025! 🚀 We're already hard at work preparing for next year's biggest Web3 event! Keep your eyes peeled for more info on ETHDenver 2025—it’s going to be epic! 🌟
Transcript
[Music] all right hello everyone thank you for joining us my name is ramtin madani in this presentation we are going to introduce the nois swap protocol along with a wide variety of amm development tools basically we're going to talk about the underlying math behind automated Market making so for those of you who are familiar with the well-known x y equal to K formula or perhaps the car. or Unis swap V3 formula or perhaps the balancer formula here the X and Y AIS represent the amount of the reserves in your liquidity pool have you ever wondered what is special about this formulas have you ever had ideas on how to improve them well these are actually not easy questions so I'm going to break them down into the following ones what we are first going to Define what a good curve is what is ESP special about the algebraic equations in Unis swap curve. and balancer that makes them profitable then we are going to characterize the family of all good curves we will see that the majority of these custom curves do not have a clean mathematical formulation like X yal to K they may not even have a closed form next I'm going to show you how to store any of these arbitrary cures efficiently on evm we're going to introduce a bunch of tools that facilitate working with arbitrary custom curves lastly we're going to show that you do not necessarily have to have any fees or buy and sell a spread in order to make money as an LP and that is why we have named this Protocol no swap in this presentation and the next one on Thursday we're going to show you that the LPS are better off with alternative approaches all right okay first we need to come up with a better way of visualizing these curves the main problem with this geometric illustration is that it does not offer insights on how the liquidity is distributed to address this we are going to introduce the notion of liquidity distribution function consider the price Horizon the thing that bothers me about the price uh is that is the asymmetry that is why it is very helpful to instead visualize the price on a logarithmic scale from negative Infinity to positive Infinity This way everything is symmetric for example zero price zero is mapped to negative Infinity every price point uh up there uh has an equivalent logarithmic price under below Horizon price one is mapped to the origin and plus infinity is mapped to plus infinity on a high level the liquidity distribution function is like a histogram to derive it we need to Mark several prices with arbitrary granularity and then we need to measure the amount of liquidity within each of these intervals so for XY equal to 1 we can measure the amount of liquidity from negative Infinity to the logarithmic price -1 which would give us this bar the amount of liquidity from1 to the origin would give us another bar with equal height we get another bar from the origin to the logarithmic plus uh price plus one and from 1 to plus infinity so we have a bunch of equal bars once you increase granularity you get a flat line from negative INF Infinity to plus infinity that is what XY equal to 1 is it behaves similarly independent of price now if we do the same for a formula adopted by curve. 5 for example we quickly realize that there is more emphasis on the center the liquidity is lower on the S in comparison with the center and with increased granularity it gives us the following bump this is why curvey is more efficient for stable pools compared to X yal to 1 in general to derive the diagram for an arbitrary curve you need to solve a system of differential equations I'm going to go over it really fast it just the function C here is the algebraic equation to be investigated like X yal to 1 for example X notot and Y KN are the current Reserve values for the two tokens respectively Q is the logarithmic price and X and Y functions represent the reserve values corresponding to every possible price movement for the X yal to one curve this would look like this once solved you will have the token amounts with respect to the actual price values and then this formula tells you exactly how the liquidity is distributed all of the details are in our yellow paper if you plug log in the X and Y functions in this distribution formula you'll get a constant value as we demonstrated before so I encourage you guys to pay more attention to the liquidity distribution concept that we are introducing uh here as opposed to the actual curve on which swaps take place basically any distribution can be transformed to a curve and vice versa so from now on let's focus on the liquidity distribution as opposed to the curve this is how no swap solidity code operates now say you want to create you want to be creative and you want to uh make your own custom curve and you want to make sure that there is a mathematical proof guarantee that it is safe and secure for LPS um nois swap allows you to initialize your own pool with your own custom curve so here is the interface that you will be facing when you want to initialize a pool I'm going to start with kernel compact array argument this is where you can do most of your customizations it allows you to input any arbitrary PE wise linear liquidity distribution function it you can make it look like this you can make it look like that you can make it look like this one as complicated as you want want whatever your heart desires as long as it is safe which is verified on chain there are a lot of forbidden Maneuvers that you need to comply with but as long as it is safe the protocol allows it then when somebody does a swap the protocol jumps on different pieces of this kernel function and calculates the outgoing and incoming amounts that happens in the integral Library which calculates the of your distribution function from the current price to the Target price which is determined based on either the amount is specified or the logarithmic price limits we have a function in the integral Library which evaluates the value of this diagram at a specific point there is another function which calculates the integral for the outgoing amount and there is another function which calculates the integral for the incoming amount now we don't have any fees any in the protocol so a question arises as to how you can make money for the LPS Let Me elaborate the way traditional amms for example make money is that they distribute their liquidity like this there is a big hole in which no liquidity is present and there is constant constant liquidity in other areas the left boundary of this hole is the Buy price and the right boundary of this hole is the sell price the formula is not really X yal to K when they buy the formula is this one where X notot is the current reserve of token X in this case they confiscate this much of the incoming token X as fee and don't count it towards token y when they sell the formula is this where why not is the current reserve of token Y in this case they confest this much of the incoming token Ys fee and don't count it towards token X once a swap takes place the little zero region is shifted to a vicinity of the new price and this way the liquidity keeps growing this is much more pronounced with concentrated liquidity amm out there we can see the liquidity gap for different feers here basically half of each concentrated liquidity interval is empty and for stable coins it is basically very hard to be called an amm because there are just two constant prices imposed now in nois swab you have the option to use a kernel like this but we would not recommend it in fact you can get rid of the buy and sell spread entirely by avoiding the uh liquidity Gap then your distribution function would look like this for example and you still make money for LPS as we Illustrated before it could be anything as long as it is safe and profitable the protocol allows it and from a geometric point of view the curve would look like this for example the your liquidity distribution function the kernal function that you work with is transformed into something like this and we have a smooth differentiable C curve it is not bent it is not pointed because there is no spread which means that the buy and sell prices are identical a swapper can move the reserve amounts by giving some token X and taking some token y then another smooth and differentiable curve is built on top of the previous one here the blue curve and the yellow curve are tangent and the new one is within the old one on then a second swapper can move the reserve amount on a new on the new curve and the curve evolves once more to the green one this can happen again over and over and this is how liquidity grows we we went from an initial point to a Higher One via a bunch of tangent smooth and differentiable curves so yeah we are looking forward to creative custom curve ideas from you guys nois swab is basically a safe and secure platform for you to satisfy your amm curiosity and creativity so the next argument in the initialized interface is the unsalted pool ID which encapsulate a lot of components the least significant 160 bits of the pool ID is the hook address you also have the option to subscribe to one of are incentive pools so that your LPS are rewarded with the protocols no fee tokens the next 20 bits are the permission Flags these includes all the hook permissions as well as the pool owner permissions for for instance this there is a specific flag determining whether the initial kernel function can be modified dynamically the next 8 Bits host the offset price which basically indicates the origin of the price Horizon isn't that annoying when uh you have a stable coin and the price constantly um transitions from one interval to another one you can adjust the offset price to avoid that lastly we have the most significant uh 68 bits which would allow people to mine a good-look deterministic p ID it is kind of like the create two evm op code tag zero and tag one can represent native erc2 ERC 699 or ERC 1155 tokens they can even represent noi swap LP positions you can be as creative as you want with these pools for multi- tokens the tag is calculated as a hash of token address and token ID the exact formulas are provided in the yellow paper pool growth portion is the chunk of growth that the pool owner receives and the rest goes to the lpce so the pool owner can be rewarded for optimal Kel design there is a protocol level limit imposed on this value and because we want to protect the LPS and there also is a permission flag in the pool ID determining whether it can be changed the curve array is basically the initial state of the pool in order to fully understand the hooks you should learn a little bit about how nois swap handles memory let me share an overview with you guys during the execution of a Noy swap external methods every parameter occupies a specific place in memory all parameters are compactly encoded in memory in their dedicated place there are Setter and getter functions associated with each of these many parameters and then when we invoke a hook an entire snapshot of memory is sent s to the hook contract as call data this feature costs zero gas and gives the hook contract access to all of the available input and pool parameters for instance the color of the current context is a stored here and then the hook contract can inquire the color of the prior context by looking up this specific place in its call data this way you can have as many parameters as you want without errors like a stack too deep you don't have to pay for memory expansion cost for external calls you don't have to pay for memory expansion cost for emitting events this is all handled in memory. Soul all of the pointers sets and get functions are there you can find a thorough description of all parameters there as well there also are GA functions to be used by hook contracts this one for example inquires about uh the color of the prior context by reading the dedicated place in call data another thing that I want to mention in the is the operator contract that allows you to have unlimit ultimate flexibility with the core it can act as a router it can be used for your method of a slipage control as well it is built similar to evm itself you guys uh are probably familiar with most of these commands um it has its own memory and it allows you to do all sorts of arithmetic and logic you can tamper with its control sequence as well have if conditions or even for Loops you can interact with other cont contracts such as WRA ether and permit 2 you can interact with token and multi- token contracts so you can do some calculations based on the outcome uh based on the outcome you can specify an amount and perform a swap the output will be written on memory and you can do perhaps another swap based on that it is a complete touring machine and also when a swap is reverted it does not affect your call to the operator automatically what happens is that the success of your swap call is written as a Boolean on memory and you can perform any logic on that you may decide to revert the whole thing or you may perform a contingency swap instead so and also this um operator contract can be inherited by hook contracts so that it becomes a warm address and you don't pay twice when you want to interact with the hooked uh pool you pay once for both the operator contract and the hook if the hook uses the operator contract so that was the primary reason to implement it this way in order to save gas for uh for the people who want to um interact with many pools and uh there is a singl tone implemented so you can interact with as many pools as you want uh there are uh you can also deposit your uh tokens into the single tone and use them very efficiently transact them far more efficiently than erc20 standard transfers and you can also store multiple balances in one storage slot in order to further save gas for those of you who want to do WR Arbitrage Bots you who want to uh do a lot of swaps uh this is this is very helpful um our swap uh function also has some nice features uh for example you can uh set an arbitrary Direction not necessarily A Boolean Z 041 which helps you do an optimal perform an optimal Arbitrage swap many many other features that we are going to cover some of them in the next presentation uh please reach out to us and check out our GitHub repositories give us feedback uh pool requests and everything we welcome all of that we just opened up made the GitHub repository public a few days ago so we are looking forward to feedback from the community Community we are on all social media as well we are looking forward to hearing from you your insights and your ideas if you are interested there are tons of opportunities in our group as well thank you very much
Automatic transcript — names and jargon may be misspelled.