Published
Edited
Feb 21, 2022
1 fork
Insert cell
Insert cell
amountToDistribute = 10000
Insert cell
ignoreAccountsBelow = 20
Insert cell
grainConfig = ({
allocationPolicies: [
{
policyType: "IMMEDIATE",
budget: G.fromInteger(amountToDistribute),
numIntervalsLookback: 8
}
// {
// policyType: "RECENT",
// budget: G.fromInteger(amountToDistribute),
// discount: 0.16,
// exclusions: []
// }
],
maxSimultaneousDistributions: 1,
accountingEnabled: true
})
Insert cell
Insert cell
Insert cell
md`<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
# Behind the Scenes`
Insert cell
currencyDetails = ({ name: "USDC", suffix: " USDC", decimals: 2 })
Insert cell
flatEarnings2 = {
const map = new Map();
grainOutput2.distributions.forEach(x => {
x.allocations.forEach(a => {
a.receipts.forEach(r => {
const name = ledger.account(r.id).identity.name;
map.set(name, G.add(map.get(name) || G.ZERO, r.amount));
});
});
});
return map;
}
Insert cell
G = sc.ledger.grain
Insert cell
credGrainView = loadCredGrainView(repoAndBranch)
Insert cell
ledger = {
const ledger = await loadLedger(repoAndBranch);
// Uncomment this line to include all participants, regardless of activation status
//for (const a of ledger.accounts()) ledger.activate(a.identity.id);
return ledger;
}
Insert cell
grainOutput2 = {
return sc.api.grain.grain({
credGrainView,
ledger: sc.ledger.ledger.Ledger.fromEventLog(ledger.eventLog()),
grainConfig,
currencyDetails,
allowMultipleDistributionsPerInterval: true
})
}
Insert cell
import {
// Our Instance Data
// Instance Data Getters
loadLedger, // Function for getting a ledger using a repo/branch string
loadCredGrainView, // Function for getting a ledger using a repo/branch string
// Libraries
sc, // The SourceCred API Library
// Input Modules. Example usage: viewof repoAndBranch = html`${repoAndBranchInput}`
repoAndBranchInput // A URL query string parser and input box combo for user-provided repo/branch string
} from "@sourcecred/quick-imports"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more