Ooki
  • ๐Ÿ‘‹Introduction to Ooki
  • ๐Ÿ“–About Ooki
  • โ”FAQ
  • ๐Ÿ“šGlossary
  • Protocol
    • ๐Ÿ’ฑTrade
      • Opening A Trade
      • Managing/Closing Trade
      • Trade History
      • Leverage
      • Short Selling
      • Complex Orders
    • ๐Ÿ’ธBorrow
      • Liquidation
    • ๐ŸงฎLend
    • ๐ŸฆStake
    • ๐Ÿ“‘Fees
  • Governance
    • ๐Ÿ›๏ธOoki DAO
    • ๐Ÿ—ณ๏ธVoting
    • ๐Ÿ‘จโ€๐Ÿ”งDelegating
  • Tokenomics
    • ๐Ÿ’ฐOverview
    • ๐ŸŽŠToken Migration
  • Developers
    • โšกFlash Borrow
    • ๐ŸงนSweep Fees
    • ๐Ÿ”ฃInterest Rates
    • ๐Ÿ›ก๏ธGuardians
    • ๐ŸฆบAudits
    • ๐ŸนBug Bounty
    • ๐Ÿ“ŠPrice Oracle
    • ๐Ÿš„Avoiding Frontrunning
    • ๐Ÿ“”Contracts
    • Data API
  • Ooki Ecosystem
    • โ›“๏ธMultichain
    • ๐Ÿ—ƒ๏ธBrand Assets
    • ๐Ÿ–Š๏ธStyle Guide
  • Additional Resources
  • Twitter
  • Telegram
  • Discord
  • YouTube
  • GitHub
  • Instagram
  • Blog
Powered by GitBook
On this page
  • OOKI Token Contract
  • cOOKI/vBZRX Contract
  • MintCoordinator
  • IToken Contract
  • Router Contract
  • Functions

Was this helpful?

  1. Developers

Contracts

PreviousAvoiding FrontrunningNextMultichain

Last updated 3 years ago

Was this helpful?

Using Brownie you can interact with the Ooki contracts. Below is an explanation for using each function. See our github for additional references:

OOKI Token Contract

0x0De05F6447ab4D22c8827449EE4bA2D5C288379B

cOOKI/vBZRX Contract

0xb72b31907c1c95f3650b64b2469e08edacee5e8f

MintCoordinator

0x93c608Dc45FcDd9e7c5457ce6fc7f4dDec235b68

IToken Contract

Router Contract

Functions

Load protocol

  • BZX = Contract.from_abi("BZX", "0xfe4F0eb0A1Ad109185c9AaDE64C48ff8e928e54B", interface.IBZx.abi)

Load iTokens

  • iUSDTAddress = BZX.underlyingToLoanPool(USDT.address)

  • iUSDT = Contract.from_abi("iUSDT", address=iUSDTAddress, abi=LoanTokenLogicStandard.abi)

Approve

  • WMATIC.approve(iUSDT, 2256-1, {'from': accounts[0]})

  • USDT.approve(BZX, 2256-1, {'from': accounts[0]})

  • WMATIC.approve(BZX, 2**256-1, {'from': accounts[0]})

Open Long 5x MATIC/USDT (using matic as collateral)

iUSDT.marginTrade('0x0000000000000000000000000000000000000000000000000000000000000000', 5e18, 0, 10e18, '0x0000000000000000000000000000000000000000', accounts[0], b'', {'from': accounts[0], "value": 10e18}) 
loan =BZX.getLoan(history[-1].return_value[0]) 
Loan has structure

struct Loan {
   bytes32 id;                 // id of the loan
   bytes32 loanParamsId;       // the linked loan params id
   bytes32 pendingTradesId;    // the linked pending trades id
   uint256 principal;          // total borrowed amount outstanding
   uint256 collateral;         // total collateral escrowed for the loan
   uint256 startTimestamp;     // loan start time
   uint256 endTimestamp;       // for active loans, this is the expected loan end time, for in-active loans, is the actual (past) end time
   uint256 startMargin;        // initial margin when the loan opened
   uint256 startRate;          // reference rate when the loan opened for converting collateralToken to loanToken
   address borrower;           // borrower of this loan
   address lender;             // lender of this loan
   bool active;                // if false, the loan has been fully closed
}

Deposit collateral

  • BZX.depositCollateral(loan[0], 10e18, {'from': accounts[0]})

Close loan with swap

  • BZX.closeWithSwap(loan[0], accounts[0], loan[5], True, b'', {'from': accounts[0]})

Close loan with deposit

  • BZX.closeWithDeposit(loan[0], accounts[0], loan[4], {'from': accounts[0]})

Get loans

  • loans = BZX.getActiveLoansAdvanced(0,100,True,True)

  • loan = loans[0]

Returning loan and getting collateral:

BZX.liquidate(loan[0], accounts[0], loan[13], {'from': accounts[0]})

Rollover

BZX.rollover(loan[0], b'', {'from':accounts[0]})

Flash loans/Flash borrow

  • Flashborrow has the following arguments:

    • flashBorrow(uint256 borrowAmount, address borrower, address target, string signature, bytes data), it should be call from contract layer.

Example can be found

๐Ÿ“”
https://github.com/bZxNetwork/contractsV2
https://github.com/bZxNetwork/flashloan-sample