{"id":470677,"date":"2025-08-14T03:03:57","date_gmt":"2025-08-14T03:03:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=470677"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=470677","title":{"rendered":"<span>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Uniswap v4: \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>Uniswap V4<\/strong>\u00a0&#8212; \u044d\u0442\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 DeFi \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443\u00a0<strong>&#171;Singleton Design&#187;<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0443\u043b\u0430.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f: \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043b\u0430 \u0432\u0441\u0435 \u043f\u0443\u043b\u044b \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c &#171;\u0445\u0443\u043a\u0438&#187; \u0434\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e 1 \u043f\u0443\u043b = 1 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0444\u0430\u0431\u0440\u0438\u043a\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v3-core\/blob\/main\/contracts\/UniswapV3Factory.sol\" rel=\"noopener noreferrer nofollow\">UniswapV3Factory.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v3-core\/blob\/main\/contracts\/UniswapV3PoolDeployer.sol\" rel=\"noopener noreferrer nofollow\">UniswapV3PoolDeployer.sol<\/a>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/127\/0a4\/48a\/1270a448ac22723140727500b042c6d4.png\" width=\"2054\" height=\"1088\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/127\/0a4\/48a\/1270a448ac22723140727500b042c6d4.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/127\/0a4\/48a\/1270a448ac22723140727500b042c6d4.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u0432\u0430\u043f\u0430, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v3-periphery\/blob\/main\/contracts\/SwapRouter.sol\" rel=\"noopener noreferrer nofollow\">SwapRouter.sol<\/a>\u00a0\u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a \u043f\u0443\u043b\u0443.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/88f\/32f\/486\/88f32f4864a59dbf92909a4c25ea8fb2.png\" width=\"2014\" height=\"802\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/88f\/32f\/486\/88f32f4864a59dbf92909a4c25ea8fb2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/88f\/32f\/486\/88f32f4864a59dbf92909a4c25ea8fb2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L117\" rel=\"noopener noreferrer nofollow\">initialize()<\/a>\u00a0\u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>. \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0443\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u0432\u0430\u043f\u0430, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>, \u043d\u043e \u0432\u0441\u044f \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u0443\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Pool.sol\" rel=\"noopener noreferrer nofollow\">Pool.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u00a0<code>PoolManager.sol<\/code><\/p>\n<p>\u0421\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u044e \u0433\u0430\u0437\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043f\u0443\u043b\u0430. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u043c\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u0443\u043b\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0443\u043b\u044b, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0433\u0430\u0437.<\/p>\n<h3>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h3>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u043d\u0430 \u0434\u0432\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0432\u0435\u0440\u0441\u0438\u044f\u043c:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/tree\/main\" rel=\"noopener noreferrer nofollow\">v4-core<\/a>.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\" rel=\"noopener noreferrer nofollow\">v4-periphery<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>Core \u0432\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0443\u043b\u044b, \u0430 periphery \u2014 \u0437\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u043a \u043f\u0443\u043b\u0430\u043c. \u0422\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0443\u043b\u043e\u0432, \u0440\u043e\u0443\u0442\u0435\u0440\u0430, LP \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0432 \u0434\u0432\u0443\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/37d\/7a9\/2b3\/37d7a92b343ab191b090becdab1ccad3.png\" width=\"2484\" height=\"1206\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/37d\/7a9\/2b3\/37d7a92b343ab191b090becdab1ccad3.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/37d\/7a9\/2b3\/37d7a92b343ab191b090becdab1ccad3.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u042f \u0432\u044b\u043f\u0438\u0441\u0430\u043b \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0440\u0430\u0437\u0431\u0438\u0442\u044b\u0445 \u043d\u0430 4 \u0433\u0440\u0443\u043f\u043f\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0438\u043d\u0438\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043f\u0435\u0440\u0432\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u043e\u0437\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0435\u043b\u0435\u043d\u044b\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0445\u0443\u043a\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430, \u0442\u0435\u043c \u043e\u043d \u0432\u0430\u0436\u043d\u0435\u0435 \u0432 \u043a\u043e\u0434\u0435 Uniswap. \u041d\u0430 \u0441\u0445\u0435\u043c\u0435 \u0442\u0430\u043a\u0438\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>. \u0421\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b core, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u043b\u0430\u043c\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>. \u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b periphery, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b \u0433\u0440\u0443\u043f\u043f\u044b core.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/PositionManager.sol\" rel=\"noopener noreferrer nofollow\">PositionManager.sol<\/a>. \u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b periphery, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e LP \u0442\u043e\u043a\u0435\u043d\u0430 (\u043d\u0444\u0442\u0438\u0448\u043a\u0438), \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435\u00a0<code>PoolManager.sol<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432<\/h3>\n<p>\u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\n<p><strong>modifyLiquidity()<\/strong>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c\u044e: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041e\u0431\u044b\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u043c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<code>PositionManager.sol<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>swap()<\/strong>. \u041e\u0431\u043c\u0435\u043d \u0430\u043a\u0442\u0438\u0432\u043e\u0432. \u041e\u0431\u044b\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<code>V4Router.sol<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>donate()<\/strong>. \u041f\u0440\u044f\u043c\u044b\u0435 \u0434\u043e\u043d\u0430\u0442\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u0443\u043b\u0435 \u0432 \u043e\u0431\u0445\u043e\u0434 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>mint()\/burn()<\/strong>. \u041c\u0438\u043d\u0442 \u0438 \u0441\u0436\u0438\u0433\u0430\u043d\u0438\u0435 ERC-6909, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0441\u0432\u0430\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d, \u0430 \u0441\u043c\u0438\u043d\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u0432 ERC-6909. \u041c\u0438\u043d\u0442 ERC-6909 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u043f\u043e \u0433\u0430\u0437\u0443, \u0447\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u0435\u0440 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>take()\/settle()<\/strong>. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0433\u0430\u0448\u0435\u043d\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u043e\u0432. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f flash loans \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u044f\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u044b \u0438\u0437 \u043f\u0443\u043b\u0430 \u0432 \u0434\u043e\u043b\u0433 \u0438 \u043f\u043e\u0433\u0430\u0441\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>sync()<\/strong>. \u0414\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0443\u043b\u0430 \u0441 \u0435\u0433\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u043c\u0438 \u0440\u0435\u0437\u0435\u0440\u0432\u0430\u043c\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0438 \u0446\u0435\u043d\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u0430\u0434\u0436\u0430<\/strong><\/p>\n<p>\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0443\u043b\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 mapping \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0443\u043b\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">mapping(PoolId id =&gt; Pool.State) internal _pools;<\/code><\/pre>\n<p><strong>PoolId<\/strong>\u00a0&#8212; \u044d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0443\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435\u00a0<code>bytes32<\/code>. \u041f\u043e \u0441\u0443\u0442\u0438, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0435\u0448\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0443\u043b\u0430. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f id \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/types\/PoolId.sol#L9\" rel=\"noopener noreferrer nofollow\">PoolIdLibrary<\/a>\u00a0\u0441 \u043e\u0434\u043d\u043e\u0439 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439\u00a0<code>toId()<\/code>.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u0437\u044f\u0442\u043e \u0438\u0437 PoolKey.sol struct PoolKey {     \/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043a\u0435\u043d\u0435 0     Currency currency0;     \/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043a\u0435\u043d\u0435 1     Currency currency1;     \/\/ \u041a\u043e\u043c\u0438\u0441\u0441\u0438\u044f     uint24 fee;     \/\/ \u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u0438\u043a\u0430     int24 tickSpacing;     \/\/ \u0410\u0434\u0440\u0435\u0441 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0445\u0443\u043a\u0430     IHooks hooks; }  library PoolIdLibrary {     function toId(PoolKey memory poolKey) internal pure returns (PoolId poolId) {         assembly (\"memory-safe\") {             \/\/ 0xa0 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 PoolKey (5 slots of 32 bytes)             poolId := keccak256(poolKey, 0xa0)         }     } }<\/code><\/pre>\n<p><code>Pool.State<\/code>\u00a0&#8212; \u044d\u0442\u043e \u0432\u0441\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0443\u043b\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u0441\u0442\u043e\u0440\u0430\u0434\u0436\u0435\u00a0<code>PoolManager.sol<\/code>\u00a0\u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0438\u043a\u0430.<\/p>\n<pre><code class=\"javascript\">int24 private constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING; int24 private constant MIN_TICK_SPACING = TickMath.MIN_TICK_SPACING;<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u0430\u0434\u0436\u0430 \u043f\u043e\u043f\u0440\u044f\u0442\u0430\u043d\u044b \u043f\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f\u00a0<code>PoolManager.sol<\/code>.<\/p>\n<p><strong>\u041e\u0442 \u0447\u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f PoolManager<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/63f\/69a\/b41\/63f69ab41e33704aacc2d6b581a07490.png\" width=\"1866\" height=\"804\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/63f\/69a\/b41\/63f69ab41e33704aacc2d6b581a07490.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/63f\/69a\/b41\/63f69ab41e33704aacc2d6b581a07490.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/NoDelegateCall.sol\" rel=\"noopener noreferrer nofollow\">NoDelegateCall.sol<\/a>. \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u0417\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438. \u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438,\u00a0<code>delegateCall<\/code>\u00a0\u043a\u00a0<code>PoolManager<\/code>\u00a0\u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d \u0432 \u0446\u0435\u043b\u044f\u0445 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/ERC6909Claims.sol\" rel=\"noopener noreferrer nofollow\">ERC6909Claims.sol<\/a>. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043d\u0442\u0438\u0442\u044c \u0438 \u0441\u0436\u0438\u0433\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u0432 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u0430\u043a\u0442\u0438\u0432\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/Extsload.sol\" rel=\"noopener noreferrer nofollow\">Extsload.sol<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/Exttload.sol\" rel=\"noopener noreferrer nofollow\">Exttload.sol<\/a>. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/TransientStateLibrary.sol\" rel=\"noopener noreferrer nofollow\">TransientStateLibrary.sol<\/a>\u00a0\u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0421\u0430\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u043e\u0432 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0433\u0440\u0443\u043f\u043f\u044b core. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435, \u0435\u0441\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u0442\u043e \u0442\u0430\u043c \u0431\u044b\u043b\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0433\u0438\u043a\u0438, \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043d\u043e\u0439 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fd1\/345\/7ab\/fd13457abd308b60515ab73721ff1a98.png\" width=\"1318\" height=\"1102\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/fd1\/345\/7ab\/fd13457abd308b60515ab73721ff1a98.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fd1\/345\/7ab\/fd13457abd308b60515ab73721ff1a98.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441\u0438\u043b\u044c\u043d\u043e\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/tree\/main\/src\/libraries\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u044c\u0448\u0435<\/a>. \u041d\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Pool.sol\" rel=\"noopener noreferrer nofollow\">Pool.sol<\/a>. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b \u043a \u043f\u0443\u043b\u0443: \u043e\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u0434\u043e \u0441\u0432\u0430\u043f\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u0438\u043a\u0435.<\/p>\n<p>\u0412\u00a0<code>Pool.sol<\/code>\u00a0\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Pool.sol#L83C1-L91C6\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/a>\u00a0\u043f\u0443\u043b\u0430. \u041c\u044b \u043e\u0431\u0435\u0449\u0430\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435.<\/p>\n<pre><code class=\"javascript\">struct State {     Slot0 slot0; \/\/ \u0423\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0431\u0430\u0439\u0442\u044b: \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c, \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044f, \u0444\u043b\u0430\u0433 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0442\u0438\u043a     uint256 feeGrowthGlobal0X128; \/\/ \u041d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 0     uint256 feeGrowthGlobal1X128; \/\/ \u041d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 1     uint128 liquidity; \/\/ \u041e\u0431\u0449\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u0443\u043b\u0430, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438     mapping(int24 tick =&gt; TickInfo) ticks; \/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u043e \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0442\u0438\u043a\u0430\u0445     mapping(int16 wordPos =&gt; uint256) tickBitmap; \/\/ \u0411\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0438 \u0441\u0432\u043e\u043f\u0430\u0445     mapping(bytes32 positionKey =&gt; Position.State) positions; \/\/ \u0425\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0432 \u043f\u0443\u043b\u0435 }<\/code><\/pre>\n<p>\u0423\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/StateLibrary.sol\" rel=\"noopener noreferrer nofollow\">StateLibrary.sol<\/a>. \u041f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e Slot0. \u041d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u00a0<code>PositionManager.sol<\/code>\u00a0\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Slot0.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Position.sol\" rel=\"noopener noreferrer nofollow\">Position.sol<\/a>. \u041e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/TickBitmap.sol\" rel=\"noopener noreferrer nofollow\">TickBitmap.sol<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/TickMath.sol\" rel=\"noopener noreferrer nofollow\">TickMath.sol<\/a>. \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0438\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/SwapMath.sol\" rel=\"noopener noreferrer nofollow\">SwapMath.sol<\/a>. \u041f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0432\u043e\u043f\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Hooks.sol\" rel=\"noopener noreferrer nofollow\">Hooks.sol<\/a>. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0445\u0443\u043a\u043e\u0432: \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0434\u0430\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u0434\u043e\u043c \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u0424\u043b\u043e\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0444\u043b\u043e\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u0445. \u0423\u0441\u043b\u043e\u0432\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0434\u0432\u0430 \u0442\u0438\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0430\u043a\u0442\u0438\u0432\u044b \u0432 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043f\u0443\u043b \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0441\u0432\u0430\u043f \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0fa\/a29\/c5f\/0faa29c5fa43a98c1445c6e377e1d48b.png\" width=\"1976\" height=\"732\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/0fa\/a29\/c5f\/0faa29c5fa43a98c1445c6e377e1d48b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0fa\/a29\/c5f\/0faa29c5fa43a98c1445c6e377e1d48b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0438 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u043c\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/PositionManager.sol#L195\" rel=\"noopener noreferrer nofollow\">PositionManager.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol#L32\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u041e\u0431\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/BaseActionsRouter.sol\" rel=\"noopener noreferrer nofollow\">BaseActionsRouter.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u043b\u0430\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<h3>\u041a\u0440\u043e\u0441\u0441-\u0432\u0435\u0440\u0441\u0438\u043e\u043d\u043d\u0430\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u0430\u044f, \u0442\u0440\u0435\u0442\u044c\u044f \u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u0418 \u044f \u0434\u0443\u043c\u0430\u044e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b! \u0421\u0432\u0430\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0446\u0435\u043b\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043e\u0431\u043c\u0435\u043d\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0443\u043b\u044b \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432. \u0422\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<strong>UniversalRouter<\/strong>\u00a0\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/51e\/48e\/b6d\/51e48eb6da46e9ef12227753059627b5.png\" width=\"1996\" height=\"646\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/51e\/48e\/b6d\/51e48eb6da46e9ef12227753059627b5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/51e\/48e\/b6d\/51e48eb6da46e9ef12227753059627b5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\/blob\/main\/contracts\/UniversalRouter.sol\" rel=\"noopener noreferrer nofollow\">UniversalRouter.sol<\/a>\u00a0\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 (\u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f00\/ef7\/3e8\/f00ef73e8bc59df2ea1a5f15d419fe02.png\" width=\"1846\" height=\"1094\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/f00\/ef7\/3e8\/f00ef73e8bc59df2ea1a5f15d419fe02.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f00\/ef7\/3e8\/f00ef73e8bc59df2ea1a5f15d419fe02.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437\u00a0<code>UniversalRouter.sol<\/code>\u00a0\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\/blob\/main\/contracts\/UniversalRouter.sol#L35\" rel=\"noopener noreferrer nofollow\">execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline)<\/a>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u043a\u043e\u043c\u0430\u043d\u0434 (\u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0432\u0430\u043f \u0432 UniV2), \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0430\u0434\u0440\u0435\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u0441\u0443\u043c\u043c\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b) \u0438 \u0434\u0435\u0434\u043b\u0430\u0439\u043d.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434: \u043a\u0430\u043a \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 execute().<\/p>\n<pre><code class=\"javascript\">import {Commands} from 'universal-router\/contracts\/libraries\/Commands.sol';  ...  function executeV2SwapExactOut(address recipient, uint256 amountIn, uint256 amountOutMin) external {     uint256 deadline = block.timestamp + 60;     bytes memory commands = abi.encodePacked(bytes1(uint8(Commands.V2_SWAP_EXACT_OUT)));      bytes[] memory inputs = new bytes[](1);     inputs[0] = abi.encode(       recipient,       amountIn,       amountOutMin,       abi.encodePacked(WETH, DAI),       true \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043a\u0442\u043e \u043e\u043f\u043b\u0430\u0442\u0438\u0442 \u0432\u044b\u0437\u043e\u0432     );      IUniversalRouter(router).execute{value: 0}(commands, inputs, deadline); }<\/code><\/pre>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434 \u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">bytes memory commands = abi.encodePacked(     bytes1(uint8(Commands.V2_SWAP_EXACT_OUT)),     bytes1(uint8(Commands.V4_POSITION_MANAGER_CALL)) );<\/code><\/pre>\n<p><em>\u0412\u0430\u0436\u043d\u043e!<\/em>\u00a0\u0421\u0442\u043e\u0438\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432. \u0412 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\/blob\/main\/contracts\/modules\/uniswap\/v4\/V4SwapRouter.sol#L11\" rel=\"noopener noreferrer nofollow\">V4SwapRouter.sol<\/a>\u00a0\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 periphery.<\/p>\n<h3>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043f\u0440\u0438\u0435\u043c\u044b \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435.<\/p>\n<h4>\u0420\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0443\u043b\u0430<\/h4>\n<p>\u041f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u043f\u0443\u043b\u044b \u0442\u043e\u043a\u0435\u043d\u043e\u0432 &#171;\u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u044b&#187;, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0443\u043b\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e, \u0438 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u043c\u0435\u0448\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0430\u0442\u0430\u043a\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 (reentrancy).<\/p>\n<p>\u041e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u043f\u0443\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L104\" rel=\"noopener noreferrer nofollow\">unlock()<\/a>. \u041f\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443, \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<code>unlock()<\/code>\u00a0\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u00a0<code>PoolManager.sol<\/code>.<\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438\u00a0<a href=\"https:\/\/eips.ethereum.org\/EIPS\/eip-1153\" rel=\"noopener noreferrer nofollow\">EIP-1153: Transient storage opcodes<\/a>.<\/p>\n<blockquote>\n<p>\u041c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u0440\u043e Transient Storage. \u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0448\u044c \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u043e \u0438\u0449\u0438 \u0435\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0433\u043e wiki \u0432 \u043f\u0430\u043f\u043a\u0435 EIPs.<\/p>\n<\/blockquote>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0443\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0430 \u0441\u0445\u0435\u043c\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d0\/4d6\/659\/1d04d6659fc24e4e08ba89f2c5528b3c.png\" width=\"1802\" height=\"922\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1d0\/4d6\/659\/1d04d6659fc24e4e08ba89f2c5528b3c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d0\/4d6\/659\/1d04d6659fc24e4e08ba89f2c5528b3c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041b\u044e\u0431\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u043f\u0430\u0432\u0448\u0435\u0435 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 (<code>V4Router.sol<\/code>,\u00a0<code>PositionManager.sol<\/code>) \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/BaseActionsRouter.sol#L26\" rel=\"noopener noreferrer nofollow\">unlock()<\/a>\u00a0\u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L104\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438\u00a0<code>PoolManager.sol<\/code>\u00a0\u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L110\" rel=\"noopener noreferrer nofollow\">unlockCallback()<\/a>. \u0417\u0430\u0442\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/BaseActionsRouter.sol#L51\" rel=\"noopener noreferrer nofollow\">\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f<\/a>\u00a0\u0438 \u0441\u043d\u043e\u0432\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u043d\u0430\u00a0<code>PoolManager.sol<\/code>\u00a0\u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0443\u043b \u0431\u0443\u0434\u0435\u0442 \u0441\u043d\u043e\u0432\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L113\" rel=\"noopener noreferrer nofollow\">\u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d<\/a>\u00a0\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0442\u043e \u043f\u0443\u043b \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043b, \u0442\u043e\u0442 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">function unlock(bytes calldata data) external override returns (bytes memory result) {     if (Lock.isUnlocked()) AlreadyUnlocked.selector.revertWith();      \/\/ \u0420\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u043b, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0431\u044b\u043b \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d     Lock.unlock();      \/\/ \u0414\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438     result = IUnlockCallback(msg.sender).unlockCallback(data);      ...      \/\/ \u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u043f\u0443\u043b     Lock.lock(); }<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/SafeCallback.sol\" rel=\"noopener noreferrer nofollow\">unlockCallback()<\/a>\u00a0\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/SafeCallback.sol\" rel=\"noopener noreferrer nofollow\">SafeCallback.sol<\/a>, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/BaseActionsRouter.sol#L12C19-L12C36\" rel=\"noopener noreferrer nofollow\">BaseActionsRouter.sol<\/a>.<\/p>\n<p>\u0421\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/BaseActionsRouter.sol#L32\" rel=\"noopener noreferrer nofollow\">BaseActionsRouter.sol<\/a>.<\/p>\n<pre><code class=\"javascript\">function _unlockCallback(bytes calldata data) internal override returns (bytes memory) {     \/\/ \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0437\u043e\u0432\u0430     (bytes calldata actions, bytes[] calldata params) = data.decodeActionsRouterParams();      \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f     _executeActionsWithoutUnlock(actions, params);      return \"\"; }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0430\u043c\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (Transient Storage).<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Lock.sol\" rel=\"noopener noreferrer nofollow\">Lock.sol<\/a>\u00a0\u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u043e\u0432\u044b\u0445 \u043e\u043f\u043a\u043e\u0434\u043e\u0432\u00a0<code>tstore<\/code>,\u00a0<code>tload<\/code>.<\/p>\n<pre><code class=\"javascript\">library Lock {     \/\/ \u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0435\u0448 \u0441\u043b\u043e\u0442\u0430     bytes32 internal constant IS_UNLOCKED_SLOT = ...;      function unlock() internal {         assembly (\"memory-safe\") {             \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e             tstore(IS_UNLOCKED_SLOT, true)         }     }      function lock() internal {         assembly (\"memory-safe\") {             \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043e             tstore(IS_UNLOCKED_SLOT, false)         }     }      ... }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u043f\u0440\u0430\u0437\u0434\u043d\u0435\u043d\u0430, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 Solidity \u0432\u0432\u0435\u0434\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c.<\/p>\n<h4>\u041a\u0430\u043a \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0445\u0443\u043a\u0438<\/h4>\n<p>\u0422\u0435\u043e\u0440\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0430. \u0413\u043e\u0442\u043e\u0432\u0438\u0442\u0435 \u0432\u0430\u0448 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0445\u0443\u043a\u0430 (\u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/utils\/BaseHook.sol\" rel=\"noopener noreferrer nofollow\">BaseHook.sol<\/a>) \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u043f\u0443\u043b \u0441 \u044d\u0442\u0438\u043c \u0445\u0443\u043a\u043e\u043c. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u043e\u0442 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0445\u0443\u043a\u0430.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0438 \u0445\u0443\u043a\u043e\u0432 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<ol>\n<li>\n<p>\u0417\u043d\u0430\u0442\u044c \u0445\u0443\u043a \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0443\u043b\u0430 (\u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c)<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0445\u0443\u043a\u0430<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u0441\u0435 \u0445\u0443\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L187\" rel=\"noopener noreferrer nofollow\">swap()<\/a>\u00a0\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25d\/bd0\/92c\/25dbd092c87c0fa38e686d817a5bc7cd.png\" width=\"940\" height=\"1168\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/25d\/bd0\/92c\/25dbd092c87c0fa38e686d817a5bc7cd.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/25d\/bd0\/92c\/25dbd092c87c0fa38e686d817a5bc7cd.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0437\u0430\u043f\u0443\u0441\u043a \u0445\u0443\u043a\u0430 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u044f\u043c\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<code>beforeSwap()<\/code>\/<code>afterSwap()<\/code>.<\/p>\n<pre><code class=\"javascript\">function swap(PoolKey memory key, SwapParams memory params, bytes calldata hookData)     external     onlyWhenUnlocked     noDelegateCall     returns (BalanceDelta swapDelta) {     ...      BeforeSwapDelta beforeSwapDelta;     {         int256 amountToSwap;         uint24 lpFeeOverride;         (amountToSwap, beforeSwapDelta, lpFeeOverride) =          \/\/ \u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u0430 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u0432\u043e\u043f\u0430         key.hooks.beforeSwap(key, params, hookData);          swapDelta = _swap(...);     }      BalanceDelta hookDelta;     \/\/ \u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0445\u0443\u043a\u0430     (swapDelta, hookDelta) = key.hooks.afterSwap(key, params, swapDelta, hookData, beforeSwapDelta);      ... }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0445\u0443\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u043b\u044e\u0431\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0425\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0434\u0440\u0435\u0441\u0435 \u0445\u0443\u043a\u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/types\/PoolKey.sol#L21\" rel=\"noopener noreferrer nofollow\">PoolKey<\/a>.<\/p>\n<p><em>\u0412\u0430\u0436\u043d\u043e!<\/em>\u00a0\u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<code>swap()<\/code>\u00a0\u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c\u00a0<code>bytes calldata hookData<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0432 \u0445\u0443\u043a.<\/p>\n<p><strong>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0445\u0443\u043a\u043e\u0432<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441 \u0444\u043b\u043e\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0445\u0443\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/65c\/095\/529\/65c09552900fba538510bdda0376145b.png\" width=\"1908\" height=\"1138\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/65c\/095\/529\/65c09552900fba538510bdda0376145b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/65c\/095\/529\/65c09552900fba538510bdda0376145b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e, \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0441\u0432\u043e\u043f\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u00a0<code>PoolManager.sol<\/code>\u00a0\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u00a0<code>PoolKey<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0438\u043c\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043a\u0435\u043d\u0430\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0430\u0434\u0440\u0435\u0441\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0445\u0443\u043a\u043e\u0432.<\/p>\n<p><em>\u0412\u0430\u0436\u043d\u043e!<\/em>\u00a0\u0410\u0434\u0440\u0435\u0441 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0445\u0443\u043a\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u043f\u0443\u043b\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0445\u0443\u043a\u043e\u0432 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u043b\u0430.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u044b \u0445\u0443\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b\u00a0<code>IHooks<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u0438 \u0435\u0441\u043b\u0438 \u0445\u0443\u043a \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<code>CustomHook.sol<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\u00a0<code>BaseHook.sol<\/code>.<\/p>\n<p><strong>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0445\u0443\u043a\u043e\u0432<\/strong><\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u0445\u0443\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Hooks.sol\" rel=\"noopener noreferrer nofollow\">Hooks.sol<\/a>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u0443\u043a \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0437\u043e\u0432 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u043a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442. \u041d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0442\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0433\u0430\u0437, \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043d\u0438\u043a\u0443\u0434\u0430.<\/p>\n<pre><code class=\"javascript\">function beforeSwap(IHooks self, PoolKey memory key, SwapParams memory params, bytes calldata hookData)     internal     returns (int256 amountToSwap, BeforeSwapDelta hookReturn, uint24 lpFeeOverride) {     ...      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0445\u0443\u043a \u0430\u043a\u0442\u0438\u0432\u0435\u043d     if (self.hasPermission(BEFORE_SWAP_FLAG)) {         \/\/ \u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 beforeSwap \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435 \u0445\u0443\u043a\u0430         bytes memory result = callHook(self, abi.encodeCall(IHooks.beforeSwap, (msg.sender, key, params, hookData)));          ...     } }<\/code><\/pre>\n<p><strong>\u0425\u0443\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong><\/p>\n<p>\u0415\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0445\u0443\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0430\u0434\u0440\u0435\u0441 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0445\u0443\u043a\u0430 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439, \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/utils\/HookMiner.sol\" rel=\"noopener noreferrer nofollow\">HookMiner.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0430\u0434\u0440\u0435\u0441 \u0445\u0443\u043a\u0430 \u0437\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0441\u0432\u0430\u043f \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435) \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0443\u043a \u0430\u043a\u0442\u0438\u0432\u0435\u043d.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u043b\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0445\u0443\u043a\u0430.<\/p>\n<pre><code class=\"javascript\">function initialize(PoolKey memory key, uint160 sqrtPriceX96) external noDelegateCall returns (int24 tick) {     ...      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0430\u0434\u0440\u0435\u0441\u0430 \u0445\u0443\u043a\u0430     if (!key.hooks.isValidHookAddress(key.fee)) Hooks.HookAddressNotValid.selector.revertWith(address(key.hooks));      ...      \/\/ \u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u0430 \u0434\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u043b\u0430     key.hooks.beforeInitialize(key, sqrtPriceX96);      PoolId id = key.toId();     tick = _pools[id].initialize(sqrtPriceX96, lpFee);      ...      \/\/ \u0412\u044b\u0437\u043e\u0432 \u0445\u0443\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u043b\u0430     key.hooks.afterInitialize(key, sqrtPriceX96, tick); }<\/code><\/pre>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>Uniswap V4 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u043d\u0434\u044b \u0432 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 DeFi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u0443\u043b\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u0438\u043d \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0433\u0430\u0437 \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043d\u043e \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 &#171;\u0441\u043b\u043e\u0436\u043d\u044b\u0435&#187; \u0441\u0432\u043e\u043f\u044b, \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u043f\u0443\u043b\u0430\u043c\u0438.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 V4, \u0441 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0447\u0435\u0440\u0435\u0437\u00a0<code>PoolManager.sol<\/code>, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0443 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f EIP-1153), \u0437\u0430\u0449\u0438\u0449\u0430\u044f \u043e\u0442 reentrancy \u0430\u0442\u0430\u043a.<\/p>\n<p>\u041d\u043e\u0432\u0430\u044f \u0444\u0438\u0447\u0430 &#171;\u0445\u0443\u043a\u0438&#187; \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<p>Uniswap V4 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u043d\u043e \u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0438\u043d\u043d\u043e\u0432\u0430\u0446\u0438\u0439 \u0432 DeFi, \u043e\u0436\u0438\u0434\u0430\u044e\u0449\u0430\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u043a\u043b\u0430\u0434\u0430!<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u044b V4, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0440 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u043e\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a\u00a0<code>Pool.sol<\/code>,\u00a0<code>SwapMath.sol<\/code>\u00a0\u0438\u00a0<code>Hooks.sol<\/code>, \u0434\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 \u0445\u0443\u043a\u0430\u043c\u0438.<\/p>\n<p><em>\u041c\u044b \u0441 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0438\u0448\u0435\u043c \u0432 \u043d\u0430\u0448\u0435\u043c<\/em><a href=\"https:\/\/t.me\/+8p2iaLV6_tBmNTZi\" rel=\"noopener noreferrer nofollow\"><em> Telegram<\/em><\/a><em>-\u043a\u0430\u043d\u0430\u043b\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u044b\u0441\u043b\u0438 \u0432\u0441\u043b\u0443\u0445, \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438. \u041d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0441\u0451 \u043e\u0444\u043e\u0440\u043c\u043b\u044f\u0435\u043c \u0432 \u0441\u0442\u0430\u0442\u044c\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0449\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u0432 \u0442\u0435\u043b\u0435\u0433\u0443. \u0422\u0430\u043a \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438 \u0447\u0442\u043e \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0435\u043c, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c.<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/935928\/\"> https:\/\/habr.com\/ru\/articles\/935928\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>Uniswap V4<\/strong>\u00a0&#8212; \u044d\u0442\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 DeFi \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u0432, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443\u00a0<strong>&#171;Singleton Design&#187;<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0443\u043b\u0430.<\/p>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u043f\u0440\u0435\u0442\u0435\u0440\u043f\u0435\u043b\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f: \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043b\u0430 \u0432\u0441\u0435 \u043f\u0443\u043b\u044b \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c &#171;\u0445\u0443\u043a\u0438&#187; \u0434\u043b\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e 1 \u043f\u0443\u043b = 1 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442. \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0444\u0430\u0431\u0440\u0438\u043a\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v3-core\/blob\/main\/contracts\/UniswapV3Factory.sol\" rel=\"noopener noreferrer nofollow\">UniswapV3Factory.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v3-core\/blob\/main\/contracts\/UniswapV3PoolDeployer.sol\" rel=\"noopener noreferrer nofollow\">UniswapV3PoolDeployer.sol<\/a>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u0432\u0430\u043f\u0430, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v3-periphery\/blob\/main\/contracts\/SwapRouter.sol\" rel=\"noopener noreferrer nofollow\">SwapRouter.sol<\/a>\u00a0\u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a \u043f\u0443\u043b\u0443.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol#L117\" rel=\"noopener noreferrer nofollow\">initialize()<\/a>\u00a0\u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>. \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0443\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u0432\u0430\u043f\u0430, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>, \u043d\u043e \u0432\u0441\u044f \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 \u043f\u0443\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Pool.sol\" rel=\"noopener noreferrer nofollow\">Pool.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u00a0<code>PoolManager.sol<\/code><\/p>\n<p>\u0421\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u044e \u0433\u0430\u0437\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0443\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043f\u0443\u043b\u0430. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u043c\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u0443\u043b\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u043f\u0443\u043b\u044b, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0433\u0430\u0437.<\/p>\n<h3>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430<\/h3>\n<p>\u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u0438 \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u043d\u0430 \u0434\u0432\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0432\u0435\u0440\u0441\u0438\u044f\u043c:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/tree\/main\" rel=\"noopener noreferrer nofollow\">v4-core<\/a>.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\" rel=\"noopener noreferrer nofollow\">v4-periphery<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>Core \u0432\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0443\u043b\u044b, \u0430 periphery \u2014 \u0437\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u043a \u043f\u0443\u043b\u0430\u043c. \u0422\u0430\u043a\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0443\u043b\u043e\u0432, \u0440\u043e\u0443\u0442\u0435\u0440\u0430, LP \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0432 \u0434\u0432\u0443\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u042f \u0432\u044b\u043f\u0438\u0441\u0430\u043b \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0440\u0430\u0437\u0431\u0438\u0442\u044b\u0445 \u043d\u0430 4 \u0433\u0440\u0443\u043f\u043f\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0421\u0438\u043d\u0438\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043f\u0435\u0440\u0432\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u043e\u0437\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0435\u043b\u0435\u043d\u044b\u0439 \u0446\u0432\u0435\u0442<\/strong>\u00a0\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0445\u0443\u043a\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430, \u0442\u0435\u043c \u043e\u043d \u0432\u0430\u0436\u043d\u0435\u0435 \u0432 \u043a\u043e\u0434\u0435 Uniswap. \u041d\u0430 \u0441\u0445\u0435\u043c\u0435 \u0442\u0430\u043a\u0438\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>. \u0421\u0430\u043c\u044b\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b core, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u043b\u0430\u043c\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>. \u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b periphery, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b \u0433\u0440\u0443\u043f\u043f\u044b core.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/PositionManager.sol\" rel=\"noopener noreferrer nofollow\">PositionManager.sol<\/a>. \u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f\u044b periphery, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e LP \u0442\u043e\u043a\u0435\u043d\u0430 (\u043d\u0444\u0442\u0438\u0448\u043a\u0438), \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0435\u00a0<code>PoolManager.sol<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432<\/h3>\n<p>\u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/PoolManager.sol\" rel=\"noopener noreferrer nofollow\">PoolManager.sol<\/a>\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\n<p><strong>modifyLiquidity()<\/strong>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c\u044e: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041e\u0431\u044b\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u043c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<code>PositionManager.sol<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>swap()<\/strong>. \u041e\u0431\u043c\u0435\u043d \u0430\u043a\u0442\u0438\u0432\u043e\u0432. \u041e\u0431\u044b\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043d\u043e \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<code>V4Router.sol<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>donate()<\/strong>. \u041f\u0440\u044f\u043c\u044b\u0435 \u0434\u043e\u043d\u0430\u0442\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u0443\u043b\u0435 \u0432 \u043e\u0431\u0445\u043e\u0434 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>mint()\/burn()<\/strong>. \u041c\u0438\u043d\u0442 \u0438 \u0441\u0436\u0438\u0433\u0430\u043d\u0438\u0435 ERC-6909, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435. \u041f\u043e\u0441\u043b\u0435 \u0441\u0432\u0430\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d, \u0430 \u0441\u043c\u0438\u043d\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u0432 ERC-6909. \u041c\u0438\u043d\u0442 ERC-6909 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u043f\u043e \u0433\u0430\u0437\u0443, \u0447\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u0435\u0440 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>take()\/settle()<\/strong>. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0433\u0430\u0448\u0435\u043d\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u043e\u0432. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f flash loans \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0437\u044f\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u044b \u0438\u0437 \u043f\u0443\u043b\u0430 \u0432 \u0434\u043e\u043b\u0433 \u0438 \u043f\u043e\u0433\u0430\u0441\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>sync()<\/strong>. \u0414\u043b\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0443\u043b\u0430 \u0441 \u0435\u0433\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u043c\u0438 \u0440\u0435\u0437\u0435\u0440\u0432\u0430\u043c\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0438 \u0446\u0435\u043d\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u0430\u0434\u0436\u0430<\/strong><\/p>\n<p>\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0443\u043b\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 mapping \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0443\u043b\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">mapping(PoolId id =&gt; Pool.State) internal _pools;<\/code><\/pre>\n<p><strong>PoolId<\/strong>\u00a0&#8212; \u044d\u0442\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0443\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435\u00a0<code>bytes32<\/code>. \u041f\u043e \u0441\u0443\u0442\u0438, \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u0435\u0448\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0443\u043b\u0430. \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f id \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/types\/PoolId.sol#L9\" rel=\"noopener noreferrer nofollow\">PoolIdLibrary<\/a>\u00a0\u0441 \u043e\u0434\u043d\u043e\u0439 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439\u00a0<code>toId()<\/code>.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u0437\u044f\u0442\u043e \u0438\u0437 PoolKey.sol struct PoolKey {     \/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043a\u0435\u043d\u0435 0     Currency currency0;     \/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043a\u0435\u043d\u0435 1     Currency currency1;     \/\/ \u041a\u043e\u043c\u0438\u0441\u0441\u0438\u044f     uint24 fee;     \/\/ \u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u0438\u043a\u0430     int24 tickSpacing;     \/\/ \u0410\u0434\u0440\u0435\u0441 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u0445\u0443\u043a\u0430     IHooks hooks; }  library PoolIdLibrary {     function toId(PoolKey memory poolKey) internal pure returns (PoolId poolId) {         assembly (\"memory-safe\") {             \/\/ 0xa0 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 PoolKey (5 slots of 32 bytes)             poolId := keccak256(poolKey, 0xa0)         }     } }<\/code><\/pre>\n<p><code>Pool.State<\/code>\u00a0&#8212; \u044d\u0442\u043e \u0432\u0441\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0443\u043b\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u0441\u0442\u043e\u0440\u0430\u0434\u0436\u0435\u00a0<code>PoolManager.sol<\/code>\u00a0\u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0449\u0438\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u0442\u0438\u043a\u0430.<\/p>\n<pre><code class=\"javascript\">int24 private constant MAX_TICK_SPACING = TickMath.MAX_TICK_SPACING; int24 private constant MIN_TICK_SPACING = TickMath.MIN_TICK_SPACING;<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u0430\u0434\u0436\u0430 \u043f\u043e\u043f\u0440\u044f\u0442\u0430\u043d\u044b \u043f\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f\u00a0<code>PoolManager.sol<\/code>.<\/p>\n<p><strong>\u041e\u0442 \u0447\u0435\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f PoolManager<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/NoDelegateCall.sol\" rel=\"noopener noreferrer nofollow\">NoDelegateCall.sol<\/a>. \u0417\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430. \u0417\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438. \u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432, \u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438,\u00a0<code>delegateCall<\/code>\u00a0\u043a\u00a0<code>PoolManager<\/code>\u00a0\u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d \u0432 \u0446\u0435\u043b\u044f\u0445 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/ERC6909Claims.sol\" rel=\"noopener noreferrer nofollow\">ERC6909Claims.sol<\/a>. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043d\u0442\u0438\u0442\u044c \u0438 \u0441\u0436\u0438\u0433\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u0432 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442 \u0430\u043a\u0442\u0438\u0432\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/Extsload.sol\" rel=\"noopener noreferrer nofollow\">Extsload.sol<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/Exttload.sol\" rel=\"noopener noreferrer nofollow\">Exttload.sol<\/a>. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/TransientStateLibrary.sol\" rel=\"noopener noreferrer nofollow\">TransientStateLibrary.sol<\/a>\u00a0\u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0421\u0430\u043c\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u043e\u0432 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0433\u0440\u0443\u043f\u043f\u044b core. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435, \u0435\u0441\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u0442\u043e \u0442\u0430\u043c \u0431\u044b\u043b\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0433\u0438\u043a\u0438, \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043d\u043e\u0439 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441\u0438\u043b\u044c\u043d\u043e\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/tree\/main\/src\/libraries\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u044c\u0448\u0435<\/a>. \u041d\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Pool.sol\" rel=\"noopener noreferrer nofollow\">Pool.sol<\/a>. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b \u043a \u043f\u0443\u043b\u0443: \u043e\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u0434\u043e \u0441\u0432\u0430\u043f\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u0438\u043a\u0435.<\/p>\n<p>\u0412\u00a0<code>Pool.sol<\/code>\u00a0\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Pool.sol#L83C1-L91C6\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f<\/a>\u00a0\u043f\u0443\u043b\u0430. \u041c\u044b \u043e\u0431\u0435\u0449\u0430\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435.<\/p>\n<pre><code class=\"javascript\">struct State {     Slot0 slot0; \/\/ \u0423\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0431\u0430\u0439\u0442\u044b: \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c, \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u044f, \u0444\u043b\u0430\u0433 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0442\u0438\u043a     uint256 feeGrowthGlobal0X128; \/\/ \u041d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 0     uint256 feeGrowthGlobal1X128; \/\/ \u041d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443 1     uint128 liquidity; \/\/ \u041e\u0431\u0449\u0430\u044f \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u0443\u043b\u0430, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438     mapping(int24 tick =&gt; TickInfo) ticks; \/\/ \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u043e \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0442\u0438\u043a\u0430\u0445     mapping(int16 wordPos =&gt; uint256) tickBitmap; \/\/ \u0411\u0438\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0438 \u0441\u0432\u043e\u043f\u0430\u0445     mapping(bytes32 positionKey =&gt; Position.State) positions; \/\/ \u0425\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0432 \u043f\u0443\u043b\u0435 }<\/code><\/pre>\n<p>\u0423\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/StateLibrary.sol\" rel=\"noopener noreferrer nofollow\">StateLibrary.sol<\/a>. \u041f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e Slot0. \u041d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u00a0<code>PositionManager.sol<\/code>\u00a0\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Slot0.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Position.sol\" rel=\"noopener noreferrer nofollow\">Position.sol<\/a>. \u041e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/TickBitmap.sol\" rel=\"noopener noreferrer nofollow\">TickBitmap.sol<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/TickMath.sol\" rel=\"noopener noreferrer nofollow\">TickMath.sol<\/a>. \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0438\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/SwapMath.sol\" rel=\"noopener noreferrer nofollow\">SwapMath.sol<\/a>. \u041f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0432\u043e\u043f\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/Uniswap\/v4-core\/blob\/main\/src\/libraries\/Hooks.sol\" rel=\"noopener noreferrer nofollow\">Hooks.sol<\/a>. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u0445\u0443\u043a\u043e\u0432: \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0434\u0430\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u0434\u043e\u043c \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u0424\u043b\u043e\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0444\u043b\u043e\u0443 \u0432\u044b\u0437\u043e\u0432\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u043e \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u0445. \u0423\u0441\u043b\u043e\u0432\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0434\u0432\u0430 \u0442\u0438\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0430\u043a\u0442\u0438\u0432\u044b \u0432 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043f\u0443\u043b \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0441\u0432\u0430\u043f \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u0430 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0438 \u043b\u0438\u043a\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u043c\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/PositionManager.sol#L195\" rel=\"noopener noreferrer nofollow\">PositionManager.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/V4Router.sol#L32\" rel=\"noopener noreferrer nofollow\">V4Router.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043f\u0443\u043b\u043e\u0432.<\/p>\n<p>\u041e\u0431\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u00a0<a href=\"https:\/\/github.com\/Uniswap\/v4-periphery\/blob\/main\/src\/base\/BaseActionsRouter.sol\" rel=\"noopener noreferrer nofollow\">BaseActionsRouter.sol<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u043b\u0430\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<h3>\u041a\u0440\u043e\u0441\u0441-\u0432\u0435\u0440\u0441\u0438\u043e\u043d\u043d\u0430\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u0430\u044f, \u0442\u0440\u0435\u0442\u044c\u044f \u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430. \u0418 \u044f \u0434\u0443\u043c\u0430\u044e \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b! \u0421\u0432\u0430\u043f\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0446\u0435\u043b\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043e\u0431\u043c\u0435\u043d\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0443\u043b\u044b \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432. \u0422\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u043b\u043e\u0439\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00a0<strong>UniversalRouter<\/strong>\u00a0\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\/blob\/main\/contracts\/UniversalRouter.sol\" rel=\"noopener noreferrer nofollow\">UniversalRouter.sol<\/a>\u00a0\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 (\u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437\u00a0<code>UniversalRouter.sol<\/code>\u00a0\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<a href=\"https:\/\/github.com\/Uniswap\/universal-router\/blob\/main\/contracts\/UniversalRouter.sol#L35\" rel=\"noopener noreferrer nofollow\">execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline)<\/a>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u043a\u043e\u043c\u0430\u043d\u0434 (\u0438\u043b\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0432\u0430\u043f \u0432 UniV2), \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0430\u0434\u0440\u0435\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u0441\u0443\u043c\u043c\u0430 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b) \u0438 \u0434\u0435\u0434\u043b\u0430\u0439\u043d.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434: \u043a\u0430\u043a \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432 execute().<\/p>\n<pre><code class=\"javascript\">import {Commands} from 'universal-router\/contracts\/libraries\/Commands.sol';  ...  function executeV2SwapExactOut(address recipient, uint256 amountIn, uint256 amountOutMin) external {     uint256 deadline = block.timestamp + 60;     bytes memory commands =<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-470677","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/470677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=470677"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/470677\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=470677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=470677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=470677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}