Only this pageAll pages
Powered by GitBook
1 of 5

Developers V1

Smart Contracts Overview

Introduction

Themis Protocol is a Layer2 native crypto trading platform that provides collateralized lending of NFTs through historical NFT transaction data. Themis itself is a set of DeFi protocols developed based on smart contracts. It allows users to play different roles in the governance chain according to their risk appetite and earn corresponding yields.

Core Source

The source code is included in the final production version of the protocol. Eventual changes (smart contracts updates, bug fixes, etc.) will be applied through subsequent merge requests.

The contracts are based on proxy

[Code Source Code](GitHub - Themis-protocol/Solidity-Open-Source: Themis smart contract source. Verified on Etherscan

https://etherscan.io/address/0xdC72d3FeEF3Fe708563cCB59401814B4921B7667#code

https://etherscan.io/address/0x5eF264Cb6e8b6743251B6FD93CCee7Fbcf3508C4#readProxyContract

https://etherscan.io/address/0x6885eF891808Dc88D948Dc95904dF2367AD99394#code

https://etherscan.io/address/0x168D095d7F88f3bA71BB1aCF4ebF31E287778895#codeGitHub - Themis-protocol/Solidity-Open-Source: Themis smart contract source. Verified on Etherscan

https://etherscan.io/address/0xdC72d3FeEF3Fe708563cCB59401814B4921B7667#code

https://etherscan.io/address/0x5eF264Cb6e8b6743251B6FD93CCee7Fbcf3508C4#readProxyContract

https://etherscan.io/address/0x6885eF891808Dc88D948Dc95904dF2367AD99394#code

https://etherscan.io/address/0x168D095d7F88f3bA71BB1aCF4ebF31E287778895#code)

Summary of Smart Contract

Contract
Address
Proxy Address

LendCompound

0x08cE6fED8EC9BaB309E1E60c215DcaDDb27A5791

0x6885eF891808Dc88D948Dc95904dF2367AD99394

BorrowCompound

0x051EA1d16c74ca222a08d3DDA5Ab0dE9F282cc10

0x5eF264Cb6e8b6743251B6FD93CCee7Fbcf3508C4

Auction

0x3a9d18C5292A7f973e8676201EC6EB2D233Ab01E

0x168D095d7F88f3bA71BB1aCF4ebF31E287778895

UniswapV3ChainLinkUsdOracle

0x3833B1Aa2a83b7d8B33D02ACdC7c1f5b290C17b3

0xdC72d3FeEF3Fe708563cCB59401814B4921B7667

EarlyFarming

0xB4b0a28D12895aBA0Be561971f4bdC0431C96f8b

0x8DA6E80fdd442099D1C56F21eA1ce9217F2501F9

EarlyFarmingNFT

0xabA479cd8dCaBC0020c24864f4805fC296364c4F

EarlyFarmingNFTDescriptor

0x12aDea6CfC72C42E879f8552CE4ac24ca0AFeA41

0xd433b6B1c8812c7318074074D0Aade1903e28916

Pool

Pool is for lending of cryto. Price feed by ChainLink

Token
Address
Pool Id

USDC

0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

0

WETH

0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

1

USDT

0xdac17f958d2ee523a2206206994597c13d831ec7

2

FRAX

0x853d955acef822db058eb8505911ed77f175b99e

4

MIM

0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3

5

UST

0xa693b19d2931d498c5b318df961919bb4aee87a5

6

FEI

0x956F47F50A910163D8BF957Cf5846D573E7f87CA

7

UNI

0x1f9840a85d5af5bf1d1762f925bdaddc4201f984

8

LINK

0x514910771af9ca656af840dff83e8264ecf986ca

9

1inch

0x111111111117dc0aa78b770fa6a738034120c302

10

Audits report

The Audits is proceeding with several Audition agencies. Now we are cooperating with:

  • Peckshield

Bug bounty

The bug bounty program is proceeding.

We want Themis protocol to be the best it can be, so we’re calling on our community to help us find any bugs or vulnerabilities.

More details about the bounty proceeds and how to apply can be found here:

Immunefi Bug Bounty

License

The Themis Protocol is under The-SPDX-License-Identifier: MIT

Lending

Smart Contract:[ThemisLendCompound.sol](Solidity-Open-Source/ThemisLendCompound.sol at main · Themis-protocol/Solidity-Open-Source · GitHub)

Functions

tokenOfPid

mapping(address => uint256) public tokenOfPid;

Get token address and its pool id

Parameters:

Name
Type
Description

address

address

token address

lendPoolInfo

CompoundLendPool[] public lendPoolInfo;

Get info of the lending pool

Parameters:

Name
Type
Description

pid

uint256

Pool Id of the token

Returns:

Name
Type
Description

token

address

Token Address

spToken

address

SP Token Address

curSupply

uint256

current supply in pool

curBorrow

uint256

current borrowing of pool

totalRecvInterests

uint256

User receives interest

userLend

function userLend(
    uint256 _pid, 
    uint256 _amount) public nonReentrant whenNotPaused

Borrowing Token from the Lendingpool contract

Parameters:

Name
Type
Description

_pid

uint256

Pool Id of the token

_amount

uint256

the amount to lend

userRedeem

function userRedeem(
    uint256 _pid, 
    uint256 _amount) public nonReentrant whenNotPaused 
returns(uint256)

Repay the loan

Parameters:

Name
Type
Description

_pid

uint256

Pool Id of the token

_amount

uint256

the repayent amount

pendingRedeemInterests

function pendingRedeemInterests(
    uint256 _pid, 
    address _user) 
public view returns(
            uint256 _lendInterests,
            uint256 _platFormInterests)

Query the pending redeemed Interests of a user address

Parameters:

Name
Type
Description

_pid

uint256

Pool Id of the token

_user

address

Wallet address of a user

getPoolLength

function getPoolLength() 
    external view returns(uint256 poolLength)

Get the pool length of pool

getLendPoolIdsOfOwner

function getLendPoolIdsOfOwner(
    address owner) external view returns (uint256[] memory) 

Get the lend pool ids of owner

Parameters:

Name
Type
Description

owner

address

Wallet address of a user

Events

Borrowing

Smart Contract:[ThemisBorrowCompound.sol](Solidity-Open-Source/ThemisBorrowCompound.sol at main · Themis-protocol/Solidity-Open-Source · GitHub)

Functions

getUserMaxBorrowAmount

function getUserMaxBorrowAmount(
    uint256 pid, 
    uint256 tokenId, 
    uint256 borrowAmount,
    address _user) public view 
returns(
    uint256 _maxBorrowAmount,
    bool _flag)

Get the max borrow amount of a user when the user trying to collateral the NFT

Parameters:

Name
Type
Description

pid

uint256

the ID of borrowing pool

tokenId

uint256

NFT ID to collateral

borrowAmount

uint256

input of borrow amount

_user

address

Wallet address of a user

Returns:

Name
Type
Description

_maxBorrowAmount

uint256

Max borrow amount

_flag

bool

Over loan amount

v3NFTBorrow

function v3NFTBorrow(
    uint256 pid, 
    uint256 tokenId, 
    uint256 borrowAmount) public

Parameters:

Name
Type
Description

pid

uint256

Pool ID

tokenId

uint256

NFT ID to collateral

borrowAmount

uint256

borrow amount

userReturn

Repayment the loan

function userReturn(
    uint256 bid,
    uint256 repayAmount) public

Parameters:

Name
Type
Description

bid

uint256

Borrow ID

repayAmount

uint256

repay amount

getBorrowPoolIdsOfOwner

Get the pid of a user

function getBorrowPoolIdsOfOwner(
    address owner
) external view returns (uint256[] memory)

Parameters:

Name
Type
Description

owner

address

wallet address of a user

getBorrowIdsOfOwnerAndPoolId

Get the borrow id of the owner form pid when user get a loan

function getBorrowIdsOfOwnerAndPoolId(
    address owner,
    uint256 pid
) external view returns (uint256[] memory)

Parameters:

Name
Type
Description

owner

address

Wallet address of owner

pid

uint256

Owner's pid

borrowInfo

Get the borrow id info

BorrowInfo[] public borrowInfo;

Parameters:

Name
Type
Description

bid

uint256

borrow id

Returns

Name
Type
Description

user

address

wallet address of user

pid

uint256

pool id of a loan

tokenId

uint256

Collateralized NFT token ID

Auction

Smart Contract:[ThemisAuction.sol](Solidity-Open-Source/ThemisAuction.sol at main · Themis-protocol/Solidity-Open-Source · GitHub)

Functions

doAuction

Participation in the auction

There are two types of auction: buy it now and Dutch auction. In this method, amount has a minimum starting price requirement

Buy it now: when the amount paid for a lot is greater than or equal to the Buy it now price, it is counted as a buy it now price and the excess amount is returned to the user address

Dutch auction: no more details

function doAuction(
    uint256 auctionId,
    uint256 amount) external

Parameters:

Name
Type
Description

auctionId

uint256

The token ID of the lot

amount

uint256

Payment amount

doHarvestAuction

Claim the lot when user bid it succesful

function doHarvestAuction(uint256 auctionId) external

Parameters:

Name
Type
Description

auctionId

uint256

The token ID of the lot

getAuctioningIds

Get all lot IDs

function getAuctioningIds() external view returns (uint256[] memory)

getBidAuctioningIds

Get the IDs of lots with a history of participation

function getBidAuctioningIds() external view returns (uint256[] memory)

getUserBidAuctioningIds

Get the lot ID of the specified user's participation

function getUserBidAuctioningIds(
    address user
) public view returns (uint256[] memory)

Parameters:

Name
Type
Description

user

address

wallet address of a user

getUserBidAuctioningInfos

Get lots info in user participation

function getUserBidAuctioningInfos(
    address user
) external view returns (BidAuctionInfo[] memory)

Parameters:

Name
Type
Description

user

address

wallet address of a user

Returns:

BidAuctionInfo Data structure

Name
Type
Description

auctionId

uint256

lot ID

harvestAddress

address

winner's address

harvestFlag

boolean

Harvest or not?

Oracle

Smart Contract:[UniswapV3ChainLinkUsdOracle.sol](Solidity-Open-Source/UniswapV3ChainLinkUsdOracle.sol at main · Themis-protocol/Solidity-Open-Source · GitHub)

Functions

getLatestPrice

Get the latest price for a token

function getLatestPrice(
    address _token
) public view returns (int256 _answer,int _decimals)

Parameters:

Name
Type
Description

_token

address

sellected token address

Returns:

Name
Type
Description

_answer

uint256

Amount of acceptance

_decimals

int

Decimal of the token

getTWAPQuoteNft

Get a price quote for the NFT for the selected Token

function getTWAPQuoteNft(
    uint256 _tokenId,
    address _quoteToken
) external view returns(
            uint256 _quoteAmount,
            uint256 _gasEstimate
        )

Parameters:

Name
Type
Description

_tokenId

uint256

NFT ID

_quoteToken

address

token address

Returns:

Name
Type
Description

_quoteAmount

uint256

quote amount

_gasEstimate

uint256

estimated gas