2021-05-26 01:42:35 +00:00
|
|
|
pragma solidity ^0.7.0;
|
|
|
|
pragma experimental ABIEncoderV2;
|
2021-05-26 15:28:01 +00:00
|
|
|
|
|
|
|
import {DSMath} from "./common/math.sol";
|
2021-05-26 01:42:35 +00:00
|
|
|
|
|
|
|
interface ManagerLike {
|
2021-05-26 15:28:01 +00:00
|
|
|
function ilks(uint256) external view returns (bytes32);
|
|
|
|
|
|
|
|
function owns(uint256) external view returns (address);
|
|
|
|
|
|
|
|
function urns(uint256) external view returns (address);
|
2021-05-26 01:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface VatLike {
|
2021-05-26 15:28:01 +00:00
|
|
|
function ilks(bytes32)
|
|
|
|
external
|
|
|
|
view
|
|
|
|
returns (
|
|
|
|
uint256,
|
|
|
|
uint256,
|
|
|
|
uint256,
|
|
|
|
uint256,
|
|
|
|
uint256
|
|
|
|
);
|
|
|
|
|
|
|
|
function dai(address) external view returns (uint256);
|
|
|
|
|
|
|
|
function urns(bytes32, address) external view returns (uint256, uint256);
|
|
|
|
|
|
|
|
function gem(bytes32, address) external view returns (uint256);
|
2021-05-26 01:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface PipLike {
|
|
|
|
function peek() external view returns (bytes32, bool);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SpotLike {
|
2021-05-26 15:28:01 +00:00
|
|
|
function ilks(bytes32) external view returns (PipLike, uint256);
|
2021-05-26 01:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contract Variables {
|
2021-05-26 15:28:01 +00:00
|
|
|
ManagerLike public constant managerContract =
|
|
|
|
ManagerLike(0x5ef30b9986345249bc32d8928B7ee64DE9435E39);
|
|
|
|
SpotLike public constant spotContract =
|
|
|
|
SpotLike(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3);
|
|
|
|
VatLike public constant vatContract =
|
|
|
|
VatLike(0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B);
|
2021-05-26 01:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contract VaultResolver is Variables, DSMath {
|
|
|
|
function getOwner(uint256 id) external view returns (address owner) {
|
|
|
|
owner = managerContract.owns(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPosition(uint256 id) external view returns (uint256 networth) {
|
|
|
|
address urn = managerContract.urns(id);
|
|
|
|
bytes32 ilk = managerContract.ilks(id);
|
|
|
|
|
|
|
|
(uint256 ink, uint256 art) = vatContract.urns(ilk, urn);
|
2021-05-26 15:28:01 +00:00
|
|
|
(, uint256 rate, uint256 priceMargin, , ) = vatContract.ilks(ilk);
|
2021-05-26 01:42:35 +00:00
|
|
|
|
|
|
|
(, uint256 mat) = spotContract.ilks(ilk);
|
|
|
|
uint256 price = rmul(priceMargin, mat);
|
2021-05-26 15:28:01 +00:00
|
|
|
price = price / 1e9;
|
2021-05-26 01:42:35 +00:00
|
|
|
|
|
|
|
uint256 supply = wmul(ink, price);
|
|
|
|
uint256 borrow = rmul(art, rate);
|
|
|
|
|
|
|
|
networth = sub(supply, borrow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contract InstaMakerDAOAggregateResolver is VaultResolver {
|
|
|
|
string public constant name = "MakerDAO-Aggregate-Resolver-v1.0";
|
|
|
|
}
|