This is a low level interface to a liquidity pool for two tokens. ETH and an ERC-20 Token called spacecoin.
More about SpaceCoin
constructor()
_transfer(address from, address to, uint256 amount) internal override
transfer()
function
_transfer()
function in order to charge a tax when applicableSpaceCoinICO
contribute()
_checkValidityOfContribution()
2. Set a contributionLock so that this and other functions cannot be re-entered via the .call method that transfers the refund
1. if there was no contributionLock, an attacker could re-enter the contribute function, which isn’t a huge vulnerability but it would corrupt some of the events emitted
3. Calculates two different values, valid contribution adjusted for the individual limit vs. valid contributions adjusted for the fund limit, picks the lower of the two, and refunds the excess. For example, speaking generally, if individual contribution is 9, individual limit is 10, current fund is 3, and fund limit is 5 and amount to contribute is 9, valid contribution adjusted for individual limit is 1 (10-9) and valid contribution adjusted for fund limit is 2 (5-3). We would pick the former so we’d effectively contribute 1 and be refunded 8
4. At the end of the function, if we are in the open phase, we redeem SPC for the user automatically. Note that there is an internal version of redeem which does not check for the contribution lock