# Funding

All Funding & Account API endpoints require authentication. Please create OKX API keys to interact with these functions successfully.&#x20;

## Funding

### Get Currencies

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-currencies>
{% endhint %}

#### Function Name:

```javascript
fundingGetCurrencies()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetCurrencies(exchange, options) {
    try {
        let result = await exchange.fundingGetCurrencies(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetCurrencies(myOkxAccount)
```

### Get Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for the required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-balance>
{% endhint %}

#### Function Name:

```javascript
fundingGetBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetBalance(exchange, options) {
    try {
        let result = await exchange.fundingGetBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetBalance(myOkxAccount)
```

### Get Account Asset Valuation

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-account-asset-valuation>
{% endhint %}

#### Function Name:

```javascript
fundingGetAssetValuation()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetAssetValuation(exchange, options) {
    try {
        let result = await exchange.fundingGetAssetValuation(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetAssetValuation(myOkxAccount)
```

### Funds Transfer

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-funds-transfer>
{% endhint %}

#### Function Name:

```javascript
fundingAssetTransfer()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingAssetTransfer(exchange, options) {
    try {
        let result = await exchange.fundingAssetTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingAssetTransfer(myOkxAccount,
{
    ccy:"USDT",
    amt:"1.5",
    from:"6",
    to:"18"
})
```

### Get Funds Transfer State

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-funds-transfer-state>
{% endhint %}

#### Function Name:

```javascript
fundingGetFundsTransferState()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetFundsTransferState(exchange, options) {
    try {
        let result = await exchange.fundingGetFundsTransferState(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetFundsTransferState(myOkxAccount,
{
    transId: "1",
    type: "1"
})
```

### Asset Bill Details

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-asset-bills-details>
{% endhint %}

#### Function Name:

```javascript
fundingGetAssetBillsDetails()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetAssetBillsDetails(exchange, options) {
    try {
        let result = await exchange.fundingGetAssetBillsDetails(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetAssetBillsDetails(myOkxAccount)
```

### Get Deposit Address

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-deposit-address>
{% endhint %}

#### Function Name:

```javascript
fundingGetDepositAddress()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetDepositAddress(exchange, options) {
    try {
        let result = await exchange.fundingGetDepositAddress(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetDepositAddress(myOkxAccount, 
            {
                ccy: "BTC"
            })
```

### Get Deposit History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-deposit-history>
{% endhint %}

#### Function Name:

```javascript
fundingGetDepositHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetDepositHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetDepositHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetDepositHistory(myOkxAccount)
```

### Withdrawal

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-withdrawal>
{% endhint %}

#### Function Name:

```javascript
fundingWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingWithdrawal(exchange, options) {
    try {
        let result = await exchange.fundingWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingWithdrawal(myOkxAccount, 
{
    amt:"1",
    fee:"0.0005",
    dest:"4",
    ccy:"BTC",
    chain:"BTC-Bitcoin",
    toAddr:"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"
})
```

### Get Withdrawal History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-withdrawal-history>
{% endhint %}

#### Function Name:

```javascript
fundingGetWithdrawalHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetWithdrawalHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetWithdrawalHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetWithdrawalHistory(myOkxAccount)
```

### Small Assets Convert

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-small-assets-convert>
{% endhint %}

#### Function Name:

```javascript
fundingConvertDust()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingConvertDust(exchange, options) {
    try {
        let result = await exchange.fundingConvertDust(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingConvertDust(myOkxAccount,
{
   ccy:["BTC","USDT"]
})
```

### Get Saving Balance

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-saving-balance>
{% endhint %}

#### Function Name:

```javascript
fundingGetSavingBalance()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetSavingBalance(exchange, options) {
    try {
        let result = await exchange.fundingGetSavingBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetSavingBalance(myOkxAccount)
```

### Savings Purchase/Redemption

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-savings-purchase-redemption>
{% endhint %}

#### Function Name:

```javascript
fundingSavingsAndPurchaseRedemption()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingSavingsAndPurchaseRedemption(exchange, options) {
    try {
        let result = await exchange.fundingSavingsAndPurchaseRedemption(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingSavingsAndPurchaseRedemption(myOkxAccount,
{
    ccy:"BTC",
    amt:"1",
    side:"purchase",
    rate:"0.01"
}
)
```

### Set Lending Rate

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-set-lending-rate>
{% endhint %}

#### Function Name:

```javascript
fundingSetLendingRate()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingSetLendingRate(exchange, options) {
    try {
        let result = await exchange.fundingSetLendingRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingSetLendingRate(myOkxAccount,
{
    ccy:"BTC",
    rate:"0.02"
}
)
```

### Get Lending History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-lending-history>
{% endhint %}

#### Function Name:

```javascript
fundingGetLendingHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetLendingHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetLendingHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetLendingHistory(myOkxAccount)
```

### Get Public Borrow Info

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-public-borrow-info-public>
{% endhint %}

#### Function Name:

```javascript
fundingGetPublicBorrowInfo()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetPublicBorrowInfo(exchange, options) {
    try {
        let result = await exchange.fundingGetPublicBorrowInfo(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetPublicBorrowInfo(myOkxAccount)
```

### Get Public Borrow History

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-get-public-borrow-history-public>
{% endhint %}

#### Function Name:

```javascript
fundingGetPublicBorrowHistory()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingGetPublicBorrowHistory(exchange, options) {
    try {
        let result = await exchange.fundingGetPublicBorrowHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingGetPublicBorrowHistory(myOkxAccount)
```

### Lightning Deposits

{% hint style="warning" %}
Not currently supported
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-lightning-deposits>
{% endhint %}

#### Function Name:

```javascript
fundingLightningDeposit()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingLightningDeposit(exchange, options) {
    try {
        let result = await exchange.fundingLightningDeposit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingLightningDeposit(myOkxAccount,
{
        ccy: "BTC",
        amt: "0.1"
}
)
```

### Lightning Withdrawals

{% hint style="warning" %}
Not currently supported
{% endhint %}

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-lightning-withdrawals>
{% endhint %}

#### Function Name:

```javascript
fundingLightningWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingLightningWithdrawal(exchange, options) {
    try {
        let result = await exchange.fundingLightningWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingLightningWithdrawal(myOkxAccount,
{
    ccy:"BTC",
    invoice:"lnbc100u1psnnvhtpp5yq2x3q5hhrzsuxpwx7ptphwzc4k4wk0j3stp0099968m44cyjg9sdqqcqzpgxqzjcsp5hz"
}
)
```

### Cancel Withdrawal

{% hint style="info" %}
Please refer to the official OKX API Docs for required parameters.

<https://www.okx.com/docs-v5/en/#rest-api-funding-cancel-withdrawal>
{% endhint %}

#### Function Name:

```javascript
fundingCancelWithdrawal()
```

#### Usage:

```javascript
import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function fundingCancelWithdrawal(exchange, options) {
    try {
        let result = await exchange.fundingCancelWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await fundingCancelWithdrawal(myOkxAccount,
{
   wdId:"1123456"
}
)
```
