core

package
v0.0.0-...-d2f3e30 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 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 AddTellerDetails

func AddTellerDetails(projIndex int, url string, brokerurl string, topic string) error

AddTellerDetails adds teller details to a project.

func AddWaterfallAccount

func AddWaterfallAccount(projIndex int, pubkey string, amount float64) error

AddWaterfallAccount adds a waterfall account that is eligible for funds distributed when the recipientp ays back towards a project.

func AgreeToContractConditions

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

AgreeToContractConditions agrees to specified contract conditions. This is a precursor to a legeal contract template

func CheckUsernameCollision

func CheckUsernameCollision(name string) bool

CheckUsernameCollision checks for username collisions while creating a new user

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 at $HOME. If the user does not have permissions to write to home, execution is stopped.

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 returns to investors and pays the other entities involved in the project.

func GetStageDescription

func GetStageDescription(stage int) string

GetStageDescription gets the description of a particular stage

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. Invest first calls the preInvestmentCheck function to check if the project and investor are eligbile to be invested in an invest in the project respectively. Calls the investment function associated with the platform after completing preliminary checks.

func MarkFlagged

func MarkFlagged(projIndex int, adminIndex int) error

MarkFlagged is used by an admin to mark the project as flagged

func MonitorTeller

func MonitorTeller(projIndex int, tellerUrl string)

MonitorTeller monitors a teller and checks whether its live. If not, sends an email to platform admins

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 munibond. Sends USD to the platform, receives INVAssets in return, and sends an email to the investor's email id confirming investment if it succeeds.

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. Pays the project escrow USD, and the project issuer DebtAsset and Payback Asset.

func MunibondReceive

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

MunibondReceive sends Debt and Payback assets to the recipient. Sends a notification email to the recipient containing the tx hashes of all transactions involved.

func NewUser

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

NewUser creates a new user on openx

func OpenDB

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

OpenDB opens the database at the home directory.

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. Payback calls the payback function associated with a project's desired investment model. Distributes funds to investors at the end.

func RecipientAuthorize

func RecipientAuthorize(projIndex int, recpIndex int) error

RecipientAuthorize allows a recipient to authorize a project. Promotes the stage of the project from stage 0 to stage 1. Assigns the originator to the project based on project.OriginatorIndex.

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 automatically adds reputation to the contractor on installation of a project. If entities want to reduce or report against the contractor later on, the slashing function above is called.

func RepOriginatedProject

func RepOriginatedProject(origIndex int, projIndex int) error

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

func RequestWaterfallWithdrawal

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

RequestWaterfallWithdrawal requests withdrawal of funds from the escrow account. This is used to pay developers, contractors and other entities that the recipient wishes to pay. Checks if the project is flagged and if not, decrypts the recipient's seed, signs the transaction and sends the transaction to the platform to sign and broadcast.

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 IPFS hash in the database

func SaveInvPlatformContract

func SaveInvPlatformContract(projIndex int, hash string) error

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

func SaveOriginatorMoU

func SaveOriginatorMoU(projIndex int, hash string) error

SaveOriginatorMoU saves the MoU's IPFS hash in the database

func SaveRecPlatformContract

func SaveRecPlatformContract(projIndex int, hash string) error

SaveRecPlatformContract saves the recipient-platform contract's IPFS 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. Calls the associated investment model associated with the project.

func SendUSDToPlatform

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

SendUSDToPlatform sends STABLEUSD to the platform. Used by investors investing in projects.

func StageXtoY

func StageXtoY(index int) error

StageXtoY promotes a contract's stage by one

func UnlockProject

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

UnlockProject unlocks a project that has just been invested. This function needs to be called via the RPC-APIs when the recipient clicks on their email to accept the investment, unlock the project and provide their seedpwd (so the platform can send assets to them).

func UserMarkFlagged

func UserMarkFlagged(projIndex int, userIndex int) error

UserMarkFlagged is used by users to mark a project as flagged

func ValidateUser

