Skip to content
This repository has been archived by the owner on Jun 18, 2018. It is now read-only.

Final submission #1

Merged
merged 26 commits into from
Jun 1, 2018
Merged

Final submission #1

merged 26 commits into from
Jun 1, 2018

Conversation

feuGeneA
Copy link
Owner

@feuGeneA feuGeneA commented Jun 1, 2018

No description provided.

feuGeneA added 26 commits May 21, 2018 09:32
design translated to code, and revised in response to all warnings and errors
from linting and compilation... EXCEPT for the following:

contracts/CDO.sol
  111:5  warning  Fallback function must be simple  no-complex-fallback

CODE IS UNTESTED
fallback function () was too complex, per solhint
bug: needed an additional 125000 gas to deploy all of the tranche tokens needed
during CDO instantiation

bug: had neglected to initialize the TrancheToken contract instance held within
the CDO contract

also realized that there is no DebtRegistry object available in the current
test environment, so changed the CDO contract to depend on a TermsContract
instead.
by using a global instance of the TrancheToken contract, rather than an
instance local to the CDO contract.
learned the hard way (after hours of debugging and researching) that
contract methods which change the state of the blockchain cannot return
values.  changed CDOFactory.create() to raise an event rather than
returning the contract address.

also learned that msg.sender isn't persisted through nested function
calls.  changed CDO contract constructor to accept an owner parameter.

added a test sub-section for re-use of an instantiated CDO contract.
remove unused import

use named return parameter

insert a few TODO reminders
also moved CDO instantiation and all tests up to the contract level
(out of a describe()).

also made later tests use the CDO instance created by the first test,
instead of re-instantiating
changed CDO.finalize() to raise an event instead of returning values,
since it's a transaction and not a view.

also fixed a bug with the TrancheToken where it wasn't properly
tracking ownership.
don't need to refer to them anymore, now that all of the demonstrated
techniques are being utilized in other tests.
first test of repayments being made available to tranche holders.

bug fixed: I had previously coded the CDO to handle repayments in
ether, but it really should be done in DummyToken's.  Fixed.

bug fixed: function remainingExpectedSeniorPayout() was missing a
return statement.

removed TODO to consider division truncation as I found a way to avoid
leaking repayment funds.

removed TODO about considering validity of return value fron
transactional function. decided it was okay since it's only called by
solidity code, never from js.
changed previous repayment test to repay exactly 30% of debt, in line
with example given in Instructions.  also added verification of
withdrawn amounts.

refined precision of verification in senior withdrawl test.

added test to verify that mezzanine withdrawls are denied when they're
not entitled to anything.
test needs to be more precise (needs to check that withdrawn values are
as expected), but this is what I have in place right now.

bug fix: was using the wrong loop counter variable in mezzanine
entitlement calculations!!!

bug fix: was using the wrong values to decrement
`unallocatedEntitlements` as the entitlement caclulation process was
marching on.

also realized that there never was any overflow issue, that all
anomalies I was seeing were due to the aforementioned bugs, so
converted those comparisons to tranche array lenghts back to their more
readable original forms.
added verification of exact withdrawal amounts
Well, about half as many debts as there are accounts.  one account is
for OWNER, one is for PAYER, and the rest are split between DEBTORS and
CREDITORS.

I tried with `--accounts 200` passed to ganache-cli for `yarn chain`,
and everything seemed to work fine.
@feuGeneA feuGeneA merged commit 5ef6b48 into master Jun 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant