Staking OADA

The staking feature allows users to stake their OADA tokens to receive sOADA (staked OADA) tokens, which are yield-bearing versions of OADA.

The StakeOadaRequest type defines the structure for staking requests:

// src/oada/actions.ts
// Type definition for OADA staking requests
// Specifies the amount of OADA tokens to stake
type StakeOadaRequest = {
  amount: bigint;
};

The stakeOada action handles the staking process:

// src/oada/actions.ts
// Async thunk for staking OADA tokens
// Manages the complete staking process including transaction creation, signing, and submission
export const stakeOada = createAsyncThunk<
  BasicResponse<string>,
  StakeOadaRequest,
  {
    dispatch: AppDispatch;
    state: RootState;
    extra: Services;
    rejectValue: FailResponse;
  }
>("stakeOada", async (request: StakeOadaRequest, thunkApi) => {
  // Implementation details for staking OADA tokens
  const wallet = thunkApi.getState().wallet.wallet!;
  const [utxos, changeAddress] = await getWalletUtxos(wallet);

  const ownerPkh = bech32AddressToPaymentPkh(changeAddress);

  const serverRequest = {
    ownerPkh,
    returnAddressBech32: changeAddress,
    amount: request.amount,
  };

  const requestOptions = {
    method: "POST",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json;charset=UTF-8",
    },
    body: Json.stringify(serverRequest),
  };

  const rawResponse = await fetch(
    `${oadaEndpointsUrl}/stake-oada`,
    requestOptions
  );

  const addFee = (recipe: TxRecipe) => {
    oadaFeeAddress &&
      oadaStakeFee &&
      recipe.txOuts.push({
        address: oadaFeeAddress,
        value: { lovelace: oadaStakeFee },
        datum: null,
        refScript: null,
      });
    return recipe;
  };
  const signedTxResponse = await getRecipeBuildSendTx(
    utxos,
    changeAddress,
    rawResponse,
    addFee
  );

  return signedTxResponse;
});

The StakingAmoView interface defines the structure for staking pool information:

Staking features include:

  • Dynamic staking rate calculation

  • Staking vault capacity management

  • Queue system for when vault is full

  • APY tracking and display

  • Transaction fee handling

Last updated