Saltar a contenido

Gimo Finance

Connector for Gimo Finance liquid staking on 0G Chain.

almanak.framework.connectors.gimo

Gimo Finance Connector — liquid staking on 0G Chain.

Gimo Finance is a liquid staking protocol on 0G Chain (AI L1) built on StaFi's EVM LSD Stack. Users stake A0GI (0G's native token) and receive st0G, a yield-bearing liquid staking derivative.

Architecture (StaFi EVM LSD Stack): - LsdToken (st0G): ERC-20 liquid staking derivative - StakeManager: Manages staking lifecycle and exchange rate - StakePool: Holds staked A0GI and distributes to validators

Available Operations
  • stake(): Deposit A0GI -> receive st0G
  • unstake(): Request st0G -> A0GI withdrawal (22-day unbonding)
  • withdraw(): Claim A0GI after unbonding period
Reference
  • StaFi EVM LSD Architecture: https://docs.stafi.io/lsaas/architecture_evm_lsd/
  • Gimo Finance Docs: https://docs.gimofinance.xyz/docs/

GimoAdapter

GimoAdapter(
    config: GimoConfig,
    token_resolver: TokenResolver | None = None,
)

Adapter for Gimo Finance liquid staking protocol on 0G Chain.

Provides methods for: - Stake A0GI to receive st0G - Unstake st0G to initiate A0GI withdrawal

Example

config = GimoConfig(chain="zerog", wallet_address="0x...") adapter = GimoAdapter(config) result = adapter.stake(Decimal("100.0"))

stake

stake(amount: Decimal) -> TransactionResult

Build a stake transaction to receive st0G.

Stakes A0GI (native token) to the Gimo StakePool contract and receives st0G in return. A0GI is sent as msg.value.

Parameters:

Name Type Description Default
amount Decimal

Amount of A0GI to stake

required

Returns:

Type Description
TransactionResult

TransactionResult with transaction data

unstake

unstake(amount: Decimal) -> TransactionResult

Build an unstake transaction to initiate A0GI withdrawal.

Burns st0G and initiates the 22-day unbonding period.

Parameters:

Name Type Description Default
amount Decimal

Amount of st0G to unstake

required

Returns:

Type Description
TransactionResult

TransactionResult with transaction data

compile_stake_intent

compile_stake_intent(
    intent: StakeIntent, market_snapshot: Any | None = None
) -> ActionBundle

Compile a StakeIntent to an ActionBundle.

Converts a high-level StakeIntent into executable transaction data. Stakes A0GI (native token) to receive st0G.

Parameters:

Name Type Description Default
intent StakeIntent

The StakeIntent to compile

required
market_snapshot Any | None

Optional market data (not used)

None

Returns:

Type Description
ActionBundle

ActionBundle containing transaction(s) for execution

compile_unstake_intent

compile_unstake_intent(
    intent: UnstakeIntent,
    market_snapshot: Any | None = None,
) -> ActionBundle

Compile an UnstakeIntent to an ActionBundle.

Converts a high-level UnstakeIntent into executable transaction data. Burns st0G and initiates 22-day unbonding for A0GI.

Parameters:

Name Type Description Default
intent UnstakeIntent

The UnstakeIntent to compile

required
market_snapshot Any | None

Optional market data (not used)

None

Returns:

Type Description
ActionBundle

ActionBundle containing transaction(s) for execution

GimoConfig dataclass

GimoConfig(chain: str, wallet_address: str)

Configuration for Gimo adapter.

Attributes:

Name Type Description
chain str

Must be "zerog"

wallet_address str

User wallet address

__post_init__

__post_init__() -> None

Validate configuration.

TransactionResult dataclass

TransactionResult(
    success: bool,
    tx_data: dict[str, Any] | None = None,
    gas_estimate: int = 0,
    description: str = "",
    error: str | None = None,
)

Result of a transaction build operation.

GimoEventType

Bases: Enum

Gimo event types.

GimoReceiptParser

GimoReceiptParser(chain: str = 'zerog', **kwargs: Any)

Parser for Gimo Finance transaction receipts.

Handles st0G Transfer events to detect stake (mint) and unstake (burn) operations on 0G Chain.

parse_receipt

parse_receipt(receipt: dict[str, Any]) -> ParseResult

Parse a transaction receipt for Gimo events.

Parameters:

Name Type Description Default
receipt dict[str, Any]

Transaction receipt dict

required

Returns:

Type Description
ParseResult

ParseResult with extracted stake/unstake events

extract_stake_amount

extract_stake_amount(receipt: dict[str, Any]) -> int | None

Extract stake amount (st0G received) from transaction receipt.

Parameters:

Name Type Description Default
receipt dict[str, Any]

Transaction receipt dict

required

Returns:

Type Description
int | None

st0G amount in wei if found, None otherwise

extract_unstake_amount

extract_unstake_amount(
    receipt: dict[str, Any],
) -> int | None

Extract unstake amount (st0G burned) from transaction receipt.

Parameters:

Name Type Description Default
receipt dict[str, Any]

Transaction receipt dict

required

Returns:

Type Description
int | None

st0G amount in wei if found, None otherwise

ParseResult dataclass

ParseResult(
    success: bool,
    stakes: list[StakeEventData] = list(),
    unstakes: list[UnstakeEventData] = list(),
    error: str | None = None,
    transaction_hash: str = "",
    block_number: int = 0,
)

Result of parsing a receipt.

StakeEventData dataclass

StakeEventData(
    to_address: str, amount: Decimal, token: str = ""
)

Parsed data from a stake operation (Transfer mint from zero address).

UnstakeEventData dataclass

UnstakeEventData(
    from_address: str, amount: Decimal, token: str = ""
)

Parsed data from an unstake operation (Transfer burn to zero address).