For the complete documentation index, see llms.txt. This page is also available as Markdown.

Unstaking sOADA

Users can unstake their sOADA tokens to convert them back to OADA tokens.

The UnstakeOadaRequest type defines the structure for unstaking requests:

// src/oada/actions.ts
// Type definition for sOADA unstaking requests
// Specifies the amount of sOADA tokens to unstake
type UnstakeOadaRequest = {
  amount: bigint;
};

The unstakeOada action handles the unstaking process:

// src/oada/actions.ts
// Async thunk for unstaking sOADA tokens
// Manages the complete unstaking process including transaction creation, signing, and submission
export const unstakeOada = createAsyncThunk<
  BasicResponse<string>,
  UnstakeOadaRequest,
  {
    dispatch: AppDispatch;
    state: RootState;
    extra: Services;
    rejectValue: FailResponse;
  }
>("unstakeOada", async (request: UnstakeOadaRequest, thunkApi) => {
  // Implementation details for unstaking sOADA 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}/unstake-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 OadaStakeOrderView and OadaUnstakeOrderView interfaces define the structure for stake and unstake orders:

Unstaking features include:

  • 0.1% unstaking fee

  • Dynamic conversion rate based on staking pool

  • Transaction fee handling

  • UTxO management

Last updated