Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions contracts/test/_fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,32 +320,32 @@ const createAccountTypes = async ({ vault, ousd, ousdUnlocked, deploy }) => {
creditsPerToken,
balance,
}) => {
const nonrebase_cotract_notSet_altcpt_gt = await createContract(name);
const nonrebase_contract_notSet_altcpt_gt = await createContract(name);
await ousd
.connect(matt)
.transfer(nonrebase_cotract_notSet_altcpt_gt.address, balance);
.transfer(nonrebase_contract_notSet_altcpt_gt.address, balance);
const { creditsPerTokenBN, creditsBalanceBN } = generateCreditsBalancePair({
creditsPerToken,
tokenBalance: balance,
});
await ousdUnlocked
.connect(matt)
.overwriteCreditBalances(
nonrebase_cotract_notSet_altcpt_gt.address,
nonrebase_contract_notSet_altcpt_gt.address,
creditsBalanceBN
);
await ousdUnlocked
.connect(matt)
.overwriteAlternativeCPT(
nonrebase_cotract_notSet_altcpt_gt.address,
nonrebase_contract_notSet_altcpt_gt.address,
creditsPerTokenBN
);
await ousdUnlocked.connect(matt).overwriteRebaseState(
nonrebase_cotract_notSet_altcpt_gt.address,
nonrebase_contract_notSet_altcpt_gt.address,
0 // NotSet
);

return nonrebase_cotract_notSet_altcpt_gt;
return nonrebase_contract_notSet_altcpt_gt;
};

