Git Product home page Git Product logo

compound-protocol's People

Contributors

0age avatar ajb413 avatar antoncoding avatar arjun-io avatar arr00 avatar bitcoinwarrior1 avatar coburncoburn avatar donguks avatar edd34 avatar hayesgm avatar jchittoda avatar jflatow avatar maxwolff avatar payomdousti avatar pet3ris avatar ratankaliani avatar torreyatcitty avatar trilez avatar tylerether avatar vlddm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compound-protocol's Issues

api market_history endpoint not meaningful error message

  • Github issue Im trying to pull marketdata enpoint. But met the 'Internal server error' as result.

    Below is the request

    curl 'https://api.compound.finance/api/v2/market_history/graph?asset=0xdac17f958d2ee523a2206206994597c13d831ec7&min_block_timestamp=1626294260&max_block_timestamp=1628799860&num_buckets=10'
    

    And the response is:

    {"errors":{"detail":"Internal server error"}}
    

Deploying Compound Protocol on Private networks

Hey, I am looking for deployment scripts(like truffle deploy) to deploy compound contracts on my private network. But unfortunately I am unable to do so.

Is there anything specific to this which can help us?

WalletConnect 1.5

Hello, can you please upgrade to WalletConnect 1.5? I cannot use WalletConnect to connect to many dapps. Thank you.

APY calculation method

The calculation method is different in Calculating the APY Using Rate Per Block at https://compound.finance/docs#networks.

APY = ((((Rate / ETH Mantissa * Blocks Per Day + 1) ^ Days Per Year-1))-1) * 100

supplyApy = (((Math.pow((supplyRatePerBlock / ethMantissa * blocksPerDay) + 1, daysPerYear-1)))-1) * 100;

Is it correct to correct this as follows?
APY = ((((Rate / ETH Mantissa * Blocks Per Day + 1) ^ (Days Per Year-1)))-1) * 100

Or is it the opposite?
supplyApy = (((Math.pow((supplyRatePerBlock / ethMantissa * blocksPerDay) + 1, daysPerYear))-1)-1) * 100;

Compatibility Issues with Linux

Hi, I'm facing several error while deploying contracts. Kindly help me to solve these. Which commit is stable one?

-> Compatibility issues when run running yarn deploy.
Getting scenario packages...
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.