func ValidateUser(name string, token 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. Returns true if the originator has gone through KYC or is banned

func VoteTowardsProposedProject

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

VoteTowardsProposedProject is a handler that an investor can use to vote towards a proposed project. Returns an error if the proejct's voting blaance can't be changed.

Types

type CMS

type CMS struct {
	Keys    []string // the keys of the map at level 1
	Details map[string]map[string]interface{}
}

CMS handles all the content related stuff wrt a project

type Company

type Company struct {
	// CompanyType is the type of the company
	CompanyType string

	// Name is the name of the company
	Name string

	// LegalName is the legal name of the company
	LegalName string

	// AdminEmail is the email of the admin / contact point of the company
	AdminEmail string

	// PhoneNumber is the phone number of the main contact in the company
	PhoneNumber string

	// Address is the registered address of the company
	Address string

	// Country is the country where the company is registered in
	Country string

	// City is the city in which the company is registered at
	City string

	// ZipCode is the zipcode of the city where the company is at
	ZipCode string

	// TaxIDNumber is the tax id number associated with the company
	TaxIDNumber string

	// Role isthe role of the investor in the above company
	Role string
}

Company is a struct that is used if an investor/recipient is acting on behalf of their company

type ContractAuction

type ContractAuction struct {
	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
	ProposedContract []Project

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

	// ProposedContractIndices contains the indices of all proposed projects
	ProposedContractIndices []int

	// PresentContractIndices contains the indices of all present projects
	PresentContractIndices []int

	// 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) (Entity, error)

NewContractor creates a new contractor

func NewDeveloper

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

NewDeveloper creates a new developer

func NewGuarantor

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

NewGuarantor returns a new guarantor

func NewOriginator

func NewOriginator(uname string, pwd string, seedpwd string, Name 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 (contractors, developers, originators, and guarantors) from the database

func RetrieveEntity

func RetrieveEntity(key int) (Entity, error)

RetrieveEntity retrieves an entity from the database

func SearchForEntity

func SearchForEntity(name string) (Entity, error)

SearchForEntity searches for an investor by name in the database

func TopReputationEntities

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

TopReputationEntities returns the list of all the entities belonging to a 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, token string) (Entity, error)

ValidateEntity validates the username and token 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 or changes fees later on during installation. The document should be stored in IPFS and the platform should guarantee its security.

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 is called by a contractor when they want to propose a new stage 2 contract based on an originated project.

func (*Entity) RefillEscrowAsset

func (a *Entity) RefillEscrowAsset(projIndex int, asset string,
	amount float64, seedpwd string) error

RefillEscrowAsset refills the escrow with USD from the guarantor's account. Escrow should already have a trustline set with the stablecoin provider

func (*Entity) RefillEscrowXLM

func (a *Entity) RefillEscrowXLM(projIndex int, amount float64, seedpwd string) error

RefillEscrowXLM refills the escrow with XLM from the guarantor's account

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. Slashing is a user trigerred action and happens only when entities report against a contractor.

type Feedback

type Feedback struct {
	// Content is the content of the feedback
	Content string

	// From denotes who gave the feedback
	From Entity

	// To denotes to whom the feedback was targeted towards
	To Entity

	// Date contains the data when the feedback was given
	Date string

	// Contract is the project for which the feedback was given for.
	Contract []Project
}

Feedback defines a structure used for providing feedback

type Investor

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

	// C is a structure containing all details of the company the investor is part of
	C Company

	// Company denotes whether the given investor is acting on behalf of a company
	Company bool

	// 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
}

Investor defines the investor structure

func NewInvestor

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

NewInvestor creates a new investor

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 by index from the database

func SearchForInvestor

func SearchForInvestor(name string) (Investor, error)

SearchForInvestor searches for an investor by name in 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, token string) (Investor, error)

ValidateInvestor validates an investor's token 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

func (*Investor) SetCompany

func (a *Investor) SetCompany() error

SetCompany sets the company bool to true. This enables the creation of investors who can act on behalf of a company

func (*Investor) SetCompanyDetails

func (a *Investor) SetCompanyDetails(companyType, name, legalName, adminEmail, phoneNumber, address,
	country, city, zipCode, taxIDNumber, role string) error

SetCompanyDetails sets the company struct details of the investor class

type Project

