Skip to content

Instantly share code, notes, and snippets.

@blakewest
blakewest / info.json
Created May 22, 2024 01:09
A sample of one production model, and it's full `info.json` for the Robin Project (machine learning)
{
"adjuster_model_params": {},
"best_algorithm_params": {
"": [
{
"classifier": "BaggedLogisticRegression",
"training_duration_in_days": "3650",
"feature_selector": {
"group": "all",
"list": "manual",
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "contract UpgradeableBeacon",
"name": "beacon",
"type": "address"
},
[
{
"inputs": [
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"internalType": "uint256",
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 15:02
Solidity Blogpost #1: Config Contract, snippet 7
import "./GoldfinchConfig.sol";
import "./ConfigHelper.sol";
contract CreditDesk {
GoldfinchConfig public config;
using ConfigHelper for config;
function drawdown(CreditLine creditLine, uint256 amount) public {
require(validCreditLine(creditLine), "invalid creditline!");
require(msg.sender == creditLine.owner())
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 15:00
Solidity Blogpost #1: Config Contract, snippet 6
import "./GoldfinchConfig.sol";
import "./ConfigHelper.sol";
contract CreditDesk {
GoldfinchConfig public config;
// This line is what "adds" the library methods to the config. If you aren't
// familiar with this syntax, you can just Google how libraries work in Solidity
using ConfigHelper for config;
function createCreditLine(CreditLineParams params) public {
@blakewest
blakewest / configHelper.sol
Created April 26, 2021 14:57
Solidity Blogpost #1: Config Contract, snippet 5
import "./GoldfinchConfig.sol";
import "../../interfaces/ICreditLineFactory.sol";
library ConfigHelper {
function getCreditLineFactory(GoldfinchConfig config) internal view returns(ICreditLineFactory) {
return ICreditLineFactory(creditLineFactoryAddress(config));
}
function creditLineFactoryAddress(GoldfinchConfig config) internal view returns (address) {
return config.addresses(0);
@blakewest
blakewest / creditDesk.sol
Last active April 26, 2021 15:11
Solidity Blogpost #1: Config Contract, snippet 4
import "./GoldfinchConfig.sol";
import "./ICreditLineFactory.sol";
contract CreditDesk {
GoldfinchConfig public config;
function createCreditLine(CreditLineParams params) public {
require(validParams(params), "invalid params!");
uint256 maxCreditLineAmount = config.numbers(0);
require(params.amount <= maxCreditLineAmount, "Amount is above maximum");
@blakewest
blakewest / config.sol
Last active April 26, 2021 14:56
Solidity Blogpost #1: Config Contract, snippet 3
contract GoldfinchConfig is Ownable {
// Note: Solidity creates automatic getter methods for these mappings
// So we don't need to explicitly add them ourselves.
mapping(uint256 => address) public addresses;
mapping(uint256 => uint256) public numbers;
event AddressUpdated(address owner, uint256 index, address oldValue, address newValue);
event NumberUpdated(address owner, uint256 index, uint256 oldValue, uint256 newValue);
function setAddress(uint256 addressIndex, address newAddress) public onlyAdmin {
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 14:50
Solidity Blogpost #2: Config Contract
import "./ICreditLineFactory.sol";
contract CreditDesk {
address public creditLineFactoryAddress;
uint256 public maxCreditLineAmount;
address public protocolOwner;
function createCreditLine(CreditLineParams params) public onlyOwner {
require(validParams(params), "invalid params!");
require(params.amount <= maxCreditLineAmount, "Amount is above maximum");
@blakewest
blakewest / creditDesk.sol
Created April 26, 2021 14:49
Solidity Blogpost #1: Config Contracts, snippet 1
import "./ICreditLineFactory.sol";
contract CreditDesk {
address public creditLineFactoryAddress;
function createCreditLine(CreditLineParams params) public {
require(validParams(params), "invalid params!");
ICreditLineFactory(creditLineFactoryAddress).createCreditLine(params);
}