Skip to content

Commit

Permalink
Merge pull request #152 from yieldprotocol/feat/roll-return-values
Browse files Browse the repository at this point in the history
Roll return values
  • Loading branch information
alcueca authored Apr 26, 2021
2 parents 78e173c + d05428e commit b97013c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
7 changes: 3 additions & 4 deletions contracts/Cauldron.sol
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ contract Cauldron is AccessControl() {
function roll(bytes12 vaultId, bytes6 newSeriesId, uint128 art)
external
auth
returns (uint128)
returns (DataTypes.Vault memory vault_, DataTypes.Balances memory balances_)
{
DataTypes.Vault memory vault_ = vaults[vaultId];
vault_ = vaults[vaultId];
require (vault_.owner != address(0), "Vault not found");
DataTypes.Balances memory balances_ = balances[vaultId];
balances_ = balances[vaultId];
DataTypes.Series memory oldSeries_ = series[vault_.seriesId];
DataTypes.Series memory newSeries_ = series[newSeriesId];
require (oldSeries_.baseId == newSeries_.baseId, "Mismatched bases in series");
Expand All @@ -391,7 +391,6 @@ contract Cauldron is AccessControl() {

require(_level(vault_, balances_, newSeries_) >= 0, "Undercollateralized");
emit VaultRolled(vaultId, newSeriesId, balances_.art);
return balances_.art;
}

// ==== Accounting ====
Expand Down
8 changes: 3 additions & 5 deletions contracts/Ladle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract Ladle is AccessControl() {
} else if (operation == Operation.ROLL) {
(bytes12 vaultId, bytes6 newSeriesId, uint128 max) = abi.decode(data[i], (bytes12, bytes6, uint128));
if (cachedId != vaultId) (cachedId, vault) = (vaultId, getOwnedVault(vaultId));
/* vault = */ _roll(vaultId, vault, newSeriesId, max); // TODO: _roll must return vault and balances
(vault,) = _roll(vaultId, vault, newSeriesId, max);

} else if (operation == Operation.FORWARD_DAI_PERMIT) {
(bytes6 id, bool asset, address spender, uint256 nonce, uint256 deadline, bool allowed, uint8 v, bytes32 r, bytes32 s) =
Expand Down Expand Up @@ -286,7 +286,7 @@ contract Ladle is AccessControl() {
/// @dev Change series and debt of a vault.
function _roll(bytes12 vaultId, DataTypes.Vault memory vault, bytes6 newSeriesId, uint128 max)
private
returns (uint128)
returns (DataTypes.Vault memory, DataTypes.Balances memory)
{
DataTypes.Balances memory balances = cauldron.balances(vaultId);

Expand All @@ -309,9 +309,7 @@ contract Ladle is AccessControl() {
pool.retrieveFYToken(address(fyToken)); // Get the surplus fyToken
fyToken.burn(address(fyToken), (amt * 2) - newDebt); // Burn the surplus

cauldron.roll(vaultId, newSeriesId, newDebt); // Change the series and debt for the vault

return newDebt;
return cauldron.roll(vaultId, newSeriesId, newDebt); // Change the series and debt for the vault
}

/// @dev Move collateral and debt to the owner's vault.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@truffle/hdwallet-provider": "^1.0.40",
"@types/mocha": "^8.0.0",
"@yield-protocol/utils-v2": "^2.2.1",
"@yield-protocol/vault-interfaces": "^2.0.21",
"@yield-protocol/vault-interfaces": "^2.0.22",
"@yield-protocol/yieldspace-interfaces": "^2.0.11",
"chai": "4.2.0",
"dss-interfaces": "0.1.1",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2297,10 +2297,10 @@
ethereumjs-util "^7.0.8"
ethers "^5.0.7"

"@yield-protocol/vault-interfaces@^2.0.21":
version "2.0.21"
resolved "https://registry.yarnpkg.com/@yield-protocol/vault-interfaces/-/vault-interfaces-2.0.21.tgz#71fad6616ea3ff91fee9d39adda05c05efbb3a54"
integrity sha512-ZxzDcLdIWx+19dXzcfbPrU6m76tNpB38dfTpqowWXc6mfTJQ5lUbLF+VDSmjOqnOjj0nV1zxOA1gO2n9VyCwJQ==
"@yield-protocol/vault-interfaces@^2.0.22":
version "2.0.22"
resolved "https://registry.yarnpkg.com/@yield-protocol/vault-interfaces/-/vault-interfaces-2.0.22.tgz#24b3744d36eb6ee7d6d4634be5d5e1b3604d1ff9"
integrity sha512-QQ5o2tavhFyj5f6OWBB6np3I9paywPtw8NLR8sBLPZH4dxCcP3z9Od0aRFs3V7Ie548w7eZXOXiD8/YYlGCdYg==

"@yield-protocol/yieldspace-interfaces@^2.0.11":
version "2.0.11"
Expand Down

0 comments on commit b97013c

Please sign in to comment.