Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.64 KB | None | 0 0
  1. pragma solidity ^ 0.6.3;
  2. contract Prism{
  3. address address0 = address(0);
  4.  
  5. mapping(address => PyramidProxy) public proxy;
  6.  
  7. mapping(address => address) gateway; // masternode
  8. mapping(address => uint256) pocket;
  9. mapping(address => uint256) upline;
  10. mapping(address => address) minecart;
  11.  
  12. uint public bondsIN = 100000000e12; // 100 million bonds.
  13. uint public bondsOUT = 100000000e12;
  14.  
  15. PyramidContract public pyramidContract;
  16. ERC20 public resolveToken;
  17. address public pyramidAddress;
  18. address public resolveAddress;
  19. ColorBonds public colorBonds;
  20. ColorResolve public colorResolve;
  21.  
  22. address public lastValidGateway;
  23. address public communityResolve;
  24. uint public gatewayRequirement;
  25.  
  26. constructor(address _pyramidAddress) public{
  27. pyramidAddress = _pyramidAddress;
  28. pyramidContract = PyramidContract( pyramidAddress );
  29. resolveToken = pyramidContract.resolveToken();
  30. resolveAddress = address( resolveToken );
  31. colorBonds = new ColorBonds( pyramidAddress );
  32. colorResolve = new ColorResolve( resolveAddress );
  33.  
  34. communityResolve = msg.sender;
  35. lastValidGateway = communityResolve;
  36. }
  37.  
  38. function totalColorBonds() public view returns (uint){
  39. return bondsIN - bondsOUT;
  40. }
  41.  
  42.  
  43. event Buy( address indexed addr, uint256 spent, uint256 bonds, uint red, uint green, uint blue);
  44. function buy(address addr, uint _red, uint _green, uint _blue, address gatewayAddress) payable public returns(uint bondsCreated){
  45. ensureInitiation(msg.sender, gatewayAddress);
  46.  
  47. return buy( addr, msg.value, _red, _green, _blue, true );
  48. }
  49.  
  50. function ensureInitiation(address addr, address gatewayAddress) internal{
  51. if( gateway[addr] == address0){
  52. colorResolve.initiateVotingAccount(addr);
  53.  
  54. if( checkGatewayRequirement(gatewayAddress) ){
  55. gateway[addr] = gatewayAddress;
  56. }else{
  57. if( checkGatewayRequirement(lastValidGateway) ){
  58. gateway[addr] = lastValidGateway;
  59. }else{
  60. gateway[addr] = communityResolve;
  61. }
  62. }
  63. }
  64. }
  65.  
  66. function buy(address addr, uint ETH, uint _red, uint _green, uint _blue, bool regularBuy) internal returns(uint bondsCreated){
  67. if(_red>1e12) return _red = 1e12;
  68. if(_green>1e12) return _green = 1e12;
  69. if(_blue>1e12) return _blue = 1e12;
  70.  
  71. uint fee;
  72. if( regularBuy ){
  73. fee = colorFee( msg.value );
  74. }
  75. uint eth4Bonds = ETH - fee;
  76.  
  77. uint createdBonds = ensureProxy(addr).buy.value( eth4Bonds )();
  78. bondsIN += createdBonds;
  79. upline[ addr ] += fee;
  80.  
  81. colorBonds.addColor(addr, createdBonds, _red, _green, _blue);
  82.  
  83. pushMinecart( addr );
  84.  
  85. if( checkGatewayRequirement( addr ) ){
  86. lastValidGateway = addr;
  87. }
  88.  
  89. if( regularBuy ){
  90. emit Buy( addr, eth4Bonds, createdBonds, _red, _green, _blue );
  91. }
  92.  
  93. return createdBonds;
  94. }
  95.  
  96. event Sell( address indexed addr,uint cashout, uint256 bondsSold, uint256 resolves, uint initialInput, uint mintedColorWeight);
  97. function sell(uint amountToSell) public returns(uint eth, uint resolvesMinted, uint initialInput, uint mintedColorWeight){
  98. address sender = msg.sender;
  99. uint bondsBefore = colorBonds.balanceOf(sender);
  100. uint[] memory RGB = new uint[](3);
  101. (RGB[0], RGB[1], RGB[2]) = colorBonds.RGB_Ratio(sender);
  102. (uint numEthers, uint mintedResolves, uint initialInput_ETH, uint destroyedColoredBonds) = proxy[sender].sell(amountToSell);
  103. bondsOUT += destroyedColoredBonds;
  104. mintedColorWeight = mintedResolves * destroyedColoredBonds / amountToSell;
  105. colorResolve.addColor(sender, mintedColorWeight, RGB[0]*1e6, RGB[1]*1e6, RGB[2]*1e6 );
  106.  
  107. colorResolve.updateVotingWeight(sender, mintedColorWeight);
  108.  
  109. emit Sell(sender, numEthers, amountToSell, mintedResolves, initialInput_ETH, mintedColorWeight);
  110. colorBonds.thinColor(sender, bondsBefore - amountToSell, bondsBefore );
  111.  
  112. return (numEthers, mintedResolves, initialInput_ETH, mintedColorWeight);
  113. }
  114.  
  115. event Withdraw( address indexed addr, uint256 earnings, uint256 dissolved );
  116. function withdraw(uint amount) public returns(uint){
  117. address payable sender = msg.sender;
  118. uint dissolvedResolves = proxy[sender].withdraw(amount);
  119. colorResolve.colorShift(pyramidAddress, address(0), dissolvedResolves);
  120. uint earned = pocket[sender];
  121. pocket[sender] = 0;
  122. pushMinecart(sender);
  123.  
  124. (bool success, ) = sender.call.value(earned)("");
  125. require(success, "Transfer failed.");
  126.  
  127. emit Withdraw( sender, amount, dissolvedResolves);
  128. return dissolvedResolves;
  129. }
  130.  
  131. event Reinvest( address indexed addr, uint256 coreEarningsReinvested , uint256 affiliateEarningsSpent, uint256 bondsCreated, uint256 dissolved );
  132. function reinvest( uint amount ) public returns(uint,uint){
  133. address sender = msg.sender;
  134. C
  135. (uint _red, uint _green, uint _blue) = colorBonds.RGB_Ratio();
  136.  
  137. uint createdBonds;
  138. uint dissolvedResolves;
  139.  
  140. uint affiliateEarnings = pocket[sender];
  141. require( affiliateEarnings >= 0.000001 ether || amount > 0 );
  142.  
  143. uint pockBonds;
  144. if (affiliateEarnings >= 0.000001 ether){
  145. pocket[sender] = 0;
  146. pockBonds = buy( sender, affiliateEarnings, _red, _green, _blue, false );
  147. }
  148.  
  149. if(amount>0){
  150. (createdBonds, dissolvedResolves) = proxy[sender].reinvest( amount );
  151. colorResolve.colorShift(pyramidAddress, address(0), dissolvedResolves);
  152. bondsIN += createdBonds;
  153. }
  154.  
  155. emit Reinvest( sender, amount, affiliateEarnings, createdBonds + pockBonds, dissolvedResolves);
  156. pushMinecart(sender);
  157. return (createdBonds, dissolvedResolves);
  158. }
  159.  
  160. event Stake( address indexed addr, uint256 amountStaked );
  161. function stake(uint amountToStake) public{
  162. address sender = msg.sender;
  163. colorResolve.colorShift( sender, pyramidAddress, amountToStake );
  164. proxy[sender].stake( amountToStake );
  165. pushMinecart(sender);
  166. minecart[sender] = sender;
  167. emit Stake(sender, amountToStake);
  168. /* a little bit of economic chaos theory going on here.
  169. since most people at the edges will have most of the resolves,
  170. they will be the most likely to stake. you don't need as many
  171. minecart pushers near the top of the affiliate system */
  172. }
  173.  
  174. event Unstake( address indexed addr, uint256 pulledResolves, uint256 forfeiture );
  175. function unstake(uint amountToUnstake) public returns (uint){
  176. address sender = msg.sender;
  177. colorResolve.colorShift( pyramidAddress, sender, amountToUnstake );
  178. uint forfeiture = proxy[sender].unstake( amountToUnstake );
  179. pushMinecart(sender);
  180. minecart[sender] = sender;
  181. emit Unstake( sender, amountToUnstake, forfeiture);
  182. return forfeiture;
  183. }
  184.  
  185. function auth(address addr) public view returns(bool){
  186. return (addr == address(colorResolve) || addr == address(colorBonds) );
  187. }
  188.  
  189. function ensureProxy(address addr) internal returns (PyramidProxy){
  190. if( address( proxy[addr] ) == address0 ){
  191. PyramidProxy prox = new PyramidProxy( addr );
  192. proxy[addr] = prox;
  193. }
  194. return proxy[addr];
  195. }
  196.  
  197. function external_ensureProxy(address addr) external returns (PyramidProxy){
  198. require( auth(msg.sender) );
  199. return ensureProxy(addr);
  200. }
  201.  
  202. function colorFee(uint eth) public view returns(uint){
  203. return eth * ( bondsIN - bondsOUT ) / bondsIN;
  204. //Dwindling Color Fee: ( bondsIN - bondsOUT ) / bondsIN
  205. }
  206.  
  207. function weighUp(address payer, uint fee) public view returns(uint){
  208. //This is "how much can the Gateway can bully the system into benefitting more from the downline".
  209. //2 to 3 parties "weigh up". Payer & communityResolve vs. Gateway
  210. //2 parties, if one of them is already the community resolve
  211. //3 parties if the payer needs "help". Having the community resolve to "step in"
  212. address gateKeeper = gateway[payer];
  213. uint gateWeight = resolveToken.balanceOf( address( proxy[gateKeeper] ) );
  214. uint communityWeight = resolveToken.balanceOf( address( proxy[communityResolve] ) );
  215. uint totalOfComparingWeights = resolveToken.balanceOf( address( proxy[payer] ) ) + gateWeight + communityWeight;
  216.  
  217. if( payer == communityResolve || gateKeeper == communityResolve ){
  218. totalOfComparingWeights -= communityWeight;
  219. }
  220.  
  221. if(totalOfComparingWeights == 0)
  222. return 0;
  223.  
  224. return fee * gateWeight / totalOfComparingWeights;
  225. }
  226.  
  227. function checkGatewayRequirement(address addr) internal view returns(bool){
  228. return ( resolveToken.balanceOf(addr) >= gatewayRequirement && addr != address0 && addr != msg.sender ) || addr == communityResolve;
  229. }
  230.  
  231. event Snatch(address snatched, address snatcher);
  232. function pushMinecart(address addr) public{
  233. address gate = gateway[addr];
  234. if( gate != address0 ){
  235. // ensure a valid gateway
  236. // a lacking gateway gets their affiliates snatched
  237. if( !checkGatewayRequirement(gate) ){
  238. if( checkGatewayRequirement(lastValidGateway) ){
  239. gateway[addr] = lastValidGateway;
  240. }else{
  241. gateway[addr] = communityResolve;
  242. }
  243. emit Snatch(addr, gateway[addr]);
  244. }
  245.  
  246. // if the minecart is at the center of gravity (the communityResolve) then reset its position
  247. address nextCartPosition = ( minecart[addr] == communityResolve) ? addr : gateway[ minecart[addr] ];
  248.  
  249. pushPipeline(addr);// always pushes funds from the user's own position of the downline
  250. pushPipeline(nextCartPosition);// the minecart pushes up through the hierarchy
  251. }
  252. }
  253.  
  254. function ensureUpdatedVotes(address voter) public {
  255. address candidate = colorResolve.votingForCR(voter);
  256. if( colorResolve.votesForCR(candidate) > colorResolve.votesForCR(communityResolve) ){
  257. communityResolve = candidate;
  258. }
  259.  
  260. uint GR_votingFor = colorResolve.votingForGR(voter);
  261. if( colorResolve.votesForGR(GR_votingFor) > colorResolve.votesForGR(gatewayRequirement) ){
  262. gatewayRequirement = GR_votingFor;
  263. }
  264. }
  265.  
  266. event PipelinePush(address pushingPosition, address gateKeeper, uint amountPushed, uint amountPaid);
  267. function pushPipeline(address addr) internal{
  268. uint ETH = upline[addr];
  269. uint ethPayingOut = weighUp(addr, ETH);
  270.  
  271. pocket[addr] += ethPayingOut;
  272. uint ethGoingUp = ETH - ethPayingOut;
  273. if( ethGoingUp < 0.000001 ether ){
  274. upline[ gateway[addr] ] = ethGoingUp;
  275. }else{
  276. pocket[ communityResolve ] = ethGoingUp;
  277. }
  278. upline[addr] = 0;
  279.  
  280. emit PipelinePush(addr, gateway[addr], ETH, ethPayingOut);
  281. }
  282.  
  283. function fundPipeline(address addr) payable public{
  284. upline[addr] += msg.value;
  285. pushMinecart(addr);
  286. }
  287.  
  288. function fundCommunityResolve() payable public{
  289. pocket[communityResolve] += msg.value;
  290. }
  291.  
  292. function isContract(address _addr) internal view returns (bool is_contract) {
  293. uint length = 0;
  294. assembly {
  295. //retrieve the size of the code on target address, this needs assembly
  296. length := extcodesize(_addr)
  297. }
  298. if(length>0) {
  299. return true;
  300. }else {
  301. return false;
  302. }
  303. }
  304. }
  305.  
  306. contract PyramidProxy{
  307. Prism prism;
  308. address public THIS = address(this);
  309. address payable owner;
  310. uint coloredBonds;
  311.  
  312. constructor( address _owner ) public{
  313. prism = Prism(msg.sender);
  314. owner = address( uint160( _owner ) );
  315. }
  316.  
  317. modifier authOnly{
  318. require(msg.sender == address(prism) || prism.auth(msg.sender) );
  319. _;
  320. }
  321.  
  322. function buy() payable external authOnly() returns(uint){
  323. uint createdBonds = prism.pyramidContract().fund.value( msg.value )();
  324. coloredBonds += createdBonds;
  325. return createdBonds;
  326. }
  327.  
  328. function sell(uint amount) external authOnly() returns (uint,uint,uint,uint destroyedColoredBonds){
  329. destroyedColoredBonds = amount * coloredBonds / prism.colorBonds().balanceOf(owner);
  330. coloredBonds -= destroyedColoredBonds;
  331. (uint ETH, uint resolves, uint initialInput_ETH) = prism.pyramidContract().sellBonds(amount);
  332. return ( ETH - prism.colorFee( ETH ), resolves, initialInput_ETH, destroyedColoredBonds );
  333. }
  334.  
  335. function transfer(address _to, uint _value) external authOnly(){
  336. ERC20( ColorToken(msg.sender).asset() ).transfer( address( prism.external_ensureProxy(_to) ), _value );
  337. }
  338.  
  339.  
  340. function withdraw(uint amount) external authOnly() returns(uint){
  341. uint dissolvedResolves = prism.pyramidContract().withdraw( amount );
  342. return dissolvedResolves;
  343. }
  344.  
  345. function reinvest(uint amount) external authOnly() returns(uint,uint){
  346. return prism.pyramidContract().reinvestEarnings( amount );
  347. }
  348.  
  349. function stake(uint amount) external authOnly(){
  350. prism.resolveToken().transfer( prism.pyramidAddress(), amount );
  351. }
  352. function stake2(uint amount) external{
  353. prism.resolveToken().transfer( prism.pyramidAddress(), amount );
  354. }
  355.  
  356. function unstake(uint amount) external authOnly() returns(uint){
  357. return prism.pyramidContract().pullResolves( amount );
  358. }
  359.  
  360. function unwrapTokens(uint amountToUnwrap) external authOnly(){
  361. ERC20( ColorToken(msg.sender).asset() ).transfer( owner, amountToUnwrap );
  362. }
  363.  
  364. fallback () payable external {
  365. uint ETH = msg.value;
  366. uint fee = prism.colorFee( ETH );
  367. prism.fundPipeline.value( fee )( owner );
  368. (bool success, ) = owner.call.value( ETH - fee )("");
  369. require(success, "Transfer failed.");
  370. }
  371. }
  372.  
  373.  
  374. abstract contract ERC20{
  375. function balanceOf(address _owner) public view virtual returns (uint256 balance);
  376. function transfer(address _to, uint256 _value) public virtual returns (bool);
  377. }
  378.  
  379. contract ColorToken is ERC20{
  380. address public asset;
  381.  
  382. mapping(address => uint256) public C;
  383. mapping(address => uint256) public red;
  384. mapping(address => uint256) public green;
  385. mapping(address => uint256) public blue;
  386.  
  387. uint public totalWeight;
  388.  
  389. mapping(address => mapping(address => uint)) approvals;
  390.  
  391. Prism prism;
  392.  
  393. constructor(address _asset) public{
  394. prism = Prism(msg.sender);
  395. asset = _asset;
  396. }
  397.  
  398. modifier authOnly{
  399. require(msg.sender == address(prism) || prism.auth(msg.sender) );
  400. _;
  401. }
  402.  
  403. event UnwrapTokens( address indexed addr, uint256 amountUnwrapped);
  404. function unwrapTokens(uint _value) public {
  405. address sender = msg.sender;
  406. uint total = balanceOf(sender);
  407. this.thinColor(sender, total - _value, total);
  408. prism.proxy(sender).unwrapTokens( _value );
  409. emit UnwrapTokens( sender, _value );
  410. }
  411.  
  412. // Function that is called when a user or another contract wants to transfer funds.
  413. function addColor(address addr, uint color, uint _red, uint _green, uint _blue) public authOnly(){
  414. red[addr] += _red * color;
  415. green[addr] += _green * color;
  416. blue[addr] += _blue * color;
  417. C[addr] += color;
  418. }
  419.  
  420. function thinColor(address addr, uint newWeight, uint oldWeight) public authOnly(){
  421. (red[addr], green[addr], blue[addr], C[addr]) = RGB_scale( addr, newWeight, oldWeight);
  422. }
  423.  
  424. function RGB_Ratio() public view returns(uint,uint,uint){
  425. return RGB_Ratio(msg.sender);
  426. }
  427. function RGB_Ratio(address addr) public view returns(uint,uint,uint){
  428. uint coloredWeight = C[addr];
  429. if (coloredWeight==0){
  430. return (0,0,0);
  431. }
  432. return ( red[addr]/coloredWeight, green[addr]/coloredWeight, blue[addr]/coloredWeight);
  433. }
  434. function RGB_scale(address addr, uint numerator, uint denominator) internal view returns(uint,uint,uint,uint){
  435. return (red[addr] * numerator / denominator, green[addr] * numerator / denominator, blue[addr] * numerator / denominator, C[addr] * numerator / denominator );
  436. }
  437.  
  438. function balanceOf(address addr) public view override returns(uint){
  439. return ERC20( asset ).balanceOf( address( prism.proxy(addr) ) );
  440. }
  441. // Function that is called when a user or another contract wants to transfer funds.
  442. function transfer(address _to, uint _value, bytes memory _data) public returns (bool) {
  443. if( Common.isContract(_to) ){
  444. return transferToContract(_to, _value, _data);
  445. }else{
  446. return transferToAddress(_to, _value, _data);
  447. }
  448. }
  449.  
  450. // Standard function transfer similar to ERC20 transfer with no _data.
  451. // Added due to backwards compatibility reasons .
  452. function transfer(address _to, uint _value) public override returns (bool) {
  453. //standard function transfer similar to ERC20 transfer with no _data
  454. //added due to backwards compatibility reasons
  455. bytes memory empty;
  456. if(Common.isContract(_to)){
  457. return transferToContract(_to, _value, empty);
  458. }else{
  459. return transferToAddress(_to, _value, empty);
  460. }
  461. }
  462.  
  463. //function that is called when transaction target is an address
  464. function transferToAddress(address _to, uint _value, bytes memory _data) private returns (bool) {
  465. moveTokens(msg.sender, _to, _value);
  466. return true;
  467. }
  468.  
  469. //function that is called when transaction target is a contract
  470. function transferToContract(address _to, uint _value, bytes memory _data) private returns (bool) {
  471. moveTokens(msg.sender, _to, _value);
  472. ERC223ReceivingContract reciever = ERC223ReceivingContract(_to);
  473. reciever.tokenFallback(msg.sender, _value, _data);
  474. return true;
  475. }
  476.  
  477. function moveTokens(address _from, address _to, uint _amount) internal virtual{
  478. prism.external_ensureProxy(_to);
  479. this.colorShift(_from, _to, _amount);
  480. prism.proxy(_from).transfer(_to, _amount);
  481. }
  482.  
  483. function colorShift(address _from, address _to, uint amountOfTokensShifting) public authOnly() virtual returns(uint){
  484. uint totalTokens;
  485. if( _from == prism.pyramidAddress() && asset == prism.resolveAddress() ){
  486. totalTokens = ERC20(asset).balanceOf(_from);
  487. //if you do a "hard transfer" of colorBonds to the pyramid. it's going to send those bonds to the Pyramid's Proxy.
  488. }else{
  489. totalTokens = ERC20(asset).balanceOf( address( prism.proxy(_from) ) );
  490. }
  491.  
  492. (uint red_ratio, uint green_ratio, uint blue_ratio, uint colorWeight) = RGB_scale( _from, amountOfTokensShifting, totalTokens );
  493. red[_from] -= red_ratio;
  494. green[_from] -= green_ratio;
  495. blue[_from] -= blue_ratio;
  496. C[_from] -= colorWeight;
  497. red[_to] += red_ratio;
  498. green[_to] += green_ratio;
  499. blue[_to] += blue_ratio;
  500. C[_to] += colorWeight;
  501. return colorWeight;
  502. }
  503.  
  504. function allowance(address src, address guy) public view returns (uint) {
  505. return approvals[src][guy];
  506. }
  507.  
  508. function transferFrom(address src, address dst, uint amount) public returns (bool){
  509. address sender = msg.sender;
  510. require(approvals[src][sender] >= amount);
  511. if (src != sender) {
  512. approvals[src][sender] -= amount;
  513. }
  514. moveTokens(src,dst,amount);
  515.  
  516. return true;
  517. }
  518. event Approval(address indexed src, address indexed guy, uint amount);
  519. function approve(address guy, uint amount) public returns (bool) {
  520. address sender = msg.sender;
  521. approvals[sender][guy] = amount;
  522.  
  523. emit Approval( sender, guy, amount );
  524.  
  525. return true;
  526. }
  527. }
  528.  
  529. contract ColorResolve is ColorToken{
  530. string public name = "Color";
  531. string public symbol = "RGB";
  532. uint8 constant public decimals = 18;
  533.  
  534. mapping(address => address) public votingForCR;
  535. mapping(address => uint256) public votesForCR;
  536. mapping(address => uint) public votingForGR;
  537. mapping(uint => uint256) public votesForGR;
  538.  
  539. constructor(address _asset) public ColorToken(_asset){}
  540.  
  541. function colorShift(address _from, address _to, uint _amount) public authOnly() override returns(uint){
  542. uint colorWeight = super.colorShift(_from, _to, _amount);
  543.  
  544. votesForGR[ votingForGR[_from] ] -= colorWeight;
  545. votesForCR[ votingForCR[_from] ] -= colorWeight;
  546. votesForGR[ votingForGR[_to] ] += colorWeight;
  547. votesForCR[ votingForCR[_to] ] += colorWeight;
  548.  
  549. prism.ensureUpdatedVotes(_to);
  550. return colorWeight;
  551. }
  552.  
  553. function initiateVotingAccount(address voter) external authOnly(){
  554. votingForCR[voter] = prism.communityResolve();
  555. votingForGR[voter] = prism.gatewayRequirement();
  556. }
  557.  
  558. function updateVotingWeight(address voter, uint weight) external authOnly(){
  559. votesForCR[ votingForCR[voter] ] += weight;
  560. votesForGR[ votingForGR[voter] ] += weight;
  561. prism.ensureUpdatedVotes(voter);
  562. }
  563.  
  564. function setVotingForCR(address candidate) public {
  565. address voter = msg.sender;
  566. //Contracts can't vote for anyone. Because then people would just evenly split the pool fund most of the time
  567. uint voteWeight = C[voter];
  568. votesForCR[ votingForCR[voter] ] -= voteWeight;
  569. votingForCR[ voter ] = candidate;
  570. votesForCR[ candidate ] += voteWeight;
  571. prism.ensureUpdatedVotes(voter);
  572. }
  573.  
  574. function setVotingForGR(uint MR_votingFor) public {
  575. address voter = msg.sender;
  576. uint voteWeight = C[voter];
  577. votesForGR[ votingForGR[voter] ] -= voteWeight;
  578. votingForGR[ voter ] = MR_votingFor;
  579. votesForGR[ MR_votingFor ] += voteWeight;
  580. prism.ensureUpdatedVotes(voter);
  581. }
  582. }
  583.  
  584. contract ColorBonds is ColorToken{
  585. string constant public name = "Prism";
  586. string constant public symbol = "Aura";
  587. uint8 constant public decimals = 12;
  588.  
  589. constructor(address _asset) public ColorToken(_asset){}
  590. }
  591.  
  592. abstract contract PyramidContract{
  593. function sellBonds(uint amount) public virtual returns(uint returned_eth, uint returned_resolves, uint initialInput_ETH);
  594. function resolveToken() public virtual returns(ERC20);
  595. function pullResolves(uint amount) public virtual returns(uint);
  596. function reinvestEarnings(uint amountFromEarnings) public virtual returns(uint,uint);
  597. function withdraw(uint amount) public virtual returns(uint);
  598. function fund() payable public virtual returns(uint);
  599. function resolveEarnings(address _owner) public view virtual returns (uint256 amount);
  600. }
  601.  
  602. library Common {
  603. //assemble the given address bytecode. If bytecode exists then the _addr is a contract.
  604. function isContract(address _addr) public view returns (bool is_contract) {
  605. uint length;
  606. assembly {
  607. //retrieve the size of the code on target address, this needs assembly
  608. length := extcodesize(_addr)
  609. }
  610. if(length>0) {
  611. return true;
  612. }else {
  613. return false;
  614. }
  615. }
  616. }
  617.  
  618. abstract contract ERC223ReceivingContract{
  619. function tokenFallback(address _from, uint _value, bytes calldata _data) external virtual;
  620. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement