Skip to content

Instantly share code, notes, and snippets.

View ilblackdragon's full-sized avatar

Illia Polosukhin ilblackdragon

  • NEAR Protocol
  • San Francisco, CA
View GitHub Profile
@ilblackdragon
ilblackdragon / exception_hook.py
Last active December 11, 2017 23:50
Exception Hook for not print debugging
import sys
import traceback
def _format_value(key, value, first_n=20, last_n=20):
s = repr(value)
s = s.replace('\n', ' ').strip()
if len(s) > first_n + last_n + 3:
s = s[:first_n] + "..." + s[-last_n:]
return "%s: %s" % (key, s)
@ilblackdragon
ilblackdragon / serialize.rs
Last active October 19, 2023 03:07
Protobuf vs Bincode vs CBOR
/*
test serialize_bincode_block ... bench: 2,187,247 ns/iter (+/- 305,944)
test serialize_bincode_block2 ... bench: 2,214,480 ns/iter (+/- 359,709)
test serialize_bincode_tx ... bench: 2,280 ns/iter (+/- 222)
test serialize_cbor_block ... bench: 1,950,128 ns/iter (+/- 188,149)
test serialize_cbor_tx ... bench: 2,182 ns/iter (+/- 334)
test serialize_proto_block ... bench: 3,688,611 ns/iter (+/- 541,517)
test serialize_proto_tx ... bench: 3,567 ns/iter (+/- 449)
@ilblackdragon
ilblackdragon / truffle.js
Created February 14, 2020 06:33
Truffle example
const { NearProvider, nearlib } = require('near-web3-provider');
const web3 = require('web3');
ACCOUNT_ID = 'illia'
const fileKeyStore = new nearlib.keyStores.UnencryptedFileSystemKeyStore('neardev');
const networkId = 'default';
const defaultAccount = web3.utils.keccak256(ACCOUNT_ID).slice(26, 66);
module.exports = {
networks: {

Ethereum has a conflict between native token ETH and third-party tokens.

The first example of it is Maker. In case of Maker, the user locks ETH and gets PETH (Pooled ETH) token, which then gets locked into CDPs and that issues DAI (see whiteboard for more detail). At the same time DAI borrow rate accrues to MKR token holders (via burning MKR).

There is clearly in this model a way to remove MKR and just buy more ETH for the Pool, accruing value to all of Pool holders instead (also would incentivize holding CDPs longer as it now becomes a yield generating asset) Or even better, by buying and burning ETH - value would accrue to ALL ETH holders.

Similar story goes when a third-party token is used for transaction fees or as intermediate. There are no direct captures in such a token, and it can be removed by forking the contract. The most known example is Uniswap being a Bancor without their BNT token. Bancor is splitting value between liquidity providers and BNT vs in Uniswap the value only goes to liquidity