Skip to main content

Geb

The main package used to interact with the GEB system. Includes helper functions for safe management and the contract interface object to directly call smart contracts.

Constructors

+ new Geb(network: GebDeployment, provider: GebProviderInterface | Provider): Geb

Defined in packages/geb/src/geb.ts:89

Constructor of the main Geb.js object.

Parameters:

NameTypeDescription
networkGebDeploymentEither 'arbitrum', 'arbitrum-sepolia' or an actual list of contract addresses.
providerGebProviderInterface | ProviderEither a Ethers.js provider or a Geb provider (Soon support for Web3 will be added)

Returns: Geb

Properties

contracts

contracts: ContractApis

Defined in packages/geb/src/geb.ts:87

Object containing all GEB core smart-contracts instances for direct level interactions. All of the following contracts object are one-to-one typed API to the underlying smart-contract. Read-only functions that do not change the blockchain state return a promise of the return data. State modifying function will return synchronously a pre-filled transaction request object:

{
  to: "0x123abc.."
  data: "0xabab234ab..."
}

This object follow the TransactionRequest model of ethers.js (Also similar to the model used by web.js). The object can be completed with properties such as from, gasPrice, gas (gas limit, web3.js ony) or gasLimit (gas limit, ethers.js only). The object can then be passed to the sendTransaction of ethers.js or web3.js

Example:

 // Setup geb.js an ethers
 const provider = new ethers.providers.JsonRpcProvider('http://arbitrum.infura.io/<API KEY>')
 const wallet = new ethers.Wallet('<Private key>', provider)
 const geb = new Geb('kovan', provider)

 // Contract read function: Fetch the debt ceiling
 const debtCeiling = await geb.contracts.safeEngine.globalDebtCeiling()

 // State changing function: manualy liquidate a SAFE
 const tx = geb.contracts.liquidationEngine.liquidateSAFE(ETH_A, '0x1234abc...')
 await wallet.sendTransaction(tx) // Send the Ethereum transaction

Currently the following contracts are available:

  • SAFEEngine
  • AccountingEngine
  • TaxCollector
  • LiquidationEngine
  • OracleRelayer
  • GlobalSettlement
  • DebtAuctionHouse
  • PreSettlementSurplusAuctionHouse
  • PostSettlementSurplusAuctionHouse
  • SettlementSurplusAuctioneer
  • GebSafeManager
  • GetSafes
  • BasicCollateralJoin
  • CoinJoin
  • Coin (System coin ERC20 contract)
  • GebProxyRegistry
  • FixedDiscountCollateralAuctionHouse
  • Weth (ERC20)

For detailed information about the functions of each contract we recommend referring directly to the smart contract code and documentation.

Methods

deployProxy

deployProxy(): TransactionRequest

Defined in packages/geb/src/geb.ts:133

Deploy a new proxy owned by the sender.

Returns: TransactionRequest

getErc20Contract

getErc20Contract(tokenAddress: string): Erc20

Defined in packages/geb/src/geb.ts:261

Returns an object that can be used to interact with a ERC20 token. Example:

const USDCAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
const USDC = geb.getErc20Contract(USDCAddress)

// Get 0xdefiisawesome's balance
const balance = USDC.balanceOf("0xdefiisawesome..")

// Send 1 USDC to 0xdefiisawesome (USDC has 6 decimals)
const tx = USDC.transfer("0xdefiisawesome..", "1000000")
await wallet.sendTransaction(tx)

Parameters:

NameTypeDescription
tokenAddressstringToken contract address

Returns: Erc20

getProxyAction

getProxyAction(ownerAddress: string): Promise‹GebProxyActions‹››

Defined in packages/geb/src/geb.ts:121

Given an address returns a GebProxyActions object to execute bundled operations. Important: This requires the address to have deployed a GEB proxy through the proxy registry contract. It will throw a DOES_NOT_OWN_HAVE_PROXY error if the address specified does not have a proxy. Use the deployProxy function to get a new proxy.

Parameters:

NameTypeDescription
ownerAddressstringExternally owned user account, Ethereum address that owns a GEB proxy.

Returns: Promise‹GebProxyActions‹››