This contract's source code is verified! Compiler
0.6.12+commit.27d51765
File 1 of 6: IERC20.sol
pragma solidity >=0.6.0 <0.8.0;
interface IERC20 {
function totalSupply ( ) external view returns (uint256 ) ;
function balanceOf (address account ) external view returns (uint256 ) ;
function transfer (address recipient, uint256 amount ) external returns (bool ) ;
function allowance (address owner, address spender ) external view returns (uint256 ) ;
function approve (address spender, uint256 amount ) external returns (bool ) ;
function transferFrom (address sender, address recipient, uint256 amount ) external returns (bool ) ;
event Transfer (address indexed from , address indexed to, uint256 value ) ;
event Approval (address indexed owner, address indexed spender, uint256 value ) ;
}
File 2 of 6: IFundV3.sol
pragma solidity >=0.6.10 <0.8.0;
pragma experimental ABIEncoderV2 ;
import "./ITwapOracleV2.sol" ;
interface IFundV3 {
struct Rebalance {
uint256 ratioB2Q;
uint256 ratioR2Q;
uint256 ratioBR;
uint256 timestamp;
}
function tokenUnderlying ( ) external view returns (address ) ;
function tokenQ ( ) external view returns (address ) ;
function tokenB ( ) external view returns (address ) ;
function tokenR ( ) external view returns (address ) ;
function tokenShare (uint256 tranche ) external view returns (address ) ;
function primaryMarket ( ) external view returns (address ) ;
function primaryMarketUpdateProposal ( ) external view returns (address , uint256 ) ;
function strategy ( ) external view returns (address ) ;
function strategyUpdateProposal ( ) external view returns (address , uint256 ) ;
function underlyingDecimalMultiplier ( ) external view returns (uint256 ) ;
function twapOracle ( ) external view returns (ITwapOracleV2 ) ;
function feeCollector ( ) external view returns (address ) ;
function endOfDay (uint256 timestamp ) external pure returns (uint256 ) ;
function trancheTotalSupply (uint256 tranche ) external view returns (uint256 ) ;
function trancheBalanceOf (uint256 tranche, address account ) external view returns (uint256 ) ;
function trancheAllBalanceOf (address account ) external view returns (uint256 , uint256 , uint256 ) ;
function trancheBalanceVersion (address account ) external view returns (uint256 ) ;
function trancheAllowance (
uint256 tranche,
address owner,
address spender
) external view returns (uint256 ) ;
function trancheAllowanceVersion (
address owner,
address spender
) external view returns (uint256 ) ;
function trancheTransfer (
uint256 tranche,
address recipient,
uint256 amount,
uint256 version
) external ;
function trancheTransferFrom (
uint256 tranche,
address sender,
address recipient,
uint256 amount,
uint256 version
) external ;
function trancheApprove (
uint256 tranche,
address spender,
uint256 amount,
uint256 version
) external ;
function getRebalanceSize ( ) external view returns (uint256 ) ;
function getRebalance (uint256 index ) external view returns (Rebalance memory ) ;
function getRebalanceTimestamp (uint256 index ) external view returns (uint256 ) ;
function currentDay ( ) external view returns (uint256 ) ;
function splitRatio ( ) external view returns (uint256 ) ;
function historicalSplitRatio (uint256 version ) external view returns (uint256 ) ;
function fundActivityStartTime ( ) external view returns (uint256 ) ;
function isFundActive (uint256 timestamp ) external view returns (bool ) ;
function getEquivalentTotalB ( ) external view returns (uint256 ) ;
function getEquivalentTotalQ ( ) external view returns (uint256 ) ;
function historicalEquivalentTotalB (uint256 timestamp ) external view returns (uint256 ) ;
function historicalNavs (uint256 timestamp ) external view returns (uint256 navB, uint256 navR ) ;
function extrapolateNav (uint256 price ) external view returns (uint256 , uint256 , uint256 ) ;
function doRebalance (
uint256 amountQ,
uint256 amountB,
uint256 amountR,
uint256 index
) external view returns (uint256 newAmountQ, uint256 newAmountB, uint256 newAmountR ) ;
function batchRebalance (
uint256 amountQ,
uint256 amountB,
uint256 amountR,
uint256 fromIndex,
uint256 toIndex
) external view returns (uint256 newAmountQ, uint256 newAmountB, uint256 newAmountR ) ;
function refreshBalance (address account, uint256 targetVersion ) external ;
function refreshAllowance (address owner, address spender, uint256 targetVersion ) external ;
function shareTransfer (address sender, address recipient, uint256 amount ) external ;
function shareTransferFrom (
address spender,
address sender,
address recipient,
uint256 amount
) external returns (uint256 newAllowance ) ;
function shareIncreaseAllowance (
address sender,
address spender,
uint256 addedValue
) external returns (uint256 newAllowance ) ;
function shareDecreaseAllowance (
address sender,
address spender,
uint256 subtractedValue
) external returns (uint256 newAllowance ) ;
function shareApprove (address owner, address spender, uint256 amount ) external ;
function historicalUnderlying (uint256 timestamp ) external view returns (uint256 ) ;
function getTotalUnderlying ( ) external view returns (uint256 ) ;
function getStrategyUnderlying ( ) external view returns (uint256 ) ;
function getTotalDebt ( ) external view returns (uint256 ) ;
event RebalanceTriggered (
uint256 indexed index,
uint256 indexed day,
uint256 navSum,
uint256 navB,
uint256 navROrZero,
uint256 ratioB2Q,
uint256 ratioR2Q,
uint256 ratioBR
) ;
event Settled (uint256 indexed day, uint256 navB, uint256 navR, uint256 interestRate ) ;
event InterestRateUpdated (uint256 baseInterestRate, uint256 floatingInterestRate ) ;
event BalancesRebalanced (
address indexed account,
uint256 version,
uint256 balanceQ,
uint256 balanceB,
uint256 balanceR
) ;
event AllowancesRebalanced (
address indexed owner,
address indexed spender,
uint256 version,
uint256 allowanceQ,
uint256 allowanceB,
uint256 allowanceR
) ;
}
File 3 of 6: IShareV2.sol
pragma solidity >=0.6.10 <0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol" ;
interface IShareV2 is IERC20 {
function fundEmitTransfer (address sender, address recipient, uint256 amount ) external ;
function fundEmitApproval (address owner, address spender, uint256 amount ) external ;
}
File 4 of 6: ITwapOracle.sol
pragma solidity >=0.6.10 <0.8.0;
interface ITwapOracle {
enum UpdateType {
PRIMARY,
SECONDARY,
OWNER,
CHAINLINK,
UNISWAP_V2
}
function getTwap (uint256 timestamp ) external view returns (uint256 ) ;
}
File 5 of 6: ITwapOracleV2.sol
pragma solidity >=0.6.10 <0.8.0;
import "./ITwapOracle.sol" ;
interface ITwapOracleV2 is ITwapOracle {
function getLatest ( ) external view returns (uint256 ) ;
}
File 6 of 6: ShareV2.sol
pragma solidity >=0.6.10 <0.8.0;
import "../interfaces/IFundV3.sol" ;
import "../interfaces/IShareV2.sol" ;
contract ShareV2 is IShareV2 {
uint8 public constant decimals = 18 ;
IFundV3 public immutable fund;
uint256 public immutable tranche;
string public name;
string public symbol;
constructor (
string memory name_,
string memory symbol_,
address fund_,
uint256 tranche_
) public {
name = name_;
symbol = symbol_;
fund = IFundV3(fund_);
tranche = tranche_;
}
function totalSupply ( ) external view override returns (uint256 ) {
return fund.trancheTotalSupply(tranche);
}
function balanceOf (address account ) external view override returns (uint256 ) {
return fund.trancheBalanceOf(tranche, account);
}
function transfer (address recipient, uint256 amount ) external override returns (bool ) {
fund.shareTransfer(msg .sender , recipient, amount);
return true ;
}
function allowance (address owner, address spender ) external view override returns (uint256 ) {
return fund.trancheAllowance(tranche, owner, spender);
}
function approve (address spender, uint256 amount ) external override returns (bool ) {
fund.shareApprove(msg .sender , spender, amount);
return true ;
}
function transferFrom (
address sender,
address recipient,
uint256 amount
) external override returns (bool ) {
fund.shareTransferFrom(msg .sender , sender, recipient, amount);
return true ;
}
function increaseAllowance (address spender, uint256 addedValue ) external returns (bool ) {
fund.shareIncreaseAllowance(msg .sender , spender, addedValue);
return true ;
}
function decreaseAllowance (address spender, uint256 subtractedValue ) external returns (bool ) {
fund.shareDecreaseAllowance(msg .sender , spender, subtractedValue);
return true ;
}
modifier onlyFund ( ) {
require (msg .sender = = address (fund), "Only fund" );
_ ;
}
function fundEmitTransfer (
address sender,
address recipient,
uint256 amount
) external override onlyFund {
emit Transfer(sender, recipient, amount);
}
function fundEmitApproval (
address owner,
address spender,
uint256 amount
) external override onlyFund {
emit Approval(owner, spender, amount);
}
}
{
"compilationTarget" : {
"contracts/fund/ShareV2.sol" : "ShareV2"
} ,
"evmVersion" : "istanbul" ,
"libraries" : { } ,
"metadata" : {
"bytecodeHash" : "ipfs"
} ,
"optimizer" : {
"enabled" : true ,
"runs" : 200
} ,
"remappings" : [ ]
} [{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"address","name":"fund_","type":"address"},{"internalType":"uint256","name":"tranche_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fund","outputs":[{"internalType":"contract IFundV3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fundEmitApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fundEmitTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tranche","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]