core

package
v0.0.0-...-b7d308f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2019 License: GPL-2.0, GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InvestorWeight is the percentage weight of the project's total reputation assigned to the investor
	InvestorWeight = 0.1

	// OriginatorWeight is the percentage weight of the project's total reputation assigned to the originator
	OriginatorWeight = 0.1

	// ContractorWeight is the percentage weight of the project's total reputation assigned to the contractor
	ContractorWeight = 0.3

	// DeveloperWeight is the percentage weight of the project's total reputation assigned to the developer
	DeveloperWeight = 0.2

	// RecipientWeight is the percentage weight of the project's total reputation assigned to the recipient
	RecipientWeight = 0.3

	// NormalThreshold is the normal payback interval of 1 payback period. Regular notifications are sent regardless of whether the user has paid back towards the project.
	NormalThreshold = 1

	// AlertThreshold is the threshold above which the user gets a nice email requesting a quick payback whenever possible
	AlertThreshold = 2

	// SternAlertThreshold is the threshold above when the user gets a warning that services will be disconnected if the user doesn't payback soon.
	SternAlertThreshold = 4

	// DisconnectionThreshold is the threshold above which the user gets a notification telling that services have been disconnected.
	DisconnectionThreshold = 6
)

Variables

View Source
var ContractorBucket = []byte("Contractors")

ContractorBucket is the contractor bucket

View Source
var InvestorBucket = []byte("Investors")

InvestorBucket is the investor bucket

View Source
var ProjectsBucket = []byte("Projects")

ProjectsBucket is the project bucket

View Source
var RecipientBucket = []byte("Recipients")

RecipientBucket is the recipient bucket

View Source
var Stage0 = Stage{
	Number:       0,
	FriendlyName: "Handshake",
	Name:         "Idea Consolidation",
	Activities: []string{
		"[Originator] proposes project and either secures or agrees to serve as [Solar Developer]. NOTE: Originator is the community leader or catalyst for the project, they may opt to serve as the solar developer themselves, or pass that responsibility off, going forward we will use solar developer to represent the interest of both.",
		"[Solar Developer] creates general estimation of project (eg. with an automatic calculation through Google Project Sunroof, PV) ",
		"If [Originator]/[Solar Developer] is not landowner [Host] states legal ownership of site (hard proof is optional at this stage)",
	},
	StateTrigger: []string{
		"Matching of originator with receiver, and mutual approval/intention of interest.",
	},
}

Stage0 is the Handshake stage

View Source
var Stage1 = Stage{
	Number:       1,
	FriendlyName: "Engagement",
	Name:         "RFP Development",
	Activities: []string{
		"[Solar Developer] Analyse parameters, create financial model (proforma)",
		"[Host] & [Solar Developer] engage [Legal] & begin scoping site for planning constraints and opportunities (viability analysis)",
		"[Solar Developer] Create RFP (‘Request For Proposal’)",
		"Simple: Automatic calculation (eg. Sunroof style)",
		"Complex: Public project with 3rd party RFP consultant (independent engineer)",
		"[Originator][Solar Developer][Offtaker] Post project for RFP",
		"[Beneficiary/Host] Define and select RFP developer.",
		"[Investor] First angel investment option (high risk)",
		"Allow ‘time banking’ as sweat equity, monetized as tokenized capital or shadow stock",
	},
	StateTrigger: []string{
		"Issue an RFP",
		"Letter of Intent or MOU between originator and developer",
	},
}

Stage1 is the engagement stage

View Source
var Stage2 = Stage{
	Number:       2,
	FriendlyName: "Quotes",
	Name:         "Actions",
	Activities: []string{
		"[Solar Developer][Beneficiary/Offtaker][Legal] PPA model negotiation.",
		"[Originator][Beneficiary]  Compare quotes from bidders: ",
		"[Engineering Procurement and Construction] (labor)",
		"[Vendors] (Hardware)",
		"[Insurers]",
		"[Issuer]",
		"[Intermediary Portal]",
		"[Originator/Receiver] Begin negotiation with [Utility]",
		"[Solar Developer] checks whether site upgrades are necessary.",
		"[Solar Developer][Host] Prepare submission for permitting and planning",
		"[Investor] Angel incorporation (less risk)",
	},
	StateTrigger: []string{
		"Selection of quotes and vendors",
		"Necessary identification of entities: Installers and offtaker",
	},
}

Stage2 is the quote stage

