file-lockSmart Contract

The TUSDT protocol is a collateralized debt position (CDP) system built on ink! smart contracts. It allows users to lock native token collateral in vaults, borrow a synthetic stablecoin (TUSDT), and participate in liquidation auctions when vaults become undercollateralized. The system is composed of three interdependent contracts deployed together: TusdtVault, TusdtAuction, and TusdtErc20.

Contract Architecture

The three contracts have a strict ownership hierarchy. TusdtVault is the entry point for end users and is the owner of both TusdtErc20 and TusdtAuction. Neither the token nor the auction contract should be called directly by external integrators for write operations — all state-changing flows are orchestrated through the vault.

Figure : Contract Architecture

TusdtVault instantiates both child contracts at construction time using their code hashes and retains references to their on-chain addresses. Their addresses can be retrieved at any time via get_token_address() and get_auction_address().

TusdtVault

The core contract. Handles everything related to creating vaults, borrowing, repaying, and liquidations.

Key Parameters

Parameter

Default

Description

Collateral Ratio

150%

Minimum collateral required to borrow

Liquidation Ratio

120%

Threshold where vault can be liquidated

Interest Rate

10% p.a

Compounded hourly

Liquidation Fee

upto 11%

Extra collateral added when liquidating

Auction Duration

15 Minute

How long liquidation auctions run

Key Functions

Function

Description

create_vault()

Opens a new vault with attached native tokens as collateral

add_collateral(vault_id)

Tops up collateral in an existing vault

borrow_token(vault_id, amount)

Mints TUSDT to the caller against their collateral

repay_token(vault_id, amount)

Burns TUSDT from the caller to reduce vault debt

release_collateral(vault_id, amount)

Withdraws collateral back to the caller

trigger_liquidation_auction(owner, vault_id)

Starts a liquidation auction on an unsafe vault

settle_liquidation_auction(owner, vault_id)

Completes a finalized auction and clears vault debt

get_vault(owner, vault_id)

Returns full vault state

get_max_borrow(owner, vault_id)

Returns how much TUSDT can still be borrowed

set_contract_params(params)

Owner only — updates protocol parameter

TusdtErc20

Standard token contract for TUSDT. Mint and burn are restricted to the Vault contract. Users interact with it for transfers and approvals.

Key Functions

Function

Description

transfer(to, value)

Sends TUSDT to another account

approve(spender, value)

Approves another contract or account to spend TUSDT

transfer_from(from, to, value)

Transfers on behalf of another account using allowance

balance_of(owner)

Returns TUSDT balance of an account

mint(to, value)

Owner only — creates new TUSDT tokens

burn(from, value)

Owner only — destroys TUSDT tokens

TusdtAuction

Manages liquidation auctions. Created and settled by the Vault. Bidders interact with it directly to place bids and withdraw refunds.

Key Functions

Function

Description

place_bid(auction_id, amount, metadata)

Places or increases a bid using TUSDT

finalize_auction(auction_id)

Closes an expired auction and records the winner

withdraw_refund(auction_id, bid_id)

Returns TUSDT to losing bidders after finalization

get_active_auctions(page)

Lists all currently running auctions

get_auction(auction_id)

Returns full details of a specific auction

Last updated