Published
Edited
Feb 23, 2022
Insert cell
Insert cell
amountOfUsdcToDistribute = 20000
Insert cell
ignoreAccountsBelow = 50
Insert cell
grainConfig = ({
allocationPolicies: [
{
policyType: "IMMEDIATE",
budget: G.fromInteger(amountOfUsdcToDistribute),
numIntervalsLookback: 2
}
// {
// policyType: "RECENT",
// budget: G.fromInteger(amountOfUsdcToDistribute),
// 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, [
name,
G.add(map.get(name) ? map.get(name)[1] : G.ZERO, r.amount),
ledger
.account(r.id)
.payoutAddresses.get(
'{"chainId":"1","tokenAddress":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","type":"EVM"}'
)
]);
});
});
});
return map;
}
Insert cell
ledger.accountByName("Thena")
Insert cell
G = sc.ledger.grain
Insert cell
credGrainView = loadCredGrainView("sourcecred/cred/gh-pages")
Insert cell
ledger = {
const ledger = await loadLedger("sourcecred/cred/gh-pages");
// 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
buildCsvDownload,
credGrainViewCredTable
} from "@sourcecred/quick-imports"
Insert cell
credGrainViewCredTable(
sc.core.CredGrainView.fromCredGraphAndLedger(credGraph, ledger),
1,
2
)
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