{"id":13711282,"url":"https://github.com/ethersphere/swap-swear-and-swindle","last_synced_at":"2025-03-16T17:07:55.883Z","repository":{"id":22887702,"uuid":"97146293","full_name":"ethersphere/swap-swear-and-swindle","owner":"ethersphere","description":"Contracts for Swap, Swear and Swindle. Swap is a protocol for p2p accounting. This is the basis for Swarm’s incentivization model.","archived":false,"fork":false,"pushed_at":"2024-09-09T19:21:40.000Z","size":4719,"stargazers_count":51,"open_issues_count":9,"forks_count":18,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-10T07:12:07.458Z","etag":null,"topics":["ethereum","solidity","swarm","truffle","web3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jaakmusic/swap-swear-and-swindle","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethersphere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-07-13T16:56:20.000Z","updated_at":"2024-12-08T02:10:01.000Z","dependencies_parsed_at":"2023-02-13T19:31:23.145Z","dependency_job_id":"25dee6f8-a5bd-4ebd-b93d-a3ee51f9519f","html_url":"https://github.com/ethersphere/swap-swear-and-swindle","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fswap-swear-and-swindle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fswap-swear-and-swindle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fswap-swear-and-swindle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethersphere%2Fswap-swear-and-swindle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethersphere","download_url":"https://codeload.github.com/ethersphere/swap-swear-and-swindle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902279,"owners_count":20366259,"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":["ethereum","solidity","swarm","truffle","web3"],"created_at":"2024-08-02T23:01:06.534Z","updated_at":"2025-03-16T17:07:55.849Z","avatar_url":"https://github.com/ethersphere.png","language":"TypeScript","funding_links":[],"categories":["Smart Contracts"],"sub_categories":[],"readme":"# sw3 contracts\n\nContracts for Swap, Swear and Swindle.\n\n**Please note that all contracts within this repository are considered highly experimental and may cause loss of funds if used in production.**\n\nThe `master` branch only contains the `SimpleSwap` contract for now. Everything else (full `Swap`, `Swear` and `Swindle`) can be found in the `experimental` branch.\n\n## Tests\n\nThis is a hardhat project using the truffle plugin (for tests as this used to be truffle-based). You can run tests using `yarn test`.\n\n```sh\nyarn\nyarn test\n```\n\nTo also generate coverage information use `yarn coverage` instead.\n\n## Linting\n\nThis repo currently uses `solhint` as linter. It can be called through yarn:\n\n```sh\nyarn lint\n```\n\n## Go-bindings\n\nTo generate go bindings use\n\n```sh\nyarn abigen\n```\n\nThis will generate the bindings in the `bindings/` directory. Suitable versions of `solc` and `abigen` have to be installed for this to work.\nAlternatively this can also be done through docker:\n\n```sh\ndocker build -t sw3 -f Dockerfile.abigen .\ndocker run -v $(pwd)/bindings:/sw3/bindings sw3 yarn abigen\n```\n\nIn addition to the file from `abigen` this will also generate a go file that includes the runtime bytecode.\n\nThe go bindings are automatically generated on every release git tag and the pushed to the [ethersphere/go-sw3-abi](https://github.com/ethersphere/go-sw3-abi) repository.\n\n## Deployments\n\nSwap is deployed on the following networks:\n\n| Network | Factory                                                                                                                | Token                                                                                                                            |\n| ------- | ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| Mainnet | -                                                                                                                      | [0x19062190B1925b5b6689D7073fDfC8c2976EF8Cb](https://etherscan.io/address/0x19062190b1925b5b6689d7073fdfc8c2976ef8cb)            |\n| XDai    | [0xc2d5a532cf69aa9a1378737d8ccdef884b6e7420](https://gnosisscan.io/address/0xC2d5A532cf69AA9A1378737D8ccDEF884B6E7420) | [0xdbf3ea6f5bee45c02255b2c26a16f300502f68da (bridged)](https://gnosisscan.io/address/0xdbf3ea6f5bee45c02255b2c26a16f300502f68da) |\n\n## Test Deployments\n\nSwap is deployed on the following testnets:\n\n| Network | Factory                                                                                                                       | Token                                                                                                                         |\n| ------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |\n| Sepolia | [0x0fF044F6bB4F684a5A149B46D7eC03ea659F98A1](https://sepolia.etherscan.io/address/0x0fF044F6bB4F684a5A149B46D7eC03ea659F98A1) | [0x543dDb01Ba47acB11de34891cD86B675F04840db](https://sepolia.etherscan.io/address/0x543dDb01Ba47acB11de34891cD86B675F04840db) |\n\n## Overview\n\n### SimpleSwap\n\n`SimpleSwap` is a chequebook-style contract with support hard deposits.\n\n#### Cheques\n\nThe issuer can issue cheques. Those are a signed piece of data containing the swap address, a beneficiary, and a cumulative amount. If the beneficiary wishes to cash the cheque it needs to be sent to the contract using the `cashChequeBeneficiary` function. Alternatively anyone else can also cash the cheque using `cashCheque` provided they have a signature from the beneficiary. In that case they might also get a portion of the payout as a fee. If there is not enough liquid balance in the contract part of the cheque might bounce (whether the full cheque was paid out should be verified through the `ChequeCashed` event). Later the beneficiary can try cashing again to get the remaining amount.\n\n#### Hard Deposit\n\nThe issuer can lock a certain amount of the balance to a specific beneficiary (`increaseHardDeposit`) to give solvency guarantees up to the amount of the hard deposit. Decreasing a hard deposit is a two step process: First it needs to be prepared (`prepareDecreaseHardDeposit`) to start a security delay, which the beneficiary can use to cash the outstanding cheques. Afterwards the deposit can be decreased (`decreaseHardDeposit`).\nThe balance not covered by hard deposits can be withdrawn by the issuer at any time.\n\n### Data Formats\n\n#### Signatures\n\nFor signing purposes the chequebook uses EIP-712 Ethereum typed structured data hashing and signing. The `EIP712Domain` domain name is `Chequebook` in version `1.0`. The `chainId` field is used, the `verifyingContract` and `salt` fields are omitted.\n\n#### Cheques\n\n| Field            | Type    | Description                    |\n| ---------------- | ------- | ------------------------------ |\n| swap             | address |  the swap contract this is for |\n| beneficiary      | address |  beneficiary of the cheque     |\n| cumulativePayout | uint256 | cumulative amount              |\n\n#### CashOut\n\n| Field         | Type    | Description                                    |\n| ------------- | ------- | ---------------------------------------------- |\n| swap          | address |  the swap contract this is for                 |\n| sender        | address | the address allowed to submit this cheque      |\n| requestPayout | uint256 | the maximum amount that should be paid out     |\n| recipient     | address | the target of the payment                      |\n| calleePayout  | uint256 | amount of the payout that should go the caller |\n\n#### CustomHardDepositDecreaseTimeout\n\n| Field           | Type    | Description                      |\n| --------------- | ------- | -------------------------------- |\n| swap            | address |  the swap contract this is for   |\n| beneficiary     | address |  beneficiary of the hard deposit |\n| decreaseTimeout | uint256 | new timeout                      |\n\n#### Factory\n\n`SimpleSwap` has an accompanying factory contract `SimpleSwapFactory`. Deploying through the factory guarantees that the `SimpleSwap` contract was deployed with the correct init code.\n\n## Swap\n\n`Swap` is `SimpleSwap` extended with support for promissory notes. You can find it in the `experimental` branch.\n\n## Swear and Swindle\n\n`Swear` and `Swindle` are the contracts for the trial system of sw3. You can find them in the `experimental` branch.\n\n## Releasing\n\nTo release a new stable version, tag the commit without the `-rcX` suffix.\nFor example, to release `v0.4.0`, execute the following command: `git tag v0.4.0 \u0026\u0026 git push origin v0.4.0`.\nThis will generate Golang source code for the smart contracts and publish it to the [`ethersphere/go-sw3-abi/`](https://github.com/ethersphere/go-sw3-abi/) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethersphere%2Fswap-swear-and-swindle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethersphere%2Fswap-swear-and-swindle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethersphere%2Fswap-swear-and-swindle/lists"}