Skip to content

Instantly share code, notes, and snippets.

@tvcutsem
tvcutsem / horton.js
Created May 25, 2023 23:06
Horton in JavaScript: delegation with blame attribution in an object-capability language
/*
* Horton in JavaScript: delegation with blame attribution in an object-capability language
*
* See http://erights.org/elib/capability/horton/index.html for idea and paper.
*
* Implementation based on: http://erights.org/elib/capability/horton
* (with N-ary message support, lexical nesting and rights amplification)
*
* To run:
*
const Either = (() => {
const Right = x => ({
chain: f => f(x),
ap: other => other.map(x),
alt: other => Right(x),
extend: f => f(Right(x)),
concat: other =>
other.fold(
x => other,
y => Right(x.concat(y)),

ICS: Cinderella Tokens: An Async/IBC friendly alternative to flash loans

Flashloans are a fascinating economic coordination mechanism that has emerged out the Ethereum architecture as a result of a synchronous, sequential, atomic transaction system. It allows anonymous coordination between capital providers and arbitrageurs because the capital providers can condition providing any capital on protocol enforced guarantee that the entire arbitrage is profitable denominated in the token being lent.

One of the effects of this process has been the it ensures an efficient and healthy liquidation market for the collateral in long term debt instruments. It also enables low cost scaling of economic exploits.

Why don’t flash loans exist in IBC world?

Flash loans are impossible in an IBC world because IBC semantics require finalizing a block on the origin chain rather than on the receiving chain. This makes atomicity for the lender difficult and moves us into the domain of over collateralized lending.

import curry from 'crocks/helpers/curry'
import or from 'crocks/logic/or'
import pathSatisfies from 'crocks/predicates/pathSatisfies'
import propSatisfies from 'crocks/predicates/propSatisfies'
const list = [
'nice', 'bad', 'super bad'
]
const data = [
@evilsoft
evilsoft / ours(preds addtion).md
Last active April 14, 2023 06:44
Simple Style Diffs
+ const isValidScore = score =>
+   score >= 70
+
+ const isValidUser = user =>
+   user && user.length > 3

data.reduce((acc, rec) => {
  const { score, user } = rec
@abiodun0
abiodun0 / view_and_reader_monad.js
Last active September 16, 2021 04:10
React and reader monad from first principles https://codesandbox.io/s/react-composition-rjmzd
import ReactDOM from 'react-dom'
import Reac, { createElement } from 'react'
import { compose, map, ap, pipe } from 'ramda'
import IntlMessageFormat from 'intl-messageformat'
const copyrightNotice = View(({ author, year }) => <p>© {author} {year}</p>)
const Monad = {
do: gen => {
import Maybe from 'crocks/Maybe'
import Star from 'crocks/Star'
import prop from 'crocks/Maybe/prop'
import propOr from 'crocks/helpers/propOr'
import resultToMaybe from 'crocks/Maybe/resultToMaybe'
import tryCatch from 'crocks/Result/tryCatch'
const MaybeStar =
Star(Maybe)
const Day = ({ get, left, right }) => {
const map = f => Day ({
get: f (extract()),
left, right
})
const extend = f =>
Day ({
get: (left, right) => f (Day ({ get, left, right })),
import R from 'ramda'
import { account } from 'store/lenses'
export default {
ids: R.view(account.ids),
recentActivity: R.memoize(
state => R.compose(
ids => {
const hash = R.view(account.data, state)
@i-am-tom
i-am-tom / bifunctor-profunctor.js
Created June 26, 2017 18:32
The main examples from the "Bifunctor + Profunctor" post.
const { Left, Right } = require('fantasy-eithers')
const daggy = require('daggy')
Function.prototype.map = function (f) {
return x => f(this(x))
}
//- Where everything changes...
const login = user =>
user.name == 'Tom'