View Source
var Stage3 = Stage{
	Number:       3,
	FriendlyName: "Signing",
	Name:         "Contract Execution",
	Activities: []string{
		"[Solar Developer] pays [Legal] for PPA finalization.",
		"[Solar Developer][Host] Signs site Lease with landowner.",
		"[Solar Developer] OR [Issuer] signs Offering Agreement with [Intermediary Portal].",
		"[Solar Developer][Beneficiary] selects and signs contracts with: ",
		"[Engineering Procurement and Construction] (labor)",
		"[Vendors] (Hardware)",
		"[Insurers]",
		"[Issuer] OR [Intermediary Portal]",
		"[Offtaker] OR [Solar Developer][Engineering, Procurement and Construction] sign vendor/developer EPC Contracts",
		"[Solar Developer][Offtaker] signs PPA/Offtake Agreement",
		"[Investor] 2nd stage of eligible funding",
		"[Solar Developer][Beneficiary] makes downpayment to [Engineering Procurement and Construction] (labor)",
		"[Investor] Profile with risk ",
	},
	StateTrigger: []string{
		"Execution of contracts - Sign!",
	},
}

Stage3 is the signing stage

View Source
var Stage4 = Stage{
	Number:       4,
	FriendlyName: "The Raise",
	Name:         "Finance and Capitalization",
	Activities: []string{
		"[Issuer] engages [Intermediary Portal] to develop Form C or prospectus",
		"[Intermediary Portal] lists [Issuer] project",
		"[Originator][Solar Developer][Offtaker] market the crowdfunded offering",
		"[Investors] Commit capital to the project",
		"[Intermediary Portal] closes offering and disburses capital from Escrow account to [Issuers]",
		"If [Issuer] is not also [Solar Developer] then [Issuer] passes funds to [Solar Developer] ",
	},
	StateTrigger: []string{
		"Project account receives funds that cover the raise amount. Raise amount: normally includes both project capital expenditure (i.e. hardware and labor) and ongoing Operation & Management costs",
	},
}

Stage4 is the raise stage

View Source
var Stage5 = Stage{
	Number:       5,
	FriendlyName: "Construction",
	Name:         "Payments and Construction",
	Activities: []string{
		"[Solar Developer] coordinates installation dates and arrangements with [Host][Off-takers]",
		"[Solar Developer] OR [Engineering, Procurement and Construction] take delivery of equipment from [Vendor]",
		"[Utility] issues conditional interconnection",
		"[Solar Developer] schedules installation with [Engineering, Procurement and Construction]",
		"[Engineering, Procurement and Construction] completes installation.",
		"[Solar Developer] pays [Engineering, Procurement and Construction] for substantial completion of the project.",
		"[Insurers] verifies policy, [Solar Developer] pays [Insurers]",
		"[Investor] role?",
	},
	StateTrigger: []string{
		"Installation reaches substantial completion",
		"IoT devices detect energy generation",
	},
}

Stage5 is the construction stage

View Source
var Stage6 = Stage{
	Number:       6,
	FriendlyName: "Interconnection",
	Name:         "Contract Execution",
	Activities: []string{
		"[Solar Developer] coordinates with [Engineering Procurement and Construction] to schedule interconnection dates with [Utility] ",
		"[Engineering, Procurement and Construction] submits ‘as-built’ drawings to City/County Inspectors and schedules interconnection with [Utility]",
		"[Solar Developer] schedules City/County Building Inspector visit",
		"[Utility] visits site for witness test",
		"[Utility] places project in service ",
	},
	StateTrigger: []string{
		"[Utility] places project in service",
	},
}

Stage6 is the connection stage

View Source
var Stage7 = Stage{
	Number:       7,
	FriendlyName: "Legacy",
	Name:         "Operation and Management",
	Activities: []string{
		"[Solar Developer] hires OR becomes [Manager]",
		"[Manager] hires [Operations & Maintenance] provider",
		"[Manager] sets up billing system and issues monthly bills to [Offtaker] and collects payment on bills",
		"[Manager] monitors for breaches of payment or contract, other indentures, force majeure or adverse conditions [see below for Breach Conditions]",
		"[Manager] files annual taxes",
		"[Manager] handles annual true-up on net-metering payments",
		"[Manager] makes annual cash distributions and issues 1099-DIV to [Investors] or coordinates share repurchase from [Investors]",
		"If applicable, [Manager] executes flip between [Solar Developer] ownership interest and [Tax equity investor]",
		"[Manager] OR [Operations & Maintenance] monitors system performance and coordinates with [Off-takers] to schedule routine maintenance",
		"[Manager] OR [Operations & Maintenance] coordinates with [Engineering, Procurement and Construction] to change inverters or purchase replacements from [Vendors] as needed.",
		"[Investors] can engage in secondary market (i.e. re-selling its securities). ",
	},
	StateTrigger: []string{
		"[Investors] reach preferred return rate, or Power Purchase Agreement stipulates ownership flip date or conditions ",
	},
	BreachCondition: []string{
		"[Offtaker] fails to make $/kWh payments after X period of time due. ",
	},
}

