Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Viva Network Snippets
contract MortgageListing {
// Data model separated from smart contract business logic
function setCrowdfundTerms(address addr) public;
function setFMSToken(address addr) public;
function setMortgageTerms(address addr) public;
// Crowdfund active
function openCrowdfunding() public;
function purchaseFMS(uint256 fms) public returns (bool);
function validatePurchaseFMS(uint256 fms) internal view returns (bool);
function forwardFundsToVault() internal;
// Crowdfund close
function isSuccess() public view returns (bool);
function finalize() public;
function cleanUp() public;
// Crowdfund failure
function cancelCrowdfunding() public;
function refund() internal;
// Crowdfund success
function releaseFunds() public;
function foreclosed() public;
// Mortgage payments and distribution
function receivePayment(uint256 viva) public returns (bool);
function distributePayment(uint256 viva) internal;
// Oracles (most are in the MortgageTerms)
function oracleUSD(uint256 viva) internal view returns (uint256);
// Events
event CrowdfundingSuccess();
event CrowdfundingCancelled();
}
contract FMSExchange {
// Data model separated from smart contract business logic
function setFMSToken(address addr) public;
// Trustless FMS - VIVA exchange (essentially escrowed)
function exchangeFMS(address from, address to, uint256 fmsAmount, uint256 vivaPrice) public returns (bool);
function validateExchangeFMS(address from, address to, uint256 fmsAmount, uint256 vivaPrice) internal returns (bool);
// Ommitted market-making logic
// Events
event Exchange(address indexed from, address indexed to, uint256 fmsAmount, uint256 vivaPrice);
}
contract FMSToken { // ERC20 compliant to represent FMS ownership and exchange trading
function totalSupply() public view returns (uint256);
function balanceOf(address fmsOwner) public view returns (uint256);
function allowance(address fmsOwner, address spender) public view returns (uint256);
function transfer(address to, uint256 fms) public returns (bool); // restricted to exchange
function approve(address spender, uint256 fms) public returns (bool);
function transferFrom(address from, address to, uint256 fms) public returns (bool); // restricted to exchange
// Events
event Transfer(address indexed from, address indexed to, uint256);
event Approval(address indexed fmsOwner, address indexed spender, uint256);
}
contract MortgageTerms {
// Contract of static mortgage terms (getters and in-depth mortgage term processing omitted):
// - Principal, rate (fixed or adjustable), period/term, discount, etc.
// - Dynamic credit profile (V-SCORE) oracle attached to V-ID
// - Payment/default pattern history etc.
function receivedMonthlyPayment(uint256 viva) public returns (bool);
function monthlyPaymentOwed(uint256 atDate) public returns (uint256);
function mortgageStatus() public returns (MortgageStatus); // Indicate needs foreclosure, good standing, finished, etc.
// Oracles
function oraclePropertyAssessment() internal view returns (address);
function oracleCreditProfile() internal view returns (address);
function oracleHomePurchase() internal view returns (address); // Capture progress of deal closing (e.g. protect investors
// by ensuring refundable VIVA if purchase does not close)
function oracleInterestRate(uint256 atDate) view returns (uint256);
function oracleUSD(uint256 viva) internal view returns (uint256);
}
contract CrowdfundingTerms {
// Crowdfunding event terms (getters omitted):
// - Duration, min/max FMS participation size, etc.
// - Investor authorization/blacklisting
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment