• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IndexCoop / index-protocol / 0642f533-5f74-4424-a094-986ba8051c4e

05 Feb 2025 06:01AM UTC coverage: 90.86% (-5.1%) from 95.955%
0642f533-5f74-4424-a094-986ba8051c4e

Pull #59

circleci

ckoopmann
feat: Aero Slipstream Exchange Adapter
Pull Request #59: feat: Aero Slipstream Exchange Adapter

2178 of 2520 branches covered (86.43%)

Branch coverage included in aggregate %.

0 of 11 new or added lines in 1 file covered. (0.0%)

127 existing lines in 10 files now uncovered.

3429 of 3651 relevant lines covered (93.92%)

204.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/contracts/protocol/integration/oracles/CTokenOracle.sol
1
/*
2
    Copyright 2021 Set Labs Inc.
3

4
    Licensed under the Apache License, Version 2.0 (the "License");
5
    you may not use this file except in compliance with the License.
6
    You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
    Unless required by applicable law or agreed to in writing, software
11
    distributed under the License is distributed on an "AS IS" BASIS,
12
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
    See the License for the specific language governing permissions and
14
    limitations under the License.
15

16
    SPDX-License-Identifier: Apache License, Version 2.0
17
*/
18

19
pragma solidity 0.6.10;
20

21
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
22

23
import { PreciseUnitMath } from "../../../lib/PreciseUnitMath.sol";
24
import { ICErc20 } from "../../../interfaces/external/ICErc20.sol";
25
import { IOracle } from "../../../interfaces/IOracle.sol";
26

27

28
/**
29
 * @title CTokenOracle
30
 * @author Set Protocol
31
 *
32
 * Oracle built to return cToken price by multiplying the underlying asset price by Compound's stored exchange rate
33
 */
34
contract CTokenOracle is IOracle {
35
    using SafeMath for uint256;
36
    using PreciseUnitMath for uint256;
37

38
    /* ============ State Variables ============ */
39
    ICErc20 public immutable cToken;
40
    IOracle public immutable underlyingOracle; // Underlying token oracle
41
    string public dataDescription;
42

43
    // CToken Full Unit
44
    uint256 public immutable cTokenFullUnit;
45

46
    // Underlying Asset Full Unit
47
    uint256 public immutable underlyingFullUnit;
48

49
    /* ============ Constructor ============ */
50

51
    /*
52
     * @param  _cToken             The address of Compound Token
53
     * @param  _underlyingOracle   The address of the underlying oracle
54
     * @param  _cTokenFullUnit     The full unit of the Compound Token
55
     * @param  _underlyingFullUnit The full unit of the underlying asset
56
     * @param  _dataDescription    Human readable description of oracle
57
     */
58
    constructor(
59
        ICErc20 _cToken,
60
        IOracle _underlyingOracle,
61
        uint256 _cTokenFullUnit,
62
        uint256 _underlyingFullUnit,
63
        string memory _dataDescription
64
    )
65
        public
66
    {
67
        cToken = _cToken;
68
        cTokenFullUnit = _cTokenFullUnit;
69
        underlyingFullUnit = _underlyingFullUnit;
70
        underlyingOracle = _underlyingOracle;
71
        dataDescription = _dataDescription;
72
    }
73

74
    /**
75
     * Returns the price value of a full cToken denominated in underlyingOracle value
76
     * The underlying oracle is assumed to return a price of 18 decimal
77
     * for a single full token of the underlying asset. The derived price
78
     * of the cToken is then the price of a unit of underlying multiplied
79
     * by the exchangeRate, adjusted for decimal differences, and descaled.
80
     */
81
    function read()
82
        external
83
        override
84
        view
85
        returns (uint256)
86
    {
87
        // Retrieve the price of the underlying
UNCOV
88
        uint256 underlyingPrice = underlyingOracle.read();
×
89

90
        // Retrieve cToken underlying to cToken stored conversion rate
UNCOV
91
        uint256 conversionRate = cToken.exchangeRateStored();
×
92

93
        // Price of underlying is the price value / Token * conversion / scaling factor
94
        // Values need to be converted based on full unit quantities
UNCOV
95
        return underlyingPrice.preciseMul(conversionRate).mul(cTokenFullUnit).div(underlyingFullUnit);
×
96
    }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc