# veDF Kovan Testnet
## Contract address
### **DF lock up protocol(02-14)**
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| DF | 0x79E40d67DA6eAE5eB4A93Fc6a56A7961625E15F3 | [link](https://kovan.etherscan.io/address/0x79E40d67DA6eAE5eB4A93Fc6a56A7961625E15F3) |
| vault address | 0xF4Db6BB2bd78b42e3cFbA47B667ff8A2CebB570D | [link](https://kovan.etherscan.io/address/0xF4Db6BB2bd78b42e3cFbA47B667ff8A2CebB570D) |
| sDF | 0x22A0938f726D0542Dc20e6C9D57BB97cCF940d6a | [link](https://kovan.etherscan.io/address/0x22A0938f726D0542Dc20e6C9D57BB97cCF940d6a) |
| veDF | 0x047099D138449c6e9378aa452e5F686B5625f466 | [link](https://kovan.etherscan.io/address/0x047099D138449c6e9378aa452e5F686B5625f466) |
| veDFManager | 0xdf3476DdB734497eB58E6cfc235389846153B3fe | [link](https://kovan.etherscan.io/address/0xdf3476DdB734497eB58E6cfc235389846153B3fe) |
### **DF lock up protocol(03-4)**
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| DF | 0x79E40d67DA6eAE5eB4A93Fc6a56A7961625E15F3 | [link](https://kovan.etherscan.io/address/0x79E40d67DA6eAE5eB4A93Fc6a56A7961625E15F3) |
| vault address | 0x3Ea0EA578cd03036d98279A8293ca19ddE4Bf09B | [link](https://kovan.etherscan.io/address/0x3Ea0EA578cd03036d98279A8293ca19ddE4Bf09B) |
| sDF | 0xBE3a263537F8Dc97c29d5884544Cf9F4e42299fe | [link](https://kovan.etherscan.io/address/0xBE3a263537F8Dc97c29d5884544Cf9F4e42299fe) |
| veDF | 0x65d538A6E4C06989171e24B7A4c7d74667497967 | [link](https://kovan.etherscan.io/address/0x65d538A6E4C06989171e24B7A4c7d74667497967) |
| veDFManager | 0xAf14959178d59776200E84Da9Ab92c294663A3f1 | [link](https://kovan.etherscan.io/address/0xAf14959178d59776200E84Da9Ab92c294663A3f1) |
### **DF lock up protocol(03-11)**
| Contract Name | Contract Address | Link |
| ------------- | ------------------------------------------ |:------------------------------------------------------------------------------------- |
| DF | 0x79E40d67DA6eAE5eB4A93Fc6a56A7961625E15F3 | [link](https://kovan.etherscan.io/address/0x79E40d67DA6eAE5eB4A93Fc6a56A7961625E15F3) |
| vault address | 0x3Ea0EA578cd03036d98279A8293ca19ddE4Bf09B | [link](https://kovan.etherscan.io/address/0x3Ea0EA578cd03036d98279A8293ca19ddE4Bf09B) |
| sDF | 0xBE3a263537F8Dc97c29d5884544Cf9F4e42299fe | [link](https://kovan.etherscan.io/address/0xBE3a263537F8Dc97c29d5884544Cf9F4e42299fe) |
| veDF | 0x2C9671f4f7fd226D092A2c1715b9f03749358366 | [link](https://kovan.etherscan.io/address/0x2C9671f4f7fd226D092A2c1715b9f03749358366) |
| veDFManager | 0x7259153980146593E1128d3460f356eC08FC25A5 | [link](https://kovan.etherscan.io/address/0x7259153980146593E1128d3460f356eC08FC25A5) |
### **Governance(02-23)**
| Contract Name | Contract Address | Link |
| -------------------- |:------------------------------------------ | ---- |
| veDF | 0x047099D138449c6e9378aa452e5F686B5625f466 | [link](https://kovan.etherscan.io/address/0x047099D138449c6e9378aa452e5F686B5625f466) |
| time lock | 0x32CCeCCb9e2911037C0A04E9844bC52A8ff1134B | [link](https://kovan.etherscan.io/address/0x32CCeCCb9e2911037C0A04E9844bC52A8ff1134B) |
| governance delegate | 0xfa4CF57D02E97140219D63DEb15a96d81eEbd8b0 | [link](https://kovan.etherscan.io/address/0xfa4CF57D02E97140219D63DEb15a96d81eEbd8b0) |
| governance delegator | 0x97628b2d36872ff5A1c8e1211DA62943a6245130 | [link](https://kovan.etherscan.io/address/0x97628b2d36872ff5A1c8e1211DA62943a6245130) |
### **Governance(03-14)**
| Contract Name | Contract Address | Link |
| -------------------- |:------------------------------------------ | ---- |
| veDF | 0x2C9671f4f7fd226D092A2c1715b9f03749358366 | [link](https://kovan.etherscan.io/address/0x2C9671f4f7fd226D092A2c1715b9f03749358366) |
| time lock | 0x9211Bfa57620284FdE2D8318Fd35b9a9eB56D862 | [link](https://kovan.etherscan.io/address/0x9211Bfa57620284FdE2D8318Fd35b9a9eB56D862) |
| governance delegate | 0x03aAAd8D8c30eD091f5e23658f5C08371561b0c5 | [link](https://kovan.etherscan.io/address/0x03aAAd8D8c30eD091f5e23658f5C08371561b0c5) |
| governance delegator | 0x5904B22e786437b46DA651F91e5f116945276592 | [link](https://kovan.etherscan.io/address/0x5904B22e786437b46DA651F91e5f116945276592) |
## **Calculation**
### **veDF Calculation**
**veDF amount**
```
veDFAmount = amount * weightedRate
```
~~weightedRate = ((1 + linearRate) ** 2) * linearRate~~
```
weightedRate = linearRate
```
```
linearRate = duration / (3600 * 24 * 7 * 52 * 4)
```
* **param rule**
```
param: inputAmount, inputDuration
getLocker: locker.dueTime, locker.duration, locker.amount
```
```
if (_locker.dueTime < Currentblock.timestamp)
amount = inputAmount
duration = inputDuration
```
```
if (locker.dueTime > Currentblock.timestamp)
if (inputDuration > 0)
amount = locker.amount
duration = inputDuration
if (inputAmount > 0)
amount = inputAmount
duration = locker.dueTime + inputDuration - currentBlock.timestamp
```
**Annual interest rate**
* **veDF Holder APY**
```
annualInterestRate:
rewardRate * year(365 * 24 * 3600) * 1e18 / sDFLockedAmount
```
<!-- rewardRate * year(365 * 24 * 3600) / DFLockedAmount
DFLockedAmount = sDFLockedAmount * sDF ExchangeRate -->
* **veDF Annual interest rate**
```
(annualInterest / principal) + sDF annualInterestRate
```
```
annualInterest:
rewardRate * user veDF amount * year(365 * 24 * 3600) * 1e18 / (veDF totalSupply - accSettledBalance + increase veDF amount)
user veDF amount:
if (_locker.dueTime < Currentblock.timestamp)
increase veDF amount
else
user veDF Balance + increase veDF amount
rewardRate:
call.veDFManager.getLockInfo()[3]
accSettledBalance:
call.veDFManager.getLockInfo()[2]
sDF annualInterestRate:
call.sDF.getAnnualInterestRate()
```
```
principal:
call.veDFManager.getLockerInfo(userAddress)[3] + input sDFAmount
```
<!-- lock-up sDF amount * sDF ExchangeRate -->
### **sDF Calculation**
* **sDF <-> DF**
```
DF -> sDF:
DF amount * 1e18 / exchangeRate
sDF -> DF:
sDF amount * exchangeRate / 1e18
exchangeRate:
call.sDF.getCurrentExchangeRate()
```
## **Interface Document**
_**notice: In the absence of special instructions, the data is scaled by 1e18.**_
<hr>
### **veDFManager**
**Introduction**
Welcome to Contract veDFManager's Interface Documentation!
We provide some interfaces to query infomation about dForce veDF, you can get information about.
### **User Action**
<hr>
#### **createInOne (dfCreate)**
*When the user does not have any lock information, you can call this function*
* Check whether the sender's DF allowance needs to approve.
> DF.allowance(sender, veDFManager) > deposit amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ----------------- |:--------------------------------- |
| uint256 | DF deposit amount | decimal(scaled by DF's decimals) |
| uint256 | Due time | Greenwich timestamp |
#### **create**
*When the user does not have any lock information, you can call this function*
* Check whether the sender's sDF allowance needs to approve.
> sDF.allowance(sender, veDFManager) > deposit amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ------------------ | --------------------------------- |
| uint256 | sDF deposit amount | decimal(scaled by sDF's decimals) |
| uint256 | Due time | Greenwich timestamp |
<hr>
#### **refillInOne**
*The user has locked position information and it has not expired yet. If yo.u need an additional amount, you can call this function*
* Check whether the sender's DF allowance needs to approve.
> DF.allowance(sender, veDFManager) > deposit amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ------------------ | --------------------------------- |
| uint256 | DF deposit amount | decimal(scaled by DF's decimals) |
#### **refill**
*The user has locked position information and it has not expired yet. If yo.u need an additional amount, you can call this function*
* Check whether the sender's sDF allowance needs to approve.
> sDF.allowance(sender, veDFManager) > deposit amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ------------------ | --------------------------------- |
| uint256 | sDF deposit amount | decimal(scaled by sDF's decimals) |
<hr>
#### **extend**
*The user has locked the position information and has not expired. If you need to extend the deadline, you can call this function*
**`Parameters`**
| type | description | detail |
| ------- | ----------- | ------------------- |
| uint256 | Due time | Greenwich timestamp |
<hr>
#### **refreshInOne**
*This function can be called when the user needs to lock the position again after the lock position expires*
* When the input amount is greater than the lock-up amount, Check whether the sender's sDF allowance needs to approve.
> DF.allowance(sender, veDFManager) > deposit amount - user lock-up amount
> true: Not approve
> false: approve
> input amount > lock amount
> veDF.allowance(sender, veDFManager) > amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ------------------- | -------------------------------- |
| uint256 | DF increment amount | decimal(scaled by DF's decimals) |
| uint256 | Due time | Greenwich timestamp |
#### **refresh**
*This function can be called when the user needs to lock the position again after the lock position expires*
* When the input amount is greater than the lock-up amount, Check whether the sender's sDF allowance needs to approve.
> sDF.allowance(sender, veDFManager) > deposit amount - user lock-up amount
> true: Not approve
> false: approve
> input amount > lock amount
> veDF.allowance(sender, veDFManager) > amount
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ------- | ------------------ | --------------------------------- |
| uint256 | sDF deposit amount | decimal(scaled by sDF's decimals) |
| uint256 | Due time | Greenwich timestamp |
<hr>
<!-- ## withdraw
*After the lock-up period expires, the user can call this function to take out sDF*
* Check whether the sender's veDF allowance needs to approve.
> veDF.allowance(sender, veDFManager) > sender veDF balance
> true: Not approve
> false: approve
**`Parameters`**
| type | description | detail |
| ---- | ----------- | ------ |
| none | none | | -->
<hr>
#### **getRewardInOne**
*User acquisition reward function, and reward converted to DF*
* reward: DF
**`Parameters`**
| type | description | detail |
| ---- | ----------- | ------ |
| none | none | |
#### **getReward**
*User acquisition reward function*
* reward: DF
**`Parameters`**
| type | description | detail |
| ---- | ----------- | ------ |
| none | none | |
<hr>
#### **exitInOne**
*User withdraw and getReward function*
* When the input amount is greater than the lock-up amount, Check whether the sender's veDF allowance needs to approve.
> input amount > lock amount
> veDF.allowance(sender, veDFManager) > amount
> true: Not approve
> false: approve
* withdraw: DF
* reward: DF
**`Parameters`**
| type | description | detail |
| ---- | ----------- | ------ |
| none | none | |
#### **exit2**
*User withdraw and getReward function*
* When the input amount is greater than the lock-up amount, Check whether the sender's veDF allowance needs to approve.
> input amount > lock amount
> veDF.allowance(sender, veDFManager) > amount
> true: Not approve
> false: approve
* withdraw: DF
* reward: sDF
**`Parameters`**
| type | description | detail |
| ---- | ----------- | ------ |
| none | none | |
#### **exit**
*User withdraw and getReward function*
* When the input amount is greater than the lock-up amount, Check whether the sender's sDF allowance needs to approve.
> input amount > lock amount
> veDF.allowance(sender, veDFManager) > amount
> true: Not approve
> false: approve
* withdraw: sDF
* reward: sDF
**`Parameters`**
| type | description | detail |
| ---- | ----------- | ------ |
| none | none | |
<hr>
### **Global Data**
#### **getLockersInfo (getLockInfo)**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ------------------------ | --------------------------------------------- |
| uint256 | veDF total supply | decimal(scaled by veDF decimals) |
| uint256 | Total sDF locked amount | decimal(scaled by sDF decimals) |
| uint256 | Total settled | decimal(scaled by veDF decimals) |
| uint256 | Reward distribution rate | decimal(scaled by rewardToken(DF)’s decimals) |
#### **startTime**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ----------- | ------------------------------------------------------------------------------------------------------------------- |
| uint256 | Start time | Greenwich timestamp(Through the start time, you can determine whether the deadline is in compliance with the rules) |
#### **rewardRate**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ------------------------ | --------------------------------------------- |
| uint256 | Reward distribution rate | decimal(scaled by rewardToken(DF)’s decimals) |
### **User Data**
#### **getLocker**
**`Parameters`**
| type | description |
| ------- | --------------------- |
| address | User Ethereum address |
**`Return value`**
| type | description | detail |
| ------ | ------------------- | --------------------------------- |
| uint32 | User lock deadline | Greenwich timestamp |
| uint32 | User lock duration | In seconds |
| uint96 | User lock-up amount | decimal(scaled by sDF's decimals) |
#### **getLockerInfo**
**`Parameters`**
| type | description |
| ------- | --------------------- |
| address | User Ethereum address |
**`Return value`**
| type | description | detail |
| ------- | -------------------- | ---------------------------------------- |
| uint32 | User lock start time | Greenwich timestamp |
| uint32 | User lock deadline | Greenwich timestamp |
| uint32 | User lock duration | In seconds |
| uint96 | User lock-up amount | decimal(scaled by sDF's decimals) |
| uint256 | User veDF amount | decimal(scaled by veDF's decimals) |
| uint256 | User staked veDF | decimal(scaled by veDF's decimals) |
| uint256 | User reward amount | decimal(scaled by DF's decimals) |
| uint256 | User locked status | 0: no lockup; 1: locked; 2: Lock expired |
#### **calcBalanceReceived (getExpectedAmount)**
**`Parameters`**
| type | description | detail |
| ------- | --------------------- | --------------------------------- |
| address | User Ethereum address | |
| uint256 | sDF deposit amount | decimal(scaled by sDF's decimals) |
| uint256 | Lock-up duration | In seconds |
**`Return value`**
| type | description | detail |
| ------- | ----------- | --------------------------------- |
| uint256 | veDF amount | decimal(scaled by veDF's decimals) |
#### **estimateLockerAPY (getAnnualInterestRate)**
**`Parameters`**
| type | description | detail |
| ------- | --------------------- | --------------------------------- |
| address | User Ethereum address | |
<!-- | uint256 | sDF deposit amount | decimal(scaled by sDF's decimals) |
| uint256 | Lock-up duration | In seconds | -->
**`Return value`**
| type | description | detail |
| ------- | --------------- |:------------- |
| uint256 | annual interest | decimal(1e18) |
## **StakedDF**
**Introduction**
Welcome to Contract StakedDF's Interface Documentation!
We provide some interfaces to query infomation about dForce veDF, you can get information about.
### **Global Data**
#### **getAnnualInterestRate**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | --------------- |:------------- |
| uint256 | annual interest | decimal(1e18) |
#### **getCurrentExchangeRate**
**`Parameters`**
| type | description |
| ---- | ----------- |
| none | none |
**`Return value`**
| type | description | detail |
| ------- | ---------------------- |:------------- |
| uint256 | sDF exchange DF amount | decimal(1e18) |
|Assets|Current LTV|Recommended LTV|
|---|---|---|
|USDC|80%|85%|