{"_id":"@airswap/peer","_rev":"4-d16971fa09c19ae2e4050271e02bfb86","name":"@airswap/peer","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@airswap/peer","version":"0.2.0","description":"Manages delegated trading rules for use in the Swap Protocol","license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/airswap/airswap-protocols.git"},"scripts":{"clean":"rm -rf ./build","compile":"truffle compile","coverage":"solidity-coverage","lint":"yarn eslint \"./test/**/*.js\"","truffle":"truffle --network development","test":"truffle test"},"devDependencies":{"@airswap/order-utils":"0.1.0","@airswap/test-utils":"0.1.0"},"dependencies":{"@airswap/swap":"2.0.0","openzeppelin-solidity":"^v2.2","solidity-coverage":"^0.6.3"},"bugs":{"url":"https://github.com/airswap/airswap-protocols/issues"},"homepage":"https://github.com/airswap/airswap-protocols#readme","_id":"@airswap/peer@0.2.0","_nodeVersion":"10.16.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-JYNvPZQGy1suHEnaYef9HLgQLrGOUhFDnncTIKDNwC+Tk70vmQ9qbYDTQE3yZq1ewqr3SPq98zK7bwlGRmQfkA==","shasum":"6c8c8b0a527ceb9e986845160d543314f725ff0c","tarball":"https://registry.npmjs.org/@airswap/peer/-/peer-0.2.0.tgz","fileCount":14,"unpackedSize":50433,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdVJXvCRA9TVsSAnZWagAAvB0P/RhzD3b3x1eWSMERjA6+\nr5k67A1OPJWabNqqtzITcAcJTlf607XKw7abj1dn8TJALinRdhZ3Ao1OMOu0\nTVRpT20gHPVXxw1+FzRDrkoBKP8dFhol9ARgRZsJwAc8uDTGb2rMm7NI1SdM\ngohWJQpkr+5ZiC3GzoPXvkCmz1+fD+in2qRYH2O9lPdRa++mrYFoIxPSjOdu\nYXv+EsIA6DBh3bV3NltALD91Ma01OBfCxie1HrU6SMuoHP9/bb+slteV3mzQ\nWRZ5hgP4EhHUw0Se1uY4S1tTGJY7rObM0Gzk88e7HI2vzQG6PBOMHra2ji9K\nRqBT6hnBT046CqnBRkc86Xoi4KA5NbjVz01yxEjttuXqgTpbGvq2aiADVsS9\nMMGVXiWJxDglARFcBd72jD9GTJDHS/ylXGxJZ+ECLtZRjjvJvBAfhpaFUqVK\nAWq3+EjFl/zSwwAnmuBZzi/S+NIt+GWFHswdIzCbS7rzzeuZ5HJ1IAzb4ERj\n0tbGdMmbfYj5w9Sf7zLyTryrrSBiNzmW5dvGG+XFG+NvXbMx8jJGco+NZmj0\n3rcJWBbMDteoAtZ/fMSoZbHfq7Z58ow/uPSXx1srMVAIXPzj4n+/4VEF2VRu\n6GBnQW6k94N3qRlhE12XuZW0LFmu1wdDhvv6igBNImHpuRkgQlZJyDWg9bkE\nxKCS\r\n=w5mB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID9A8zam72ezgQx543h5Z5m2A5SHGlTDv8KG3MAXfo63AiAgiA+7NzTmLy7tKBcf2gxsQYsrIk3PPpNgwdK/cXymCg=="}]},"maintainers":[{"name":"airswap","email":"opensource@airswap.io"}],"_npmUser":{"name":"airswap","email":"opensource@airswap.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/peer_0.2.0_1565824494844_0.8386221182395084"},"_hasShrinkwrap":false},"0.3.0":{"name":"@airswap/peer","version":"0.3.0","description":"Manages delegated trading rules for use in the Swap Protocol","license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/airswap/airswap-protocols.git"},"scripts":{"clean":"rm -rf ./build","compile":"truffle compile","coverage":"solidity-coverage","lint":"yarn eslint \"./test/**/*.js\"","truffle":"truffle --network development","test":"truffle test"},"devDependencies":{"@airswap/order-utils":"0.3.0","@airswap/test-utils":"0.1.0"},"dependencies":{"@airswap/swap":"2.1.0","openzeppelin-solidity":"^v2.2","solidity-coverage":"^0.6.3"},"bugs":{"url":"https://github.com/airswap/airswap-protocols/issues"},"homepage":"https://github.com/airswap/airswap-protocols#readme","_id":"@airswap/peer@0.3.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-LWPhrkOCtAAqq53oTrfQRRoeLAjZe4F5RogHqJyJt8F3QZOz31ZYluX3zGjqiuogZJ32J3sMDhlnkxKXz6Hikg==","shasum":"8c2c02365b89c02aae061a3a3230f2b5a91b38d0","tarball":"https://registry.npmjs.org/@airswap/peer/-/peer-0.3.0.tgz","fileCount":14,"unpackedSize":49995,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZ+frCRA9TVsSAnZWagAAst8QAJDPZ/gyoU2YPcHZKZQb\nkCVnuzsGBgKU69vLhiDhi7+5Ublw4OfXICcjHMulpjsnp9ziGx/5oXwK4+4G\nu45DeuazzlItEV6//I+XvapdXWzJ0pfE33QMq7hFFK/2aC/SnCl7BiLXhfjv\nw/krW5iDYJtXN3vIdxzuqPL3IByA6a+wONp1qCA05bVRbNWXRgxC05GXsixw\nh93Lq/Cc+80fB9DQ6lDR5OiF8rYu8krjfr8ibpsdrAlQ/xA7jPJyNeY/dDdM\nefSV8Yy8395TlvSzmOXyDGLapa6uFkFPx0asm9O+4svLh3uKwzTPeFucWDbq\niHzhznSwY7a0amK0+7vnvAQIkW5OwEeXudVxWKKHOldEs1PgJdm1p6mMKwCC\nAoMK7nxHqyCCafk6Fs59LEE/6o1r2tPbQWXwU8siXrbN/ZK16UCdl6oDpvOz\nuBxmbze+w4ixfVvyia2TPfxlzWkBzSUYPqVjtgFArBJf+gRBDdNdJ5tSxSNi\n43NvjPNlXDpzi4OyEzZyS2FG2qEgAKlpH6jI8lgWMNZDiBdo7nLi7nI+ZwqS\nbxSRrcf3w6zWgL6zg6RdXrGE5SrBN6EowpzFj1i17OmjCrTou5IA6AzmV/gy\n4pbUPeKt0Uq9LnKppFPegdWxLJx/RjmBe7Fr3Xzszxv/eIPZ3oUjstB3WonU\n+ILJ\r\n=gJsb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC38mUiYDqVpqRIpNoQC4REv/XQnuKw71Nnd84kpA5hdwIhAKoT02liPMkz1cXP5lWYIDieV9Y91tNIunX1LYBpka7M"}]},"maintainers":[{"name":"airswap","email":"opensource@airswap.io"}],"_npmUser":{"name":"airswap","email":"opensource@airswap.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/peer_0.3.0_1567090666547_0.10892770624926063"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-14T23:14:54.844Z","0.2.0":"2019-08-14T23:14:54.978Z","modified":"2022-04-04T12:23:21.906Z","0.3.0":"2019-08-29T14:57:46.712Z"},"maintainers":[{"email":"npm@npmjs.com","name":"npm"}],"description":"Manages delegated trading rules for use in the Swap Protocol","homepage":"https://github.com/airswap/airswap-protocols#readme","repository":{"type":"git","url":"git+https://github.com/airswap/airswap-protocols.git"},"bugs":{"url":"https://github.com/airswap/airswap-protocols/issues"},"license":"Apache-2.0","readme":"# Peer\n\n**:warning: This package is under active development. Do not use in production.**\n\n[AirSwap](https://www.airswap.io/) is a peer-to-peer trading network for Ethereum tokens. This package contains source code and tests for a basic `Peer` contract that can be deployed with trading rules. In addition, there is a `PeerFactory` contract that deploys `Peer` contracts as well.\n\n:bulb: **Note**: `solidity-coverage` does not cooperate with `view` functions. To run test coverage, remove the `view` keywords from functions in `Peer.sol`, `IPeer.sol`, and `PeerFactory.sol`.\n\n[![Discord](https://img.shields.io/discord/590643190281928738.svg)](https://discord.gg/ecQbV7H)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n## Peer\n\n### Features\n\n#### Limit Orders\n\nSet rules to only take trades at specific prices.\n\n#### Partial Fills\n\nSend up to a maximum amount of a token.\n\n### Definitions\n\n| Term              | Definition                                                                 |\n| :---------------- | :------------------------------------------------------------------------- |\n| Peer              | Smart contract that trades based on rules. Acts as taker.                  |\n| Consumer          | A party that gets quotes from and sends orders to the peer. Acts as maker. |\n| Rule              | An amount of tokens to trade at a specific price.                          |\n| Price Coefficient | The significant digits of the price.                                       |\n| Price Exponent    | The location of the decimal on the price.                                  |\n\n### Constructor\n\nCreate a new `Peer` contract.\n\n```Solidity\nconstructor(\n  address _swapContract,\n  address _peerContractOwner\n) public\n```\n\n#### Params\n\n| Name                 | Type      | Description                                           |\n| :------------------- | :-------- | :---------------------------------------------------- |\n| `_swapContract`      | `address` | Address of the swap contract used to settle trades.   |\n| `_peerContractOwner` | `address` | Address of the owner of the peer for rule management. |\n\n### Price Calculations\n\nAll amounts are in the smallest unit (e.g. wei), so all calculations based on price result in a whole number. For calculations that would result in a decimal, the amount is automatically floored by dropping the decimal. For example, a price of `5.25` and `takerParam` of `2` results in `makerParam` of `10` rather than `10.5`. Tokens have many decimal places so these differences are very small.\n\n### Set a Rule\n\nSet a trading rule on the peer.\n\n```Solidity\nfunction setRule(\n  address _takerToken,\n  address _makerToken,\n  uint256 _maxTakerAmount,\n  uint256 _priceCoef,\n  uint256 _priceExp\n) external onlyOwner\n```\n\n#### Params\n\n| Name              | Type      | Description                                                    |\n| :---------------- | :-------- | :------------------------------------------------------------- |\n| `_takerToken`     | `address` | The token the peer would send.                                 |\n| `_makerToken`     | `address` | The token the consumer would send.                             |\n| `_maxTakerAmount` | `uint256` | The maximum amount of token the peer would send.               |\n| `_priceCoef`      | `uint256` | The coefficient of the price to indicate the whole number.     |\n| `_priceExp`       | `uint256` | The exponent of the price to indicate location of the decimal. |\n\n#### Example\n\nSet a rule to send up to 100,000 DAI for WETH at 0.0032 WETH/DAI\n\n```Solidity\nsetRule(<WETHAddress>, <DAIAddress>, 100000, 32, 4)\n```\n\nSet a rule to send up to 100,000 DAI for WETH at 312.50 WETH/DAI\n\n```Solidity\nsetRule(<WETHAddress>, <DAIAddress>, 100000, 32150, 2)\n```\n\nSet a rule to send up to 100,000 DAI for WETH at 312 WETH/DAI\n\n```Solidity\nsetRule(<WETHAddress>, <DAIAddress>, 100000, 312, 0)\n```\n\n### Unset a Rule\n\nUnset a trading rule for the peer.\n\n```Solidity\nfunction unsetRule(\n  address _takerToken,\n  address _makerToken\n) external onlyOwner\n```\n\n#### Params\n\n| Name          | Type      | Description                        |\n| :------------ | :-------- | :--------------------------------- |\n| `_takerToken` | `address` | The token the peer would send.     |\n| `_makerToken` | `address` | The token the consumer would send. |\n\n### Get a Maker-Side Quote\n\nGet a quote for the maker (consumer) side. Often used to get a buy price for \\_quoteTakerToken.\n\n```Solidity\nfunction getMakerSideQuote(\n  uint256 _quoteTakerParam,\n  address _quoteTakerToken,\n  address _quoteMakerToken\n) external view returns (\n  uint256 quoteMakerParam\n)\n```\n\n#### Params\n\n| Name               | Type      | Description                                             |\n| :----------------- | :-------- | :------------------------------------------------------ |\n| `_quoteTakerParam` | `uint256` | The amount of ERC-20 token the peer would send.         |\n| `_quoteTakerToken` | `address` | The address of an ERC-20 token the peer would send.     |\n| `_quoteMakerToken` | `address` | The address of an ERC-20 token the consumer would send. |\n\n#### Reverts\n\n| Reason                | Scenario                                         |\n| :-------------------- | :----------------------------------------------- |\n| `TOKEN_PAIR_INACTIVE` | There is no rule set for this token pair.        |\n| `AMOUNT_EXCEEDS_MAX`  | The quote would exceed the maximum for the rule. |\n\n### Get a Taker-Side Quote\n\nGet a quote for the taker (peer) side. Often used to get a sell price for \\_quoteMakerToken.\n\n```Solidity\nfunction getTakerSideQuote(\n  uint256 _quoteMakerParam,\n  address _quoteMakerToken,\n  address _quoteTakerToken\n) external view returns (\n  uint256 quoteTakerParam\n)\n```\n\n#### Params\n\n| Name               | Type      | Description                                             |\n| :----------------- | :-------- | :------------------------------------------------------ |\n| `_quoteMakerParam` | `uint256` | The amount of ERC-20 token the consumer would send.     |\n| `_quoteMakerToken` | `address` | The address of an ERC-20 token the consumer would send. |\n| `_quoteTakerToken` | `address` | The address of an ERC-20 token the peer would send.     |\n\n#### Reverts\n\n| Reason                | Scenario                                         |\n| :-------------------- | :----------------------------------------------- |\n| `TOKEN_PAIR_INACTIVE` | There is no rule set for this token pair.        |\n| `AMOUNT_EXCEEDS_MAX`  | The quote would exceed the maximum for the rule. |\n\n### Get a Max Quote\n\nGet the maximum quote from the peer.\n\n```Solidity\nfunction getMaxQuote(\n  address _quoteTakerToken,\n  address _quoteMakerToken\n) external view returns (\n  uint256 quoteTakerParam,\n  uint256 quoteMakerParam\n)\n```\n\n#### Params\n\n| Name               | Type      | Description                                             |\n| :----------------- | :-------- | :------------------------------------------------------ |\n| `_quoteTakerToken` | `address` | The address of an ERC-20 token the peer would send.     |\n| `_quoteMakerToken` | `address` | The address of an ERC-20 token the consumer would send. |\n\n#### Reverts\n\n| Reason                | Scenario                                  |\n| :-------------------- | :---------------------------------------- |\n| `TOKEN_PAIR_INACTIVE` | There is no rule set for this token pair. |\n\n### Provide an Order\n\nProvide an order to the peer for taking.\n\n```Solidity\nfunction provideOrder(\n  Types.Order memory _order\n) public\n```\n\n#### Params\n\n| Name    | Type    | Description                                                |\n| :------ | :------ | :--------------------------------------------------------- |\n| `order` | `Order` | Order struct as specified in the `@airswap/types` package. |\n\n#### Reverts\n\n| Reason                | Scenario                                                       |\n| :-------------------- | :------------------------------------------------------------- |\n| `TOKEN_PAIR_INACTIVE` | There is no rule set for this token pair.                      |\n| `AMOUNT_EXCEEDS_MAX`  | The amount of the trade would exceed the maximum for the rule. |\n| `PRICE_INCORRECT`     | The order is priced incorrectly for the rule.                  |\n\n## Peer Factory\n\n### Features\n\n#### Deploys Peer Contracts\n\nCreates peers with a trusted interface\n\n#### Has lookup to find peer contracts it has deployed\n\n### Definitions\n\n| Term | Definition                                                |\n| :--- | :-------------------------------------------------------- |\n| Peer | Smart contract that trades based on rules. Acts as taker. |\n\n### Constructor\n\nCreate a new `Peer` contract.\n\n```Solidity\nconstructor(\n  address _swapContract,\n  address _peerContractOwner\n) public\n```\n\n### Create a new `Peer` contract.\n\n```Solidity\ncreatePeer(\n  address _swapContract,\n  address _peerContractOwner\n) external returns\n  (address peerContractAddress)\n```\n\n#### Params\n\n| Name                 | Type      | Description                                           |\n| :------------------- | :-------- | :---------------------------------------------------- |\n| `_swapContract`      | `address` | Address of the swap contract used to settle trades.   |\n| `_peerContractOwner` | `address` | Address of the owner of the peer for rule management. |\n\n### Lookup for deployed peers\n\nTo check whether a locator was deployed\n\n```Solidity\nfunction has(\n  bytes32 _locator\n) external returns (bool)\n```\n\n#### Params\n\n| Name       | Type      | Description                                      |\n| :--------- | :-------- | :----------------------------------------------- |\n| `_locator` | `bytes32` | locator of the peer in question, ex an `address` |\n","readmeFilename":"README.md"}