Repository: ccxt/ccxt
File: js/deribit.js (JavaScript)

Code before:
        //         "usIn": 1641515379467734,
        //         "usOut": 1641515379468095,
        //         "usDiff": 361,
        //         "testnet": false
        //     }
        //
        const volatilityResult = this.safeValue (response, 'result', {});
        const result = [];
        for (let i = 0; i < volatilityResult.length; i++) {
            const timestamp = this.safeInteger (volatilityResult[i], 0);
            const volatility = this.safeNumber (volatilityResult[i], 1);
            result.push ({
                'info': response,
                'timestamp': timestamp,
                'datetime': this.iso8601 (timestamp),
                'volatility': volatility,
            });
        }
        return result;
    }

    async fetchTransfers (code = undefined, since = undefined, limit = undefined, params = {}) {
        await this.loadMarkets ();
        if (code === undefined) {
            throw new ArgumentsRequired (this.id + ' transfer() requires a currency code argument');
        }
        const currency = this.currency (code);
        const request = {
            'currency': currency['id'],
        };
        if (limit !== undefined) {
            request['count'] = limit;
        }
        const response = await this.privateGetGetTransfers (this.extend (request, params));
        //
        //     {
        //         "jsonrpc": "2.0",
        //         "id": 7606,
        //         "result": {
        //             "count": 2,
        //             "data": [
        //                 {
        //                     "amount": 0.2,
        //                     "created_timestamp": 1550579457727,
        //                     "currency": "BTC",
        //                     "direction": "payment",
        //                     "id": 2,
        //                     "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy",
        //                     "state": "prepared",
        //                     "type": "user",
        //                     "updated_timestamp": 1550579457727

Review comment (suggestion):
I suggest that we throw early in such cases – if a required code or symbol is missing we should raise an exception even before loading the markets (where possible).

```suggestion
        if (code === undefined) {
            throw new ArgumentsRequired (this.id + ' transfer() requires a currency code argument');
        }
        await this.loadMarkets ();
```

Code after:
        //         "usIn": 1641515379467734,
        //         "usOut": 1641515379468095,
        //         "usDiff": 361,
        //         "testnet": false
        //     }
        //
        const volatilityResult = this.safeValue (response, 'result', {});
        const result = [];
        for (let i = 0; i < volatilityResult.length; i++) {
            const timestamp = this.safeInteger (volatilityResult[i], 0);
            const volatility = this.safeNumber (volatilityResult[i], 1);
            result.push ({
                'info': response,
                'timestamp': timestamp,
                'datetime': this.iso8601 (timestamp),
                'volatility': volatility,
            });
        }
        return result;
    }

    async fetchTransfers (code = undefined, since = undefined, limit = undefined, params = {}) {
        if (code === undefined) {
            throw new ArgumentsRequired (this.id + ' transfer() requires a currency code argument');
        }
        await this.loadMarkets ();
        const currency = this.currency (code);
        const request = {
            'currency': currency['id'],
        };
        if (limit !== undefined) {
            request['count'] = limit;
        }
        const response = await this.privateGetGetTransfers (this.extend (request, params));
        //
        //     {
        //         "jsonrpc": "2.0",
        //         "id": 7606,
        //         "result": {
        //             "count": 2,
        //             "data": [
        //                 {
        //                     "amount": 0.2,
        //                     "created_timestamp": 1550579457727,
        //                     "currency": "BTC",
        //                     "direction": "payment",
        //                     "id": 2,
        //                     "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy",
        //                     "state": "prepared",
        //                     "type": "user",
        //                     "updated_timestamp": 1550579457727