---
description: params of setTokenParams -> storage with [ tokens[tokenId] ] upd
---

# setTokenFactors

Updates token-related factors of the protocol by `tokenId` of yToken.

{% hint style="warning" %}
The `yToken` contract expects that underlying token info of `tokenId` is updated by calling [PriceFeed.getPrice](../../../pricefeed-contract/getprice) and [updateInterest](../../updateinterest) in the same block **before** this call.
{% endhint %}

### Types

```pascaligo
type setTokenParams     is [@layout:comb] record [
  tokenId               : nat;
  collateralFactorF     : nat;
  reserveFactorF        : nat;
  interestRateModel     : address;
  maxBorrowRate         : nat;
  threshold             : nat;
  liquidReserveRateF    : nat;
]
```



<table><thead><tr><th width="179.33333333333331" align="center">Parameter</th><th align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td align="center">tokenId</td><td align="center">nat</td><td>token identifier</td></tr><tr><td align="center">collateralFactorF</td><td align="center">nat</td><td><p>collateral factor </p><p>as float number multiplied by <code>precision</code>= 1000000000000000000n; (1e+18)</p></td></tr><tr><td align="center">reserveFactorF</td><td align="center">nat</td><td><p>reserve factor</p><p>as float number multiplied by <code>precision</code>= 1000000000000000000n; (1e+18)</p></td></tr><tr><td align="center">interestRateModel</td><td align="center">address</td><td>priceFeed proxy contract instance</td></tr><tr><td align="center">maxBorrowRate</td><td align="center">nat</td><td></td></tr><tr><td align="center">threshold</td><td align="center">nat</td><td></td></tr><tr><td align="center">liquidReserveRateF</td><td align="center">nat</td><td></td></tr></tbody></table>

### Usage

{% tabs %}
{% tab title="🌮 Taquito" %}
```typescript
const tokenId = 0; // or new BigNumber(0) or "0"
const yupana = await tezos.contract.at(yTokenAddress);
const batchArray = [
      {
        kind: "transaction",
        ...yupana.methods.updateInterest(tokenId).toTransferParams(),
      },
      {
        kind: "transaction",
        ...proxy.methods.getPrice([tokenId]).toTransferParams(),
      },
      {
        kind: "transaction",
        ...yupana.methods.setTokenFactors(
          tokenId,
          650000000000000000,
          200000000000000000,
          "KT1...",
          5000000000000,
          550000000000000000
        ).toTransferParams(),
      },
    ];
const batch = await tezos.wallet.batch(batchArray);
const operation = await batch.send();
await operation.confirmation();
```
{% endtab %}

{% tab title="🐍   Pytezos" %}
```python
token_id = 0
PRECISION = pow(10, 18)
config = {
  "collateral_factor": 0.5,
  "reserve_factor": 0.5,
  "threshold": 0.8
}
yupana = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
proxy = ContractInterface.from_michelson(prx_code) # or client.contract(prx_contract_address)...proxy = ContractInterface.from_michelson(code) # or client.contract(contract_address)...
call = pytezos.bulk(
        yupana.updateInterest(token_id),
        proxy.getPrice([token_id]),
        yupana.setTokenFactors(
             tokenId = token_id, 
             collateralFactorF = int(config["collateral_factor"] * PRECISION),
             reserveFactorF = int(config["reserve_factor"]  * PRECISION),
             interestRateModel = "KT1...",
             maxBorrowRate = 1_000_000  * PRECISION,
             threshold = int(config["threshold"] * PRECISION)
        )
    ).autofill().sign()
opg = call.inject()
```
{% endtab %}
{% endtabs %}

### Errors

* `yToken/not-admin` - `sender` is not contract admin.
* `yToken/need-update` - token price and interest not updated (see <mark style="color:orange;">warning</mark> above)