const rebase_eoa_notset_0 = await createAccount();
Expand Down Expand Up @@ -384,36 +384,36 @@ const createAccountTypes = async ({ vault, ousd, ousdUnlocked, deploy }) => {
await ousd.connect(matt).transfer(nonrebase_eoa_1.address, ousdUnits("45"));
await ousd.connect(nonrebase_eoa_1).rebaseOptOut();

const nonrebase_cotract_0 = await createContract("nonrebase_cotract_0");
const nonrebase_contract_0 = await createContract("nonrebase_contract_0");
await ousd
.connect(matt)
.transfer(nonrebase_cotract_0.address, ousdUnits("55"));
await nonrebase_cotract_0.connect(matt).rebaseOptIn();
await nonrebase_cotract_0.connect(matt).rebaseOptOut();
const nonrebase_cotract_1 = await createContract("nonrebase_cotract_1");
.transfer(nonrebase_contract_0.address, ousdUnits("55"));
await nonrebase_contract_0.connect(matt).rebaseOptIn();
await nonrebase_contract_0.connect(matt).rebaseOptOut();
const nonrebase_contract_1 = await createContract("nonrebase_contract_1");
await ousd
.connect(matt)
.transfer(nonrebase_cotract_1.address, ousdUnits("56"));
await nonrebase_cotract_1.connect(matt).rebaseOptIn();
await nonrebase_cotract_1.connect(matt).rebaseOptOut();
.transfer(nonrebase_contract_1.address, ousdUnits("56"));
await nonrebase_contract_1.connect(matt).rebaseOptIn();
await nonrebase_contract_1.connect(matt).rebaseOptOut();

const nonrebase_cotract_notSet_0 = await createContract(
"nonrebase_cotract_notSet_0"
const nonrebase_contract_notSet_0 = await createContract(
"nonrebase_contract_notSet_0"
);
const nonrebase_cotract_notSet_1 = await createContract(
"nonrebase_cotract_notSet_1"
const nonrebase_contract_notSet_1 = await createContract(
"nonrebase_contract_notSet_1"
);

const nonrebase_cotract_notSet_altcpt_gt_0 =
const nonrebase_contract_notSet_altcpt_gt_0 =
await createNonRebasingNotSetAlternativeCptContract({
name: "nonrebase_cotract_notSet_altcpt_gt_0",
name: "nonrebase_contract_notSet_altcpt_gt_0",
creditsPerToken: 0.934232,
balance: ousdUnits("65"),
});

const nonrebase_cotract_notSet_altcpt_gt_1 =
const nonrebase_contract_notSet_altcpt_gt_1 =
await createNonRebasingNotSetAlternativeCptContract({
name: "nonrebase_cotract_notSet_altcpt_gt_1",
name: "nonrebase_contract_notSet_altcpt_gt_1",
creditsPerToken: 0.890232,
balance: ousdUnits("66"),
});
Expand Down Expand Up @@ -480,16 +480,16 @@ const createAccountTypes = async ({ vault, ousd, ousdUnlocked, deploy }) => {
nonrebase_eoa_0,
nonrebase_eoa_1,
// contract account that has rebaseState: StdNonRebasing
nonrebase_cotract_0,
nonrebase_cotract_1,
nonrebase_contract_0,
nonrebase_contract_1,
// contract account that has rebaseState: NotSet
nonrebase_cotract_notSet_0,
nonrebase_cotract_notSet_1,
nonrebase_contract_notSet_0,
nonrebase_contract_notSet_1,
// contract account that has rebaseState: NotSet & alternativeCreditsPerToken > 0
// note: these are older accounts that have been migrated by the older versions of
// of the code without explicitly setting rebaseState to StdNonRebasing
nonrebase_cotract_notSet_altcpt_gt_0,
nonrebase_cotract_notSet_altcpt_gt_1,
nonrebase_contract_notSet_altcpt_gt_0,
nonrebase_contract_notSet_altcpt_gt_1,

// account delegating yield
rebase_delegate_source_0,
Expand Down
10 changes: 5 additions & 5 deletions contracts/test/token/ousd.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ describe("Token", function () {
});

it("Old code auto migrated contract when calling rebase OptIn shouldn't affect invariables", async () => {
const { nonrebase_cotract_notSet_altcpt_gt_0: contract_account, ousd } =
const { nonrebase_contract_notSet_altcpt_gt_0: contract_account, ousd } =
fixture;

const nonRebasingSupply = await ousd.nonRebasingSupply();
Expand Down Expand Up @@ -1084,16 +1084,16 @@ describe("Token", function () {
});

it("Contract should auto migrate to StdNonRebasing", async () => {
let { ousd, nonrebase_cotract_notSet_0, rebase_eoa_notset_0 } = fixture;
let { ousd, nonrebase_contract_notSet_0, rebase_eoa_notset_0 } = fixture;

await expect(
await ousd.rebaseState(nonrebase_cotract_notSet_0.address)
await ousd.rebaseState(nonrebase_contract_notSet_0.address)
).to.equal(0); // NotSet
await ousd
.connect(rebase_eoa_notset_0)
.transfer(nonrebase_cotract_notSet_0.address, ousdUnits("10"));
.transfer(nonrebase_contract_notSet_0.address, ousdUnits("10"));
await expect(
await ousd.rebaseState(nonrebase_cotract_notSet_0.address)
await ousd.rebaseState(nonrebase_contract_notSet_0.address)
).to.equal(1); // StdNonRebasing
});

Expand Down
48 changes: 24 additions & 24 deletions contracts/test/token/token-transfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe("Account type variations", function () {
rebase_contract_1,
nonrebase_eoa_0,
nonrebase_eoa_1,
nonrebase_cotract_0,
nonrebase_cotract_1,
nonrebase_cotract_notSet_0,
nonrebase_cotract_notSet_1,
nonrebase_cotract_notSet_altcpt_gt_0,
nonrebase_cotract_notSet_altcpt_gt_1,
nonrebase_contract_0,
nonrebase_contract_1,
nonrebase_contract_notSet_0,
nonrebase_contract_notSet_1,
nonrebase_contract_notSet_altcpt_gt_0,
nonrebase_contract_notSet_altcpt_gt_1,
rebase_delegate_source_0,
rebase_delegate_source_1,
rebase_delegate_target_0,
Expand Down Expand Up @@ -59,31 +59,31 @@ describe("Account type variations", function () {
expect(await ousd.rebaseState(nonrebase_eoa_1.address)).to.equal(1); // rebaseState:StdNonRebasing
await expect(nonrebase_eoa_1).has.a.balanceOf("45", ousd);

expect(await ousd.rebaseState(nonrebase_cotract_0.address)).to.equal(1); // rebaseState:StdNonRebasing
await expect(nonrebase_cotract_0).has.a.balanceOf("55", ousd);
expect(await ousd.rebaseState(nonrebase_cotract_1.address)).to.equal(1); // rebaseState:StdNonRebasing
await expect(nonrebase_cotract_1).has.a.balanceOf("56", ousd);
expect(await ousd.rebaseState(nonrebase_contract_0.address)).to.equal(1); // rebaseState:StdNonRebasing
await expect(nonrebase_contract_0).has.a.balanceOf("55", ousd);
expect(await ousd.rebaseState(nonrebase_contract_1.address)).to.equal(1); // rebaseState:StdNonRebasing
await expect(nonrebase_contract_1).has.a.balanceOf("56", ousd);

expect(await ousd.rebaseState(nonrebase_cotract_notSet_0.address)).to.equal(
expect(await ousd.rebaseState(nonrebase_contract_notSet_0.address)).to.equal(
0
); // rebaseState:NotSet
await expect(nonrebase_cotract_notSet_0).has.a.balanceOf("0", ousd);
expect(await ousd.rebaseState(nonrebase_cotract_notSet_1.address)).to.equal(
await expect(nonrebase_contract_notSet_0).has.a.balanceOf("0", ousd);
expect(await ousd.rebaseState(nonrebase_contract_notSet_1.address)).to.equal(
0
); // rebaseState:NotSet
await expect(nonrebase_cotract_notSet_1).has.a.balanceOf("0", ousd);
await expect(nonrebase_contract_notSet_1).has.a.balanceOf("0", ousd);

expect(
await ousd.rebaseState(nonrebase_cotract_notSet_altcpt_gt_0.address)
await ousd.rebaseState(nonrebase_contract_notSet_altcpt_gt_0.address)
).to.equal(0); // rebaseState:NotSet
await expect(nonrebase_cotract_notSet_altcpt_gt_0).has.a.balanceOf(
await expect(nonrebase_contract_notSet_altcpt_gt_0).has.a.balanceOf(
"65",
ousd
);
expect(
await ousd.rebaseState(nonrebase_cotract_notSet_altcpt_gt_1.address)
await ousd.rebaseState(nonrebase_contract_notSet_altcpt_gt_1.address)
).to.equal(0); // rebaseState:NotSet
await expect(nonrebase_cotract_notSet_altcpt_gt_1).has.a.balanceOf(
await expect(nonrebase_contract_notSet_altcpt_gt_1).has.a.balanceOf(
"66",
ousd
);
Expand Down Expand Up @@ -142,20 +142,20 @@ describe("Account type variations", function () {
inYieldDelegation: false,
},
{
name: "nonrebase_cotract_0",
name: "nonrebase_contract_0",
balancePartOfRebasingCredits: false,
isContract: true,
inYieldDelegation: false,
},
{
name: "nonrebase_cotract_notSet_0",
name: "nonrebase_contract_notSet_0",
balancePartOfRebasingCredits: false,
skipTransferTest: true,
isContract: true,
inYieldDelegation: false,
},
{
name: "nonrebase_cotract_notSet_altcpt_gt_0",
name: "nonrebase_contract_notSet_altcpt_gt_0",
balancePartOfRebasingCredits: false,
isContract: true,
inYieldDelegation: false,
Expand Down Expand Up @@ -196,17 +196,17 @@ describe("Account type variations", function () {
inYieldDelegation: false,
},
{
name: "nonrebase_cotract_1",
name: "nonrebase_contract_1",
balancePartOfRebasingCredits: false,
inYieldDelegation: false,
},
{
name: "nonrebase_cotract_notSet_1",
name: "nonrebase_contract_notSet_1",
balancePartOfRebasingCredits: false,
inYieldDelegation: false,
},
{
name: "nonrebase_cotract_notSet_altcpt_gt_1",
name: "nonrebase_contract_notSet_altcpt_gt_1",
balancePartOfRebasingCredits: false,
inYieldDelegation: false,
},
Expand Down