This New Technology Is Changing Fintech
Tags: blockchain, python, solidity, algotrading
Published: 2020-12-23 04:16:10

# Introduction
[Fintech](https://www.investopedia.com/terms/f/fintech.asp) is a popular buzzword. Why? Because it powers our money. Our banks, our assets, our investments all run through the tools that engineers have been building for years to make our monetary systems easy and powerful.

But what if I told you that fintech as you know it is in for a massive makeover? 

That fintech has already started handing over market share to a new technology. That the skills needed to run a successful hedge fund, asset manager, data vendor, are going through the spin cycle of reform. Many of these pieces you see today, like python, devops, and algorithmic modeling will persist, but on a totally different platform.

We will go over what defi is, and how you can join. 

If you know some #python, you'll want to stick around. 

# What is DeFi

Defi is proving to be the force that is going to be:
- More secure
- More transparent
- Faster
- Less corrupt

This year, we've seen an explosion from the defi scene, going from nearly nothing [to nearly $15b](https://defipulse.com/) in assets under management be decentralized protocols.

## So what is defi? 

Defi stands for "Decentralized Finance", and is a concept where non-custodial [smart contracts](https://www.investopedia.com/terms/s/smart-contracts.asp) hold your asset and automatically execute without a centralized intermediate. Meaning you don't have a banker who can freeze your assets anymore. You don't have an exchange where a trade takes 4 days to settle. You are finally truly in charge of your assets.

## How is that possible?

Smart Contract platforms like Ethereum allow engineers to build applications that have no centralized authority and automatically execute. Everything is transparent on-chain and every can see the code. Imagine a commons that is [tragedy resistant](https://en.wikipedia.org/wiki/Tragedy_of_the_commons) but instead of a plain or common, you have a computational system. This allows for people to truly own their asset. 

More and more protocols are running in defi, and for good reason. The value add that blockchain/smart contract platforms have around transparency and security is huge, but the other massive thing is the current yield. 

We are currently in a [low-interest rate environment](https://www.investopedia.com/terms/l/low-interest-rate-environment.asp), where banks give next to nothing for holding your money. A defi protocol can do the same thing, and for nearly the same security net you 5% - 10% APY. In a traditional finance world, this is insane. Professional hedge funds don't make anywhere near that even on a short term basis. 

Some of these platforms are doing revolutionary work. You can see the top projects at the moment on [Defipulse](https://defipulse.com/), a platform that tracks defi project growth. 

[Aave](https://aave.com/) is a decentralized borrowing and lending platforms, and has a tool called a "flash loan", which allows you to borrow as much as you want **without any collateral**. This is only possible with blockchain, but it allows you to be a whale for a very short period of time.

[Synthetix](https://www.synthetix.io/) is a decentralized protocol that allows for tokenizing assets into synthetic tokens. Meaning you can have your TSLA shares be a cryptocurrency and be traded with ease. 

I've written a lot about Synthetix because the current stock market and securities buying world is fraught with corruption. The faster we can get these protocols to scale the better. If you want to read more about the power Synthetix will have, [check this article out](https://medium.com/@patrick.collins_58673/actually-fair-stock-markets-why-you-need-to-be-bought-in-on-decentralized-exchanges-now-b98b325282d5?sk=1f973d9cf13fb488535cd7a2ca8ab97c). 

[yearn.finance](https://yearn.finance/) is the best-decentralized algotrader out there. It finds the highest APY of the various protocols and moves everyone's money to them in a way that maximized yield. In the traditional fintech world, this is a bigger issue than insider trading. A hedge fund not practicing best execution is a way bigger threat than insider trading. 

[Set Protocol](https://www.setprotocol.com/?ref=cryptocurrencyjobs.co) build your own defi strategies and become an asset manager through just your public strategy on-chain. Anyone can set up a strategy. 

# How you can get involved

I ended above with two projects that current fintech engineers love. Yearn.finance and Set Protocol. Both are the current best iterations of decentralized algoritmic trading.

Imagine wanting to start a hedge fund with an amazing strategy but not having the capital to pay for a fancy lawyer to get all the paperwork started. You can get started without any of that with a strategy on one of these platforms. I love python, as does a lot of the algorithmic trading world and yearn.finance is a project run by ex-traditional fintech engineers, and they brought python with them.

This will be your guide to get a boilerplate strategy going. 

# Getting started with Python

Install the following:
- [python](https://www.python.org/downloads/)
- [pip](https://pip.pypa.io/en/stable/installing/)
- [npm](https://www.npmjs.com/get-npm)
- brownie (see below)
```
pip install brownie
```
- ganache
```
npm install -g ganache-cli
```

Sign up for [Infura](https://infura.io/) and generate an API key. Store it in the `WEB3_INFURA_PROJECT_ID` environment variable.
```
export WEB3_INFURA_PROJECT_ID=YourProjectID
```

Sign up for [Etherscan](https://etherscan.io/) and generate an API key. This is required for fetching source codes of the mainnet contracts we will be interacting with. Store the API key in the `ETHERSCAN_TOKEN` environment variable.

```
export ETHERSCAN_TOKEN=YourApiToken
```
Then download the mix:

```
brownie bake yearn-strategy 
```

## Working with contracts

1. Open the Brownie console. This automatically launches Ganache on a forked mainnet. Ganache is a fake blockchain that will run locally on your computer. This will simulate working with the real Ethereum network. 

```
brownie console
```

2. Create variables for the Yearn Vault and Want Token addresses. These were obtained from the Yearn Registry. Also, loan the Yearn governance multisig.

```
>>> vault = Vault.at("0xBFa4D8AA6d8a379aBFe7793399D3DdaCC5bBECBB")  # yvDAI (v0.2.2)
>>> token = Token.at("0x6b175474e89094c44da98b954eedeac495271d0f")  # DAI
>>> gov = "ychad.eth"  # ENS for Yearn Governance Multisig
```

3. Deploy the `Strategy.sol` contract.

```
>>> strategy = Strategy.deploy(vault, {"from": accounts[0]})
Transaction sent: 0xc8a35b3ecbbed196a344ed6b5c7ee6f50faf9b7eee836044d1c7ffe10093ef45
  Gas price: 0.0 gwei   Gas limit: 6721975
  Flashloan.constructor confirmed - Block: 9995378   Gas used: 796934 (11.86%)
  Flashloan deployed at: 0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87
```

This will be your first transaction on-chain, nice work!

4. Approve the strategy for the Vault. We must do this because we only approved Strategies can pull funding from the Vault.

```
# 1000 DAI debt limit, no rate limit, 50 bps strategist fee
>>> vault.addStrategy(strategy, Wei("1000 ether"), 2 ** 256 - 1, 50, {"from": gov})
Transaction sent: 0xa70b90eb9a9899e8f6e709c53a436976315b4279c4b6797d0a293e169f94d5b4
  Gas price: 0.0 gwei   Gas limit: 6721975
  Transaction confirmed - Block: 9995379   Gas used: 21055 (0.31%)
```
5. Now we are ready to put our strategy into action!

```
>>> harvest_tx = strategy.harvest({"from": accounts[0]})  # perform as many time as desired...
```

`Strategy.sol` is where you can implement your own strategy and get started working with decentralized "algotrading". 

Be sure to [check out the repo](https://github.com/iearn-finance/brownie-strategy-mix) to learn more about how it works, the community around it. Once you build something awesome, be sure to make some noise! The community love meeting new people.