From 00ae8b0611ad17cf0aec73f5d3098316f561f94d Mon Sep 17 00:00:00 2001 From: stefano Date: Mon, 24 Nov 2025 11:54:23 +0000 Subject: [PATCH 1/4] update crypto wrapper --- poetry.lock | 104 +++++++++++++++++++++++++++++++++---------------- pyproject.toml | 2 +- 2 files changed, 72 insertions(+), 34 deletions(-) diff --git a/poetry.lock b/poetry.lock index 361f814..390bc4e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -700,6 +700,9 @@ groups = ["main"] files = [ {file = "ckzg-2.1.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:49ee4c830de89764bfd9e8188446f3020f14d32bd4486fcbc5a4a5afad775ac0"}, {file = "ckzg-2.1.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:3b4f0c6c2f1a629d4d64e900c65633595c63d208001d588c61b6c8bc1b189dec"}, + {file = "ckzg-2.1.5-cp310-cp310-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:10c8bc524267a40fe7c4fabd4c23f131ea18fcabd6016cdc4ddcb95cc757faf5"}, + {file = "ckzg-2.1.5-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8ea589e60db460ee9ebb678f20e74cc9289e912ccad66693b3263459933aaffc"}, + {file = "ckzg-2.1.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:97769b53f7d8c46e794d5c8aa609a4c00ec1fb050e69b6833b45dbb23a7b6501"}, {file = "ckzg-2.1.5-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a45aaea4a42babea48bb27e387fb209f2aaaaaa16abea25a4a92a056b616f9af"}, {file = "ckzg-2.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:060562273057911c39a1491e9b76055c095c10cfff1704ed70011e38b53f83d8"}, {file = "ckzg-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f12a90277b17e1cb5c326c5c261dad2ebb14a7136e754593e3a0a92c94799fc1"}, @@ -709,6 +712,9 @@ files = [ {file = "ckzg-2.1.5-cp310-cp310-win_amd64.whl", hash = "sha256:2b7ef12896e2afff613f058e3bc8e3478ff626ae8a6f2d3200950304a536935f"}, {file = "ckzg-2.1.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cead4ba760a49eaa4d7a50a0483aad9727d6103fc00c408aef15f2cd8f8dec7b"}, {file = "ckzg-2.1.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3156983ba598fa05f0136325125e75197e4cf24ded255aaa6ace068cede92932"}, + {file = "ckzg-2.1.5-cp311-cp311-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:cac601a9690f133dd9d8e85f7a96578496427d42cdea771e0e07785b1cbbe9dc"}, + {file = "ckzg-2.1.5-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:05860f1477880376106a6934becdcb3a2c6330fc2386fed0d7e8f3b0ce5df81c"}, + {file = "ckzg-2.1.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:92b18b0ec177b9e2b4238936a8bffcfdaee7626a58f8d0c7c2ac554b8a05c9b6"}, {file = "ckzg-2.1.5-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d05e2c9466b2a4214dc19da35ea4cae636e033f3434768b982d37317a0f9c520"}, {file = "ckzg-2.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c754bbc253cfce8814d633f135be4891e6f83a50125f418fee01323ba306f59a"}, {file = "ckzg-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc2b766d4aed52c8c717322f2af935da0b916bf59fbba771adb822499b45e491"}, @@ -718,6 +724,9 @@ files = [ {file = "ckzg-2.1.5-cp311-cp311-win_amd64.whl", hash = "sha256:ce2047071353ee099d44aa6575974648663204eb9b42354bfa5ac6f9b8fb63e9"}, {file = "ckzg-2.1.5-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:edead535bd9afef27b8650bba09659debd4f52638aee5ec1ab7d2c9d7e86953c"}, {file = "ckzg-2.1.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:dc78622855de3d47767cdeecfdf58fd58911f43a0fa783524e414b7e75149020"}, + {file = "ckzg-2.1.5-cp312-cp312-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:e5639064b0dd147b73f2ce2c2506844b0c625b232396ac852dc52eced04bd529"}, + {file = "ckzg-2.1.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eb0864813902b96cde171e65334ce8d13c5ff5b6855f2e71a2272ae268fa07e8"}, + {file = "ckzg-2.1.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3e6f13f673a24c01e681eb66aed8f8e4ce191f009dd2149f3e1b9ad0dd59b4cd"}, {file = "ckzg-2.1.5-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:094add5f197a3d278924ec1480d258f3b8b0e9f8851ae409eec83a21a738bffe"}, {file = "ckzg-2.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2b4b05f798784400e8c4dedaf1a1d57bbbc54de790855855add876fff3c9f629"}, {file = "ckzg-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64aef50a1cf599041b9af018bc885a3fad6a20bbaf443fc45f0457cb47914610"}, @@ -727,6 +736,9 @@ files = [ {file = "ckzg-2.1.5-cp312-cp312-win_amd64.whl", hash = "sha256:827be2aeffc8a10bfb39b8dad45def82164dfcde735818c4053f5064474ae1b4"}, {file = "ckzg-2.1.5-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0d955f4e18bb9a9b3a6f55114052edd41650c29edd5f81e417c8f01abace8207"}, {file = "ckzg-2.1.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0c0961a685761196264aa49b1cf06e8a2b2add4d57987853d7dd7a7240dc5de7"}, + {file = "ckzg-2.1.5-cp313-cp313-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:026ef3bba0637032c21f6bdb8e92aefeae7c67003bf631a4ee80c515a36a9dbd"}, + {file = "ckzg-2.1.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bf031139a86e4ff00a717f9539331ef148ae9013b58848f2a7ac14596d812915"}, + {file = "ckzg-2.1.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f51339d58541ae450c78a509b32822eec643595d8b96949fb1963fba802dc78b"}, {file = "ckzg-2.1.5-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:badb1c7dc6b932bed2c3f7695e1ce3e4bcc9601706136957408ac2bde5dd0892"}, {file = "ckzg-2.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:58d92816b9babaee87bd9f23be10c07d5d07c709be184aa7ea08ddb2bcf2541c"}, {file = "ckzg-2.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8cf39f9abe8b3f1a71188fb601a8589672ee40eb0671fc36d8cdf4e78f00f43f"}, @@ -734,6 +746,24 @@ files = [ {file = "ckzg-2.1.5-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:c39a1c7b32ac345cc44046076fd069ad6b7e6f7bef230ef9be414c712c4453b8"}, {file = "ckzg-2.1.5-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e4564765b0cc65929eca057241b9c030afac1dbae015f129cb60ca6abd6ff620"}, {file = "ckzg-2.1.5-cp313-cp313-win_amd64.whl", hash = "sha256:55013b36514b8176197655b929bc53f020aa51a144331720dead2efc3793ed85"}, + {file = "ckzg-2.1.5-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:a0cab7deaed093898a92d3644d4ca8621b63cb49296833e2d8b3edac456656d5"}, + {file = "ckzg-2.1.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:caedc9eba3d28584be9b6051585f20745f6abfec0d0657cce3dd45edb7f28586"}, + {file = "ckzg-2.1.5-cp314-cp314-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:2f67e545d41ba960189b1011d078953311259674620c485e619c933494b88fd9"}, + {file = "ckzg-2.1.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d6f65ff296033c259d0829093d2c55bb45651e001e0269b8b88d072fdc86ecc6"}, + {file = "ckzg-2.1.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0d66d34ff33be94c8a1f0da86483cd5bfdc15842998f3654ed91b8fdbffa2a81"}, + {file = "ckzg-2.1.5-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:25cf954bae3e2b2db6fa5e811d9800f89199d3eb4fa906c96a1c03434d4893c9"}, + {file = "ckzg-2.1.5-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:34d7128735e0bcfcac876bff47d0f85e674f1e24f99014e326ec266abed7a82c"}, + {file = "ckzg-2.1.5-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:1dec3efae8679f7b8e26263b8bb0d3061ef4c9c6fe395e55b71f8f0df90ca8a0"}, + {file = "ckzg-2.1.5-cp314-cp314-win_amd64.whl", hash = "sha256:ce37c0ee0effe55d4ceed1735a2d85a3556a86238f3c89b7b7d1ca4ce4e92358"}, + {file = "ckzg-2.1.5-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:db804d27f4b08e3aea440cdc6558af4ceb8256b18ea2b83681d80cc654a4085b"}, + {file = "ckzg-2.1.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:d472e3beeb95a110275b4d27e51d1c2b26ab99ddb91ac1c5587d710080c39c5e"}, + {file = "ckzg-2.1.5-cp314-cp314t-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:4b44a018124a79138fab8fde25221083574c181c324519be51eab09b1e43ae27"}, + {file = "ckzg-2.1.5-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6a91d7b444300cf8ecae4f55983726630530cdde15cab92023026230a30d094e"}, + {file = "ckzg-2.1.5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8674c64efbf2a12edf6d776061847bbe182997737e7690a69af932ce61a9c2a"}, + {file = "ckzg-2.1.5-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:4290aa17c6402c98f16017fd6ee0bff8aeb5c97be5c3cee7c72aea1b7d176f3a"}, + {file = "ckzg-2.1.5-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:a0f82b8958ea97df12e29094f0a672cbe7532399724ea61b2399545991ed6017"}, + {file = "ckzg-2.1.5-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:22300bf0d717a083c388de5cfafec08443c9938b3abde2e89f9d5d1fffde1c51"}, + {file = "ckzg-2.1.5-cp314-cp314t-win_amd64.whl", hash = "sha256:aa8228206c3e3729fc117ca38e27588c079b0928a5ab628ee4d9fccaa2b8467d"}, {file = "ckzg-2.1.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44d585f756ab223e34ac80ae04be7969cb364ee250a91f9b2b1dae37e1f3020a"}, {file = "ckzg-2.1.5-cp36-cp36m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ecade6a3aee63dffc8e8d4adba838460b40f9b29d46ffd9f4d4502261fbcddff"}, {file = "ckzg-2.1.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8548de14e6e53271b246c7dc0bf843030b7f2144edb9ea73c68f46174a2bacd6"}, @@ -752,6 +782,9 @@ files = [ {file = "ckzg-2.1.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d2fed86e47399b06b564c8d3715a3ccec5d3a0a63326227a34e15515b8c514db"}, {file = "ckzg-2.1.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b1b52d359013b551b85fff538d2ef12763abd87efbc544d6f2808b9dd6bf0a4b"}, {file = "ckzg-2.1.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4cfe1cacea729c06196dcecec9c38f9b59bb7eadce51145e7ee27de10854dd59"}, + {file = "ckzg-2.1.5-cp38-cp38-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:86233ccbb0bcaf353990ce2a8e24f1aa37782272e64ca9b55dd45895829e4980"}, + {file = "ckzg-2.1.5-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c3449126ee416b438c22cd7b7620e8f030c9ba7e030a80ebbd5924f04bc95905"}, + {file = "ckzg-2.1.5-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a687c0609de11d4eba5a982036fd77d21d35841effb468a41004c68ad13a7438"}, {file = "ckzg-2.1.5-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3d22cef6551dee8d05151cc5184c37b190101b2027c0851301393561c559c669"}, {file = "ckzg-2.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2867e4a49f19248644206e82f5b8795e22096722dcd1e21acdad133e87632d5c"}, {file = "ckzg-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e7e7fd0c4b4d2af5661e3d54648c0447d33f17cbafa5dd1b0576899864b5b7da"}, @@ -761,6 +794,9 @@ files = [ {file = "ckzg-2.1.5-cp38-cp38-win_amd64.whl", hash = "sha256:15e0f7342a451569fa427c6ad3cb992975462c52c3ecdc2bd7c3ed35847bbb8b"}, {file = "ckzg-2.1.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3773ccdb3501ff3779988aa97e5b15629d58ac02281f186030f66d2fc2b4b7ec"}, {file = "ckzg-2.1.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:2c9b798c6eb4db9cf82272e5a5c62be86f0d435206c6c49cc078cbb67ebd51bd"}, + {file = "ckzg-2.1.5-cp39-cp39-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:13c0630363a65182e99d064f7eb173195dcbdddc4048fd5b45cd0a3cd0c740f9"}, + {file = "ckzg-2.1.5-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:165efe1fac474ae58a26b742f910c0c90c01fc356aac8b680db2e02e44005adf"}, + {file = "ckzg-2.1.5-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fa231a1965be1a9c6fa50528132b71f1bc486335564baf6ab6d98aebedfb03d7"}, {file = "ckzg-2.1.5-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a3ea32c21f71b786ea04b62cbe982b600da5e6f180b1d256fc9e397074041a6d"}, {file = "ckzg-2.1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:10455cc15e769a749c19fd3031dd0149eb92c2f9b4a054117cb20327242fd920"}, {file = "ckzg-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b21c38740aa5fcdc0cacfe9eda82cbf7bdffc743fa85344495bfecc18619d7d6"}, @@ -1379,43 +1415,43 @@ test = ["pytest (>=6)"] [[package]] name = "fast-stark-crypto" -version = "0.3.8" +version = "0.5.0" description = "" optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "fast_stark_crypto-0.3.8-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:25d1e61570398a6a1e496364ff3066cf10f03cab29f35247a691bee7a1ccb402"}, - {file = "fast_stark_crypto-0.3.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0a778f6550a12ab00750760f5edecfb67deeb3613cc5df8bcf8384606e1af43"}, - {file = "fast_stark_crypto-0.3.8-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:db0f147bd04c6b62bba92bdd1679b3ec2cfe09ac5a5a3c772dcbeeef9526c5d9"}, - {file = "fast_stark_crypto-0.3.8-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b7d31521d55900916fa94c3fa17a6763b27c1eca701cca3b3bc20662d9df0c11"}, - {file = "fast_stark_crypto-0.3.8-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:e076bd7f7eac394bdbaa52998c144f75502a6b94b1f18e4b5c1c9b81a5df57a4"}, - {file = "fast_stark_crypto-0.3.8-cp310-cp310-win_amd64.whl", hash = "sha256:ca9541c05847f58a518fc6fad7f1819f38921c94677dd1a597cfc9e74dcc89b5"}, - {file = "fast_stark_crypto-0.3.8-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4d66db2abd0f5efff0f8a90b4f372c6dfad0d8e5ce9ffdfd3e7cdaf26f7bb854"}, - {file = "fast_stark_crypto-0.3.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6aae6e124751340843e7addf8411b46f3b3531ae20d6341f6e14f209b6ec3f24"}, - {file = "fast_stark_crypto-0.3.8-cp311-cp311-manylinux_2_24_aarch64.whl", hash = "sha256:08974ea1377525b784d050b4d14a1a172eb5b64296a578f81787fbf715fa08e1"}, - {file = "fast_stark_crypto-0.3.8-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:561c39018fdaa5f7fa1daed97ce68757358ea3f83366f284c1475bd84cfaa095"}, - {file = "fast_stark_crypto-0.3.8-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bc30b91c7a05fac6651591017d99c8e0cdd0190fbc749a75709eea925e67f175"}, - {file = "fast_stark_crypto-0.3.8-cp311-cp311-win_amd64.whl", hash = "sha256:bedc3e98f9e442aa1c659d783b29d27cfd1ca34e1f1398bc8382f058f35f2883"}, - {file = "fast_stark_crypto-0.3.8-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fe780380688d04494d48672ccd09ec0081bd88acc40fa6a0727962595db9ac21"}, - {file = "fast_stark_crypto-0.3.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:91ef1e59f6de29a48bb99ac8039a943878853bf0ebd8c725605f2037ab3e146a"}, - {file = "fast_stark_crypto-0.3.8-cp312-cp312-manylinux_2_24_aarch64.whl", hash = "sha256:95d5c0cf4102a32477f8a549335dc81f1b20235e6bdc88bd2893809a2178f8b0"}, - {file = "fast_stark_crypto-0.3.8-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:5ec38703fe022771f73d7b622a312878bf4446edcbcd9acc611267f00e1e9784"}, - {file = "fast_stark_crypto-0.3.8-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8fd81feb2b5cb9394f91beded15346d96d4ef59312182238de96e0c1e3b41e41"}, - {file = "fast_stark_crypto-0.3.8-cp312-cp312-win_amd64.whl", hash = "sha256:02bda2d361e99695f2f2bfd6aeca43fbc32e36fbea2bd3bbc79b0dd8eea1e647"}, - {file = "fast_stark_crypto-0.3.8-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:6b53d6a83e2f63023341d6f1424728f3a04259a07a249bf8a9c51ddef79078b1"}, - {file = "fast_stark_crypto-0.3.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:875dfb4c67990ef02eecc4ca06936f876730e66b6b1db00d4d123421670d2328"}, - {file = "fast_stark_crypto-0.3.8-cp313-cp313-manylinux_2_24_aarch64.whl", hash = "sha256:f1fed566f8c7e4e3d72fb07d20e382041c5853519eb7a55b15ae66ce09daf7f6"}, - {file = "fast_stark_crypto-0.3.8-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f246abd44044859edf66ffcdb6ca8f1224228a1cbeefc36753be7e7b8628cd52"}, - {file = "fast_stark_crypto-0.3.8-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fa3288e7d206d06615c1cb998b366a5c841de6ccbc140cd2a4c90492a2d8a044"}, - {file = "fast_stark_crypto-0.3.8-cp313-cp313-win_amd64.whl", hash = "sha256:5050982fb68b72a8eb49f62fb82f03bf6200af7d98af8fd89919294d192e42ac"}, - {file = "fast_stark_crypto-0.3.8-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f496df8d867ff41b0b16d5234e8dd0b24e39f99e812c5107ac55f2fa467ca280"}, - {file = "fast_stark_crypto-0.3.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9ad9dd756f3ab43e70a0bdf873caaf59cb8771eecd1c5340f468fb670b41f385"}, - {file = "fast_stark_crypto-0.3.8-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:658b0488743d7abff06c8cc5b531f926041d168ce80c6dfc14c1a4b27b3b7d91"}, - {file = "fast_stark_crypto-0.3.8-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:b00fb73fdea2a7e099080475ef93780a6222f3809c98b57ff95b122819617523"}, - {file = "fast_stark_crypto-0.3.8-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:745928cd2376cddc3ce448e94ef97142777cdbce2848185454986ed5570d17de"}, - {file = "fast_stark_crypto-0.3.8-cp39-cp39-win_amd64.whl", hash = "sha256:a6f047a177227605843f7dc6cb3950dd9cd505a5306e2847546b058d27447381"}, - {file = "fast_stark_crypto-0.3.8.tar.gz", hash = "sha256:0149e0389225225ee303721da0c76beea96f03de0ed799f7ab40128061a4d30d"}, + {file = "fast_stark_crypto-0.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:3832a3f7813758ee7bb891f9f34658fea77b37b53c79d51003e87992ce5e9af0"}, + {file = "fast_stark_crypto-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:36871c1200c5c29216adf75495537d06548dda9e5e4c9394639016b5bb0dac91"}, + {file = "fast_stark_crypto-0.5.0-cp310-cp310-manylinux_2_24_aarch64.whl", hash = "sha256:7733fe50fc22b52b67b0bbaaaf63bb32fb09567d08e81a00e2596c5842e63993"}, + {file = "fast_stark_crypto-0.5.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:d4af140c10233db5e0b7681b79f245959501317580a651abb8e1a52fce2c1224"}, + {file = "fast_stark_crypto-0.5.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:92baee1bf6e0cc82c48ed65909a949e305b747c76c6d81325a14aaae01f5d016"}, + {file = "fast_stark_crypto-0.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:96ee06a2f6b03680812fc53b80ae1e3f0d6f27a5de75e713e5083477b4bdca4d"}, + {file = "fast_stark_crypto-0.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9c2877a85380db62d5e87f4ccc2056c06a16b607bc1fa9e9dfe13a892b9eee8b"}, + {file = "fast_stark_crypto-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a628561357c8a80d631a2cc36f5948c76e96d069b2b6a61f7b8194b508e0f91e"}, + {file = "fast_stark_crypto-0.5.0-cp311-cp311-manylinux_2_24_aarch64.whl", hash = "sha256:bd3e90c44b970f0501e900f2f3b14a262370d10d43fbf60528442f2d0c0a359a"}, + {file = "fast_stark_crypto-0.5.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4e5b86599733844f51e437287e916ca1f2ec40aa18efbe1edb40a78560581cc2"}, + {file = "fast_stark_crypto-0.5.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bab4d4dbdfcdb9b51efe4c4c4dff5d7870c76f47bb5352582bf331c0af60ff0e"}, + {file = "fast_stark_crypto-0.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:0c81108b31199ec63f86f71060dbd507ac166ca396d8cd94917ba3f4684d1a84"}, + {file = "fast_stark_crypto-0.5.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8458db2c9e9ab80d3b1c40beea08eb96472b7cf0f298233fa54f7a84ffdd5aa8"}, + {file = "fast_stark_crypto-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d5a334f11f312eb052e1cf8b15235b1e295ab4eb609b0d46eb469ddbdae52a02"}, + {file = "fast_stark_crypto-0.5.0-cp312-cp312-manylinux_2_24_aarch64.whl", hash = "sha256:243169a170136d00b1adae2b7309fc8c6bad6340e617cd04e855c26d04d98fdc"}, + {file = "fast_stark_crypto-0.5.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2ea6306ec18045a2eac4cc396266ffc09780f79793aa214095ca2d163ddbb844"}, + {file = "fast_stark_crypto-0.5.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9d2994a3cf49ea6c515d0d32530e904c9da80c6d93f07c52abb4ac09018c02fb"}, + {file = "fast_stark_crypto-0.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:412cd6219b60661f16ba1e39ccbeb7a77445b7ddc6d1944dc1e7edc7a70e1b34"}, + {file = "fast_stark_crypto-0.5.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:101285efb15dde14962e766c56d5d5bc4684d1e0044d9b32aec36792065c9987"}, + {file = "fast_stark_crypto-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1dc09fd515494a3d03ad4b7cf28d1feb006a25b2d70d77ca97227c76bb2f2dad"}, + {file = "fast_stark_crypto-0.5.0-cp313-cp313-manylinux_2_24_aarch64.whl", hash = "sha256:60973ec77e6383332487704e67bae5909b5d34250d5fd6b1edd6f27f8907d9f1"}, + {file = "fast_stark_crypto-0.5.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:affbfc29ff1ba4af71d06eff6e7a8096f23f2e477579d0e029387691dd04beab"}, + {file = "fast_stark_crypto-0.5.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:452e8e325e8c80d7e646156c855e41077927a8bb8c6f32a19bda82b238eba1a3"}, + {file = "fast_stark_crypto-0.5.0-cp313-cp313-win_amd64.whl", hash = "sha256:285d4f65325471b915c100b8498b9b94562df3fb0553d8e0e5246e0a41d33ca3"}, + {file = "fast_stark_crypto-0.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ef4b5934b0e66488bf3a13faa612cbdf4e01b6bc4a67c59d61952a81a95da216"}, + {file = "fast_stark_crypto-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a56c16dabc202394bb92ecb1c182dc150ba9884041f02de018d087af0f425b21"}, + {file = "fast_stark_crypto-0.5.0-cp39-cp39-manylinux_2_24_aarch64.whl", hash = "sha256:849d9af0294e923323e71782d2e25f7603c9e07e56b8d3dadaf603403b7436b2"}, + {file = "fast_stark_crypto-0.5.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:01dee3ddfad45e2347ad51c34bc28b7d7c2e8c5745fd171caf49baa032bbb15c"}, + {file = "fast_stark_crypto-0.5.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:80293474d42f1aec383a2fd98983e12f20f03a127be57111b8d2a989c3bc71e6"}, + {file = "fast_stark_crypto-0.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:4313d88adadfae3f9e92a55cd873fea41a8913a2616bbb9d862514009f384f4a"}, + {file = "fast_stark_crypto-0.5.0.tar.gz", hash = "sha256:7a2b730a7cd9d53aadc6c4c443f3ef5c41cc9baf580e29c52b877536911acf0d"}, ] [[package]] @@ -3176,6 +3212,8 @@ files = [ {file = "ruamel.yaml.clib-0.2.14-cp39-cp39-win32.whl", hash = "sha256:6d5472f63a31b042aadf5ed28dd3ef0523da49ac17f0463e10fda9c4a2773352"}, {file = "ruamel.yaml.clib-0.2.14-cp39-cp39-win_amd64.whl", hash = "sha256:8dd3c2cc49caa7a8d64b67146462aed6723a0495e44bf0aa0a2e94beaa8432f6"}, {file = "ruamel.yaml.clib-0.2.14.tar.gz", hash = "sha256:803f5044b13602d58ea378576dd75aa759f52116a0232608e8fdada4da33752e"}, + {file = "ruamel_yaml_clib-0.2.14-cp314-cp314-win32.whl", hash = "sha256:9b4104bf43ca0cd4e6f738cb86326a3b2f6eef00f417bd1e7efb7bdffe74c539"}, + {file = "ruamel_yaml_clib-0.2.14-cp314-cp314-win_amd64.whl", hash = "sha256:13997d7d354a9890ea1ec5937a219817464e5cc344805b37671562a401ca3008"}, ] [[package]] @@ -3774,4 +3812,4 @@ propcache = ">=0.2.1" [metadata] lock-version = "2.1" python-versions = "^3.10" -content-hash = "74cd51c2f332c3ab9addbf3fed3075b6ac8e39a1c841b3419a7e6bcfc61e6ace" +content-hash = "51375b7d8828035c806376700c40866e63323c1a123b21eff9c130e1922abdb1" diff --git a/pyproject.toml b/pyproject.toml index c80b80a..bef0062 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ packages = [{ include = "x10" }] [tool.poetry.dependencies] aiohttp = ">=3.10.11" eth-account = ">=0.12.0" -fast-stark-crypto = "==0.3.8" +fast-stark-crypto = "==0.5.0" pydantic = ">=2.9.0" python = "^3.10" pyyaml = ">=6.0.1" From 1e7ca0393d4d52f4b09c674fe956a9d81df9b979 Mon Sep 17 00:00:00 2001 From: stefano Date: Mon, 1 Dec 2025 16:15:54 +0000 Subject: [PATCH 2/4] add vault interations --- x10/perpetual/balances.py | 11 + x10/perpetual/configuration.py | 15 +- x10/perpetual/order_object_settlement.py | 38 +++- x10/perpetual/orders.py | 14 ++ .../trading_client/account_module.py | 10 +- .../trading_client/trading_client.py | 12 + x10/perpetual/trading_client/vault_module.py | 212 ++++++++++++++++++ x10/perpetual/transfer_object.py | 2 +- x10/utils/http.py | 10 +- 9 files changed, 313 insertions(+), 11 deletions(-) create mode 100644 x10/perpetual/trading_client/vault_module.py diff --git a/x10/perpetual/balances.py b/x10/perpetual/balances.py index 6207943..a409cfc 100644 --- a/x10/perpetual/balances.py +++ b/x10/perpetual/balances.py @@ -13,3 +13,14 @@ class BalanceModel(X10BaseModel): initial_margin: Decimal margin_ratio: Decimal updated_time: int + +class SpotBalanceModel(X10BaseModel): + account_id: int + asset: str + balance: Decimal + index_price: Decimal + notional_value: Decimal + contribution_factor: Decimal + equity_contribution: Decimal + available_to_withdraw: Decimal + updated_at: int \ No newline at end of file diff --git a/x10/perpetual/configuration.py b/x10/perpetual/configuration.py index a73f24d..64364d2 100644 --- a/x10/perpetual/configuration.py +++ b/x10/perpetual/configuration.py @@ -20,8 +20,11 @@ class EndpointConfig: asset_operations_contract: str collateral_asset_on_chain_id: str collateral_decimals: int - collateral_asset_id: str starknet_domain: StarknetDomain + vault_position: int = 0 + vault_asset_on_chain_id: str = "0x0" + vault_asset_id: int = 0 + vault_asset_name: str = "UNKNOWN" TESTNET_CONFIG = EndpointConfig( @@ -30,12 +33,15 @@ class EndpointConfig: stream_url="wss://api.starknet.sepolia.extended.exchange/stream.extended.exchange/v1", onboarding_url="https://api.starknet.sepolia.extended.exchange", signing_domain="starknet.sepolia.extended.exchange", - collateral_asset_contract="0x31857064564ed0ff978e687456963cba09c2c6985d8f9300a1de4962fafa054", + collateral_asset_contract="0x05ba91db44b3e6a4485b5dbfcb17d791faa9cb6890a42731b66b3536b28b8ed5", asset_operations_contract="", - collateral_asset_on_chain_id="0x1", + collateral_asset_on_chain_id="0x31857064564ed0ff978e687456963cba09c2c6985d8f9300a1de4962fafa054", collateral_decimals=6, - collateral_asset_id="0x1", starknet_domain=StarknetDomain(name="Perpetuals", version="v0", chain_id="SN_SEPOLIA", revision="1"), + vault_position=7, + vault_asset_on_chain_id="0x613b90ecd614fdc4591f7b624242f7a27abe655f5f7f7e3bf6bff806a9ca6a0", + vault_asset_id=32, + vault_asset_name="XLP", ) MAINNET_CONFIG = EndpointConfig( @@ -48,6 +54,5 @@ class EndpointConfig: asset_operations_contract="", collateral_asset_on_chain_id="0x1", collateral_decimals=6, - collateral_asset_id="0x1", starknet_domain=StarknetDomain(name="Perpetuals", version="v0", chain_id="SN_MAIN", revision="1"), ) diff --git a/x10/perpetual/order_object_settlement.py b/x10/perpetual/order_object_settlement.py index 336ab95..0f7a3ff 100644 --- a/x10/perpetual/order_object_settlement.py +++ b/x10/perpetual/order_object_settlement.py @@ -4,7 +4,7 @@ from decimal import Decimal from typing import Callable, Optional, Tuple -from fast_stark_crypto import get_order_msg_hash +from fast_stark_crypto import get_limit_order_msg_hash, get_order_msg_hash from x10.perpetual.amounts import ( ROUNDING_BUY_CONTEXT, @@ -45,13 +45,45 @@ class SettlementDataCtx: starknet_domain: StarknetDomain -def __calc_settlement_expiration(expiration_timestamp: datetime): +def calculate_order_settlement_expiration(expiration_timestamp: datetime): expire_time_with_buffer = expiration_timestamp + timedelta(days=14) expire_time_as_seconds = math.ceil(expire_time_with_buffer.timestamp()) return expire_time_as_seconds +def hash_limit_order( + amount_base: StarkAmount, + amount_quote: StarkAmount, + max_fee: StarkAmount, + nonce: int, + position_id: int, + expiration_timestamp: datetime, + public_key: int, + starknet_domain: StarknetDomain, +) -> int: + synthetic_asset = amount_base.asset + collateral_asset = amount_quote.asset + + return get_limit_order_msg_hash( + source_position_id=position_id, + receive_position_id=position_id, + base_asset_id=int(synthetic_asset.settlement_external_id, 16), + base_amount=amount_base.value, + quote_asset_id=int(collateral_asset.settlement_external_id, 16), + quote_amount=amount_quote.value, + fee_amount=max_fee.value, + fee_asset_id=int(collateral_asset.settlement_external_id, 16), + expiration=calculate_order_settlement_expiration(expiration_timestamp), + salt=nonce, + user_public_key=public_key, + domain_name=starknet_domain.name, + domain_version=starknet_domain.version, + domain_chain_id=starknet_domain.chain_id, + domain_revision=starknet_domain.revision, + ) + + def hash_order( amount_synthetic: StarkAmount, amount_collateral: StarkAmount, @@ -73,7 +105,7 @@ def hash_order( quote_amount=amount_collateral.value, fee_amount=max_fee.value, fee_asset_id=int(collateral_asset.settlement_external_id, 16), - expiration=__calc_settlement_expiration(expiration_timestamp), + expiration=calculate_order_settlement_expiration(expiration_timestamp), salt=nonce, user_public_key=public_key, domain_name=starknet_domain.name, diff --git a/x10/perpetual/orders.py b/x10/perpetual/orders.py index 146b253..d374d59 100644 --- a/x10/perpetual/orders.py +++ b/x10/perpetual/orders.py @@ -109,6 +109,20 @@ class StarkSettlementModel(X10BaseModel): collateral_position: Decimal +class LimitOrderSettlementModel(X10BaseModel): + base_amount: int + quote_amount: int + fee_amount: int + base_asset_id: HexValue + quote_asset_id: HexValue + fee_asset_id: HexValue + expiration_timestamp: int + nonce: int + receiver_position_id: int + sender_position_id: int + signature: SettlementSignatureModel + + class StarkDebuggingOrderAmountsModel(X10BaseModel): collateral_amount: Decimal fee_amount: Decimal diff --git a/x10/perpetual/trading_client/account_module.py b/x10/perpetual/trading_client/account_module.py index 93d8bfa..5e9f253 100644 --- a/x10/perpetual/trading_client/account_module.py +++ b/x10/perpetual/trading_client/account_module.py @@ -7,7 +7,7 @@ AssetOperationStatus, AssetOperationType, ) -from x10.perpetual.balances import BalanceModel +from x10.perpetual.balances import BalanceModel, SpotBalanceModel from x10.perpetual.bridges import BridgesConfig, Quote from x10.perpetual.clients import ClientModel from x10.perpetual.fees import TradingFeeModel @@ -124,6 +124,14 @@ async def get_order_by_external_id(self, external_id: str) -> WrappedApiResponse url = self._get_url("/user/orders/external/", external_id=external_id) return await send_get_request(await self.get_session(), url, list[OpenOrderModel], api_key=self._get_api_key()) + + async def get_spot_balances(self) -> WrappedApiResponse[List[SpotBalanceModel]]: + """ + https://api.docs.extended.exchange/#get-spot-balance + """ + + url = self._get_url("/user/spot/balances") + return await send_get_request(await self.get_session(), url, List[SpotBalanceModel], api_key=self._get_api_key()) async def get_trades( self, diff --git a/x10/perpetual/trading_client/trading_client.py b/x10/perpetual/trading_client/trading_client.py index 655123a..d2b3626 100644 --- a/x10/perpetual/trading_client/trading_client.py +++ b/x10/perpetual/trading_client/trading_client.py @@ -20,6 +20,7 @@ ) from x10.perpetual.trading_client.order_management_module import OrderManagementModule from x10.perpetual.trading_client.testnet_module import TestnetModule +from x10.perpetual.trading_client.vault_module import VaultModule from x10.utils.date import utc_now from x10.utils.http import WrappedApiResponse from x10.utils.log import get_logger @@ -41,6 +42,7 @@ class PerpetualTradingClient: __order_management_module: OrderManagementModule __testnet_module: TestnetModule __config: EndpointConfig + __vault_module: VaultModule async def place_order( self, @@ -116,6 +118,12 @@ def __init__(self, endpoint_config: EndpointConfig, stark_account: StarkPerpetua self.__order_management_module = OrderManagementModule(endpoint_config, api_key=api_key) self.__testnet_module = TestnetModule(endpoint_config, api_key=api_key, account_module=self.__account_module) self.__config = endpoint_config + self.__vault_module = VaultModule( + endpoint_config, + account_module=self.__account_module, + account=stark_account, + api_key=api_key, + ) @property def info(self): @@ -136,3 +144,7 @@ def orders(self): @property def testnet(self): return self.__testnet_module + + @property + def vault(self): + return self.__vault_module diff --git a/x10/perpetual/trading_client/vault_module.py b/x10/perpetual/trading_client/vault_module.py new file mode 100644 index 0000000..9d91469 --- /dev/null +++ b/x10/perpetual/trading_client/vault_module.py @@ -0,0 +1,212 @@ +import decimal +import random +from datetime import timedelta +from decimal import Decimal +from typing import Optional + + +from x10.perpetual.accounts import StarkPerpetualAccount +from x10.perpetual.amounts import HumanReadableAmount, StarkAmount +from x10.perpetual.assets import Asset +from x10.perpetual.configuration import EndpointConfig +from x10.perpetual.order_object_settlement import ( + calculate_order_settlement_expiration, + hash_limit_order, +) +from x10.perpetual.orders import LimitOrderSettlementModel +from x10.perpetual.trading_client.account_module import AccountModule +from x10.perpetual.trading_client.base_module import BaseModule +from x10.utils.date import utc_now +from x10.utils.http import send_post_request +from x10.utils.model import SettlementSignatureModel, X10BaseModel + + +class DepositRequestModel(X10BaseModel): + from_account_id: int + to_account_id: int + collateral: Decimal + shares: Decimal + settlement: LimitOrderSettlementModel + + +class WithdrawRequestModel(X10BaseModel): + from_account_id: int + to_account_id: int + collateral: Decimal + shares: Decimal + settlement: LimitOrderSettlementModel + + +class DepositResponseModel(X10BaseModel): + pass + + +class WithdrawResponseModel(X10BaseModel): + pass + + +class VaultModule(BaseModule): + def __init__( + self, + endpoint_config: EndpointConfig, + account_module: AccountModule, + account: Optional[StarkPerpetualAccount], + api_key: Optional[str] = None, + ): + super().__init__(endpoint_config, api_key=api_key) + self._account_module = account_module + self._account = account + + async def get_vault_share_balance(self) -> Decimal: + spot_balances = (await self._account_module.get_spot_balances()).data + if spot_balances is None: + raise Exception("Failed to get spot balances") + filtered_balances = filter(lambda b: b.asset == self._get_endpoint_config().vault_asset_name, spot_balances) + vault_balance = sum(map(lambda b: b.balance, filtered_balances), Decimal(0)) + return vault_balance + + async def withdraw_from_vault( + self, + shares_amount: Decimal, + collateral_amount: Decimal, + ) -> None: + account_info = (await self._account_module.get_account()).data + assert account_info is not None + position_id = account_info.l2_vault + vault_asset_id = self._get_endpoint_config().vault_asset_on_chain_id + settlement, collateral_amount_human, shares_amount_human = self.__create_limit_order( + collateral_amount=collateral_amount, + shares_amount=shares_amount, + position_id=position_id, + vault_asset_id=vault_asset_id, + buying_shares=False, + ) + withdraw_request = WithdrawRequestModel( + from_account_id=account_info.id, + to_account_id=account_info.id, + collateral=abs(collateral_amount_human.value), + shares=abs(shares_amount_human.value), + settlement=settlement, + ) + url = self._get_url("/vault/user/withdrawals") + resp = await send_post_request( + await self.get_session(), + url, + type(None), + json=withdraw_request.to_api_request_json(exclude_none=True), + api_key=self._get_api_key(), + ) + + if resp.error is not None: + raise Exception(f"Withdraw error: {resp.error}") + return resp.data + + async def invest_in_vault( + self, + amount: Decimal, + ) -> DepositResponseModel: + account_info = (await self._account_module.get_account()).data + assert account_info is not None + position_id = account_info.l2_vault + vault_asset_id = self._get_endpoint_config().vault_asset_on_chain_id + vault_shares_expected = Decimal(1) + settlement, collateral_amount_human, shares_amount_human = self.__create_limit_order( + collateral_amount=amount, + shares_amount=vault_shares_expected, + position_id=position_id, + vault_asset_id=vault_asset_id, + buying_shares=True, + ) + deposit_request = DepositRequestModel( + from_account_id=account_info.id, + to_account_id=account_info.id, + collateral=abs(collateral_amount_human.value), + shares=abs(shares_amount_human.value), + settlement=settlement, + ) + url = self._get_url("/vault/user/deposits") + resp = await send_post_request( + await self.get_session(), + url, + DepositResponseModel, + json=deposit_request.to_api_request_json(exclude_none=True), + api_key=self._get_api_key(), + ) + + if resp.error is not None: + raise Exception(f"Deposit error: {resp.error}") + if resp.data is None: + raise Exception("Deposit response invalid") + + return resp.data + + def __create_limit_order(self, collateral_amount, shares_amount, position_id, vault_asset_id, buying_shares=True): + if self._account is None: + raise Exception("Stark account is required for vault investments") + + vault_asset = Asset( + id=0, + name="XLP", + precision=self._get_endpoint_config().collateral_decimals, + active=True, + is_collateral=True, + settlement_external_id=vault_asset_id, + settlement_resolution=10 ** self._get_endpoint_config().collateral_decimals, + l1_external_id=vault_asset_id, + l1_resolution=10 ** self._get_endpoint_config().collateral_decimals, + ) + + collateral_asset = Asset( + id=0, + name="USD", + precision=self._get_endpoint_config().collateral_decimals, + active=True, + is_collateral=True, + settlement_external_id=self._get_endpoint_config().collateral_asset_on_chain_id, + settlement_resolution=10 ** self._get_endpoint_config().collateral_decimals, + l1_external_id=self._get_endpoint_config().collateral_asset_on_chain_id, + l1_resolution=10 ** self._get_endpoint_config().collateral_decimals, + ) + + collateral_amount_human = HumanReadableAmount( + asset=collateral_asset, + value=-collateral_amount if buying_shares else collateral_amount, + ) + + shares_amount_human = HumanReadableAmount( + asset=vault_asset, + value=shares_amount if buying_shares else -shares_amount, + ) + collateral_amount_stark = collateral_amount_human.to_stark_amount(decimal.Context(rounding=decimal.ROUND_UP)) + shares_amount_stark = shares_amount_human.to_stark_amount(decimal.Context(rounding=decimal.ROUND_UP)) + + nonce = random.randint(0, 2**31 - 1) + + expire_time = utc_now() + timedelta(hours=1) + order_hash = hash_limit_order( + amount_base=shares_amount_stark, + amount_quote=collateral_amount_stark, + max_fee=StarkAmount(0, collateral_asset), + nonce=nonce, + position_id=position_id, + expiration_timestamp=expire_time, + public_key=self._account.public_key, + starknet_domain=self._get_endpoint_config().starknet_domain, + ) + order_signature = self._account.sign(order_hash) + + settlement = LimitOrderSettlementModel( + base_amount=shares_amount_stark.value, + quote_amount=collateral_amount_stark.value, + fee_amount=0, + base_asset_id=int(vault_asset.settlement_external_id, 16), + quote_asset_id=int(collateral_asset.settlement_external_id, 16), + fee_asset_id=int(collateral_asset.settlement_external_id, 16), + expiration_timestamp=calculate_order_settlement_expiration(expire_time), + nonce=nonce, + receiver_position_id=position_id, + sender_position_id=position_id, + signature=SettlementSignatureModel(r=order_signature[0], s=order_signature[1]), + ) + + return settlement, collateral_amount_human, shares_amount_human diff --git a/x10/perpetual/transfer_object.py b/x10/perpetual/transfer_object.py index 44c752a..2408278 100644 --- a/x10/perpetual/transfer_object.py +++ b/x10/perpetual/transfer_object.py @@ -76,5 +76,5 @@ def create_transfer_object( to_vault=to_vault, amount=amount, settlement=settlement, - transferred_asset=config.collateral_asset_id, + transferred_asset=config.collateral_asset_on_chain_id, ) diff --git a/x10/utils/http.py b/x10/utils/http.py index 625e97f..a94b0e9 100644 --- a/x10/utils/http.py +++ b/x10/utils/http.py @@ -1,5 +1,6 @@ import itertools import re +from types import NoneType from typing import Any, Dict, Generic, List, Optional, Sequence, Type, TypeVar, Union import aiohttp @@ -16,7 +17,7 @@ LOGGER = get_logger(__name__) CLIENT_TIMEOUT = ClientTimeout(total=DEFAULT_REQUEST_TIMEOUT_SECONDS) -ApiResponseType = TypeVar("ApiResponseType", bound=Union[int, X10BaseModel, Sequence[X10BaseModel]]) +ApiResponseType = TypeVar("ApiResponseType", bound=Union[int, X10BaseModel, Sequence[X10BaseModel], None]) class RateLimitException(X10Error): @@ -89,6 +90,13 @@ def parse_response_to_model( ) -> WrappedApiResponse[ApiResponseType]: # Read this to get more context re the type ignore: # https://github.com/python/mypy/issues/13619 + + if model_class == NoneType: + return WrappedApiResponse[None]( + status=ResponseStatus.OK, + data=None, + ) # type: ignore + return WrappedApiResponse[model_class].model_validate_json(response_text) # type: ignore[valid-type] From a6f5ffd32f721ab67c8ea79aa16e7ac81e500d2c Mon Sep 17 00:00:00 2001 From: stefano Date: Tue, 2 Dec 2025 20:27:04 +0000 Subject: [PATCH 3/4] add __aenter__ and __aexit__ to PerpetualTradingClient --- x10/perpetual/trading_client/trading_client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x10/perpetual/trading_client/trading_client.py b/x10/perpetual/trading_client/trading_client.py index d2b3626..3f498ad 100644 --- a/x10/perpetual/trading_client/trading_client.py +++ b/x10/perpetual/trading_client/trading_client.py @@ -104,6 +104,12 @@ async def close(self): await self.__account_module.close_session() await self.__order_management_module.close_session() + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc_value, traceback): + await self.close() + def __init__(self, endpoint_config: EndpointConfig, stark_account: StarkPerpetualAccount | None = None): api_key = stark_account.api_key if stark_account else None From 52e052de5c10a07e6c2ba69aa78f8f07e20f9898 Mon Sep 17 00:00:00 2001 From: stefano Date: Thu, 4 Dec 2025 15:40:52 +0000 Subject: [PATCH 4/4] update testnet config for vault token --- x10/perpetual/configuration.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x10/perpetual/configuration.py b/x10/perpetual/configuration.py index 64364d2..6e7fcfb 100644 --- a/x10/perpetual/configuration.py +++ b/x10/perpetual/configuration.py @@ -39,9 +39,9 @@ class EndpointConfig: collateral_decimals=6, starknet_domain=StarknetDomain(name="Perpetuals", version="v0", chain_id="SN_SEPOLIA", revision="1"), vault_position=7, - vault_asset_on_chain_id="0x613b90ecd614fdc4591f7b624242f7a27abe655f5f7f7e3bf6bff806a9ca6a0", - vault_asset_id=32, - vault_asset_name="XLP", + vault_asset_on_chain_id="0x04471D52BA219221ba25A254f771bDA2BC89998895D3640A307D3C49aE262990", + vault_asset_id=33, + vault_asset_name="XVS", ) MAINNET_CONFIG = EndpointConfig(