Stage7 is the legacy stage

View Source
var Stage8 = Stage{
	Number:       8,
	FriendlyName: "Handoff",
	Name:         "Ownership Flip",
	Activities: []string{
		"[Beneficiary/Offtakers] Payments accrue to cover the [Investor] principle (i.e. total raised amount)",
		"Escrow account (eg. capital account) pays off principle to [Investor]",
	},
	StateTrigger: []string{
		"[Beneficiary] (eg. Host, Holding)  becomes full legal owner of physical assets",
		"[Investors] exit the project",
	},
}

Stage8 is the legacy stage

View Source
var Stage9 = Stage{
	Number:       9,
	FriendlyName: "End of Life",
	Name:         "Disposal",
	Activities: []string{
		"[IoT] Solar equipment is generating below a productivity threshold, or shows general malfunction",
		"[Beneficiaries][Developers] dispose of the equipment to a recycling program",
		"[Developer/Recycler] Certifies equipment is received",
	},
	StateTrigger: []string{
		"Project termination",
		"Wallet terminations",
	},
}

Stage9 is the end of life stage

Functions

func AgreeToContractConditions

func AgreeToContractConditions(contractHash string, projIndex string,
	debtAssetCode string, entityIndex int, seedpwd string) error

AgreeToContractConditions agrees to some specified contract conditions

func CheckUsernameCollision

func CheckUsernameCollision(name string) bool

CheckUsernameCollision checks for username collisions in openx's database

func CoverFirstLoss

func CoverFirstLoss(projIndex int, entityIndex int, amount float64) error

CoverFirstLoss covers first loss for investors by sending funds from the guarantor's account

func CreateHomeDir

func CreateHomeDir()

CreateHomeDir creates a home directory

func DeleteKeyFromBucket

func DeleteKeyFromBucket(key int, bucketName []byte) error

DeleteKeyFromBucket deletes a given key from the bucket

func DistributePayments

func DistributePayments(recipientSeed string, escrowPubkey string, projIndex int, amount float64) error

DistributePayments distributes the return promised as part of the project back to investors and pays the other entities involved in the project

func InitializePlatform

func InitializePlatform() error

InitializePlatform imports handlers from the main platform struct that are necessary for starting the platform

func Invest

func Invest(projIndex int, invIndex int, invAmount float64, invSeed string) error

Invest is the main invest function of the opensolar platform

func MunibondInvest

func MunibondInvest(issuerPath string, invIndex int, invSeed string, invAmount float64,
	projIndex int, invAssetCode string, totalValue float64, seedInvestmentFactor float64, seed bool) error

MunibondInvest invests in a specific munibond

func MunibondPayback

func MunibondPayback(issuerPath string, recpIndex int, amount float64, recipientSeed string, projIndex int,
	assetName string, projectInvestors []int, totalValue float64, escrowPubkey string) (float64, error)

MunibondPayback is used by the recipient to pay the platform back. Here, we pay the project escrow instead of the platform since it is responsible for redistribution of funds

func MunibondReceive

func MunibondReceive(issuerPath string, recpIndex int, projIndex int, debtAssetId string,
	paybackAssetId string, years int, recpSeed string, totalValue float64, paybackPeriod int) error

MunibondReceive sends assets to the recipient

func NewUser

func NewUser(name string, pwhash string, seedpwd string, realname string) (openx.User, error)

NewUser creates a new user in openx's database

func OpenDB

func OpenDB() (*bolt.DB, error)

OpenDB opens the db, calls essentials for helpers

func Payback

func Payback(recpIndex int, projIndex int, assetName string, amount float64, recipientSeed string) error

Payback is called by the recipient when they choose to pay towards the project according to the payback interval

func RecipientAuthorize

func RecipientAuthorize(projIndex int, recpIndex int) error

RecipientAuthorize allows a recipient to authorize a specific project

func RefillPlatform

func RefillPlatform(publicKey string) error

RefillPlatform checks whether the platform has any xlm and if its balance is less than 21 XLM, it proceeds to ask friendbot for more test xlm

func RepInstalledProject

func RepInstalledProject(contrIndex int, projIndex int) error

RepInstalledProject adds reputatuon to the contractor on completion of installation of a project. By default, we add reputation to the entity. In case the recipient wants to dispute this claim, we review and change the reputation accordingly

func RepOriginatedProject

func RepOriginatedProject(origIndex int, projIndex int) error

RepOriginatedProject adds reputation to an originator on successful origination of a contract

func RetrieveUser

func RetrieveUser(key int) (openx.User, error)

RetrieveUser retrieves a user from openx's database

func SaveContractHash

