Submitted by gpersoon
The use of setYieldSource leaves the contract in a temporary inconsistent state because it changes the underlying yield source,
but doesnt (yet) transfer the underlying balances, while the shares stay the same.
The function balanceOfToken will show the wrong results, because it is based on _sharesToToken, which uses yieldSource.balanceOfToken(address(this)), that isnt updated yet.
More importantly supplyTokenTo will give the wrong amount of shares back:
First it supplies tokens to the yieldsource.
Then is calls _mintShares, which calls _tokenToShares, which calculates the shares, using yieldSource.balanceOfToken(address(this))
This yieldSource.balanceOfToken(address(this)) only contains the just supplied tokens, but doesnt include the tokens from the previous YieldSource.
So the wrong amount of shares is given back to the user; they will be given more shares than appropriate which means they can drain funds later on (once transferFunds has been done).
It is possible to make use of this problem in the following way:
Reocommend removing the function setYieldSource  (e.g. only leave swapYieldSource)
Or temporally disable actions like supplyTokenTo, redeemToken and balanceOfToken, after setYieldSource and until transferFunds has been done.
PierrickGT (PoolTogether) confirmed and resolved:
