{"id":24995398,"url":"https://github.com/compolabs/spark-miden-v1","last_synced_at":"2025-09-11T13:35:47.865Z","repository":{"id":242595906,"uuid":"809993386","full_name":"compolabs/spark-miden-v1","owner":"compolabs","description":"Client-Side Proving Central Limit Order Book","archived":false,"fork":false,"pushed_at":"2024-10-17T20:52:06.000Z","size":554,"stargazers_count":8,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T23:41:45.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compolabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-03T21:06:20.000Z","updated_at":"2024-10-17T20:52:09.000Z","dependencies_parsed_at":"2024-06-17T19:43:20.125Z","dependency_job_id":"834dafb7-ce53-4667-8449-82a88f5c1942","html_url":"https://github.com/compolabs/spark-miden-v1","commit_stats":null,"previous_names":["compolabs/spark-miden-v1"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compolabs%2Fspark-miden-v1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compolabs%2Fspark-miden-v1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compolabs%2Fspark-miden-v1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compolabs%2Fspark-miden-v1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compolabs","download_url":"https://codeload.github.com/compolabs/spark-miden-v1/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514221,"owners_count":21116903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T15:37:39.997Z","updated_at":"2025-04-12T04:11:04.154Z","avatar_url":"https://github.com/compolabs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# SPARK-MIDEN-V1\n\n### Settlement of Spot Order Trades with SWAPp\n\nSettlement of spot order trades on Spark-Miden-v1 is achieved through the use of partially fillable swap notes (SWAPp). SWAPp notes have the following characteristics:\n\n### SWAPp Characteristics\n1. Can function as a regular SWAP note (as defined in the Miden-base repository).\n2. Allow a user wallet to partially consume them, as long as the consuming wallet has the necessary SWAPp add-on procedures.\n3. Are reclaimable by the creator.\n\n### What is Partial Consumption of a SWAPp Note?\n\nPartial consumption means that a user who does not have sufficient liquidity to completely fill the SWAPp note can still execute their trade at the specified ratio of requested to offered tokens in the SWAPp note. \n\nWhen partially filling a SWAPp note with liquidity L, the remaining liquidity L1 in the SWAPp note is added to the new outputted SWAPp note.\n\nThe process of partially filling a SWAPp note can continue N times until the liquidity in the SWAPp note is completely exhausted.\n\n### Partial SWAPp fulfillment\n![alt text](./docs/PartialFillSWAPp.svg)\n\n## SWAPp Note Inputs\n\n\n*In the context of Miden, when describing the stack, capitalized words represent four stack elements. Four stack elements are referred to as words.*\n```\nInputs: [REQUESTED_ASSET, SWAP_TAG, SWAP_COUNT, creator_id]\n```\n\nThe payback recipient is the RECIPIENT digest of the P2ID note.\n\nThe RECIPIENT digest is defined as:\n\n```\nhash(hash(hash(serial_num, [0; 4]), script_hash), input_hash)\n```\n\nThe REQUESTED_ASSET is defined as:\n```\n[faucet_id, 0, 0, amount]\n```\n\nThe SWAPp note is reclaimable by the initial creator of the SWAPp note. After each partial consumption of the SWAPp note, the sender of the note changes. However, since the PAYBACK_RECIPIENT input of the SWAPp note does not change, we can compute the PAYBACK_RECIPIENT hash inside the SWAPp note using the account ID of the currently executing account. If the PAYBACK_RECIPIENT hash matches the SWAPp note input for the PAYBACK_RECIPIENT, this means that the currently executing account is the initial creator.\n\nThis is achieved by calling the account::get_id procedure and then computing the PAYBACK_RECIPIENT digest inside the note.\n\n## Output of Partially Consuming a SWAPp Note\n\nWhen partially consuming a SWAPp note, two notes are outputted:\n1. A P2ID note with the requested asset for the SWAPp note creator.\n2. A new SWAPp note with L1 liquidity of the asset being sold.\n\n### Running Tests:\n```\ncargo test --test mock_integration\n```\n\n### Formatting MASM\n```\ncargo masm-fmt \"src/**/*.masm\"\n```\n\n#### Installing masm-formatter\n```\ncargo install masm-formatter\n```\n\n\n### Running CLI\n\n```\ncargo build --release\n./target/release/cli init\n./target/release/cli/setup\n\n./target/release/cli query \u003cBTC/ETH tag\u003e\n./target/release/cli query \u003cETH/BTC tag\u003e\n\n./target/release/cli login\n\n./target/release/cli order \u003cloggedInId\u003e \u003cfaucet_id_0\u003e 5 \u003cfaucet_id_1\u003e 5\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompolabs%2Fspark-miden-v1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompolabs%2Fspark-miden-v1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompolabs%2Fspark-miden-v1/lists"}