# Whitelisting extension to the swaps contract This document describes an extension to [the swaps contract](https://hackmd.io/iArxW3FyR_e85JNPYvuQhQ?both). It limits the set of addresses that are allowed to appear as FA2 token in `assets_offered` or `assets_requested`. An administrator entity is responsible for regulating this whitelist. We aim at a boilerplate-free composable implementation that allows including other desired functionality without significant effort. [Toc] ## Contract parts The plan is to develop one contract consisting of few components that can be reused for other purposes. The contract ha sto consist of the following parts: 1. Base swap contract; 2. Simple administrator contract. As base we will pick the existing [`simple_admin` contract](https://github.com/tqtezos/minter-sdk/blob/e7f441ea43e57a81cccb8dbda16cbd70481afd1b/contracts/ligo/fa2_modules/simple_admin.mligo) that is already present in `minter-sdk` repository. We will strip the current pausing functionality. Except for that, the storage, entrypoints and semantics should be inherited. 3. Whitelisting component and the swaps contract with whitelisting itself. The last point is to be described further in this document. ## Whitelisting component ### Types The storage of the whitelist component is solely `big_map address ()`. ### Entrypoints #### Update whitelist ```ocaml | Update_allowed of address list ``` This entrypoint allows setting the new whitelist, disregard what the old whitelist value was. Can be invoked only by the admin, fails with `NOT_ADMIN` otherwise. ### Modification of the base swaps contract The whitelisting component provides a method for modifying behaviour of `main` of the base swaps contract. This ensures that the whitelisting capability can be composed with other extensions to the swaps contract that may be requested in the future. #### Start swap entrypoint In case any of `assets_offered.fa2_address` or `assets_requested.fa2_address` addresses do not appear in the whitelist `big_map`, `SWAP_OFFERED_FA2_NOT_WHITELISTED` or `SWAP_REQUESTED_FA2_NOT_WHITELISTED` error is raised respectively. #### Cancel swap entrypoint Not updated. #### Accept swap entrypoint Not updated.