{"id":26057857,"url":"https://github.com/syvb/yosoku-core","last_synced_at":"2026-04-16T21:36:19.339Z","repository":{"id":280502581,"uuid":"791033742","full_name":"syvb/yosoku-core","owner":"syvb","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-02T17:23:29.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T20:13:50.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syvb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-04-24T01:14:34.000Z","updated_at":"2024-09-02T17:23:32.000Z","dependencies_parsed_at":"2025-03-03T20:13:51.952Z","dependency_job_id":"f25e99b2-0eba-400a-82d1-6704549f4d88","html_url":"https://github.com/syvb/yosoku-core","commit_stats":null,"previous_names":["syvb/yosoku-core"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syvb%2Fyosoku-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syvb%2Fyosoku-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syvb%2Fyosoku-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syvb%2Fyosoku-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syvb","download_url":"https://codeload.github.com/syvb/yosoku-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242546038,"owners_count":20147096,"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-03-08T11:59:24.573Z","updated_at":"2025-12-06T21:02:38.220Z","avatar_url":"https://github.com/syvb.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yosoku\n\n*Yosoku* is an append-only financial ledger, intended for use in financial applications such as prediction markets. Currently this is more of an idea than an actual implementation; the code in this repo is very minimal.\n\n## How it works\n\nAll Yosoku data is stored in an append-only ledger, which is a list of transaction. `Ledger` is a trait, so there can be multiple different implementations of a ledger (e.g. `MemoryLedger`, `PostgresLedger`).\n\n### What's in a ledger\n\nA ledger is a list of transactions. A transaction has a list of postings and some metadata (monotonic creation time, creator, and arbitrary metadata). A posting increases/decreases a specified account by a specified amount. The postings of a transaction always sum to zero.\n\n#### Example\n```\nLedger\n  Transaction\n    # Create user 1 with 100¤ initial balance \n    Creator: SYSTEM_ACCOUNT\n    Status: Finalized at Jan 1 2024 00:00\n    Data: AccountCreation(Account(1), User)\n    Postings:\n      SYSTEM_ACCOUNT: -100¤\n      Account(1): +100¤\n  Transaction\n    # Create market\n    Creator: Account(1)\n    Status: Finalized at Jan 1 2024 00:03\n    Data: AccountCreation(Account(2), Contract(\"Will Twilight Sparkle win my Best Pony award?\", ...))\n    Postings:\n      # initial subsidy\n      Account(1): -20¤\n      Account(2): +20¤\n  Transaction\n    # Bet 5¤ on YES\n    Creator: Account(1)\n    Status: Finalized at Jan 1 2024 00:06\n    Data: Bet(Account(2), Outcome::YES)\n    Postings:\n      Account(1): -6¤\n      # Pay 5¤ to contract\n      Account(2): +5¤\n      # Pay fee to system\n      SYSTEM_ACCOUNT: +1¤\n  # ... 115¤ of other bets ...\n  Transaction\n    # Resolve market\n    Creator: Account(1)\n    Status: Finalized at Jan 2 2024 00:06\n    Data: Resolve(Account(2), Outcome::YES)\n    Postings:\n      # Reduce market balance to zero\n      Account(2): -120¤\n      # Send payouts using market balance\n      Account(1): +10¤\n      Account(3):  +30¤\n      Account(4):  +80¤\n```\n\n### Ledger implementations\n\n`MemoryLedger` is the simplest ledger - it just[^ml-time] stores a list of transactions. Most queries on a `MemoryLedger` is slow - for example, `MemoryLedger::account_balance` has to look at every transaction in the ledger to find out which ones affect the provided account. `PostgresLedger` (coming soon!) is much more efficent, by using various indexes and caches to make commonly used queries faster. However, it always produces the same results as a memory ledger.\n\nSince all ledger implementations implement the same `Ledger` interface, user code doesn't need to care what ledger implementation is being used. You can use a `MemoryLedger` for local testing, a `SqliteLedger` in dev, and a `PostgresLedger` in production - they are indistinguishable from the perspective of user code.\n\n[^ml-time]: It also stores a time number (incremented on every transaction), so that transaction times are deterministic.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyvb%2Fyosoku-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyvb%2Fyosoku-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyvb%2Fyosoku-core/lists"}