func SaveContractHash(projIndex int, hash string) error

SaveContractHash saves a contract's hash in the database

func SaveInvPlatformContract

func SaveInvPlatformContract(projIndex int, hash string) error

SaveInvPlatformContract saves the investor-platform contract's hash in the database

func SaveOriginatorMoU

func SaveOriginatorMoU(projIndex int, hash string) error

SaveOriginatorMoU saves the MoU's hash in the database

func SaveRecPlatformContract

func SaveRecPlatformContract(projIndex int, hash string) error

SaveRecPlatformContract saves the recipient-platform contract's hash in the database

func SeedInvest

func SeedInvest(projIndex int, invIndex int, invAmount float64, invSeed string) error

SeedInvest is the seed investment function of the opensolar platform

func SendUSDToPlatform

func SendUSDToPlatform(invSeed string, invAmount float64, memo string) (string, error)

SendUSDToPlatform sends STABLEUSD back to the platform

func StageXtoY

func StageXtoY(index int) error

StageXtoY promtoes a contract from stage X.Number to stage Y.Number

func UnlockProject

func UnlockProject(username string, pwhash string, projIndex int, seedpwd string) error

UnlockProject unlocks a specific project that has just been invested in

func ValidateUser

func ValidateUser(name string, pwhash string) (openx.User, error)

ValidateUser validates a user with openx's database

func VerifyBeforeAuthorizing

func VerifyBeforeAuthorizing(projIndex int) bool

VerifyBeforeAuthorizing verifies information on the originator before upgrading the project stage

func VoteTowardsProposedProject

func VoteTowardsProposedProject(invIndex int, votes float64, projectIndex int) error

VoteTowardsProposedProject is a handler that an investor would use to vote towards a specific proposed project on the platform.

Types

type ArchitectureHelper

type ArchitectureHelper struct {
	SpaceLayoutImage   string
	SolarOutputImage   string
	SolarArray         string
	DailyAvgGeneration string
	System             string
	InverterSize       string
	DesignDescription  string
}

ArchitectureHelper defines the content that goes into the architecture section of the frontend

type BulletHelper

type BulletHelper struct {
	Bullet1 string
	Bullet2 string
	Bullet3 string
}

BulletHelper is a list of hashes that will appear on the project info page on the frontend

type CommunityEngagementHelper

type CommunityEngagementHelper struct {
	Width    int
	Title    string
	ImageURL string
	Content  string
	Link     string
}

CommunityEngagementHelper defines the content that goes into the community engagement section of the frontend

type ContractAuction

type ContractAuction struct {
	// TODO: this struct isn't used yet as it needs handlers and stuff, but when
	// we move off main.go for testing, this must be used in order to make stuff
	// easier for us.
	AllContracts    []Project
	AllContractors  []Entity
	WinningContract Project
}

ContractAuction is an auction struct

type Entity

type Entity struct {
	// U is the base User class inherited from openx
	U *openx.User

	// Contractor is a bool that is set if the entity is a contractor
	Contractor bool

	// Developer is a bool that is set if the entity is a developer
	Developer bool

	// Originator is a bool that is set if the entity is a originator
	Originator bool

	// Guarantor is a bool that is set if the entity is a guarantor
	Guarantor bool

	// PastContracts contains a list of all past contracts associated with the entity
	PastContracts []Project

	// ProposedContracts contains a list of all proposed contracts associated with the entity
	ProposedContracts []Project

	// PresentContracts contains a list of all present contracts associated with the entity
	PresentContracts []Project

	// PastFeedback contains a list of all feedback on the given entity
	PastFeedback []Feedback

	// Collateral is the amount the entity is willing to put up as collateral to secure projects
	Collateral float64

	// CollateralData contains data on the collateral amount that the entity is willing to pledge
	CollateralData []string

	// FirstLossGuarantee is the seed that will be used to transfer funds to investors in case the recipient refuses to pay
	FirstLossGuarantee string

	// 	FirstLossGuaranteeAmt is the amount that the guarantor is expected to cover in the case of a breach
	FirstLossGuaranteeAmt float64
}

Entity defines a common structure for contractors, developers and originators

func NewContractor

func NewContractor(uname string, pwd string, seedpwd string, Name string,
	Address string, Description string) (Entity, error)

NewContractor creates a new contractor

func NewDeveloper

func NewDeveloper(uname string, pwd string, seedpwd string, Name string,
	Address string, Description string) (Entity, error)

NewDeveloper creates a new developer

func NewGuarantor

func NewGuarantor(uname string, pwd string, seedpwd string, Name string,
	Address string, Description string) (Entity, error)

NewGuarantor returns a new guarantor

func NewOriginator

func NewOriginator(uname string, pwd string, seedpwd string, Name string,
	Address string, Description string) (Entity, error)

