Skip to content

Commit

Permalink
Update sdk (#59)
Browse files Browse the repository at this point in the history
* feat: added debt surplus and collateral auctions (#44)

* feat: add auction route

* chore: fix some texts and add temporary surplus image

* feat: add autions to navbar

* chore: add auction types

* feat: add auction components

* feat: add temporary useAuction hook

* chore: fix surplus icon

* feat: use hook for mocked values

* fix: error loading vaults with outdated sdk

* chore: add console.error

* feat: add call to sdk for events

* feat: add more auction files

* chore: remove example values and use sdk auction call

* feat: add approve token logic, temporary disabled

* feat: add more mocked values for auction state

* fix: logs and wallet error

* fix: helper function

* chore: remove temporary values from AuctionBlock

* chore: add new temporary value on auctionModel

* chore: better mocking on the auction hook

* chore: remove temporary commented code

* chore: remove temporary commented code

* chore: remove temporary commented code in AuctionsList

* chore: add space on AuctionBlock

* feat: search surplus and debt auctions separately

* feat: update sdk

* chore: use geb hook (#52)

* feat: implement auctions data  (#54)

* chore: use geb hook

* fix: approve logic

* feat: auctions config data fetch

* feat: accounting engine data

* feat: safeEngine data

* feat: implement surplus auction data

* feat: surplus bid functionality

* feat: debt auctions

* chore: fix buy and sell decimals on useAuction

* fix: start auction logic

* feat: update user hai and kite balances

* fix: approve logic and update list after bidding

* feat: get internal values

* fix: formatNumber function

* fix: bid in debt auctions

* fix: auctionPayments logic

* feat: batch coin protocol balance (#55)

* feat: batch coin protocol balance

* feat: save fetched values

---------

Co-authored-by: Ardy <ardy@defi.sucks>

---------

Co-authored-by: shaito <shaito@defi.sucks>
Co-authored-by: shaito <106555513+0xShaito@users.noreply.github.com>

* feat: update sdk

* feat: settle auctions from the UI (#58)

* feat: use proxy when claim and fix debt error bug

* feat: settle auctions from the ui

* chore: log proxy address

* feat: update auctions after an action

* feat: fetch collateral auction data (#57)

* feat: fetch collateral auction data

* feat: implement collateral auctions section (#59)

* feat: update sdk + set empty list on change

* fix: undefined geb

* feat: auctions loading (#60)

* feat: auctions on state (#63)

* feat: auctions on state

* feat: switch statement

* feat: collateral auctions dropdown (#62)

* feat: auctions loading

* chore: temporary mocked auctions

* feat: collaterals dropdown

* feat: improve buy collateral modals

* feat: auctions on state

* feat: switch statement

* feat: update get collateral price contract

* fix: switch functions

* fix: contract variable names

* chore: update fetchCollateralAuctionData function

---------

Co-authored-by: shaito <shaito@defi.sucks>

* feat: auctions timeout (#68)

* fix: empty auctions (#65)

* fix: empty auctions

* feat: empty auctions

* feat: claiming hai and kite (#67)

* feat: get collateral data implementation (#69)

* feat: add collateralData into state

* feat: store collateral and hai input amounts

* fix: typo

* feat: get prices

* fix: typo

* feat: fill collateral auction data

* chore: update sdk

* feat: remove temporary any

* feat: initial amount

---------

Co-authored-by: shaito <shaito@defi.sucks>

* feat: collateral auction max discount time

---------

Co-authored-by: Ardy <116569704+0xArdy@users.noreply.github.com>

* feat: collateral modals (#70)

* feat: auctions timeout (#68)

* fix: empty auctions (#65)

* fix: empty auctions

* feat: empty auctions

* feat: claiming hai and kite (#67)

* feat: add collateralData into state

* feat: store collateral and hai input amounts

* fix: typo

* feat: get prices

* fix: typo

* feat: fill collateral auction data

* chore: update sdk

* feat: approval logic

* feat: collateral auction checks

* feat: update state after buy collateral

* fix: remove redundant code

* chore: remove unused code

* feat: cooldown text

* fix: cooldown text

* feat: collateral FAQ

* chore: remove comments

* chore: run prettier

* chore: update sdk

* fix: undo sellAmountParsed function changes

* fix: remove collateral conditionals on AuctionBlock component

---------

Co-authored-by: shaito <shaito@defi.sucks>
Co-authored-by: shaito <106555513+0xShaito@users.noreply.github.com>

* chore: remove staked_token things and unused variables (#71)

* feat: update state after buy collateral

* fix: remove redundant code

* chore: remove unused code

* feat: cooldown text

* fix: cooldown text

* feat: collateral FAQ

* chore: remove comments

* chore: remove staked_tokens things

* fix: remove unused vars

* chore: run prettier

* feat: optimize stone image

* feat: set isSubmitting to false when tx fails

---------

Co-authored-by: shaito <shaito@defi.sucks>
Co-authored-by: shaito <106555513+0xShaito@users.noreply.github.com>

* fix: decimals, duplicated buy rows and update branch with dev (#72)

* style: improve buttons feedback (#46)

* feat: low decimals

* feat: fix token pricing

* fix: modify safe token price + hai balance

* fix: create safe token pricing

* style: add opacity on hover in safeList, back, deposit and repay buttons

* feat: fix back button logic and set deposit as default

---------

Co-authored-by: shaito <shaito@defi.sucks>

* feat: airdrop claimer (#51)

* feat: airdrop claimer

* feat: better tx management

* fix: text

* fix: text

* fix: handle tx reject

* feat: fetch collateral auction data

* feat: implement collateral auctions section (#59)

* feat: update sdk + set empty list on change

* fix: undefined geb

* feat: auctions loading (#60)

* feat: auctions on state (#63)

* feat: auctions on state

* feat: switch statement

* feat: collateral auctions dropdown (#62)

* feat: auctions loading

* chore: temporary mocked auctions

* feat: collaterals dropdown

* feat: improve buy collateral modals

* feat: auctions on state

* feat: switch statement

* feat: update get collateral price contract

* fix: switch functions

* fix: contract variable names

* chore: update fetchCollateralAuctionData function

---------

Co-authored-by: shaito <shaito@defi.sucks>

* feat: auctions timeout (#68)

* fix: empty auctions (#65)

* fix: empty auctions

* feat: empty auctions

* feat: claiming hai and kite (#67)

* feat: add collateralData into state

* feat: store collateral and hai input amounts

* fix: typo

* feat: get prices

* fix: typo

* feat: fill collateral auction data

* chore: update sdk

* feat: approval logic

* feat: collateral auction checks

* feat: update state after buy collateral

* fix: remove redundant code

* chore: remove unused code

* feat: cooldown text

* fix: cooldown text

* feat: collateral FAQ

* chore: remove comments

* chore: remove staked_tokens things

* fix: remove unused vars

* chore: run prettier

* feat: optimize stone image

* feat: set isSubmitting to false when tx fails

* feat: remove duplicated buy items

* fix: remove more than 18 decimals on inputs

* chore: remove erc20 hai balance from coin internal balance

* chore: remove unused function

* fix: build

* fix: collateral input

* fix: remove log

* chore: rename variables

* fix: max buttons on buy collateral auctions

* fix: result values

* fix: auctions navbar on mobile

* chore: update pkg

* fix: debt bids

---------

Co-authored-by: shaito <shaito@defi.sucks>
Co-authored-by: shaito <106555513+0xShaito@users.noreply.github.com>

* chore: remove logs

---------

Co-authored-by: shaito <shaito@defi.sucks>
Co-authored-by: shaito <106555513+0xShaito@users.noreply.github.com>

* fix: modify safe inputs

* feat: updating sdk (#75)

* feat: virtually taxing collaterals before state querying (#64)

* feat: remove starter bidder and add Max texts (#78)

* feat: remove starter bidder

* feat: max texts on buy collateral modals

* feat: liquidate own safe (#77)

* feat: liquidate own safe

* feat: liquidate vault

* feat: liquidate vault

* feat: sdk

* feat: liquidate vault

* feat: liquidatable text + other hardcoded variables

* feat: pr fixes

* feat: wrap ether (#74)

* fix: modify safe inputs

* feat: wrap ether setup

* fix: close modal after deposit

* feat: use eth balance and update weth balance after wrap

* feat: leave 0.01 eth when the user click max

* feat: show eth balance on modal

* fix: remove classname

* fix: texts

* chore: rename files

* feat: better collateral auction max 

* feat: better cah max

* feat: better cah max

* feat: analytics tab 

* feat: analytics setup

* chore: remove some class names and add comments

* feat: adding batch analytics query contract

* feat: tables

* chore: remove log

* fix: list keys

* feat: use virtual analytic contract to fetch data

* fix: filter undefined contracts

* feat: adding debtAmount per collat (#82)

* feat: adding debtAmount per collat

* fix: typo

* feat: adding redemption rate query

* feat: debt column (#83)

* feat: adding debtAmount per collat

* fix: typo

* feat: adding redemption rate query

* feat: debt column

* feat: format numbers

* feat: use format function

* chore: hide locked amount

* style: cards

* style: cards width

* feat: adding descriptions to market and redemption prices

---------

Co-authored-by: Weißer Hase <wei3erHase@protonmail.com>

* feat: adding redemption rates to stats (#86)

* feat: adding partial rr to analytics script

* refactor: standarizing decoded vars declaration

* fix: typo in sol file

* feat: adding stability fee to collat analytics

* fix: typo

* feat: redemption rate cards (#87)

* feat: adding partial rr to analytics script

* refactor: standarizing decoded vars declaration

* fix: typo in sol file

* feat: adding stability fee to collat analytics

* fix: typo

* feat: redemption rate cards and remove some  unused code

* feat: add iRate, pRate and improve ststyles and code

---------

Co-authored-by: Weißer Hase <wei3erHase@protonmail.com>

* feat: bump sdk version

* feat: cleaning texts and adding cah faq 

* feat: cleaning texts and adding cah faq

* fix: rm empty

* feat: added borrow rates to collats (#88)

* feat: added borrow rates to collats

* feat: improve hai prices precision

* feat: add erc20 link in collaterals table

* feat: added button to auction debt (#91)

* feat: added button to auction debt

* fix: typos

* fix: debt amount to start auction

* fix: debt calculation

* fix: rm negative surplus

* fix: debt calculation

* fix: typo

* fix: types on useStartAuction hook

---------

Co-authored-by: Ardy <116569704+0xArdy@users.noreply.github.com>

* fix: faq typo and linter run (#93)

* fix: faq typo

* chore: run prettier

* feat: added collateral and global stats (#92)

* feat: added erc20 balance and debts

* feat: querying debt ceilings

* feat: added delayed oracle

* feat: added oracle title

* feat: improved rate multiplication calc

* feat: added collateral debt utilization

* feat: add collateralization ratio and debt utilization

* feat: querying SF in treasury

* feat: add scroll in collateral table

* feat: fix wad percentages

* feat: reordered table

* feat: add tooltips on collat table (#97)

* feat: add scroll in collateral table

* feat add tooltip on collat table

* feat: added descriptions

* fix: run prettier

---------

Co-authored-by: Weißer Hase <wei3erHase@protonmail.com>

* feat: added description and fixed typo

---------

Co-authored-by: Ardy <116569704+0xArdy@users.noreply.github.com>

* install sdk

* feat: add contract descriptions (#98)

* feat: add contract descriptions

* feat: fix contract descriptions

* fix: addressing comments in pr

---------

Co-authored-by: Weißer Hase <wei3erHase@protonmail.com>

* initial test

* fix icons

* feat: fixes for rc-1.1 (#85)

* chore: use canary release

* fix: package.json

* fix: build

* fix: build

* fix: pkg

* feat: fixing interfaces for clean deployment

* feat: add example.env file

* feat: working with linked sdk

* feat: adding lockedAmount from safe engine

* fix: fetch user safes data

* fix: solidity interfaces

* feat: redeploy airdropper

* feat: canary sdk release

* fix: cah auctions card

* fix: batch scripting

* fix: systemCoin contract description

* fix: systemCoin contract description linter

* fix: collateral bid in recent txs

* fix: stability fee calc on safes

* chore: importing sdk v1.1

---------

Co-authored-by: Weißer Hase <wei3erHase@protonmail.com>

* rename haiBalance

* cleanup 1st attempt

* Install from registry

* sdk version

* text copy

* detectNetwork type error

---------

Co-authored-by: Ardy <116569704+0xArdy@users.noreply.github.com>
Co-authored-by: shaito <shaito@defi.sucks>
Co-authored-by: shaito <106555513+0xShaito@users.noreply.github.com>
Co-authored-by: Weißer Hase <wei3erHase@protonmail.com>
  • Loading branch information
5 people committed Aug 8, 2023
1 parent 511b7f8 commit ff902e6
Show file tree
Hide file tree
Showing 61 changed files with 2,008 additions and 783 deletions.
2 changes: 2 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_NETWORK_ID = 420
REACT_APP_NETWORK_URL = https://opt-goerli.g.alchemy.com/v2/API_KEY
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
"@ethersproject/experimental": "5.4.0",
"@ethersproject/providers": "5.4.5",
"@gnosis.pm/safe-apps-web3-react": "^0.6.0",
"@hai-on-op/sdk": "0.1.1-rc.14",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.1",
"@usekeyp/od-sdk": "^1.1.0-rc.2",
"@walletconnect/web3-provider": "1.8.0",
"@web3-react/core": "^6.0.9",
"@web3-react/injected-connector": "^6.0.7",
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/TokensData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract TokensData {
tokensData[i] = TokenData(_balanceE18, _decimals);
}

// // encode return data
// encode return data
bytes memory data = abi.encode(tokensData);

// force constructor return via assembly
Expand Down
164 changes: 164 additions & 0 deletions solidity/contracts/VirtualAnalyticsData.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

uint256 constant RAY = 1e27;

interface IERC20 {
function balanceOf(address _user) external view returns (uint256 _balance);
function totalSupply() external view returns (uint256 _totalSupply);
}

interface ISAFEEngine {
struct SAFEEngineCollateralData {
uint256 /* WAD */ debtAmount;
uint256 /* WAD */ lockedAmount;
uint256 /* RAY */ accumulatedRate;
uint256 /* RAY */ safetyPrice;
uint256 /* RAY */ liquidationPrice;
}
struct SAFEEngineParams {
uint256 /* WAD */ safeDebtCeiling;
uint256 /* RAD */ globalDebtCeiling;
}
struct SAFEEngineCollateralParams {
uint256 /* RAD */ debtCeiling;
uint256 /* RAD */ debtFloor;
}
function coinBalance(address _user) external view returns (uint256 _coinBalance);
function debtBalance(address _user) external view returns (uint256 _debtBalance);
function globalDebt() external view returns (uint256 _globalDebt);
function globalUnbackedDebt() external view returns (uint256 _globalUnbackedDebt);
function cData(bytes32 _cType) external view returns (SAFEEngineCollateralData memory _cData);
function params() external view returns (SAFEEngineParams memory _params);
function cParams(bytes32 _cType) external view returns (SAFEEngineCollateralParams memory _cParams);
}

interface IBaseOracle {
function getResultWithValidity() external view returns (uint256 _result, bool _validity);
function read() external view returns (uint256 _value);
}

interface IDelayedOracle is IBaseOracle {
function priceSource() external view returns (IBaseOracle _priceSource);
function getNextResultWithValidity() external view returns (uint256 _result, bool _validity);
function lastUpdateTime() external view returns (uint256 _lastUpdateTime);
}

interface IOracleRelayer {
struct OracleRelayerCollateralParams {
IDelayedOracle oracle;
uint256 safetyCRatio;
uint256 liquidationCRatio;
}
function marketPrice() external view returns (uint256 _marketPrice);
function redemptionPrice() external returns (uint256 _redemptionPrice);
function redemptionRate() external view returns (uint256 _redemptionRate);
function cParams(bytes32 _cType) external view returns (OracleRelayerCollateralParams memory _cParams);
}

interface IPIDController {
struct DeviationObservation {
uint256 timestamp;
int256 proportional;
int256 integral;
}
function deviationObservation() external view returns (DeviationObservation memory __deviationObservation);
function getGainAdjustedPIOutput(int256 _proportionalTerm,int256 _integralTerm) external view returns (int256 _piOutput);
function getBoundedRedemptionRate(int256 _piOutput) external view returns (uint256 _redemptionRate);
}

interface ITaxCollector {
struct TaxCollectorCollateralData {
uint256 nextStabilityFee;
uint256 updateTime;
uint256 secondaryReceiverAllotedTax; // [wad%]
}
function cData(bytes32 _cType) external view returns (TaxCollectorCollateralData memory _cData);
}

contract VirtualAnalyticsData {
struct AnalyticsData {
uint256 erc20Supply;
uint256 globalDebt;
uint256 globalDebtCeiling;
uint256 globalUnbackedDebt;
uint256 marketPrice;
uint256 redemptionPrice;
uint256 redemptionRate;
uint256 redemptionRatePTerm;
uint256 redemptionRateITerm;
uint256 surplusInTreasury;
TokenAnalyticsData[] tokenData;
}

struct TokenAnalyticsData {
address delayedOracle;
uint256 debtAmount;
uint256 debtCeiling;
uint256 lockedAmount;
uint256 currentPrice;
uint256 nextPrice;
uint256 stabilityFee;
}

constructor(
IERC20 _haiToken,
ISAFEEngine _safeEngine,
IOracleRelayer _oracleRelayer,
IPIDController _pidController,
ITaxCollector _taxCollector,
address _stabilityFeeTreasury,
bytes32[] memory cTypes
) {
TokenAnalyticsData[] memory tokenAnalyticsData = new TokenAnalyticsData[](cTypes.length);
for (uint256 i = 0; i < cTypes.length; i++) {
bytes32 cType = cTypes[i];
uint256 _debtAmount = _safeEngine.cData(cType).debtAmount;
IDelayedOracle _oracle = _oracleRelayer.cParams(cType).oracle;
(uint256 _currentPrice,) = _oracle.getResultWithValidity();
(uint256 _nextPrice,) = _oracle.getNextResultWithValidity();

tokenAnalyticsData[i] = TokenAnalyticsData({
delayedOracle: address(_oracle),
debtAmount: _debtAmount,
debtCeiling: _safeEngine.cParams(cType).debtCeiling / RAY,
lockedAmount: _safeEngine.cData(cType).lockedAmount,
currentPrice: _currentPrice,
nextPrice: _nextPrice,
stabilityFee: _taxCollector.cData(cType).nextStabilityFee
});
}

IPIDController.DeviationObservation memory deviationObservation = _pidController.deviationObservation();
int256 _pOutput = _pidController.getGainAdjustedPIOutput(deviationObservation.proportional, 0);
int256 _iOutput = _pidController.getGainAdjustedPIOutput(0, deviationObservation.integral);

uint256 _surplusInTreasury =
_haiToken.balanceOf(address(_stabilityFeeTreasury)) * RAY
+ _safeEngine.coinBalance(address(_stabilityFeeTreasury))
- _safeEngine.debtBalance(address(_stabilityFeeTreasury));

AnalyticsData memory analyticsData = AnalyticsData({
erc20Supply: _haiToken.totalSupply(),
globalDebt: _safeEngine.globalDebt() / RAY,
globalDebtCeiling: _safeEngine.params().globalDebtCeiling / RAY,
globalUnbackedDebt: _safeEngine.globalUnbackedDebt() / RAY,
marketPrice: _oracleRelayer.marketPrice(),
redemptionPrice: _oracleRelayer.redemptionPrice() / 1e9,
redemptionRate: _oracleRelayer.redemptionRate(),
redemptionRatePTerm: _pidController.getBoundedRedemptionRate(_pOutput),
redemptionRateITerm: _pidController.getBoundedRedemptionRate(_iOutput),
surplusInTreasury: _surplusInTreasury / RAY,
tokenData: tokenAnalyticsData
});

// encode return data
bytes memory data = abi.encode(analyticsData);

// force constructor return via assembly
assembly {
let dataStart := add(data, 32) // abi.encode adds an additional offset
return(dataStart, sub(msize(), dataStart))
}
}
}
34 changes: 10 additions & 24 deletions solidity/contracts/VirtualAuctionsData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ interface IERC20 {

interface IAccountingEngine {
struct AccountingEngineParams {
// Whether the system transfers surplus instead of auctioning it
uint256 surplusIsTransferred;
// Delay between surplus actions
uint256 surplusDelay;
// Delay after which debt can be popped from debtQueue
uint256 popDebtDelay;
// Time to wait (post settlement) until any remaining surplus can be transferred to the settlement auctioneer
uint256 disableCooldown;
// Amount of surplus stability fees transferred or sold in one surplus auction
uint256 surplusAmount;
// Amount of stability fees that need to accrue in this contract before any surplus auction can start
uint256 surplusBuffer;
// Amount of protocol tokens to be minted post-auction
uint256 debtAuctionMintedTokens;
// Amount of debt sold in one debt auction (initial coin bid for debtAuctionMintedTokens protocol tokens)
uint256 debtAuctionBidSize;
}

Expand All @@ -42,28 +34,22 @@ interface IAccountingEngine {

interface ISurplusAuctionHouse {
struct SurplusAuctionHouseParams {
// Minimum bid increase compared to the last bid in order to take the new one in consideration
uint256 bidIncrease; // [wad]
// How long the auction lasts after a new bid is submitted
uint256 bidDuration; // [seconds]
// Total length of the auction
uint256 totalAuctionLength; // [seconds]
uint256 recyclingPercentage;
uint256 /* WAD % */ bidIncrease;
uint256 /* seconds */ bidDuration;
uint256 /* seconds */ totalAuctionLength;
address bidReceiver;
uint256 /* WAD % */ recyclingPercentage;
}

function params() external view returns (SurplusAuctionHouseParams memory _params);
}

interface IDebtAuctionHouse {
struct DebtAuctionHouseParams {
// Minimum bid increase compared to the last bid in order to take the new one in consideration
uint256 bidDecrease; // [wad]
// Increase in protocol tokens sold in case an auction is restarted
uint256 amountSoldIncrease; // [wad]
// How long the auction lasts after a new bid is submitted
uint256 bidDuration; // [seconds]
// Total length of the auction
uint256 totalAuctionLength; // [seconds]
uint256 /* WAD */ bidDecrease;
uint256 /* WAD % */ amountSoldIncrease;
uint256 /* seconds */ bidDuration;
uint256 /* seconds */ totalAuctionLength;
}

function params() external view returns (DebtAuctionHouseParams memory _params);
Expand Down Expand Up @@ -125,7 +111,7 @@ contract VirtualAuctionsData {
coinTokenSafeBalance: _safeEngine.coinBalance(_proxy)
});

// // encode return data
// encode return data
bytes memory data = abi.encode(auctionsData);

// force constructor return via assembly
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/VirtualCollateralAuctionData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract VirtualCollateralAuctionsData {
});
}

// // encode return data
// encode return data
bytes memory data = abi.encode(collateralAuctionsData);

// force constructor return via assembly
Expand Down
45 changes: 16 additions & 29 deletions solidity/contracts/VirtualLiquidationData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,21 @@ interface IOracleRelayer {

interface ISAFEEngine {
struct SAFEEngineParams {
// Total amount of debt that a single safe can generate
uint256 safeDebtCeiling; // [wad]
// Maximum amount of debt that can be issued
uint256 globalDebtCeiling; // [rad]
uint256 /* WAD */ safeDebtCeiling;
uint256 /* RAD */ globalDebtCeiling;
}

struct SAFEEngineCollateralParams {
// Maximum amount of debt that can be generated with this collateral type
uint256 debtCeiling; // [rad]
// Minimum amount of debt that must be generated by a SAFE using this collateral
uint256 debtFloor; // [rad]
uint256 /* RAD */ debtCeiling;
uint256 /* RAD */ debtFloor;
}

struct SAFEEngineCollateralData {
// Total amount of debt issued by a collateral type
uint256 debtAmount; // [wad]
// Accumulated rate of a collateral type
uint256 accumulatedRate; // [ray]
// Floor price at which a SAFE is allowed to generate debt
uint256 safetyPrice; // [ray]
// Price at which a SAFE gets liquidated
uint256 liquidationPrice; // [ray]
uint256 /* WAD */ debtAmount;
uint256 /* WAD */ lockedAmount;
uint256 /* RAY */ accumulatedRate;
uint256 /* RAY */ safetyPrice;
uint256 /* RAY */ liquidationPrice;
}

function globalDebt() external view returns (uint256);
Expand All @@ -59,18 +52,13 @@ interface ILiquidationEngine {
}

interface ITaxCollector {
struct TaxCollectorParams {
address primaryTaxReceiver;
uint256 globalStabilityFee;
uint256 maxSecondaryReceivers;
struct TaxCollectorCollateralData {
uint256 /* RAY */ nextStabilityFee;
uint256 updateTime;
uint256 /* WAD % */ secondaryReceiverAllotedTax;
}

struct TaxCollectorCollateralParams {
uint256 stabilityFee;
}

function params() external view returns (TaxCollectorParams memory);
function cParams(bytes32) external view returns (TaxCollectorCollateralParams memory);
function cData(bytes32) external view returns (TaxCollectorCollateralData memory);
function taxSingle(bytes32) external;
}

Expand Down Expand Up @@ -113,8 +101,7 @@ contract VirtualLiquidationData {
IOracleRelayer.OracleRelayerCollateralParams memory _oracleRelayerCParams = oracleRelayer.cParams(cType);
ILiquidationEngine.LiquidationEngineCollateralParams memory _liquidationEngineCParams =
liquidationEngine.cParams(cType);
ITaxCollector.TaxCollectorParams memory _taxCollectorParams = taxCollector.params();
ITaxCollector.TaxCollectorCollateralParams memory _taxCollectorCParams = taxCollector.cParams(cType);
ITaxCollector.TaxCollectorCollateralData memory _taxCollectorCData = taxCollector.cData(cType);

tokenLiquidationData[i] = TokenLiquidationData({
accumulatedRate: _safeEngineCData.accumulatedRate,
Expand All @@ -124,7 +111,7 @@ contract VirtualLiquidationData {
safetyCRatio: _oracleRelayerCParams.safetyCRatio,
liquidationCRatio: _oracleRelayerCParams.liquidationCRatio,
liquidationPenalty: _liquidationEngineCParams.liquidationPenalty,
stabilityFee: _taxCollectorParams.globalStabilityFee + _taxCollectorCParams.stabilityFee
stabilityFee: _taxCollectorCData.nextStabilityFee
});
}

Expand Down
Loading

0 comments on commit ff902e6

Please sign in to comment.