type Project struct {
	// Index is the project index
	Index int

	// TotalValue is the value of value of the advertised project
	TotalValue float64

	// Lock locks investments in order to wait for the recipient's confirmation
	Lock bool

	// LockPwd is the recipient's seedpwd. Will be set to null after used once
	LockPwd string

	// Chain is the blockchain the smart contract is based on
	Chain string

	// OneTimeUnlock is a one time unlock password where the recipient stores their. Set to null after single use
	OneTimeUnlock string

	// AmountOwed is the amount owed to investors.
	AmountOwed float64

	// Reputation is the positive reputation associated with a project
	Reputation float64

	// Votes is the number of votes towards a proposed contract by investors
	Votes float64

	// OwnershipShift is the percentage of the project that the recipient owns
	OwnershipShift float64

	// StageData is the data associated with stage migrations
	StageData []string

	// StageChecklist is the checklist that has to be completed before moving on to the next stage
	StageChecklist []map[string]bool

	// InvestorMap publicKey: %investment map
	InvestorMap map[string]float64

	// SeedInvestorMap publicKey: %investment map for seed invstors
	SeedInvestorMap map[string]float64

	// WaterfallMap publickey:amount map used to pay project stakeholders
	WaterfallMap map[string]float64

	// RecipientIndex is the index of the project's main recipient
	RecipientIndex int

	// OriginatorIndex is the originator's index
	OriginatorIndex int

	// GuarantorIndex is the person guaranteeing the project
	GuarantorIndex int

	// ContractorIndex is the person who proposed the contract
	ContractorIndex int

	// InvestorIndices contains the various investors who have invested
	InvestorIndices []int

	// SeedInvestorIndices contains investors who took part before the contract was at stage 3
	SeedInvestorIndices []int

	// DateInitiated contains the date when the project was created
	DateInitiated string

	// DateFunded contains the date that the project completed the stage 4-5 migration
	DateFunded string

	// DateLastPaid contains the int64 ie unix time of last payment
	DateLastPaid int64

	// AuctionType is the type of the auction the recipient has chosen (if they have)
	AuctionType string

	// InvestmentType is the type of investment - equity crowdfunding, municipal bond, normal crowdfunding, etc
	InvestmentType string

	// PaybackPeriod is the frequency in number of weeks that the recipient has to pay back the platform
	PaybackPeriod time.Duration

	// Stage is the stage at which the contract is at
	Stage int

	// InvestorAssetCode the code of the asset given to investors on investment in the project
	InvestorAssetCode string

	// DebtAssetCode is the code of the asset given to recipients on receiving a project
	DebtAssetCode string

	// PaybackAssetCode is the code of the asset given to recipients on receiving a project
	PaybackAssetCode string

	// SeedAssetCode is the code of the asset given to seed investors on seed investment in the project
	SeedAssetCode string

	// SeedInvestmentFactor is the factor that a seed investor's investment is multiplied by in case they do invest at the seed stage
	SeedInvestmentFactor float64

	// SeedInvestmentCap is the max amount that a seed investor can put in a project when it is the seed stage
	SeedInvestmentCap float64

	// EscrowPubkey is the publickey of the escrow we setup after project investment
	EscrowPubkey string

	// EscrowLock is used to lock the escrow in case someting goes wrong
	EscrowLock bool

	// MoneyRaised is total money that has been raised until now
	MoneyRaised float64

	// SeedMoneyRaised is the total seed money that has been raised until now
	SeedMoneyRaised float64

	// EstimatedAcquisition is the year by which the recipient is expected to repay the initial investment amount
	EstimatedAcquisition int

	// BalLeft is the balance left against the original investment
	BalLeft float64

	// AdminFlagged is set if someone reports the project
	AdminFlagged bool

	// FlaggedBy is the index of the admin who flagged the project
	FlaggedBy int

	// UserFlaggedBy contains the indices of users who flagged the project
	UserFlaggedBy []int

	// Reports is the total number of reports against this particular project
	Reports int

	// TellerUrl isthe url of the teller
	TellerUrl string

	// BrokerUrl isthe url of the MQTT broker
	BrokerUrl string

	// TellerPublishTopic is the topic using which the publisher / subscriber must post / subscribe messages from
	TellerPublishTopic string

	// Metadata contains other metadata and is used to derive project asset ids.
	Metadata string

	// InterestRate is the rate of return for investors
	InterestRate float64 `json:"Interest Rate"`

	// Content contains the bulk of the non smart contract data
	Content CMS

	// below are non critical params only used on the frontend
	Name               string    `json:"Name"`                 // the name of the project / the identifier by which its referred to
	City               string    `json:"City"`                 // the city in which the project is located at
	State              string    `json:"State"`                // the state in which the project has been installed in
	Country            string    `json:"Country"`              // the country in which the project has been installed in
	SelfFund           float64   `json:"Amount Self Funded"`   // the amount that a beneficiary / recipient puts in a project without 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
	MainDeveloperIndex int       `json:"Main Developer Index"` // the main developer of the project
	DeveloperIndices   []int     `json:"Developer Indices"`    // the indices of the developers involved in the project`
	ContractorFee      float64   `json:"Contractor Fee"`       // fee paid to the contractor from the total fee of the project
	OriginatorFee      float64   `json:"Originator Fee"`       // fee paid to the originator included in the total value of the project
	DeveloperFee       []float64 `json:"Developer Fee"`        // the fees charged by the developers
	MainImage          string    `json:"MainImage"`            // The main image of the project
	SmallImage         string    `json:"SmallImage"`           // The small image to be used on the explore tab
}

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 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 provide the seedpwd and unlock them.