NewOriginator creates a new originator

func RetrieveAllEntities

func RetrieveAllEntities(role string) ([]Entity, error)

RetrieveAllEntities gets all the proposed contracts associated with a particular entity

func RetrieveAllEntitiesWithoutRole

func RetrieveAllEntitiesWithoutRole() ([]Entity, error)

RetrieveAllEntitiesWithoutRole retrieves all the entities from the database

func RetrieveEntity

func RetrieveEntity(key int) (Entity, error)

RetrieveEntity retrieves an entity from the database

func RetrieveEntityHelper

func RetrieveEntityHelper(key int) (Entity, error)

RetrieveEntityHelper is a helper associated with the RetrieveEntity function

func TopReputationEntities

func TopReputationEntities(role string) ([]Entity, error)

TopReputationEntities returns the list of all the entities belonging to a specific role in descending order of reputation

func TopReputationEntitiesWithoutRole

func TopReputationEntitiesWithoutRole() ([]Entity, error)

TopReputationEntitiesWithoutRole returns the list of all the entities in descending order of reputation

func ValidateEntity

func ValidateEntity(name string, pwhash string) (Entity, error)

ValidateEntity validates the username and pwhash of the entity

func (*Entity) AddCollateral

func (contractor *Entity) AddCollateral(amount float64, data string) error

AddCollateral adds a collateral that can be used as guarantee in case the contractor reneges on a particular contract

func (*Entity) AddFirstLossGuarantee

func (a *Entity) AddFirstLossGuarantee(seedpwd string, amount float64) error

AddFirstLossGuarantee adds the given entity as a first loss guarantor

func (*Entity) Originate

func (contractor *Entity) Originate(panelSize string, totalValue float64, location string,
	years int, metadata string, recIndex int, auctionType string) (Project, error)

Originate creates and saves a new origin contract

func (*Entity) Propose

func (contractor *Entity) Propose(panelSize string, totalValue float64, location string,
	years int, metadata string, recIndex int, projectIndex int, auctionType string) (Project, error)

Propose proposes a new stage 2 contract

func (*Entity) Save

func (a *Entity) Save() error

Save saves an Entity's details

func (*Entity) Slash

func (contractor *Entity) Slash(contractValue float64) error

Slash slashes the contractor's reputation in the event of bad behaviour.

type ExecutiveSummaryHelper

type ExecutiveSummaryHelper struct {
	Investment            map[string]string
	Financials            map[string]string
	ProjectSize           map[string]string
	SustainabilityMetrics map[string]string
}

ExecutiveSummaryHelper defines the content that goes into the executive summary section

type ExplorePageSummaryHelper

type ExplorePageSummaryHelper struct {
	Solar   string
	Storage string
	Tariff  string
	Stage   int
	Return  string
	Rating  string
	Tax     string
	ETA     int
}

ExplorePageSummaryHelper defines the params that will appear on the frontend's explore page

type Feedback

type Feedback struct {
	Content string
	// the content of the feedback, good / bad
	// maybe we could have a rating system baked in? a star based rating system?
	// would be nice, idk
	From Entity
	// who gave the feedback?
	To Entity
	// regarding whom is this feedback about
	Date string
	// time at which this feedback was written
	Contract []Project
}

Feedback defines a structure that can be used for providing feedback about entities

type FinancialHelper

type FinancialHelper struct {
	Return    float64
	Insurance string
	Tariff    string
	Maturity  string
}

FinancialHelper defines the financial specifics of the project

type HashHelper

type HashHelper struct {
	LegalProjectOverviewHash string
	LegalPPAHash             string
	LegalRECAgreementHash    string
	GuarantorAgreementHash   string
	ContractorAgreementHash  string
	StakeholderAgreementHash string
	CommunityEnergyHash      string
	FinancialReportingHash   string
}

HashHelper defines the hashes that will appear on the project documents page

type InvestmentHelper

type InvestmentHelper struct {
	Capex              string
	Hardware           float64
	FirstLossEscrow    string
	CertificationCosts string
}

InvestmentHelper defines the investment specifics of the project

type Investor