-> When running this command "yarn repl -n rinkeby", I got this error.
$ ./scenario/script/repl -n rinkeby
Skipping Scenario Rebuild (set rebuild=true to force)
Compiling Solidity contracts...
Compiling contracts {contracts,contracts/**,tests/Contracts}/*.sol with solc to /home/aman/Aman/selenium/compound-protocol/.build/contracts.json...
SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
undefined
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Cannot deploy locally (issue in deploy.scen)

Running yarn deploy locally produces the following error:

error: Error: Failed to find string value by index (got undefined): [["Contracts","Comptroller"]], index contains: {"PriceOracle":{"description":"Fixed Price Oracle","address":"0x5dcf6E29b6c7e2a64F79416C84F959A2F0455fc6"},"Contracts":{"ZRX":"0x16405D3abB9e1066B9a71eb5FD93DABF4D23a058","PriceOracle":"0x5dcf6E29b6c7e2a64F79416C84F959A2F0455fc6","YesNo":"0x96d28812b1C1242E3fB21c981560f509029E1f91","DAI":"0x1d6ea546e9439DECC122DF9cFA50c0563d1bE8Be","StdInterest":"0x831dc59601481092e41E4Cf11F5b3f907dB2e954","Unitroller":"0x9B26Fb4c3004F63de1D1FF6bfDaD3ADA2b0F708D","BAT":"0x6473726c37357Fca32c74D6a6aeec703A0648B4C","Asdasdfas":"0xb21985b8d83640460c9Bd032593923A75b099eaF","REP":"0xB15801A4192eA9cD12820b4556593319E9B7B129","USDC":"0x4b778C79058976a74D5003D3953f133834Ea5832","ScenarioG5":"0xbaC2bD377f4cCb95C7D3515baEa2f6a3631D21A4","InterestRateModel":"0xcD28806E02fB05801361f724D35Ce59f223D0cE8"},"Constructors":{"ZRX":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002307800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035a52580000000000000000000000000000000000000000000000000000000000","PriceOracle":"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000","YesNo":"0x","DAI":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003446169000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034441490000000000000000000000000000000000000000000000000000000000","StdInterest":"0x0000000000000000000000000000000000000000000000000000048c27395000","Unitroller":"0x","BAT":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000015426173696320417474656e74696f6e20546f6b656e000000000000000000000000000000000000000000000000000000000000000000000000000000000000034241540000000000000000000000000000000000000000000000000000000000","Asdasdfas":"0x","REP":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000005417567757200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035245500000000000000000000000000000000000000000000000000000000000","USDC":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000004555344430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045553444300000000000000000000000000000000000000000000000000000000","ScenarioG5":"0x","InterestRateModel":"0x00000000000000000000000000000000000000000000000000016bcc41e90000"},"Blocks":{"ZRX":4,"PriceOracle":4,"YesNo":1,"DAI":6,"StdInterest":2,"Unitroller":3,"BAT":5,"Asdasdfas":1,"REP":7,"USDC":1,"ScenarioG5":1,"InterestRateModel":3},"Comptroller":{"YesNo":{"address":"0x96d28812b1C1242E3fB21c981560f509029E1f91","contract":"ComptrollerScenario","description":"Scenario Comptroller Impl"},"Asdasdfas":{"address":"0xb21985b8d83640460c9Bd032593923A75b099eaF","contract":"ComptrollerScenario","description":"Scenario Comptroller Impl"},"ScenarioG5":{"address":"0xbaC2bD377f4cCb95C7D3515baEa2f6a3631D21A4","contract":"ComptrollerScenario","description":"Scenario Comptroller Impl"}},"InterestRateModel":{"InterestRateModel":{"name":"InterestRateModel","contract":"InterestRateModelHarness","description":"Fixed rate 0.04% per block","address":"0xcD28806E02fB05801361f724D35Ce59f223D0cE8"},"StdInterest":{"name":"StdInterest","contract":"InterestRateModelHarness","description":"Fixed rate 0.0005% per block","address":"0x831dc59601481092e41E4Cf11F5b3f907dB2e954"}},"Tokens":{"ZRX":{"description":"Standard","name":"0x","symbol":"ZRX","decimals":18,"contract":"FaucetToken","address":"0x16405D3abB9e1066B9a71eb5FD93DABF4D23a058"},"BAT":{"description":"NonStandard","name":"Basic Attention Token","symbol":"BAT","decimals":18,"contract":"FaucetNonStandardToken","address":"0x6473726c37357Fca32c74D6a6aeec703A0648B4C"},"DAI":{"description":"Standard","name":"Dai","symbol":"DAI","decimals":18,"contract":"FaucetToken","address":"0x1d6ea546e9439DECC122DF9cFA50c0563d1bE8Be"},"REP":{"description":"Standard","name":"Augur","symbol":"REP","decimals":18,"contract":"FaucetToken","address":"0xB15801A4192eA9cD12820b4556593319E9B7B129"},"USDC":{"description":"Standard","name":"USDC","symbol":"USDC","decimals":18,"contract":"FaucetToken","address":"0x4b778C79058976a74D5003D3953f133834Ea5832"}},"Unitroller":{"description":"Unitroller","address":"0x9B26Fb4c3004F63de1D1FF6bfDaD3ADA2b0F708D"}}
      at getContractDataString (/Users/bschreck/compound-protocol/scenario/src/ContractLookup.ts:46:11)
      at getWorldContract (/Users/bschreck/compound-protocol/scenario/src/ContractLookup.ts:57:19)
      at Arg.getComptroller [as getter] (/Users/bschreck/compound-protocol/scenario/src/ContractLookup.ts:89:10)
      at /Users/bschreck/compound-protocol/scenario/src/Command.ts:120:25
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at Fetcher.getArgs (/Users/bschreck/compound-protocol/scenario/src/Command.ts:103:53)
      at Fetcher.fetch (/Users/bschreck/compound-protocol/scenario/src/Command.ts:225:16),
  event: [
    'Gate',
    [ 'CToken', 'cZRX', 'Address' ],
    [
      'CToken', 'Deploy',
      'CErc20', 'cZRX',
      [Array],  [Array],
      [Array],  [Array],
      [Array],  [Array]
    ]
  ]
}

This is related to the first CToken initialization line in deploy.scen

Token pre-approval not working for BAT

Hi There,

I'm running this scenario on a patch (#83) and not able to approve the cBAT contract to pull BAT.

#!/usr/bin/env yarn repl -s

PrintTransactionLogs
Alias CompHolder "0xC89b6f0146642688bb254bF93C28fcCF1E182C81"
Alias USDCWhale "0x3dfd23a6c5e8bbcfc9581d2e864a68feb6a076d3"
Alias DAIWhale "0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503"
Alias BATWhale "0x312Da0eae223B2062Ecd4d3f3A1100Eb7d4414B1"
Web3Fork "https://mainnet-eth.compound.finance/@11458477" (CompHolder USDCWhale DAIWhale)
UseConfigs mainnet

-- Deploy the flywheel impl
ComptrollerImpl Deploy Standard ComptrollerG7

-- Baseline USDC comp speed before the patch
Assert Equal (Comptroller CompSpeed cUSDC) 5.3786477206671197e16

-- Mint tokens
From BATWhale (Trx GasPrice 0 (Erc20 BAT Approve cBAT UInt256Max))

The error I'm getting is:

Command: From BATWhale (Trx GasPrice 0 (Erc20 BAT Approve cBAT UInt256Max))
> TypeError: erc20.methods.approve is not a function

This does work for cUSDC, however. Looking at the BAT contract, it does seem to have the approve function available: https://etherscan.io/address/0x0d8775f648430679a709e98d2b0cb6250d2887ef#code.

COMP Distribution Initialization

COMP market indices effectively began counting at 0 instead of compInitialIndex (1e36) due to an initialization bug for the โ€œupgrade existing markets into comped marketsโ€ path. Suppliers are still implicitly initialized at the initial index value, and so cannot accrue COMP for the period of time it took for the actual index to grow to the intended initial index value. Not only that, but any attempt to claim COMP before the market indices reached the intended initial value would revert.

Fortunately, since it only impacted suppliers (the initial index value is completely arbitrary on the borrow side, although the intended initial index for borrowers was still not set), and since the supplier calculation is based on cToken amounts (which all have 8 decimals), it only took ~50 blocks for all COMP supply indices to surpass the intended initial value, at which point there was no further impact.

Without further mitigation, it is possible for future markets to experience the same issue during their initialization - though it can also be avoided if refreshCompSpeeds (or anything else which calls updateCompSupplyIndex) is not called before making the new market into a COMP market. Thus it is effectively necessary to add the COMP market (_addCompMarkets) in the same transaction as supporting the market (_supportMarket) in order to avoid this issue.

ReEntrancy with multiple coordinating malicious cTokens

The borrowFresh and redeemFresh functions transfer tokens out of the protocol before updating internal accounting. This is a reentrancy vulnerability for tokens that define a malicious transfer function. The cToken contract has a reentrancy guard for this purpose. However, if multiple malicious tokens coordinate, the reentrancy guards on individual tokens are not sufficient to prevent the comptroller from reading stale liquidity data when checking these transfers.

Compound governance has been diligent in not listing malicious tokens, but the contracts should be fixed for the future.

The fix is to simply move the doTransferOut call to after internal accounting in the affected functions.

https://github.com/compound-finance/compound-protocol/blob/master/contracts/CToken.sol#L786
https://github.com/compound-finance/compound-protocol/blob/master/contracts/CToken.sol#L694

This flaw was discovered by DeFiPie, an independent deployment of the Compound Protocol.

Eth sent to Timelock will be locked in current implementation

I came across this problem while playing around with the new governance contracts.

Here's what I did
Setup the governance contracts (Comp, GovernorBravoDelegate, GovernorBravoDelegator, Timelock)

  1. Send eth to timelock contract
  2. Setup a proposal to send 0.1 eth out. Code snippet in ether.js below. proxy refers to GovernorBravoDelegator instance using GovernorBravoDelegate's abi.
    await proxy.propose(
      [signers[3].address],
      [ethers.utils.parseEther("0.1")],
      [""],
      [ethers.BigNumber.from(0)],
      "Send funds to 3rd signer"
    );
  1. Vote and have the proposal succeed.
  2. Execute the proposal, the proposal number here is arbitrary.
await proxy.execute(2);  // this fails
await proxy.execute(2, {value: ethers.utils.parseEther("0.1")})  // this would work
  1. 0.1 eth will be sent out, but it is sent from the msg.sender not from the timelock contract

Changing this line on GovernorBravoDelegate will address the issue and allow for eth in the Timelock contract to be sent out.

// Before
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);

// After, don't duplicate the proposal.values[i]
timelock.executeTransaction.value(0)(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);

The solution I found above is definitely not ideal, any other ideas appreciated.

`CErc20Delegator` pads return value bytes

When upgrading the cToken contracts between cDAI and cUSDT, there was an attempt to shave some gas off the delegator contract, by inlining some assembly to perform delegate calls on the delegatee contract. However, the assembly inadvertently appends extra bytes to the ABI-encoded return value, which still decode properly in the EVM and other tools, but can lead to apparent issues for systems which use less robust ABI-decoding logic.

There would be no harm in switching back to the cDAI version of the CErc20Delegator contract. The extra bytes could also be trimmed with more assembly, though this also introduces new (obscure) code to be audited.

Missing signature of event AccrueInterest in the abi

Hi,

I found there two types of event AccrueInterest, whose signatures are: 0x4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04 and
0x875352fb3fadeb8c0be7cbbe8ff761b308fa7033470cd0287f02f3436fd76cb9,

but it seems that the CompoundABI is missing the first signature, which constantly throws the error:

error="no event with id: 0x307834646563303465373530636131313533376361626364386139656162303634393464653038646133373335626338383731636434313235306531393062633034"

when I try to use func (abi *ABI) EventByID(topic common.Hash) (*Event, error) to get the event by its ID.

I was wondering if I was using the wrong abi?

Thanks!

Cannot reproduce latest deploy scripts on master

Hi There,

I'm having trouble reproducing the GovernorBravo deployment scripts on master.

After installing the repository, I'm running the following:

./spec/sim/0009-gov-bravo/hypothetical_upgrade_post_propose.scen

Which results in this error:

Command: From CompVoter1 (GovernorBravo GovernorBravoDelegator Propose "Grant Comp" [(Address Comptroller)] [0] ["_grantComp(address,uint256)"] [[(Address Arr00) 2]])
TypeError: governor.methods.propose is not a function
    at propose (/Users/p/Dev/compound-protocol/scenario/src/Event/GovernorBravoEvent.ts:92:22)
    at Command_1.Command.namePos [as processor] (/Users/p/Dev/compound-protocol/scenario/src/Event/GovernorBravoEvent.ts:348:22)
    at Command.process (/Users/p/Dev/compound-protocol/scenario/src/Command.ts:201:25)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Object.processGovernorBravoEvent (/Users/p/Dev/compound-protocol/scenario/src/Event/GovernorBravoEvent.ts:554:10)
    at Command.process (/Users/p/Dev/compound-protocol/scenario/src/Command.ts:201:14)
    at processCoreEvent (/Users/p/Dev/compound-protocol/scenario/src/CoreEvent.ts:869:10)
    at View.process (/Users/p/Dev/compound-protocol/scenario/src/Command.ts:203:14)
    at processCoreEvent (/Users/p/Dev/compound-protocol/scenario/src/CoreEvent.ts:869:10)
    at /Users/p/Dev/compound-protocol/scenario/src/CoreEvent.ts:66:15
    at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:14
    at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31
    at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31
    at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31
    at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31 {
  error: TypeError: governor.methods.propose is not a function
      at propose (/Users/p/Dev/compound-protocol/scenario/src/Event/GovernorBravoEvent.ts:92:22)
      at Command_1.Command.namePos [as processor] (/Users/p/De/compound-protocol/scenario/src/Event/GovernorBravoEvent.ts:348:22)
      at Command.process (/Users/p/Dev/compound-protocol/scenario/src/Command.ts:201:25)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at Object.processGovernorBravoEvent (/Users/p/Dev/compound-protocol/scenario/src/Event/GovernorBravoEvent.ts:554:10)
      at Command.process (/Users/p/Dev/compound-protocol/scenario/src/Command.ts:201:14)
      at processCoreEvent (/Users/p/Dev/compound-protocol/scenario/src/CoreEvent.ts:869:10)
      at View.process (/Users/p/Dev/compound-protocol/scenario/src/Command.ts:203:14)
      at processCoreEvent (/Users/p/Dev/compound-protocol/scenario/src/CoreEvent.ts:869:10)
      at /Users/p/Dev/compound-protocol/scenario/src/CoreEvent.ts:66:15
      at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:14
      at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31
      at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31
      at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31
      at /Users/p/Dev/compound-protocol/scenario/src/Repl.ts:177:31,
  event: [
    'From',
    'CompVoter1',
    [
      'GovernorBravo',
      'GovernorBravoDelegator',
      'Propose',
      [Array],
      [Array],
      [Array],
      [Array],
      [Array]
    ]
  ]
}

Attaching the mainnet-abi.json selection for GovernorBravo.propose:

{
    "constant": false,
    "inputs": [
        {
            "internalType": "address[]",
            "name": "targets",
            "type": "address[]"
        },
        {
            "internalType": "uint256[]",
            "name": "values",
            "type": "uint256[]"
        },
        {
            "internalType": "string[]",
            "name": "signatures",
            "type": "string[]"
        },
        {
            "internalType": "bytes[]",
            "name": "calldatas",
            "type": "bytes[]"
        },
        {
            "internalType": "string",
            "name": "description",
            "type": "string"
        }
    ],
    "name": "propose",
    "outputs": [
        {
            "internalType": "uint256",
            "name": "",
            "type": "uint256"
        }
    ],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function",
    "signature": "0xda95691a"
},

Cannot confirm BAT supply transaction through Metamask

I cannot supply my BATs to the compound layer.

  1. metamask Mainnet is connected and shows the BAT balance.
  2. I connect it to app.compound ( i have Brave browser but it is disabled for this site - its guard is down )
  3. I try to supply BAT however the confirm button is always greyed out.

bat compound

Two different definitions of `PotLike`

Hi There,

DAIInterestRateModelV3 and CDaiDelegate now have two different implementations of the Maker PotLike interface with the same name.

DAIInterestRateModelV3.sol

contract PotLike {
    function chi() external view returns (uint);
    function dsr() external view returns (uint);
    function rho() external view returns (uint);
    function pie(address) external view returns (uint);
    function drip() external returns (uint);
    function join(uint) external;
    function exit(uint) external;
}

CDaiDelegate.sol

interface PotLike {
    function chi() external view returns (uint);
    function pie(address) external view returns (uint);
    function drip() external returns (uint);
    function join(uint) external;
    function exit(uint) external;
}

Generally, there seems to be a practice of renaming old interfaces/contracts using versions to avoid confusion and conflicts within compilation/flattening tools - I wonder if this should be applicable in this instance as well?

In-kind liquidation for older markets

Older markets suffer from a previous bug in the CToken contract which prevents being liquidated in the same asset that is being supplied. The markets which this issue currently affects are cBAT, cETH, cREP, cSAI, cUSDC, cWBTC, cZRX.

Given the collateral requirements, and the fact that only interest accumulation (not price risk) can put an in-kind borrower underwater, it was previously deemed non-critical to the health of the protocol to deprecate the older markets. Governors may consider other mechanisms to migrate these markets in the future, such as the deprecation of the cSAI market and its effective replacement by the newer, immutable cDAI market. Another more invasive option is that a liquidation function could be added to the Comptroller (or elsewhere, with appropriate *Allowed hook changes), which could perform the liquidate without requiring the re-entrancy.

Note: it's somewhat impossible to prevent in-kind borrowing without major complexity, as a user could supply asset A, borrow asset B, receive cTokens of asset A and then redeem the cTokens of B, effectively being the same as supply A and borrow A.

liquidateBorrow problem

I am currently implementing a compound liquidation robot, and I am stuck on how to calculate repayAmount correctly when call liquidateBorrow, can anyone help? many thanks

Can saddle deployment scripts be non-deterministic

Hi There,

I'm running the following script on the active vesting branch: #71.

#!/usr/bin/env yarn repl -s

-- This script tests a hypothetical upgrade with one time and streaming grants

PrintTransactionLogs
Alias CompHolder "0x19bc62ff7cd9ffd6bdced9802ff718f09f7259f1"
Alias USDCWhale "0x3dfd23a6c5e8bbcfc9581d2e864a68feb6a076d3"
Web3Fork "https://mainnet-eth.compound.finance/@10706095" (CompHolder USDCWhale Tarun)
UseConfigs mainnet

-- Deploy the flywheel impl

ComptrollerImpl Deploy Standard ComptrollerG6

-- Baseline initial flywheel speed
Assert Equal (Erc20 cUSDC TokenBalance USDCWhale) 0
From USDCWhale (Trx GasPrice 0 (Erc20 USDC Approve cUSDC UInt256Max))
From USDCWhale (Trx GasPrice 0 (CToken cUSDC Mint 10000e6))
AdvanceBlocks 10
-- Comptroller ClaimComp USDCWhale

The script was previously working but is now reverting randomly at different points where it ran previously.

Couple of ideas

Is there anything that the scripts modify (perhaps mainnet.json or mainnet-abi.json?) that could make it non-deterministic?

I also haven't change any configuration such as gas limits.

I've tried to killall ganache-cli to make sure there is no interference with local processes.

CTokenRequest on Rinkeby network returns 500 error

CTokenRequest request works fine on Mainnet, Ropsten, Kovan networks, but same request with query param "network=rinkeby" and cUSDC (0x5b281a6dda0b271e91ae35de655ad301c976edb1) or any other asset ends with 500 Server Error.

[Feature] Provide a "Pre-Liquidation Liquidator" which can only be called by the investor himself

Saving the investors from paying the liquidation fee when they e.g. have an own watcher running to ensure the health of their LTV ratio ...

I only found the https://compound.finance/docs/ctokens#liquidate-borrow function and the https://compound.finance/docs/ctokens#repay-borrow function. I'm looking for something like "repay-using-collateral".

I think it would be cool for investors to give them the chance to trigger the non-costly own pre-liquidation clearing before the liquidation threshold is reached.

This feature makes sense for investors who do not have the immediate liquidity to just pay back their loans in order to free their assets --> therefore I call this feature pre-liquidation liquidator.

I would be available for pair programming around this topic. And I would love to use this new feature e.g. in investment scenarios like:

https://github.com/compound-developers/compound-borrow-examples/pull/4/files#diff-c01084a9b4ef09920fc40dd8eee592e8133336f3c4f88b2574e361483ead79b2R53-R63

Is the calculation formula correct or not?

Regarding to the function of distributeBorrowerComp() in https://github.com/compound-finance/compound-protocol/blob/master/contracts/Comptroller.sol,
the formula of calculating account borrow amount is:
uint borrowerAmount = div_(CToken(cToken).borrowBalanceStored(borrower), marketBorrowIndex);

I saw the borrowAmount calculation in cToken is:
recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex

Is the borrowerAmount in distributeBorrowerComp() correct or not?

Flash Loan Griefing

Flash loans can be used to borrow large amounts, call refreshCompSpeeds, and then repay. Only impacts markets until speeds are refreshed again, which can be performed by any address at any time.

Rollup command not found

Trying to install this as a npm dependency like so with Node.js v12.19.0 on MacOS

"dependencies": {
    "compound": "[email protected]:compound-finance/compound-protocol.git"
  },

but this results in the following error

npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.

> @solidity-parser/[email protected] prepack /Users/user/.npm/_cacache/tmp/git-clone-8d928a59
> npm run build && npm run generate-types


> @solidity-parser/[email protected] build /Users/user/.npm/_cacache/tmp/git-clone-8d928a59
> rollup -c rollup.config.js

sh: rollup: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @solidity-parser/[email protected] build: `rollup -c rollup.config.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @solidity-parser/[email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2021-02-14T20_45_12_695Z-debug.log
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! premature close

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2021-02-14T20_45_13_185Z-debug.log

On Kovan network, the COMP address in Comptroller.sol is wrong

In deployed comptroller contract on kovan network, getCompAddress function of comptroller is returning the COMP address of main network(Actual COMP Address: 0xc00e94Cb662C3520282E6f5717214004A7f26888, Expected COMP Address: 0x61460874a7196d6a22d1ee4922473664b3e95270) .

Ledger Confirmation

I tried using the app today to supply some USDT and withdrawl some ETH Both time it will let me confirm on ly Nano S but the app doesn't see that confirmation and just waits indefinetly. Any Ideas

A question about COMP distribution

While update supply index and borrow index, you use the same compSpeed value to calculate. Will it double distribute COMP? I think it should be compRate = borrowSpeed + supplySpeed.

Max Repay amount discrepancy

When I borrow DAI with ETH as collateral say 100 DAI,
and after some time I repay full amount, say 100.000435245 with interest. -> I got the amount from getAccountSnapshot("my address")

Even after the repay with above amount my borrowed amount still shows up, in getAccountSnapshot("my address") with much lesser amount say 0.0000035343478

I think the problem is because the time interval between call creation and transaction execution as interest is calculated based on every block. How can I over come it?

delegatecall in GovernorBravoDelegator

Hi, is there an explanation on how the governance contracts are pieced together?

I managed to get it working only by replacing the delegatecall method inside DelegateTo function in the Delegator contract into a 'simple' call method. Initialization of delegate-contract kept failing because it seemed the function was using the storage of the delegator instead of that of delegate. The delegatecall method brings along the storage of the caller, i read then, so i replaced it with call and got the initialisation to work. In my current setup delegator is the admin of delegate and delegate is the admin of timelock.

I managed to write proposald, castvotes, queue the proposal. Now i am trying to write a proposal that executes. This gets reverted in the timelock:

propose(
[],
[0],
["_setProposalThreshold(uint256)"],
[web3.eth.abi.encodeParameters(["uint256"],[33])],
"set proposal threshold to 33"
);

Now i am wondering whether i made a wrong assumption before and doing it all wrong. ..

Suggestions a highly appreciated!

Thanks, Joera

approve ffffff in app.compound.finance is risky

Hi,

I am from Ownbit [https://ownbit.io] wallet team, and we are integrating with Compound protocol. When we tried to use https://app.compound.finance/ we found the approve function is passing fffffff as the amount which we thing may lead to future problems.

Function: approve(address _spender, uint256 _value)
โ€‹
MethodID: 0x095ea7b3
[0]: 000000000000000000000000f650c3d88d12db855b8bf7d11be6c55a4e07dcc9
[1]: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Take USDT for example, this call will make cUSDT contract has the ability to transfer all tokens in my account now and in future. This is unnecessary and risky.

Unused variable: `select_chain`

Hi Team,

please fix issue with unused variable ...
log:

   Compiling sc-executor-wasmtime v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-executor v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-client-api v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-block-builder v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-consensus v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-consensus-epochs v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-consensus-uncles v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-state-db v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-light v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-transaction-pool v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling substrate-frame-rpc-system v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-rpc v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-basic-authorship v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-consensus-aura v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-consensus-babe v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-client-db v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-network-gossip v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-offchain v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-informant v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-finality-grandpa v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-chain-spec v2.0.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-finality-grandpa-rpc v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-service v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-sync-state-rpc v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
   Compiling sc-cli v0.8.0 (https://github.com/compound-finance/substrate?branch=master#3bb13fdc)
warning: unused variable: `select_chain`
   --> node/src/rpc.rs:103:9
    |
103 |         select_chain, // XXX delete?
    |         ^^^^^^^^^^^^ help: try ignoring the field: `select_chain: _`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `chain_spec`
   --> node/src/rpc.rs:104:9
    |
104 |         chain_spec,   // XXX delete?
    |         ^^^^^^^^^^ help: try ignoring the field: `chain_spec: _`

    Building [=====================> ] 1077/1078: gateway(bin)
warning: 2 warnings emitted

    Finished release [optimized] target(s) in 15m 44s

Assets which are supplied but not 'entered' can still be seized

The collateral factor times the amount of the asset supplied, times the price, equals the collateral value of an asset supplied by a user. However, this only applies to assets which a user has 'entered' into by calling enterMarkets on the Comptroller. Assets which are not entered into do not add to a user's borrowing power.

On the other hand, when liquidating a borrower, a liquidator may choose which asset the user has supplied which they would like to liquidate. Currently, a liquidator may choose to seize any asset which a borrower is supplying in order to repay their borrow and liquidate them. It would probably be more fair to only allow seizing assets which the borrower has entered into.

Being liquidated in an asset which is not providing collateral value, actually helps the borrower become healthy again more quickly, since their borrowing power is not simultaneously decreased by the action. However, if a user intended to be able to lose the supplied asset during liquidation, they would have entered into the market to begin with, as that would have strictly increased their initial borrowing power.

Testing comptroller on Rinkeby

Testing an integration with COMP from an external contract I wanted to make use of the claimComp(address) function.

However, the Comptroller address provided at the documentation 0x2eaa9d77ae4d8f9cdd9faacd44016e746485bddb looks outdated.

Is the latest version of Comptroller available at any testnet? Otherwise, could this be updated?

Cannot check token balances in Saddle scripts

While trying to write sanity checking scripts for basic Comptroller testing, I was not able to check balances on cTokens for some reason. When I run the original deploy script for the COMP patch it failed too:

https://github.com/compound-finance/compound-protocol/blob/master/spec/sim/0001-comp-distribution-patch/hypothetical_upgrade.scen

It says it is failing to find the indices for cBAT and cUSDC:

EventProcessingError: Failed to find string value by index (got undefined): [["Tokens","cUSDC","address"]], index contains: 
<redacted>

Any thoughts on what may have caused this? It seems like a json error perhaps when a market is missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.