Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
publiuss committed Aug 6, 2023
2 parents 5a33b28 + 893c99d commit c2543e2
Show file tree
Hide file tree
Showing 23 changed files with 393 additions and 125 deletions.
4 changes: 2 additions & 2 deletions protocol/contracts/C.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ library C {
//////////////////// Well ////////////////////

uint256 internal constant WELL_MINIMUM_BEAN_BALANCE = 1000_000_000; // 1,000 Beans
address constant internal BEANSTALK_PUMP = 0xc4AD29ba4B3c580e6D59105FFf484999997675Ff;
address constant BEAN_ETH_WELL = 0x9bAaB117304f7D6517048e371025dB8f89a8DbE5;
address constant internal BEANSTALK_PUMP = 0xBA510f10E3095B83a0F33aa9ad2544E22570a87C;
address constant BEAN_ETH_WELL = 0x23ba274B6Bc6505bca604940B13325D4E3f869b8;

function getSeasonPeriod() internal pure returns (uint256) {
return CURRENT_SEASON_PERIOD;
Expand Down
7 changes: 7 additions & 0 deletions protocol/contracts/beanstalk/init/InitBipBasinIntegration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pragma experimental ABIEncoderV2;
import {AppStorage} from "../AppStorage.sol";
import {C} from "contracts/C.sol";
import {LibWhitelist} from "contracts/libraries/Silo/LibWhitelist.sol";
import {LibDiamond} from "contracts/libraries/LibDiamond.sol";



/**
Expand All @@ -34,6 +36,8 @@ contract InitBipBasinIntegration {


function init() external {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();

LibWhitelist.updateStalkPerBdvPerSeasonForToken(C.BEAN, NEW_BEAN_SEEDS_PER_BDV);
LibWhitelist.updateStalkPerBdvPerSeasonForToken(C.CURVE_BEAN_METAPOOL, NEW_BEAN_3CRV_SEEDS_PER_BDV);
LibWhitelist.whitelistToken(
Expand All @@ -45,5 +49,8 @@ contract InitBipBasinIntegration {
);

s.beanEthPrice = 1;

// adds ERC1155MetadataURI for ERC165 Interface ID
ds.supportedInterfaces[0x0e89341c] = true;
}
}
3 changes: 3 additions & 0 deletions protocol/contracts/beanstalk/init/InitDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ contract InitDiamond {
ds.supportedInterfaces[type(IERC165).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
ds.supportedInterfaces[0xd9b67a26] = true; // ERC1155
ds.supportedInterfaces[0x0e89341c] = true; // ERC1155Metadata


C.bean().approve(C.CURVE_BEAN_METAPOOL, type(uint256).max);
C.bean().approve(C.curveZapAddress(), type(uint256).max);
Expand Down
35 changes: 24 additions & 11 deletions protocol/contracts/beanstalk/metadata/MetadataFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;

import {LibLegacyTokenSilo} from "contracts/libraries/Silo/LibLegacyTokenSilo.sol";
import "./MetadataImage.sol";
import {LibBytes} from "contracts/libraries/LibBytes.sol";
import {LibTokenSilo} from "contracts/libraries/Silo/LibTokenSilo.sol";


/**
Expand All @@ -19,6 +20,9 @@ import "./MetadataImage.sol";
*/
contract MetadataFacet is MetadataImage {
using LibStrings for uint256;
using LibStrings for int256;

event URI(string _uri, uint256 indexed _id);

/**
* @notice Returns the URI for a given depositId.
Expand All @@ -29,24 +33,33 @@ contract MetadataFacet is MetadataImage {
*/
function uri(uint256 depositId) external view returns (string memory) {
(address token, int96 stem) = LibBytes.unpackAddressAndStem(depositId);
int96 stemTip = LibTokenSilo.stemTipForToken(token);
require(token != address(0), "Silo: metadata does not exist");
bytes memory attributes = abi.encodePacked(
'\n\nToken Symbol: ', getTokenName(token),
'\nToken Address: ', LibStrings.toHexString(uint256(token), 20),
'\nId: ', depositId.toHexString(32),
'\nDeposit stem: ', uint256(stem).toString(),
'\nDeposit inital stalk per BDV: ', uint256(LibTokenSilo.stalkIssuedPerBdv(token)).toString(),
'\nDeposit grown stalk per BDV": ', uint256(LibTokenSilo.stemTipForToken(token) - stem).toString(),
'\nDeposit seeds per BDV": ', uint256(LibLegacyTokenSilo.getSeedsPerToken(token)).toString(),
'\n\nDISCLAIMER: Due diligence is imperative when assessing this NFT. Opensea and other NFT marketplaces cache the svg output and thus, may require the user to refresh the metadata to properly show the correct values."'
'\\n\\nToken Symbol: ', getTokenName(token),
'\\nToken Address: ', LibStrings.toHexString(uint256(token), 20),
'\\nId: ', depositId.toHexString(32),
'\\nstem: ', int256(stem).toString(),
'\\ninital stalk per BDV: ', uint256(LibTokenSilo.stalkIssuedPerBdv(token)).toString(),
'\\ngrown stalk per BDV: ', uint256(stemTip - stem).toString(),
'\\nstalk grown per BDV per season: ', uint256(LibTokenSilo.stalkEarnedPerSeason(token)).toString(),
'\\n\\nDISCLAIMER: Due diligence is imperative when assessing this NFT. Opensea and other NFT marketplaces cache the svg output and thus, may require the user to refresh the metadata to properly show the correct values."'
);
return string(abi.encodePacked("data:application/json;base64,",LibBytes64.encode(abi.encodePacked(
'{',
'"name": "Beanstalk Deposit", "description": "A Beanstalk Deposit.',
'"name": "Beanstalk Silo Deposits", "description": "An ERC1155 representing an asset deposited in the Beanstalk Silo. Silo Deposits gain stalk and bean seignorage.',
attributes,
string(abi.encodePacked(', "image": "', imageURI(depositId), '"')),
string(abi.encodePacked(', "image": "', imageURI(token, stem, stemTip), '"')),
'}'
))
));
}

function name() external pure returns (string memory){
return "Beanstalk Silo Deposits";
}

function symbol() external pure returns (string memory){
return "DEPOSIT";
}
}
Loading

0 comments on commit c2543e2

Please sign in to comment.