func RetrieveOriginatorProjects

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

RetrieveOriginatorProjects retrieves projects that are associated with a originator from the database

func RetrieveProject

func RetrieveProject(key int) (Project, error)

RetrieveProject retrieves a project by index from the database

func RetrieveProjectsAtStage

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

RetrieveProjectsAtStage retrieves projects at a stage from the database

func RetrieveRecipientProjects

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

RetrieveRecipientProjects retrieves projects that are associated with a recipient from the database.

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 of installation.

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 is paid by the highest bidder.

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 project. There are four options blind, civkrey, english and dutch.

func (*Project) SetStage

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

SetStage sets the stage of a project

type Recipient

type Recipient struct {

	// U imports the base User class from openx
	U *openx.User

	// C is a structure containing all details of the company the investor is part of
	C Company

	// Company denotes whether the given investor is acting on behalf of a company
	Company bool

	// ReceivedSolarProjects stores the projects that the recipient is receiver of
	ReceivedSolarProjects []string

	// ReceivedSolarProjectIndices stores the indices of the projects the recipient is part of
	ReceivedSolarProjectIndices []int

	// DeviceId is the device ID of the associated solar hub / IoT device
	DeviceId string

	// DeviceStarts contains the start time of the above IoT devices.
	DeviceStarts []string

	// DeviceLocation stores the physical location of the device powered by Google APIs.
	DeviceLocation string

	// StateHashes stores the list of state updates (ipfs hashes) of the teller
	StateHashes []string

	// TellerEnergy contains the net energy consumed during a given period
	TellerEnergy uint32

	// Autoreload is a bool to denote whether the recipient wants to reload balance from their secondary account
	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 by index from the database

func SearchForRecipient

func SearchForRecipient(name string) (Recipient, error)

SearchForRecipient searches for a recipient by name in the database

func TopReputationRecipients

func TopReputationRecipients() ([]Recipient, error)

TopReputationRecipients returns a list of recipients sorted by descending reputation

func ValidateRecipient

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

ValidateRecipient validates a recipient's token and username

func (*Recipient) Save

func (a *Recipient) Save() error

Save saves a Recipient's details

func (*Recipient) SetCompany

func (a *Recipient) SetCompany() error

SetCompany sets the company bool to true

func (*Recipient) SetCompanyDetails

func (a *Recipient) SetCompanyDetails(companyType, name, legalName, adminEmail, phoneNumber, address,
	country, city, zipCode, taxIDNumber, role string) error

SetCompanyDetails stores the company details in the recipient class

func (*Recipient) SetOneTimeUnlock

func (a *Recipient) SetOneTimeUnlock(projIndex int, seedpwd string) error

SetOneTimeUnlock sets a one time seedpwd that can be used to automatically unlock the project once an investment comes in

type Stage

type Stage struct {
	Number          int
	FriendlyName    string   // the informal name that one can use while referring to the stage
	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 contains the details of different stages on Opensolar

Jump to

Keyboard shortcuts

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