Develop, Backtest, and
Execute in DeFi with Ease.

Our technology lays the foundation for a new paradigm in digital assets: from data-sourcing and strategy development over backtesting and simulation to analytics — we cover your DeFi infrastructure needs in one simple Python package. No Solidity required.


Introducing Dojo

An institutional-grade DeFi platform that seamlessly integrates with your trading workflow, empowering users with instant, on-premise connectivity to DeFi.

Compass Labs
Dojo Simulation Dashboard
Compass Docs
2021-06-21
2021-06-21
UniswapV3Env
TraderAgent/LPAgent
Rewards
UniswapV3
Explore
Bookmarks

Use the this tool to explore the simulation. You can plot any 2 quantities against each other over time.

What does Dojo offer?

Protocol Integration


Bridging the gap. A unified interface for DeFi interoperability across protocols and chains.

Dojo offers a unified Python interface to the most liquid spot, lending and derivatives exchanges, enabling users with instant connectivity from a single platform. Dojo is successfully integrated with Uniswap, Aave and soon GMX.

Dojo

Data accessibility


Decipher history. Access to detailed DeFi data across multiple blockchain networks.

Curated and fast access to tick-level on-chain data in standardized data formats, including event and function call data for any contract since network inception. Versatile delivery in your preferred format.

1,800
1,820
1,840
1,860
1,880
1,900

Python Interface


Smart contracts, simplified. Develop strategies in pure Python.

Seamlessly access DeFi with simple Python functions like aave_flashloan or uniswap_trade. Run arbitrary Python code, make API calls, and incorporate external data feeds, leveraging the full power of Python's ecosystem. No need to run a node or manage data pipelines — everything you need is readily available and easy to use.

Solidity
1

// SPDX-License-Identifier: MIT

2

pragma solidity ^0.8.0;

3

import "@aave/protocol-v2/contracts/interfaces/IFlashLoanReceiver.sol";

4

import "@aave/protocol-v2/contracts/interfaces/ILendingPool.sol";

5

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

6

contract FlashLoanReceiver is IFlashLoanReceiver {

7

ILendingPool public lendingPool;

8

constructor(address _lendingPool) {

9

lendingPool = ILendingPool(_lendingPool);

10

}

11

function executeOperation(

12

address[] memory assets,

13

uint256[] memory amounts,

14

uint256[] memory premiums,

15

address initiator,

16

bytes memory params

17

) external override {

18

(address recipient) = abi.decode(params, (address));

19

for (uint256 i = 0; i < assets.length; i++) {

20

IERC20(assets[i]).transfer(recipient, amounts[i]);

21

}

22

for (uint256 i = 0; i < assets.length; i++) {

23

uint256 amountOwing = amounts[i] + premiums[i];

24

IERC20(assets[i]).approve(address(lendingPool), amountOwing);

25

}

26

}

27

function initiateFlashLoan(address[] memory assets, uint256[] memory amounts, bytes memory params) external {

28

lendingPool.flashLoan(address(this), assets, amounts, params);

29

}

30

}

Solidity
1

const axios = require('axios');

2

3

async function fetchHistoricPrices(token0, token1, startTime, endTime) {

4

const query = `

5

{

6

pair(id: "${token0}-${token1}") {

7

token0 {

8

symbol

9

}

10

token1 {

11

symbol

12

}

13

token0Price

14

token1Price

15

token0PriceHistory(first: 1000, where: { timestamp_gte: ${startTime}, timestamp_lte: ${endTime} }, orderBy: timestamp, orderDirection: asc) {

16

price

17

timestamp

18

}

19

token1PriceHistory(first: 1000, where: { timestamp_gte: ${startTime}, timestamp_lte: ${endTime} }, orderBy: timestamp, orderDirection: asc) {

20

price

21

timestamp

22

}

23

}

24

}

25

`;

26

27

try {

28

const response = await axios.post('https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', {

29

query: query

30

});

31

return response.data.data.pair;

32

} catch (error) {

33

console.error('Error fetching historic prices:', error);

34

return null;

35

}

36

}

37

38

// Example usage

39

const token0 = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'; // Token0 address (e.g., ETH)

40

const token1 = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; // Token1 address (e.g., DAI)

41

const startTime = Math.floor((Date.now() - 7 * 24 * 60 * 60 * 1000) / 1000); // 7 days ago in Unix timestamp

42

const endTime = Math.floor(Date.now() / 1000); // Current time in Unix timestamp

43

44

fetchHistoricPrices(token0, token1, startTime, endTime)

45

.then(pairData => {

46

console.log(pairData);

47

})

48

.catch(error => {

49

console.error('Error:', error);

50

});

python logo
1

env = UniswapV3Env(

2

data_range = (2021-06-01, 2023-03-04)

3

)

4

5

env.load_data()

6

7

policy = [

8

AAVEv3FlashLoan(amount = 1_000_000),

9

UniswapV3Trade(pool = 'USDC-WETH', amount = 1_000_000),

10

Balv2Trade(pool = 'USDC-WETH', amount = 'max'),

11

AAVEv3FlashLoanRepay(amount = 1_000_000),

12

]

13

14

testnet.backtest_run(env, [policy])

15

16

sandbox.live_run(private_key = '0x0..', env, [policy])

Simulation Platform


Practice before you preach. Test, train and monitor strategies and smart contracts.

Backtest and simulate DeFi strategies and smart contracts using Dojo’s agent-based simulator. Model realistic market dynamics in a safe environment. Monitor performance and protocol statistics.