type Investor struct {
	// U is the base User class inherited from openx
	U *openx.User

	// VotingBalance is the balance associated with the particular investor (equal to the amount of USD he possesses)
	VotingBalance float64

	// AmountInvested is the total amount invested by the investor
	AmountInvested float64

	// InvestedSolarProjects is a list of the investor assets of the opensolar projects the investor has invested in
	InvestedSolarProjects []string

	// InvestedSolarProjectsIndices is an integer list of the projects the investor has invested in
	InvestedSolarProjectsIndices []int

	// InvestedSolarProjects is a list of the investor assets of the opensolar projects the investor has invested in
	SeedInvestedSolarProjects []string

	// InvestedSolarProjectsIndices is an integer list of the projects the investor has invested in
	SeedInvestedSolarProjectsIndices []int

	// WeightedROI is the weighted ROI that the investor is expected to get for his investments
	WeightedROI string

	// AllTimeReturns is the all time returns the investor has realized from his investments
	AllTimeReturns []float64

	// ReceivedRECs is a list of the RECs the recipient has invested in
	ReceivedRECs string

	// Prorata is the pro rata in all the projects that the investor has invested in
	Prorata string
}

Investor defines the investor structure

func NewInvestor

func NewInvestor(uname string, pwd string, seedpwd string, Name string) (Investor, error)

NewInvestor creates a new investor based on params passed

func RetrieveAllInvestors

func RetrieveAllInvestors() ([]Investor, error)

RetrieveAllInvestors gets a list of all investors in the database

func RetrieveInvestor

func RetrieveInvestor(key int) (Investor, error)

RetrieveInvestor retrieves an investor from the database

func TopReputationInvestors

func TopReputationInvestors() ([]Investor, error)

TopReputationInvestors gets a list of all the investors sorted by descending reputation

func ValidateInvestor

func ValidateInvestor(name string, pwhash string) (Investor, error)

ValidateInvestor validates an investor's pwhash and username

func (*Investor) CanInvest

func (a *Investor) CanInvest(targetBalance float64) bool

CanInvest checks whether an investor has the required funds to invest in a project

func (*Investor) ChangeVotingBalance

func (a *Investor) ChangeVotingBalance(votes float64) error

ChangeVotingBalance changes the voting balance of a user

func (*Investor) Save

func (a *Investor) Save() error

Save saves an Investor's details

type Project

