Questions tagged [amm]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
27 views

How is the derivation of the Constant Product AMM formula of Uniswap?

I was researching about Uniswap v1 and I found that the code is using the following formula to get the amount out of a swap: Formula: Reference to code Everyone says that this formula is derived of ...
santipu_'s user avatar
0 votes
0 answers
33 views

Do Balancer swaps only update the state of the Vault?

I'm trying to understand the Balancer v2 architecture. When a swap occurs in a given pool_id, does this only result in updating the state of the Vault, and pool contracts themselves are just constant ...
Sergio Gliesh's user avatar
1 vote
0 answers
32 views

How to setup routing in pancakeswap

Pancake V2 has this smart order routing(SOR) feature. I was wondering how to build this efficiently, so that I can do permutation and combinations on existing pairs and get their reserves, and thereby ...
Manav Notnani's user avatar
1 vote
1 answer
285 views

What is the quote function in UniswapV2Library used for?

What is the purpose of the quote function and how does it differ from getAmountOut?
Jolow's user avatar
  • 23
0 votes
1 answer
443 views

Does the sqrtPricex96 on the Uniswap V3 swap-event represent the average price paid by the swapper, or the new price of the pool after swap?

sqrtPricex96 on a Uniswap V3 swap-event can be used to calculate the token1/token0 price. I'm not asking how to do this conversion. Instead I'm asking which token1/token0 price does this represent? ...
Geert-Jan's user avatar
  • 169
0 votes
2 answers
191 views

how to make a contract compatible with different ERC-20 Decimals

I'm making a tutorial about how to create an AMM ( Automated Market Maker ), but I have a problem with the decimals. Both tokens have different decimals, and when I want to transfer them, the ...
George Lopez's user avatar
0 votes
1 answer
717 views

Can someone explain Uniswap's v2 getAmountIn?

Code can be seen here: https://github.com/Uniswap/v2-periphery/blob/master/contracts/libraries/UniswapV2Library.sol#L53 What I don't understand is that if you use the constant product formula, you ...
U Avalos's user avatar
  • 113
0 votes
1 answer
94 views

How to do Snapshot and extract Token Balances for Holders of UniV2Pair?

Trying to figure out how to get all addresses and balances of all holders for both token0 and token1 from a UniPair and make a snapshot for all individual balances. What I'm interested in is: ...
Liberalite's user avatar
0 votes
1 answer
422 views

UniSwap v2 Subgraph return 0 for Volume in USD and ETH

I've forked Uniswap v2 contracts including WETH, and Deployed on Rinkeby. the functionality of Creating Pools, adding and removing liquidity works fine. Now to get the stats like TVL, Volume, 24hr ...
Muhammad Taqi's user avatar
0 votes
1 answer
77 views

Liquidity pool price and oracle price

I am trying to wrap my head around. I understand the concept of x*y=k vol. when we are calculating this we can get the price but there’s also an exchange price, say eth. That means the pool will have ...
hammies's user avatar
  • 105
2 votes
2 answers
358 views

Curve AMM - How is fee calculated when adding liquidity?

When adding liquidity to Curve AMM, fees are calculated by the following code _fee: uint256 = self.fee * N_COINS / (4 * (N_COINS - 1)) https://github.com/curvefi/curve-contract/blob/...
tsknakamura's user avatar
1 vote
2 answers
140 views

How would I create my own amm or exchange?

Good afternoon, I have a goal of making my own amm website similar to pancake swap or uniswap and I don't have great first place to start to break ground on actually developing, I have a some what of ...
Magnio's user avatar
  • 11
1 vote
1 answer
397 views

uniswap price for pair

If I go to https://app.uniswap.org/#/add/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2/3000?chain=mainnet I can see liquidity details for USDC-DAI It looks like ...
user1995187's user avatar
1 vote
0 answers
140 views

How to calculate annual percentage yield on an AMM?

A related question has been asked here but a satisfactory answer has not been provided. I understand that APY for x*y=k AMMs is a function of average volume(V), liquidity provided by LP(l), fee(f) and ...
MShakeG's user avatar
  • 1,398
0 votes
1 answer
242 views

How can I get all the holders of an LP token for a date range

Is there any api/contract call sample etc that can help me get a list of everyone who holds an LP token within a particular date range? I. E people who held it thro and never transferred it or sold it ...
Layinka's user avatar
  • 111
1 vote
0 answers
261 views

Looking for a price impact calculator

Looking for a calculator to work out price impact based on differing variables. Token start price Liquidity Total supply of tokens Buy amount Usd pair Cheers 🍻
Michael Kearney's user avatar
0 votes
2 answers
3k views

Swap exact ETH for min tokens not accurate?

Just swapped some tokens on an AMM. AMM said minimum I will receive was around 282 tokens, I really recevied around 254 tokens. I had slippage at 12% as the token I was trading takes 10% reflections. ...
May 's user avatar
  • 1
1 vote
1 answer
536 views

PancakeSwap charges a fee to mint LP according to their code?

I am looking at the PancakeSwap contract for LP's and I noticed they charge a fee for creating LP's. No where in their documentation does it say there is a fee for depositing liquidity. What is ...
Picard78's user avatar
  • 139
1 vote
0 answers
133 views

Are all of these Dexes just frontend interface to coin swapping contracts? Uniswap, 1inch, balance defi-swap, shibaswap, etc

I'm still wrapping my head around all these swapping services like Uniswap, sushiswap, etc... Uniswap Sushiswap 1 Inch Balancer Defiswap Shibaswap Are all those above just front end interface to ...
Patoshi パトシ's user avatar
4 votes
0 answers
948 views

Uniswap V2 AmountIn Calculation Procedure

So, I was working on a project which heavily uses uniswap. I have to show the calculations and derivations of stuff that is happening inside uniswap. So, I was reading it's whitepaper, seeing it ...
Hokkyokusei's user avatar
0 votes
1 answer
361 views

Is there a way to find out how much I earned in fees from just the UniswapPair V2 contract?

Let's say I add liquidity to the ETH-USDT pool, then I remove liquidity some time later. In between that time, trades have happened and people have added and removed liquidity too. I only have what's ...
doctopus's user avatar
  • 315
1 vote
0 answers
651 views

Is the Uniswap v2 0.3% trading fee calculated wrong?

I am digging into the details of how the token swapping fee is calculated and I cannot get a formula that reproduces the expected 0.3% fee. Let's say there's a USDT-ETH pool with: 1000 USDT 10 ETH k =...
doctopus's user avatar
  • 315
1 vote
1 answer
503 views

Uniswap WETH_WBTC price is orders of magnitude off when using constant product market maker formula

I am trying to calculate the value of an exchange on Uniswap using Web3js and methods from the Uniswap smart contract. This is the Uniswap contract address for the WETH (Wrapped Ether) : WBTC (Wrapped ...
MikeG's user avatar
  • 113