> For the complete documentation index, see [llms.txt](https://docs.aozo.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aozo.io/stake/developers-and-ecosystem/builder-resources/liquid-crowdloan.md).

# Liquid Crowdloan

## Extrinsics

{% hint style="info" %}
Cross-chain transact from **Kusama to Bifrost** (Contributors have to cross their KSM to Bifrost for using SALP)
{% endhint %}

<mark style="color:purple;">`api.tx.polkadotXcm.execute`</mark>

{% code title="Example" lineNumbers="true" fullWidth="false" %}

```rust
const theAmount = new BigNumber(amount).multipliedBy(new BigNumber(1000000000000)).toFixed();
const paras = [
  {
    X1: { Parachain: getEnvs().PARACHAIN_ID },
  },
  {
    X1: {
      AccountId32: {
        network: {
          Any: null,
        },
        id: sender,
      },
    },
  },
  [
    {
      ConcreteFungible: {
        id: {
          Null: null,
        },
        amount: theAmount,
      },
    },
  ],
  3000000,
];
const transferHandle = await api.tx.xcmPallet.reserveTransferAssets(...paras);
const info = await api.tx.xcmPallet.reserveTransferAssets(...paras).paymentInfo(sender);
```

{% endcode %}

***

{% hint style="info" %}
Cross-chain transact from **Bifrost to Kusama** (for users who want to transfer KSM back to the relay-chain)
{% endhint %}

<mark style="color:purple;">`api.tx.polkadotXcm.execute`</mark>

{% code title="Example" lineNumbers="true" %}

```rust
const theAmount = new BigNumber(amount).multipliedBy(new BigNumber(1000000000000)).toString();
const paras = [
  {
    WithdrawAsset: {
      assets: [
        {
          ConcreteFungible: {
            id: {
              X1: {
                Parent: null,
              },
            },
            amount: theAmount,
          },
        },
      ],
      effects: [
        {
          BuyExecution: {
            fees: {
              All: null,
            },
            weight: 0,
            debt: 3000000000,
            haltOnError: false,
            xcm: [],
          },
        },
        {
          InitiateReserveWithdraw: {
            assets: [
              {
                All: null,
              },
            ],
            reserve: {
              X1: {
                Parent: null,
              },
            },
            effects: [
              {
                BuyExecution: {
                  fees: {
                    All: null,
                  },
                  weight: 0,
                  debt: 3000000000,
                  haltOnError: false,
                  xcm: [],
                },
              },
              {
                DepositAsset: {
                  assets: [
                    {
                      All: null,
                    },
                  ],
                  dest: {
                    X1: {
                      AccountId32: {
                        network: {
                          Any: null,
                        },
                        id: receiver,
                      },
                    },
                  },
                },
              },
            ],
          },
        },
      ],
    },
  },
  3000000000,
];
const transferHandle = await api.tx.polkadotXcm.execute(...paras);
const info = await api.tx.polkadotXcm.execute(...paras).paymentInfo(sender);
```

{% endcode %}

***

{% hint style="info" %}
Bifrost call **Contribute**
{% endhint %}

<mark style="color:purple;">`api.tx.salp.contribute`</mark>

* Authentication: User’s signature address
* Parameter:
  * `index: ParaId; //Contribute to a paraid`
  * `value: Balance; //The amount of contribution`
* Description: The user calls this function to contribute to a `fund` (ongoing).

{% code title="Example" lineNumbers="true" %}

```rust
const keyring = new Keyring({type: 'sr25519'});

const provider = new WsProvider(BIFROST_END_POINT);
const api = await ApiPromise.create(options({provider: provider}));

const sudo = keyring.addFromUri(BIFROST_SUDO_PHRASE);

const extrinsic = api.tx.salp.contribute(PARA_ID, BALANCE);
const ext_hash = await extrinsic.signAndSend(sudo);
```

{% endcode %}

***

{% hint style="info" %}
Parachain auciton fail, call **refund** function manually
{% endhint %}

<mark style="color:purple;">api.tx.salp.refund</mark>

* Authentication: User’s signature address
* Parameter:
  * `index: ParaId; //The paraId needs to refund`
* Description: When the `fund` fails and the funds have been withdrawable, the user can redeem the contributed funds with the locked `vsToken/vsBond`.

<figure><img src="https://content.gitbook.com/content/r31MTx7UH8xa62qIBTTw/blobs/IRaTwL19OJFXEPJh18qs/image.png" alt=""><figcaption><p>Example</p></figcaption></figure>

***

{% hint style="info" %}
Call the **redeem** function when parachain fund retired.
{% endhint %}

<mark style="color:purple;">`api.tx.salp.redeem`</mark>

* Authentication: User’s signature address
* Parameter:
  * `index: ParaId; //vsbond Parameter: paraId`
  * `value: Balance; //redeem amount`
* Description: When the user holds the `vsbond` that reaches the redemption period, the combination of `vsbond` + `vsToken` can be used to redeem the underlaying KSM, which will be sent to the user’s address on relay chain.

![Example](https://hackmd.io/_uploads/rydaOvxzY.png)

## Storage <a href="#storage" id="storage"></a>

{% hint style="info" %}
Query for Bifrost Assets
{% endhint %}

<mark style="color:purple;">`api.query.tokens.accounts`</mark>

* Parameter:
  * `0: AccountId; //query the address`
  * `1: CurrencyId; //type of assets`
* Description: Query an address’s assets amount.

***

{% hint style="info" %}
Query vsKSM,vsBond total issuance
{% endhint %}

<mark style="color:purple;">`api.query.tokens.totalIssuance`</mark>

* Parameter:
  * `0: CurrencyId; //type of assets`
* Description: Query assets amount of a paraId.

***

{% hint style="info" %}
Query a specific fund info
{% endhint %}

<mark style="color:purple;">`api.query.salp.funds`</mark>

* Parameter:
  * `0: ParaId; //Parachain ID`
* Description: Query the fund info of a paraId.

***

{% hint style="info" %}
Query the contribution info of a user
{% endhint %}

{% code overflow="wrap" %}

```bash
curl http://localhost:29999 -H "Content-Type:application/json;charset=utf-8" -d '{"jsonrpc":"2.0","id":1,"method":"salp_getContribution","params": [2001, "Hsjp321vR7quo4ETVyuUFbrJMddW7K7qPndtxCZHzY1CCHA"]}'
```

{% endcode %}

* aParameter:
  * `0: ParaId; //Parachain ID`
  * `1: AccountId; //ss58 account address`
* Description: Query the contribution info of an user.

## Bifrost Service <a href="#bifrost-service" id="bifrost-service"></a>

[<mark style="color:purple;">https://bifrost-service.bifrost.finance/graphql</mark>](https://bifrost-service.bifrost.finance/graphql)

<mark style="color:purple;">`salp_contributed`</mark>

* Graphql API
  * Parameter:
    * `account; //ss58 bifrost account address`
    * `para_id; //ParaId`
  * Description：Query the contribution details of a certain ParaId/or the contribution details of a certain user address. (Deleting `account` means to query all the contribution details of a ParaId.)

{% code title="Example" lineNumbers="true" %}

```graphql
query {
  salp_contributed(
    account:"ftEXBzn7nKfUsoDRtw39AUMGdwQY37SMPuC6HEXkPmN1cvf",
    para_id:"2088"
  ){
    para_id
    balance
    account
    block_timestamp
    block_height
  }
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aozo.io/stake/developers-and-ecosystem/builder-resources/liquid-crowdloan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