type Project struct {
	Index                     int     // an Index to keep track of how many projects exist
	Name                      string  // the name of the project / the identifier by which its referred to
	State                     string  // the state in which the project has been installed in
	Country                   string  // the country in which the project has been installed in
	TotalValue                float64 // the total money that we need from investors
	PanelSize                 string  // size of the given panel, for diplsaying to the user who wants to bid stuff
	PanelTechnicalDescription string  // This should talk about '10x 100W Komaes etc'
	Inverter                  string  // the inverter of the installed project
	ChargeRegulator           string  // the charge regulator of the installed project
	ControlPanel              string  // the control panel of the installed project
	CommBox                   string  // the comm box of the installed project
	ACTransfer                string  // the AC transfer of the installed project
	SolarCombiner             string  // the solar combiner of the installed project
	Batteries                 string  // the batteries of the installed project
	IoTHub                    string  // the IoT Hub installed as part of the project
	Rating                    string  // the rating of the project (Moody's, etc)
	Metadata                  string  // other metadata which does not have an explicit name can be stored here. Used to derive assetIDs

	// Define parameters related to finance
	MoneyRaised          float64 // total money that has been raised until now
	SeedMoneyRaised      float64 // total seed money that has been raised until now
	EstimatedAcquisition int     // the year in which the recipient is expected to repay the initial investment amount by
	BalLeft              float64 // denotes the balance left to pay by the party, percentage raised is not stored in the database since that can be calculated
	InterestRate         float64 // the rate of return for investors
	Tax                  string  // the specifications of the tax system associated with this particular project

	// Define dates of creation and funding
	DateInitiated string // date the project was created on the platform
	DateFunded    string // date that the project completed the stage 4-5 migration
	DateLastPaid  int64  // int64 ie unix time since we need comparisons on this one

	// Define technical parameters
	AuctionType           string  // the type of the auction in question. Default is blind auction unless explicitly mentioned
	InvestmentType        string  // the type of investment - equity crowdfunding, municipal bond, normal crowdfunding, etc defined in models
	PaybackPeriod         int     // the frequency in number of weeks that the recipient has to pay the platform
	Stage                 int     // the stage at which the contract is at, float due to potential support of 0.5 state changes in the future
	InvestorAssetCode     string  // the code of the asset given to investors on investment in the project
	DebtAssetCode         string  // the code of the asset given to recipients on receiving a project
	PaybackAssetCode      string  // the code of the asset given to recipients on receiving a project
	SeedAssetCode         string  // the code of the asset given to seed investors on seed investment in the project
	SeedInvestmentFactor  float64 // the factor that a seed investor's investment is multiplied by in case he does invest at the seed stage
	SeedInvestmentCap     float64 // the max amount that a seed investor can put in a project when it is in its seed stages
	ProposedInvestmentCap float64 // the max amount that an investor can invest in when the project is in its proposed stage (stage 2)
	SelfFund              float64 // the amount that a beneficiary / recipient puts in a project wihtout asking from other investors. This is not included as a seed investment because this would mean the recipient pays his own investment back in the project
	EscrowPubkey          string  // the publickey of the escrow we setup after project investment
	EscrowLock            bool    // used to lock the escrow in case someting goes wrong

	// Describe issuer of security and the broker dealer
	SecurityIssuer string // the issuer of the security
	BrokerDealer   string // the broker dealer associated with the project

	// Define the various entities that are associated with a specific project
	RecipientIndex              int       // The index of the project's recipient
	OriginatorIndex             int       // the originator of the project
	GuarantorIndex              int       // the person guaranteeing the specific project in question
	ContractorIndex             int       // the person with the proposed contract
	MainDeveloperIndex          int       // the main developer of the project
	BlendedCapitalInvestorIndex int       // the index of the blended capital investor
	InvestorIndices             []int     // The various investors who have invested in the project
	SeedInvestorIndices         []int     // Investors who took part before the contract was at stage 3
	RecipientIndices            []int     // the indices of the recipient family (offtakers, beneficiaries, etc)
	DeveloperIndices            []int     // the indices of the developers involved in the project`
	ContractorFee               float64   // fee paid to the contractor from the total fee of the project
	OriginatorFee               float64   // fee paid to the originator included in the total value of the project
	DeveloperFee                []float64 // the fees charged by the developers
	DebtInvestor1               string    // debt investor index, if any
	DebtInvestor2               string    // debt investor index, if any
	TaxEquityInvestor           string    // tax equity investor if any

	// Define parameters that will not be defined directly but will be used for the backend flow
	Lock            bool               // lock investment in order to wait for recipient's confirmation
	LockPwd         string             // the recipient's seedpwd. Will be set to null as soon as we use it.
	Votes           float64            // the number of votes towards a proposed contract by investors
	AmountOwed      float64            // the amoutn owed to investors as a cumulative sum. Used in case of a breach
	Reputation      float64            // the positive reputation associated with a given project
	OwnershipShift  float64            // the percentage of the project that the recipient now owns
	StageData       []string           // the data associated with stage migrations
	StageChecklist  []map[string]bool  // the checklist that has to be completed before moving on to the next stage
	InvestorMap     map[string]float64 // publicKey: percentage donation
	SeedInvestorMap map[string]float64 // the list of all seed investors who've invested in the project
	WaterfallMap    map[string]float64 // publickey:amount map ni order to pay multiple accounts. A bit ugly, but should work fine. Make map before using

	// Define things that will be displayed on the frontend
	Terms               []TermsHelper               // the terms of the project
	ExecutiveSummary    ExecutiveSummaryHelper      // the bigger struct that holds all the executive summary metrics
	AutoReloadInterval  float64                     // the interval in which the user's funds reach zero
	ResilienceRating    float64                     // resilience of the project
	ActionsRequired     string                      // the action(s) required by the user
	Bullets             BulletHelper                // list of bullet points to be displayed on the frontend
	Hashes              HashHelper                  // list of hashes to be displayed on the project details page
	PendingDocuments    map[int]string              // a map of the user id and the document he needs to follow on. This text would match the index map in the user struct
	ContractList        []string                    // the list of contracts to be displayed on the frontend
	Architecture        ArchitectureHelper          // the section labeled "Architecture/Project Design"
	Context             string                      // the section titled "Context"
	SummaryImage        string                      // the url to the image linked in the summary
	CommunityEngagement []CommunityEngagementHelper // the section labelled "Community Engagement" on the frontend
	ExplorePageSummary  ExplorePageSummaryHelper    // the summary on the explore page tab

	EngineeringLayoutType string
	FEText                map[string]interface{} // put all the fe text in here reading it from the relevant json file(s)
	MapLink               string                 // the google maps link to the installation site

	Chain string // the chain on which the project desires to be.
}

Project defines the project investment structure in opensolar

func RetrieveAllProjects

func RetrieveAllProjects() ([]Project, error)

RetrieveAllProjects retrieves all projects from the database

func RetrieveContractorProjects

func RetrieveContractorProjects(stage int, index int) ([]Project, error)

RetrieveContractorProjects retrieves projects that are associated with a specific contractor from the db

func RetrieveLockedProjects

func RetrieveLockedProjects() ([]Project, error)

RetrieveLockedProjects retrieves all the projects that are locked and are waiting for the recipient to unlock them

func RetrieveOriginatorProjects

func RetrieveOriginatorProjects(stage int, index int) ([]Project, error)

RetrieveOriginatorProjects retrieves projects that are associated with a specific originator from the db

func RetrieveProject

func RetrieveProject(key int) (Project, error)

RetrieveProject retrieves a project from the database

