# Contract Interaction Sequence -Membership ## Brief about protocol Buying a membership on clubs mean staking $DEV tokens. Each staking position is represented by an NFT called as [sToken](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/s-token/STokensManager.sol). Transfer of NFT means transfer of staking position This NFT cannot be minted by any external address other than [lockup contract](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/lockup/Lockup.sol#L172). This NFT contract allow some customization through [descriptors](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/s-token/STokensManager.sol#L31). Each `_property` can have [multiple descriptors](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/s-token/STokensManager.sol#L36) as well mapped to bytes32 payload If there is a descriptor then must have a [`onBeforeMint`](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/s-token/STokensManager.sol#L191) function which should return `true` bool value for a successful staking. ## Sequence of interactions happening on clubs ## Buying a Membership (all of the below action happens in a single transaction) [ex](https://mumbai.polygonscan.com/tx/0x94b14ff7b375d384ae927bc0ef9ccdffc0c53f1b041067cfe7b8fe451bae064b) 1. Since Buying is actually means staking $DEV tokens, but we allowed this to happen via ETH/WETH. 2. So, we call [`swapEthAndStakeDev` ](https://github.com/dev-protocol/eth-swap-and-stake/blob/main/contracts/SwapAndStakeV3Polygon.sol#L47). Arguments are passed from predefined configs 3. It takes ETH/WETH from `msg.sender` then swaps ETH/WETH to DEV token using uniswap pool. 5. Now [`depositToProperty`](https://github.com/dev-protocol/eth-swap-and-stake/blob/main/contracts/SwapAndStakeV3Polygon.sol#L178) function is called. 6. Which further calls[`_implDepositToProperty` ](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/lockup/Lockup.sol#L129) . It transfers ERC20 DEV token to specified property and calls [`mint`](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/lockup/Lockup.sol#L172) function of sToken 7. `mint` function checks the conditions and seeks the boolean value of [`onBeforeMint`](https://github.com/dev-protocol/protocol-v2/blob/main/contracts/src/s-token/STokensManager.sol#L191) from specified descriptor. 8. Now, if a sToken is successfully minted to `calling contract or address` then `depositToProperty` function call will be executed successfully. 9. But, ability to control a staking process with enforcing some business logic lies in sToken contract with the help of descriptors, [Example](https://github.com/dev-protocol/dynamic-s-tokens-simple-collections/blob/main/contracts/SimpleCollections.sol) 10. Now, sToken minted is returned back to original `msg.sender` ## Creating a Membership 1. At the time of activation and right after the project is tokenised. It sets the [SimpleCollections](https://github.com/dev-protocol/dynamic-s-tokens-simple-collections/blob/main/contracts/SimpleCollections.sol) as descriptor. Example [TX](https://mumbai.polygonscan.com/tx/0x57a3e310fe246a10e416c8277292a8fcd781b45ada8bbfff34fa5ea2b38e3c90) 2. Now, it sets the config for a particular memberships. Example [tx](https://mumbai.polygonscan.com/tx/0x459643c8be66ceb452c6fb25049e0ae738ff34802eaae67d5d514fe910c0629e)