This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Cert } = require('@0xcert/cert'); | |
| const { HttpProvider } = require('@0xcert/ethereum-http-provider'); | |
| const { AssetLedger } = require('@0xcert/ethereum-asset-ledger'); | |
| (async () => { | |
| const schema = { | |
| "$schema": "http://json-schema.org/draft-07/schema", | |
| "description": "A digital assets that have a unique combination of different properties.", | |
| "properties": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract MyContract { | |
| event MyLog(string, uint256); | |
| function supplyErc20ToCompound( | |
| address _erc20Contract, | |
| address _cErc20Contract, | |
| uint256 _numTokensToSupply | |
| ) public returns (uint) { | |
| // Create a reference to the underlying asset contract, like DAI. | |
| Erc20 underlying = Erc20(_erc20Contract); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const main = async function() { | |
| console.log('Now transferring DAI from my wallet to MyContract...'); | |
| let transferResult = await daiContract.methods.transfer( | |
| myContractAddress, | |
| web3.utils.toHex(10e18) // 10 DAI to send to MyContract | |
| ).send({ | |
| from: myWalletAddress, | |
| gasLimit: web3.utils.toHex(150000), // posted at compound.finance/developers#gas-costs | |
| gasPrice: web3.utils.toHex(20000000000), // use ethgasstation.info (mainnet only) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Mint some cDAI by sending DAI to the Compound Protocol | |
| console.log('MyContract is now minting cDAI...'); | |
| let supplyResult = await myContract.methods.supplyErc20ToCompound( | |
| daiMainNetAddress, | |
| compoundCDaiContractAddress, | |
| web3.utils.toHex(10e18) // 10 DAI to supply | |
| ).send({ | |
| from: myWalletAddress, | |
| gasLimit: web3.utils.toHex(5000000), // posted at compound.finance/developers#gas-costs | |
| gasPrice: web3.utils.toHex(20000000000), // use ethgasstation.info (mainnet only) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Call redeem based on a cToken amount | |
| const amount = web3.utils.toHex(cTokenBalance * 1e8); | |
| const redeemType = true; // true for `redeem` | |
| // Call redeemUnderlying based on an underlying amount | |
| // const amount = web3.utils.toHex(balanceOfUnderlying); | |
| // const redeemType = false; //false for `redeemUnderlying` | |
| // Retrieve your asset by exchanging cTokens | |
| console.log('Redeeming the cDAI for DAI...'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| echo "waiting for the following arguments: username + max-page-number" | |
| exit 1 | |
| else | |
| name=$1 | |
| fi | |
| if [ -z "$2" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: AGPL-3.0-or-later | |
| // The ABI encoder is necessary, but older Solidity versions should work | |
| pragma solidity ^0.7.0; | |
| pragma experimental ABIEncoderV2; | |
| // These definitions are taken from across multiple dydx contracts, and are | |
| // limited to just the bare minimum necessary to make flash loans work. | |
| library Types { | |
| enum AssetDenomination { Wei, Par } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import print_function | |
| import requests | |
| data = [] | |
| timestamp = 1530367200 # 2018-07-01 00:00 AEST | |
| for t in range(1530367200, 1530367200-365*24*60*60, -2001*60*60): | |
| data = requests.get( | |
| 'https://min-api.cryptocompare.com/data/histohour?fsym=BTC&tsym=AUD&toTs=%s&limit=%s' \ | |
| % (t, min(365*24-len(data), 2000)) | |
| ).json()['Data'] + data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.2; | |
| contract ethernalSale { | |
| struct order { | |
| uint amount; | |
| address buyer; | |
| } | |
| mapping (uint => order) orderBook; | |
| mapping (address => uint) balanceOf; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// @dev given a number get a slice of any bits, at certain offset | |
| /// @param _n a number to be sliced | |
| /// @param _nbits how many bits long is the new number | |
| /// @param _offset how many bits to skip | |
| function _sliceNumber(uint256 _n, uint256 _nbits, uint256 _offset) private pure returns (uint256) { | |
| // mask is made by shifting left an offset number of times | |
| uint256 mask = uint256((2**_nbits) - 1) << _offset; | |
| // AND n with mask, and trim to max of _nbits bits | |
| return uint256((_n & mask) >> _offset); | |
| } |
OlderNewer