mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
Pushed common folder
This commit is contained in:
parent
e081d33521
commit
0b048fbcc1
|
@ -1,7 +1,7 @@
|
||||||
pragma solidity ^0.7.0;
|
pragma solidity ^0.7.0;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import { DSMath } from "../../../common/math.sol";
|
import { DSMath } from "../../common/math.sol";
|
||||||
|
|
||||||
interface AaveProtocolDataProvider {
|
interface AaveProtocolDataProvider {
|
||||||
function getUserAccountData(address user) external view returns (
|
function getUserAccountData(address user) external view returns (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
pragma solidity ^0.7.0;
|
pragma solidity ^0.7.0;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import { DSMath } from "../../../common/math.sol";
|
import { DSMath } from "../../common/math.sol";
|
||||||
|
|
||||||
interface CTokenInterface {
|
interface CTokenInterface {
|
||||||
function exchangeRateCurrent() external returns (uint);
|
function exchangeRateCurrent() external returns (uint);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
pragma solidity ^0.7.0;
|
pragma solidity ^0.7.0;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import { DSMath } from "../../../common/math.sol";
|
import { DSMath } from "../../common/math.sol";
|
||||||
interface ManagerLike {
|
interface ManagerLike {
|
||||||
function ilks(uint) external view returns (bytes32);
|
function ilks(uint) external view returns (bytes32);
|
||||||
function owns(uint) external view returns (address);
|
function owns(uint) external view returns (address);
|
||||||
|
|
33
contracts/common/interfaces.sol
Normal file
33
contracts/common/interfaces.sol
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
interface TokenInterface {
|
||||||
|
function approve(address, uint256) external;
|
||||||
|
function transfer(address, uint) external;
|
||||||
|
function transferFrom(address, address, uint) external;
|
||||||
|
function deposit() external payable;
|
||||||
|
function withdraw(uint) external;
|
||||||
|
function balanceOf(address) external view returns (uint);
|
||||||
|
function decimals() external view returns (uint);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MemoryInterface {
|
||||||
|
function getUint(uint id) external returns (uint num);
|
||||||
|
function setUint(uint id, uint val) external;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InstaMapping {
|
||||||
|
function cTokenMapping(address) external view returns (address);
|
||||||
|
function gemJoinMapping(bytes32) external view returns (address);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AccountInterface {
|
||||||
|
function enable(address) external;
|
||||||
|
function disable(address) external;
|
||||||
|
function isAuth(address) external view returns (bool);
|
||||||
|
function cast(
|
||||||
|
string[] calldata _targets,
|
||||||
|
bytes[] calldata _datas,
|
||||||
|
address _origin
|
||||||
|
) external payable returns (bytes32);
|
||||||
|
}
|
50
contracts/common/math.sol
Normal file
50
contracts/common/math.sol
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
|
||||||
|
|
||||||
|
contract DSMath {
|
||||||
|
uint constant WAD = 10 ** 18;
|
||||||
|
uint constant RAY = 10 ** 27;
|
||||||
|
|
||||||
|
function add(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.add(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sub(uint x, uint y) internal virtual pure returns (uint z) {
|
||||||
|
z = SafeMath.sub(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mul(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.mul(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function div(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.div(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function wmul(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.add(SafeMath.mul(x, y), WAD / 2) / WAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
function wdiv(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.add(SafeMath.mul(x, WAD), y / 2) / y;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rdiv(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.add(SafeMath.mul(x, RAY), y / 2) / y;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rmul(uint x, uint y) internal pure returns (uint z) {
|
||||||
|
z = SafeMath.add(SafeMath.mul(x, y), RAY / 2) / RAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toInt(uint x) internal pure returns (int y) {
|
||||||
|
y = int(x);
|
||||||
|
require(y >= 0, "int-overflow");
|
||||||
|
}
|
||||||
|
|
||||||
|
function toRad(uint wad) internal pure returns (uint rad) {
|
||||||
|
rad = mul(wad, 10 ** 27);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
37
contracts/common/stores-polygon.sol
Normal file
37
contracts/common/stores-polygon.sol
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
import { MemoryInterface } from "./interfaces.sol";
|
||||||
|
|
||||||
|
|
||||||
|
abstract contract Stores {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return matic address
|
||||||
|
*/
|
||||||
|
address constant internal maticAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return Wrapped MATIC address
|
||||||
|
*/
|
||||||
|
address constant internal wmaticAddr = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return memory variable address
|
||||||
|
*/
|
||||||
|
MemoryInterface constant internal instaMemory = MemoryInterface(0x6C7256cf7C003dD85683339F75DdE9971f98f2FD);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Get Uint value from InstaMemory Contract.
|
||||||
|
*/
|
||||||
|
function getUint(uint getId, uint val) internal returns (uint returnVal) {
|
||||||
|
returnVal = getId == 0 ? val : instaMemory.getUint(getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Set Uint value in InstaMemory Contract.
|
||||||
|
*/
|
||||||
|
function setUint(uint setId, uint val) virtual internal {
|
||||||
|
if (setId != 0) instaMemory.setUint(setId, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
42
contracts/common/stores.sol
Normal file
42
contracts/common/stores.sol
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
import { MemoryInterface, InstaMapping } from "./interfaces.sol";
|
||||||
|
|
||||||
|
|
||||||
|
abstract contract Stores {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return ethereum address
|
||||||
|
*/
|
||||||
|
address constant internal ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return Wrapped ETH address
|
||||||
|
*/
|
||||||
|
address constant internal wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return memory variable address
|
||||||
|
*/
|
||||||
|
MemoryInterface constant internal instaMemory = MemoryInterface(0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Return InstaDApp Mapping Addresses
|
||||||
|
*/
|
||||||
|
InstaMapping constant internal instaMapping = InstaMapping(0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Get Uint value from InstaMemory Contract.
|
||||||
|
*/
|
||||||
|
function getUint(uint getId, uint val) internal returns (uint returnVal) {
|
||||||
|
returnVal = getId == 0 ? val : instaMemory.getUint(getId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Set Uint value in InstaMemory Contract.
|
||||||
|
*/
|
||||||
|
function setUint(uint setId, uint val) virtual internal {
|
||||||
|
if (setId != 0) instaMemory.setUint(setId, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user