# LSR Testnet(Kovan)
## Contract address
### Liquid Stability Reserve(2022-07-23)
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| LSRFactory | 0x06852f0B6aA3E3eccb66bC275186dCAFB97fC2C5 | [link](https://kovan.etherscan.io/address/0x06852f0B6aA3E3eccb66bC275186dCAFB97fC2C5) |
#### LSR(USDC)
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| LSR(USDC) | 0x1E2BfC4d0104E314E91dC52C3407002CbB1A040F | [link](https://kovan.etherscan.io/address/0x1E2BfC4d0104E314E91dC52C3407002CbB1A040F) |
| msd(USX) | 0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e | [link](https://kovan.etherscan.io/address/0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e) |
| USDC | 0x11513151a77fE2Bc43fdEdeACE05c4F35ff81A8f | [link](https://kovan.etherscan.io/address/0x11513151a77fE2Bc43fdEdeACE05c4F35ff81A8f) |
| DForceLendingStrategy(USDC) | 0xD9A0b2620E132153e57A8bC63c3aF6a77cfC3880 | [link](https://kovan.etherscan.io/address/0xD9A0b2620E132153e57A8bC63c3aF6a77cfC3880) |
#### LSR(USDT)
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| LSR(USDT) | 0x00C4b81F79153dfDA7289257BBf6b0023aB0E9f8 | [link](https://kovan.etherscan.io/address/0x00C4b81F79153dfDA7289257BBf6b0023aB0E9f8) |
| msd(USX) | 0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e | [link](https://kovan.etherscan.io/address/0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e) |
| USDT | 0x95F46c202e3816e287E849DFa025C0b070ae7210 | [link](https://kovan.etherscan.io/address/0x95F46c202e3816e287E849DFa025C0b070ae7210) |
| DForceLendingStrategy(USDT) | 0xc42B0AC9E9e60Ef5c9B03d31DC75e50AE6140120 | [link](https://kovan.etherscan.io/address/0xc42B0AC9E9e60Ef5c9B03d31DC75e50AE6140120) |
#### LSR(DAI)
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| LSR(DAI) | 0x87911d24b8b1aeaC3eE62793aF230D7a82fcEbeA | [link](https://kovan.etherscan.io/address/0x87911d24b8b1aeaC3eE62793aF230D7a82fcEbeA) |
| msd(USX) | 0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e | [link](https://kovan.etherscan.io/address/0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e) |
| DAI | 0x49ad4e09Ed76080d0480F4F371f8F8e64D61aB1E | [link](https://kovan.etherscan.io/address/0x49ad4e09Ed76080d0480F4F371f8F8e64D61aB1E) |
| DForceLendingStrategy(DAI) | 0x252Ddf36616E613912e9DC8Ca3Dfa9A23F6F3ECf | [link](https://kovan.etherscan.io/address/0x252Ddf36616E613912e9DC8Ca3Dfa9A23F6F3ECf) |
#### LSR(BUSD)
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| LSR(BUSD) | 0x2556BBB3225a471746E614517EAD4fc10E5Fc03E | [link](https://kovan.etherscan.io/address/0x2556BBB3225a471746E614517EAD4fc10E5Fc03E) |
| msd(USX) | 0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e | [link](https://kovan.etherscan.io/address/0xF76eAd4da04BbeB97d29F83e2Ec3a621d0FB3c6e) |
| BUSD | 0xfD399A4989deBD753Bfa7aDd304DfD94b8F5d708 | [link](https://kovan.etherscan.io/address/0xfD399A4989deBD753Bfa7aDd304DfD94b8F5d708) |
| DForceLendingStrategy(BUSD) | 0xbB8a89129B02Ac3121737Ec62E6ae2e6Ff28afdE | [link](https://kovan.etherscan.io/address/0xbB8a89129B02Ac3121737Ec62E6ae2e6Ff28afdE) |
### implementation
| Contract Name | Contract Address | Link |
| ----------------------- | ---------------------------------------------- |:------------------------------------------------------------------------------- |
| LSRFactory impl | 0x6774bE7069B4C3c1ae789d1902a865ef9091D943 | [link](https://kovan.etherscan.io/address/0x6774bE7069B4C3c1ae789d1902a865ef9091D943) |
| LSR impl | 0xcEBCE0DF710e00EBa89C8272eD27Df4a0c7111ed | [link](https://kovan.etherscan.io/address/0xcEBCE0DF710e00EBa89C8272eD27Df4a0c7111ed) |
| MSDControllerV2 impl | 0xb9366dad59Ad443E3c160104bab6eadAF54E50C4 | [link](https://kovan.etherscan.io/address/0xb9366dad59Ad443E3c160104bab6eadAF54E50C4) |
### Related Contracts
| Contract Name | Contract Address | Link |
| ----------------- | ------------------------------------------ |:------------------------------------------------------------------------------- |
| ProxyAdmin | 0xB455bfB432991CE874eb2A84e5ad552b655759c9 | [link](https://kovan.etherscan.io/address/0xB455bfB432991CE874eb2A84e5ad552b655759c9) |
| MSDController | 0xC3d28CEDf33aaCd171601a9D7E773703Cd8CBAeA | [link](https://kovan.etherscan.io/address/0xC3d28CEDf33aaCd171601a9D7E773703Cd8CBAeA) |
## ABI
All abi can be found in https://github.com/dforce-network/LSR/tree/dev/abi
| Contract | ABI |
|:-------- |:-------------------------- |
| LSR | LSR.json |
| LSR | DForceLendingStrategy.json |
## Calculation
### Convert Decimals
```
_convertDecimals(_amount,_amountUnitIn,_amountUnitOut) {
return _amount.mul(_amountUnitOut).div(_amountUnitIn);
}
```
### **Buy Msd**
**buy fee**
> msdAmount = _convertDecimals(inputAmount, [mprDecimalScaler](#mprDecimalScaler), [msdDecimalScaler](#msdDecimalScaler))
> fee = msdAmount.mul([taxIn](#taxIn)).div(1e18)
**msd amount**
> msdAmount = msdAmount.sub(fee)
**input amount max**
> [strategy](#strategy).[limitOfDeposit()](#limitOfDeposit)
**buy msd max**
> [msdQuota](#msdQuota)
### **Sell Msd**
**sell fee**
fee = inputAmount.mul([taxOut](#taxOut)).div(1e18)
**msd amount**
> tokenAmount = _convertDecimals(inputAmount.sub(fee), [msdDecimalScaler](#msdDecimalScaler), [mprDecimalScaler](#mprDecimalScaler))
**buy token max**
> [mprOutstanding](#mprOutstanding)
## **Interface Document**
_**notice: In the absence of special instructions, the data is scaled by 1e18.**_
<hr>
### **LSR**
**Introduction**
Welcome to Contract LSR's Interface Documentation!
We provide some interfaces to query infomation about dForce LSR, you can get information about.
### **User Action**
<hr>
#### **buyMsd**
*When the user buys msd(USX), you can call this function*
* Check whether the sender's Token allowance needs to approve.
> Token.allowance(sender, LSR) > input amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ----------------- |:--------------------------------- |
| uint256 | Token amount | decimal(scaled by Token's decimals) |
#### **buyMsd (recipient)**
*When the user buys msd(USX), you can call this function*
* Check whether the sender's Token allowance needs to approve.
> Token.allowance(sender, LSR) > input amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ----------------- |:--------------------------------- |
| address | recipient address | |
| uint256 | Token amount | decimal(scaled by Token's decimals) |
<hr>
#### **sellMsd**
*When the user sell msd(USX), you can call this function*
* Check whether the sender's msd(USX) allowance needs to approve.
> msd(USX).allowance(sender, LSR) > input amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ----------------- |:--------------------------------- |
| uint256 | msd(USX) amount | decimal(scaled by msd(USX)'s decimals) |
#### **sellMsd (recipient)**
*When the user buys msd(USX), you can call this function*
* Check whether the sender's msd(USX) allowance needs to approve.
> msd(USX).allowance(sender, LSR) > input amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ----------------- |:--------------------------------- |
| address | recipient address | |
| uint256 | msd(USX) amount | decimal(scaled by msd(USX)'s decimals) |
<hr>
### **Data**
#### <a id="msdDecimalScaler"></a>**msdDecimalScaler (msdAmountUnit)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | amount of a msd | wei |
#### <a id="mprDecimalScaler"></a>**mprDecimalScaler (tokenAmountUnit)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | amount of a token | wei |
<hr>
#### <a id="taxIn"></a>**taxIn (buyFee)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | buy msd fee | decimal(scaled by 1e18) |
#### <a id="taxOut"></a>**taxOut (sellFee)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | sell msd fee | decimal(scaled by 1e18) |
<hr>
#### <a id="mintCap"></a>**mintCap**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | LSR mint cap | decimal(scaled by msd(USX)'s decimals) |
#### <a id="totalMint"></a>**totalMint**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | LSR total mint | decimal(scaled by msd(USX)'s decimals) |
<hr>
#### <a id="msdQuota"></a>**msdQuota**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | msd(USX) quota | decimal(scaled by msd(USX)'s decimals) |
#### <a id="mprQuota"></a>**mprQuota (tokenQuota)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------------------- |
| uint256 | token quota | decimal(scaled by token's decimals) |
#### <a id="mprOutstanding"></a>**mprOutstanding (tokenAvailableQuota)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | -------------------------------- | ----------------------------------- |
| uint256 | available quota for token in lsr | decimal(scaled by token's decimals) |
#### <a id="totalDeposits"></a>**totalDeposits**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | -------------------------------- | ----------------------------------- |
| uint256 | quota for token in lsr | decimal(scaled by token's decimals) |
<hr>
#### <a id="getAmountToBuy"></a>**getAmountToBuy (getBuyMsdAmount)**
**`Parameters`**
| type | description |
| ------- | --------------------- |
| uint256 | amount of spent token |
**`Return value`**
| type | description | detail |
| ------- | ------------------------------------- | -------------------------------------- |
| uint256 | amount of msd(USX) that can be bought | decimal(scaled by msd(USX)'s decimals) |
#### <a id="getAmountToSell"></a>**getAmountToSell (getSellMsdAmount)**
**`Parameters`**
| type | description |
| ------- | ------------------- |
| uint256 | amount of spent msd |
**`Return value`**
| type | description | detail |
| ------- | ---------------------------------- | ----------------------------------- |
| uint256 | amount of token that can be bought | decimal(scaled by token's decimals) |
#### <a id="paused"></a>**paused**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| bool | Pause state of LSR | true: pause; false: unpause |
#### <a id="strategy"></a>**strategy**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------------------- | ------ |
| address | Active strategy address | |
## **LSR Factory**
<!-- > [strategy address](#strategy) -->
### **Data**
#### <a id="getAllLSRs"></a>**getAllLSRs**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| address[] | lsr address list | |
| address[] | msd address list | |
| address[] | mpr address list | |
## **LSR Strategy**
> [strategy address](#strategy)
### **Data**
#### <a id="limitOfDeposit"></a>**limitOfDeposit**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| uint256 | limit of deposit | wei |
#### <a id="depositStatus"></a>**depositStatus**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| bool | deposit status of the strategy | true: pause; false: unpause |
#### <a id="withdrawStatus"></a>**withdrawStatus**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ----------------------- |
| bool | withdraw status of the strategy | true: pause; false: unpause |