Introducing 10KSwap: An AMM protocol that advances with Ethereum
10KSwap(10kswap.com), being built on StarkNet, is an AMM protocol that advances with Ethereum. 10K aims to revolutionize the performance of the AMM protocol by leveraging the rollup feature, bringing lower fees, less friction, and ultimately better liquidity to the L2 world and advance DeFi adoption.
10KSwap is the first open source AMM deployed on StarkNet Mainnet. We trust Ethereum and StarkNet, which represents the most advanced rollup trend. With its unique Cairo-VM giving developers a new development option, higher TPS and a computational cost that can be ignored. We believe AMM will be the most direct beneficiary of these two features.
With Cairo-VM, the gas cost required to perform calculation is much lower than for state updates, and on top of this we will increase the appropriate amount of calculation to reduce the number of state updates, continue to improve contract performance, and further reduce gas costs. Ensuring that 10K brings users a lightning-fast trading experience while enjoying the security of broad consensus - that's what every DeFi user wants to see, and we look forward to exploring this magical starfield with the pioneers on StarkNet.
10KSwap has adopted an immutable scheme where the protocol does not serve centralized interests. When it is fully delivered by the creator, the power is left to the community. It is a reflection of the spirit of decentralization, and our desire to work with users to make the impossible triangle possible.
In subsequent developments, we will continue to explore the potential of zk-tech to develop an AMM that is more LP friendly and allows for finer control of liquidity distribution.
The key technology is how to use Cairo to develop the "Rich Convex Function", and we will bring the results to the community. All the development process is open source and available as reference material, hoping to motivate more Dapp developers to inspire them to get involved in the L2 ecosystem and build DeFi. The following three products will be brought to the community.
1). A summary tutorial related to development.
2). A more generic and accessible development scaffolding.
3). SDK and DeFi contract libraries to facilitate dapp development.
git clone [email protected]:0x60018/10k_swap-contracts.git
cd 10k_swap-contracts
yarn install
npx hardhat starknet-compile contracts/l0k_factory.cairo
npx hardhat test l0k_factory.test.ts
mainStable versiondevelopNew PRs and features
- Mainnet Adddress:
0x01c0a36e26a8f822e0d81f20a5a562b16a8f8a3dfd99801367dd2aea8f1a87a2 - Goerli Adddress:
0x06c31f39524388c982045988de3788530605ed08b10389def2e7b1dd09d19308
func PairCreated(token0 : felt, token1 : felt, pair : felt, index : felt):
endtoken0is guaranteed to be strictly less thantoken1by sort order.pairtoken0 & token1 pair addressindexpair index, start from 0
func constructor(pairClass : felt, feeToSetter : felt):
endpairClassl0k_pair contract class hashfeeToSetterfeeTo address manager
func feeTo() -> (feeTo : felt):
end- Returns
feeTo
func feeToSetter() -> (feeToSetter : felt):
end- Returns
feeToSetter
func getPair(token0 : felt, token1 : felt) -> (pair : felt):
endtoken0-token1-- Returns
pair
func allPairs(index : felt) -> (pair : felt):
endindexpair index- Returns
pair
func allPairsLength() -> (length : felt):
end- Returns
length
func createPair(tokenA : felt, tokenB : felt) -> (pair : felt):
endtokenAA token addresstokenBB token address- Returns
pair - Emits
PairCreated
func setFeeTo(feeTo : felt) -> ():
endfeeTo-
func setFeeToSetter(feeToSetter : felt) -> ():
endfeeToSetter-
- ClassHash:
0x231adde42526bad434ca2eb983efdd64472638702f87f97e6e3c084f264e06f
ERC20 functions and events based on openzeppelin cairo, click here for details.
Thanks to openzeppelin for powering cairo.
func Mint(sender : felt, amount0 : Uint256, amount1 : Uint256):
endsenderMinteramount0Token0 amountamount1Token1 amount
func Burn(sender : felt, amount0 : Uint256, amount1 : Uint256, to : felt):
endsenderBurneramount0Token0 amountamount1Token1 amounttoRecipient
func Swap(
sender : felt,
amount0In : Uint256,
amount1In : Uint256,
amount0Out : Uint256,
amount1Out : Uint256,
to : felt,
):
endsenderSwaperamount0InToken0 in amountamount1InToken1 in amountamount0OutToken0 out amountamount1OutToken1 out amounttoRecipient
func Sync(reserve0 : felt, reserve1 : felt):
endreserve0Token0 quantity in pairreserve1Token1 quantity in pair
func MINIMUM_LIQUIDITY() -> (MINIMUM_LIQUIDITY : felt):
endMINIMUM_LIQUIDITY-
func factory() -> (factory : felt):
endfactoryl0k_factory contract
func token0() -> (token0 : felt):
endtoken0-
func token1() -> (token1 : felt):
endtoken1-
func blockTimestampLast() -> (blockTimestampLast : felt):
endblockTimestampLast-
func price0CumulativeLast() -> (price0CumulativeLast : felt):
endprice0CumulativeLast-
func price1CumulativeLast() -> (price1CumulativeLast : felt):
endprice1CumulativeLast-
func kLast() -> (kLast : felt):
endkLast-
func getReserves() -> (reserve0 : felt, reserve1 : felt, blockTimestampLast : felt):
endreserve0Token0 quantity in pairreserve1reserve1 quantity in pairblockTimestampLast-
func initialize() -> (token0 : felt, token1 : felt):
endcalled once by the factory at time of deployment
token0-token1-
func mint(to : felt) -> (liquidity : Uint256):
endtoRecipient- RETURNS:
liquidityPair token quantity - Emits
Mint,Sync,TransferERC20
func burn(to : felt) -> (amount0 : Uint256, amount1 : Uint256):
endtoRecipient- RETURNS:
amount0Received token0 quantity,amount1Received token0 quantity - Emits
Burn,Sync,TransferERC20
func swap(amount0Out : Uint256, amount1Out : Uint256, to : felt) -> ():
endamount0Out-amount1Out-toRecipient- Emits
Swap,Sync
func skim() -> (to : felt):
endtoRecipient
func sync() -> ():
end- Emits
Sync
- Mainnet Adddress:
0x07a6f98c03379b9513ca84cca1373ff452a7462a3b61598f0af5bb27ad7f76d1 - Goerli Adddress:
0x00975910cd99bc56bd289eaaa5cee6cd557f0ddafdb2ce6ebea15b158eb2c664
func factory() -> (factory : felt):
endfactoryl0k_factory contract
func quote(amountA : Uint256, reserveA : felt, reserveB : felt) -> (amountB : Uint256):
endamountATokenA quantityreserveATokenA quantity in pairreserveBTokenB quantity in pair- Returns
amountBReceived tokenB quantity
func getAmountOut(amountIn : Uint256, reserveIn : felt, reserveOut : felt) -> (amountOut : Uint256):
endamountInTokenIn quantityreserveInTokenIn quantity in pairreserveOutTokenOut quantity in pair- Returns
amountOutReceived tokenOut quantity
func getAmountOut(amountOut : Uint256, reserveIn : felt, reserveOut : felt) -> (amountIn : Uint256):
endamountOutTokenOut quantityreserveInTokenIn quantity in pairreserveOutTokenOut quantity in pair- Returns
amountInReceived tokenIn quantity
func getAmountsOut(amountIn : Uint256, path_len : felt, path : felt*) -> (amounts_len : felt, amounts : Uint256*):
endamountInTokenIn quantitypath_lenPath's lengthpath[TokenA, TokenB, ...]- Returns
amounts_lenamounts's length,amountsreceived tokens amount
func getAmountsIn(amountOut : Uint256, path_len : felt, path : felt*) -> (amounts_len : felt, amounts : Uint256*):
endamountOutTokenOut quantitypath_lenPath's lengthpath[TokenB, TokenA, ...]- Returns
amounts_lenamounts's length,amountssend tokens amount
func addLiquidity(
tokenA : felt,
tokenB : felt,
amountADesired : Uint256,
amountBDesired : Uint256,
amountAMin : Uint256,
amountBMin : Uint256,
to : felt,
deadline : felt,
) -> (amountA : Uint256, amountB : Uint256, liquidity : Uint256):
endtokenATokenA addresstokenBTokenB addressamountADesired-amountBDesired-amountAMin-amountBMin-toRecipientdeadlineExpired timestamp(unix)- Returns
amountAUsed tokenA quantity,amountBUsed tokenB quantity,liquidityPair token quantity
func removeLiquidity(
tokenA : felt,
tokenB : felt,
liquidity : Uint256,
amountAMin : Uint256,
amountBMin : Uint256,
to : felt,
deadline : felt,
) -> (amountA : Uint256, amountB : Uint256):
endtokenATokenA addresstokenBTokenB addressliquidityPair token quantityamountAMin-amountBMin-toRecipientdeadlineExpired timestamp(unix)- Returns
amountAReceived tokenA quantity,amountBReceived tokenB quantity
func swapExactTokensForTokens(
amountIn : Uint256,
amountOutMin : Uint256,
path_len : felt,
path : felt*,
to : felt,
deadline : felt,
) -> (amounts_len : felt, amounts : Uint256*):
endamountIn-amountOutMin-path_len-path-toRecipientdeadlineExpired timestamp(unix)- Returns
amounts_lenamounts's length,amountsreceived tokens amount
func swapTokensForExactTokens(
amountOut : Uint256,
amountInMax : Uint256,
path_len : felt,
path : felt*,
to : felt,
deadline : felt,
) -> (amounts_len : felt, amounts : Uint256*):
endamountOut-amountInMax-path_len-path-toRecipientdeadlineExpired timestamp(unix)- Returns
amounts_lenamounts's length,amountssend tokens amount
func swapExactTokensForTokensSupportingFeeOnTransferTokens(
amountIn : Uint256,
amountOutMin : Uint256,
path_len : felt,
path : felt*,
to : felt,
deadline : felt,
):
endamountIn-amountOutMin-path_len-path-toRecipientdeadlineExpired timestamp(unix)- Returns
amounts_lenamounts's length,amountssend tokens amount
