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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more