Building an SDK 0.1.14 – Adding a Contracts module


The idea of adding this was to make accessing Balancer contracts easier for users. Normally you need to find and import ABIs and deal with deployment addresses, if we want to make it easy we should just remove that complexity.

Also we are trying to make the main SDK functions return the contract name and functions as part of the attributes returned. This means the user could then just call using something like:

const { contractName, functionName, attributes } = transactionAttributes;



Typechain is a package that provides TypeScript bindings for Ethereum contracts. This means functions are statically typed and there is also IDE support which makes things safer and easier to develop against.

Balancer has its own @balancer-labs/typechain package that exposes instances of the commononly used contracts. Adding this to the SDK means we can remove the need to import ABI jsons and we can now create instances of contracts by doing:

import {
} from '@balancer-labs/typechain';


which will return a typed Vault contract.


  • Uses BALANCER_NETWORK_CONFIG and to find vault/lidoRelayer/multicall addresses.
  • Added contracts getter to SDK module:
        public config: BalancerSdkConfig,
        public sor = new Sor(config),
        public subgraph = new Subgraph(config),
        public pools = new Pools(config),
        public balancerContracts = new Contracts(config, sor.provider)
    ) { ... }

get contracts(): ContractInstances {
        return this.balancerContracts.contracts;

This can then be called like:

const vaultContract = balancer.contracts['vault'];


const vaultContract = balancer.contracts.vault

which will provide typed function refs.


One interesting discussion is the trade off of using the Contracts module within other modules. As of now only the Swaps and Multicaller modules using contracts. Using the Contracts module means we either have to pass Contracts in constructor, which adds an extra step if someone want to use modules independently:

const contracts = new Contracts(config)
const swaps = new Swaps(config, contracts)

or we instantiate Contracts within the module – which ends up happening twice if we use the high level SDK function as it is also instantiated there. For now we have decided to use the Typechain factories to instantiate the contracts within the module and will revisit in future if needed.

Photo by Pablo Arroyo on Unsplash


Market-Protocol Fit – describes some of how Balancer ⚖️ are approaching things. It’s a whole new world!

👨‍🏫 Etsy’s Journey to TypeScript – trying to improve my Typescript as much as possible and there’s some interesting stuff here.

⏱️ Just-in-time Liquidity – pretty interesting MEV attack. Random idea – could this be a type of exchange where users get a better price and “LPs” rebalance?

Cool tool 🧰: eth-sdk, provide the address of the contract you want to interact with and it will pull down abi from Etherscan API and create Typescript and Ethers instances.

📺 How to make hard choices – worth a watch. Drifting…

This guy has some awesome NFT displays and a guide! 🖼️

️️️⏪ Replaying a transaction (from its hash ️️️) to get a revert reason. (Needs an archive node)

Flickr Engineering Team Vision & Guiding Principles – some good examples for how I should approach things. ✔️

🎵 Watched some of the Beatles Get Back doc and it showed how powerful it is when people truly work together. Fred Wilson said it better than I can!

💹 Ming Zhao on Twitter has some really good TLDR threads on more advanced finance stuff. Like this 12 Crypto Hedge Fund Trading Strategies.

Damn – Cobie is fast becoming one of my crypto heroes and his Substack is really good! 🔥

6 figures a day 🤑 selling Excel courses – meet Miss Excel

🍴 Tenderly forking end point – super useful for building/testing.

The Nothingness Of Money – no one knows where the finish line is, so be present and enjoy the journey! 🧘

🦄 Dune is one of the companies I always had a feeling would do well – from nobody to unicorn in 3 years shares their inspiring story so far.

The Crazy Idea Framework 🤪 sounds like an interesting one to try for investing.

How People Think, Morgan Housel 🧙‍♂️ is one of the best and this feels like it should be read every week as a reminder!

🌺 Bloom Filters are cool! Here’s an interesting thread on how Lens protocol is using them.

Pretty interesting negotiation advice – already feel like I’m constantly negotating with my 2 year old 👼

😎 This post about Alan Kay and his inventions is just really cool.

Quality of life vs quantity – makes you think 🤔

Death by PowerPoint: the slide that killed seven people – puts boring PowerPoints into a whole new perspective. 😥

😨 Shadow of the Sun – this is just brutal. Some of the descriptions are my idea of hell I think.

Photo by Ving N on Unsplash