func RetrieveProjectsAtStage

func RetrieveProjectsAtStage(stage int) ([]Project, error)

RetrieveProjectsAtStage retrieves projects at a specific stage from the database

func RetrieveRecipientProjects

func RetrieveRecipientProjects(stage int, index int) ([]Project, error)

RetrieveRecipientProjects retrieves projects that are associated with a specific recipient from the db

func SelectContractBlind

func SelectContractBlind(arr []Project) (Project, error)

SelectContractBlind selects the winning bid based on blind auction rules (in a blind auction, the bid with the highest price wins)

func SelectContractTime

func SelectContractTime(arr []Project) (Project, error)

SelectContractTime selects the winning contract based on the least time proposed for completion

func SelectContractVickrey

func SelectContractVickrey(arr []Project) (Project, error)

SelectContractVickrey selects the winning bid based on vickrey auction rules (in a vickrey auction, the bid with the second highest price wins)

func (Project) CalculatePayback

func (project Project) CalculatePayback(amount float64) float64

CalculatePayback calculates the amount of payback assets that must be issued in relation to the total amount invested in the project

func (*Project) Save

func (a *Project) Save() error

Save saves a Project's details

func (*Project) SetAuctionType

func (project *Project) SetAuctionType(auctionType string) error

SetAuctionType sets the auction type of a specific project

func (*Project) SetStage

func (a *Project) SetStage(number int) error

SetStage sets the stage of a project

type ProjectSizeHelper

type ProjectSizeHelper struct {
	PVSolar          string
	Storage          string
	Critical         float64
	InverterCapacity string
}

ProjectSizeHelper defines size, storage and other params that are part of the project size section

type Recipient

type Recipient struct {
	U *openx.User
	// user related functions are called as an instance directly
	ReceivedSolarProjects       []string
	ReceivedSolarProjectIndices []int
	ReceivedConstructionBonds   []string
	// ReceivedProjects denotes the projects that have been received by the recipient
	// instead of storing the PaybackAssets and the DebtAssets, we store this
	DeviceId string
	// the device ID of the associated solar hub. We don't do much with it here,
	// but we need it on the IoT Hub side to check login stuff
	DeviceStarts []string
	// the start time of the devices recorded for reference. We could monitor unscheduled
	// closes on the platform level as well and send email notifications or similar
	DeviceLocation string
	// the location of the device. Teller gets location using google's geolocation
	// API. Accuracy is of the order ~1km radius. Not great, but enough to detect
	// theft or something
	StateHashes []string
	// StateHashes provides the list of state updates (ipfs hashes) that the teller associated with this
	// particular recipient has communicated.
	TotalEnergyCP float64
	// the total energy produced by the recipient's assets in the current period
	TotalEnergy float64
	// the total energy produced by the recipient's assets over all billed periods
	Autoreload bool
}

Recipient defines the recipient structure

func NewRecipient

func NewRecipient(uname string, pwd string, seedpwd string, Name string) (Recipient, error)

NewRecipient creates and returns a new recipient

func RetrieveAllRecipients

func RetrieveAllRecipients() ([]Recipient, error)

RetrieveAllRecipients gets a list of all Recipients in the database

func RetrieveRecipient

func RetrieveRecipient(key int) (Recipient, error)

RetrieveRecipient retrieves a recipient from the database

func TopReputationRecipients

func TopReputationRecipients() ([]Recipient, error)

TopReputationRecipients returns a list of recipients sorted by descending reputation

func ValidateRecipient

func ValidateRecipient(name string, pwhash string) (Recipient, error)

ValidateRecipient validates a recipient's pwhash and username

func (*Recipient) Save

func (a *Recipient) Save() error

Save saves a Recipient's details

type SolarProjectArray

type SolarProjectArray []Project

SolarProjectArray is an array of Projects

type Stage

type Stage struct {
	Number          int
	FriendlyName    string   // the informal name that one can use while referring to the stage (nice for UI as well)
	Name            string   // this is a more formal name to give to the given stage
	Activities      []string // the activities that are covered in this particular stage and need to be fulfilled in order to move to the next stage.
	StateTrigger    []string // trigger state change from n to n+1
	BreachCondition []string // define breach conditions for a particular stage
}

Stage is the evolution of the erstwhile static stage integer construction

type SustainabilityHelper

type SustainabilityHelper struct {
	CarbonDrawdown string
	CommunityValue string
	LCA            string
}

SustainabilityHelper defines parameters relevant to sustainability that ae important to the project

type TermsHelper

type TermsHelper struct {
	Variable      string
	Value         string
	RelevantParty string
	Note          string
	Status        string
	SupportDoc    string
}

TermsHelper is an object containing the various terms associated with the project

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL