├── .prettierignore ├── src ├── helpers │ ├── constants.ts │ └── database.ts └── mappings │ ├── payroll.ts │ └── sablier.ts ├── .eslintignore ├── .yarnrc.yml ├── networks ├── bsc.json ├── goerli.json ├── kovan.json ├── matic.json ├── optimism.json ├── ropsten.json ├── arbitrum.json ├── avalanche.json ├── mainnet.json └── rinkeby.json ├── .gitignore ├── .editorconfig ├── abis ├── ERC20NameBytes32.json ├── ERC20SymbolBytes32.json ├── ERC20.json ├── Sablier.json └── Payroll.json ├── .prettierrc.yml ├── .eslintrc.yml ├── .github └── workflows │ ├── ci.yml │ └── deploy.yml ├── templates ├── v1.1.0.yml └── v1.0.0-and-v1.1.0.yml ├── README.md ├── schema.graphql ├── package.json └── LICENSE.md /.prettierignore: -------------------------------------------------------------------------------- 1 | # directories 2 | .yarn/ 3 | build/ 4 | node_modules/ 5 | src/types/ 6 | -------------------------------------------------------------------------------- /src/helpers/constants.ts: -------------------------------------------------------------------------------- 1 | import { BigInt } from "@graphprotocol/graph-ts"; 2 | 3 | export let CUTOFF_STREAM_ID: BigInt = BigInt.fromI32(100000); 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # directories 2 | .yarn/ 3 | build/ 4 | node_modules/ 5 | src/types/ 6 | 7 | # files 8 | npm-debug.log* 9 | templatify.js 10 | yarn-debug.log* 11 | yarn-error.log* 12 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | 3 | plugins: 4 | - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs 5 | spec: "@yarnpkg/plugin-interactive-tools" 6 | 7 | yarnPath: .yarn/releases/yarn-3.1.0.cjs 8 | -------------------------------------------------------------------------------- /networks/bsc.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "bsc", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0x05BC7f5fb7F248d44d38703e5C921A8c16825161", 7 | "startBlock": 10874288 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /networks/goerli.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "goerli", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0xFc7E3a3073F88B0f249151192812209117C2014b", 7 | "startBlock": 5081638 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /networks/kovan.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "kovan", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0x5eb34b5d5c75ce2119078e5b3f6a3f30e457e46b", 7 | "startBlock": 25902228 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /networks/matic.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "matic", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0xAC18EAB6592F5fF6F9aCf5E0DCE0Df8E49124C06", 7 | "startBlock": 19055943 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /networks/optimism.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "optimism", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0x6c5927c0679e6d857e87367bb635decbcb20f31c", 7 | "startBlock": 4207146 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /networks/ropsten.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "ropsten", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0xcd79FFea8e2E6eFDAe92554Fdd1F154bB7c62D0f", 7 | "startBlock": 10566441 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # directories 2 | .yarn/* 3 | !.yarn/releases 4 | !.yarn/plugins 5 | build/ 6 | lib/ 7 | node_modules/ 8 | src/types/ 9 | 10 | # files 11 | .DS_Store 12 | .env 13 | npm-debug.log* 14 | subgraph.yaml 15 | yarn-debug.log* 16 | yarn-error.log* 17 | *.log 18 | -------------------------------------------------------------------------------- /networks/arbitrum.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "arbitrum-one", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0xadb944b478818d95659067e70d2e5fc43fa3ede9", 7 | "startBlock": 7517896 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /networks/avalanche.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "avalanche", 3 | "contracts": { 4 | "sablier": { 5 | "v1-1-0": { 6 | "address": "0x73f503fad13203c87889c3d5c567550b2d41d7a4", 7 | "startBlock": 11807565 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # All files 7 | [*] 8 | charset = utf-8 9 | end_of_line = lf 10 | indent_size = 2 11 | indent_style = space 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | -------------------------------------------------------------------------------- /abis/ERC20NameBytes32.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "internalType": "bytes32", 9 | "name": "", 10 | "type": "bytes32" 11 | } 12 | ], 13 | "payable": false, 14 | "stateMutability": "view", 15 | "type": "function" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /abis/ERC20SymbolBytes32.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "symbol", 6 | "outputs": [ 7 | { 8 | "internalType": "bytes32", 9 | "name": "", 10 | "type": "bytes32" 11 | } 12 | ], 13 | "payable": false, 14 | "stateMutability": "view", 15 | "type": "function" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /.prettierrc.yml: -------------------------------------------------------------------------------- 1 | arrowParens: avoid 2 | bracketSpacing: true 3 | endOfLine: auto 4 | importOrder: ["", "^[./]"] 5 | importOrderParserPlugins: ["jsx", "typescript"] 6 | importOrderSeparation: true 7 | importOrderSortSpecifiers: true 8 | printWidth: 120 9 | singleQuote: false 10 | tabWidth: 2 11 | trailingComma: all 12 | 13 | overrides: 14 | - files: ["*.yaml", "*.yml"] 15 | options: 16 | bracketSpacing: false 17 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | extends: 2 | - "eslint:recommended" 3 | - "plugin:@typescript-eslint/eslint-recommended" 4 | - "plugin:@typescript-eslint/recommended" 5 | - "prettier" 6 | parser: "@typescript-eslint/parser" 7 | plugins: 8 | - "@typescript-eslint" 9 | root: true 10 | rules: 11 | "@typescript-eslint/no-inferrable-types": "off" 12 | "@typescript-eslint/no-unused-vars": 13 | - error 14 | - argsIgnorePattern: _ 15 | varsIgnorePattern: _ 16 | "prefer-const": "off" 17 | -------------------------------------------------------------------------------- /networks/mainnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "mainnet", 3 | "contracts": { 4 | "payroll": { 5 | "address": "0xbd6a40Bb904aEa5a49c59050B5395f7484A4203d", 6 | "startBlock": 8921861 7 | }, 8 | "sablier": { 9 | "v1-0-0": { 10 | "address": "0xA4fc358455Febe425536fd1878bE67FfDBDEC59a", 11 | "startBlock": 8921858 12 | }, 13 | "v1-1-0": { 14 | "address": "0xCD18eAa163733Da39c232722cBC4E8940b1D8888", 15 | "startBlock": 12749357 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /networks/rinkeby.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "rinkeby", 3 | "contracts": { 4 | "payroll": { 5 | "address": "0x7ee114C3628Ca90119fC699f03665bF9dB8f5faF", 6 | "startBlock": 5428801 7 | }, 8 | "sablier": { 9 | "v1-0-0": { 10 | "address": "0xc04Ad234E01327b24a831e3718DBFcbE245904CC", 11 | "startBlock": 5428792 12 | }, 13 | "v1-1-0": { 14 | "address": "0xC1f3af5DC05b0C51955804b2afc80eF8FeED67b9", 15 | "startBlock": 8865670 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "CI" 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | 8 | jobs: 9 | ci: 10 | runs-on: "ubuntu-latest" 11 | steps: 12 | - name: "Check out the repo" 13 | uses: "actions/checkout@v4" 14 | 15 | - name: "Install Node.js" 16 | uses: "actions/setup-node@v3" 17 | with: 18 | cache: "yarn" 19 | node-version: "18" 20 | 21 | - name: "Install dependencies" 22 | run: "yarn install --immutable" 23 | 24 | - name: "Lint the code" 25 | run: "yarn run lint" 26 | 27 | - name: "Generate the subgraph manifest" 28 | run: "yarn run prepare:mainnet" 29 | 30 | - name: "Generate the AssemblyScript types" 31 | run: "yarn run codegen" 32 | 33 | - name: "Build the subgraph" 34 | run: "yarn run build" 35 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: "Deploy Subgraph" 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | network: 7 | description: "Network name in lowercase" 8 | required: true 9 | 10 | jobs: 11 | deploy: 12 | runs-on: "ubuntu-latest" 13 | steps: 14 | - name: "Check out the repo" 15 | uses: "actions/checkout@v4" 16 | 17 | - name: "Install Node.js" 18 | uses: "actions/setup-node@v3" 19 | with: 20 | cache: "yarn" 21 | node-version: "18" 22 | 23 | - name: "Install dependencies" 24 | run: "yarn install --immutable" 25 | 26 | - name: "Lint the code" 27 | run: "yarn run lint" 28 | 29 | - name: "Generate the subgraph manifest" 30 | run: "yarn run prepare:mainnet" 31 | 32 | - name: "Generate the AssemblyScript types" 33 | run: "yarn run codegen" 34 | 35 | - name: "Deploy to ${{ inputs.network }}" 36 | run: yarn run deploy:${{ inputs.network }} --access-token ${{ secrets.THE_GRAPH_TOKEN }} 37 | -------------------------------------------------------------------------------- /templates/v1.1.0.yml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.2 2 | description: Money streaming protocol 3 | repository: https://github.com/sablier-labs/v1-subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: SablierV1.1.0 9 | network: {{network}} 10 | source: 11 | abi: Sablier 12 | address: "{{contracts.sablier.v1-1-0.address}}" 13 | startBlock: {{contracts.sablier.v1-1-0.startBlock}} 14 | mapping: 15 | kind: ethereum/events 16 | apiVersion: 0.0.5 17 | abis: 18 | - name: ERC20 19 | file: ./abis/ERC20.json 20 | - name: ERC20NameBytes32 21 | file: ./abis/ERC20NameBytes32.json 22 | - name: ERC20SymbolBytes32 23 | file: ./abis/ERC20SymbolBytes32.json 24 | - name: Sablier 25 | file: ./abis/Sablier.json 26 | entities: 27 | - Cancellation 28 | - Stream 29 | - StreamTransaction 30 | - Token 31 | - Withdrawal 32 | eventHandlers: 33 | - event: CreateStream(indexed uint256,indexed address,indexed address,uint256,address,uint256,uint256) 34 | handler: handleCreateStream 35 | - event: WithdrawFromStream(indexed uint256,indexed address,uint256) 36 | handler: handleWithdrawFromStream 37 | - event: CancelStream(indexed uint256,indexed address,indexed address,uint256,uint256) 38 | handler: handleCancelStream 39 | file: ./src/mappings/sablier.ts 40 | language: wasm/assemblyscript 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sablier Legacy Subgraph 2 | 3 | This is the subgraph of the Sablier Legacy token streaming protocol. The most recent release is called Lockup and can be found [here](https://github.com/sablier-labs/lockup). For more details about how Sablier works, check out our docs at [docs.sablier.com](https://docs.sablier.com)/. 4 | 5 | You can interact with the subgraph using The Graph's hosted service: 6 | 7 | - [sablier-labs/sablier](https://thegraph.com/explorer/subgraph/sablier-labs/sablier) 8 | - [sablier-labs/sablier-arbitrum](https://thegraph.com/explorer/subgraph/sablier-labs/sablier-arbitrum) 9 | - [sablier-labs/sablier-avalanche](https://thegraph.com/explorer/subgraph/sablier-labs/sablier-avalanche) 10 | - [sablier-labs/sablier-bsc](https://thegraph.com/explorer/subgraph/sablier-labs/sablier-bsc) 11 | - [sablier-labs/sablier-matic](https://thegraph.com/explorer/subgraph/sablier-labs/sablier-matic) 12 | - [sablier-labs/sablier-optimism](https://thegraph.com/explorer/subgraph/sablier-labs/sablier-optimism) 13 | 14 | ## Queries 15 | 16 | Below are a few ways to show how to query the Sablier Legacy subgraph for data. The queries show most of the information that 17 | is queryable, but there are many other filtering options that can be used. Just check out the GraphQL API. 18 | 19 | ### Query All Streams 20 | 21 | ```graphql 22 | { 23 | streams { 24 | id 25 | cancellation { 26 | recipientBalance 27 | timestamp 28 | txhash 29 | } 30 | deposit 31 | ratePerSecond 32 | recipient 33 | sender 34 | startTime 35 | stopTime 36 | timestamp 37 | token { 38 | id 39 | decimals 40 | name 41 | symbol 42 | } 43 | txs { 44 | id 45 | block 46 | event 47 | from 48 | timestamp 49 | to 50 | } 51 | withdrawals { 52 | id 53 | amount 54 | } 55 | } 56 | } 57 | ``` 58 | 59 | ### Query All Streams for a Particular User 60 | 61 | You can do this with the [`where`](https://thegraph.com/docs/en/querying/graphql-api/#example-using-where) clause. Make sure that the user address is in lowercase: 62 | 63 | ```graphql 64 | { 65 | streams(where: { sender: "0xcafe...beef" }) { 66 | id 67 | } 68 | } 69 | ``` 70 | 71 | ### Query All Transactions 72 | 73 | ```graphql 74 | { 75 | transactions { 76 | id 77 | block 78 | event 79 | from 80 | stream { 81 | id 82 | } 83 | timestamp 84 | to 85 | } 86 | } 87 | ``` 88 | -------------------------------------------------------------------------------- /src/mappings/payroll.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, dataSource } from "@graphprotocol/graph-ts"; 2 | 3 | import { CUTOFF_STREAM_ID } from "../helpers/constants"; 4 | import { createStreamTransaction, loadOrCreateToken } from "../helpers/database"; 5 | import { CreateSalary as CreateSalaryEvent, Payroll as PayrollContract } from "../types/Payroll/Payroll"; 6 | import { Sablier as SablierContract, Sablier__getStreamResult } from "../types/SablierV1.1.0/Sablier"; 7 | import { Stream, StreamToSalary } from "../types/schema"; 8 | 9 | /// Maps and normalises salaries as streams. The "payroll" naming might sound awkward, but this is due 10 | /// to historical reasons. We initially thought of Sablier as having a narrow scope. But after writing 11 | /// the contracts, we realised that the same code can be used for far more use cases. 12 | export function handleCreateSalary(event: CreateSalaryEvent): void { 13 | if (event.params.salaryId.ge(CUTOFF_STREAM_ID)) { 14 | return; 15 | } 16 | 17 | // Get hold of the Payroll.sol and Sablier.sol contract instances. 18 | let payrollAddress: Address = dataSource.address(); 19 | let payrollContract: PayrollContract = PayrollContract.bind(payrollAddress); 20 | let sablierAddress = payrollContract.sablier(); 21 | let sablierContract: SablierContract = SablierContract.bind(sablierAddress); 22 | 23 | // Query the Sablier.sol for the newly created stream. 24 | let streamId: BigInt = event.params.streamId; 25 | let getStreamResult: Sablier__getStreamResult = sablierContract.getStream(streamId); 26 | let tokenAddress: string = getStreamResult.value3.toHex(); 27 | 28 | // Create the stream entity. Yes, the id of the Stream entity is the salary id. 29 | let salaryId: string = event.params.salaryId.toString(); 30 | let stream: Stream = new Stream(salaryId); 31 | stream.sender = event.params.company; 32 | stream.recipient = getStreamResult.value1; 33 | stream.deposit = getStreamResult.value2; 34 | stream.token = tokenAddress; 35 | stream.startTime = getStreamResult.value4; 36 | stream.stopTime = getStreamResult.value5; 37 | stream.ratePerSecond = getStreamResult.value7; 38 | stream.timestamp = event.block.timestamp; 39 | stream.save(); 40 | 41 | // Create the streamToSalary entity. 42 | let streamToSalary: StreamToSalary = new StreamToSalary(streamId.toString()); 43 | streamToSalary.salaryId = event.params.salaryId; 44 | streamToSalary.save(); 45 | 46 | // Create adjacent but important entities. 47 | createStreamTransaction("CreateStream", event, salaryId); 48 | loadOrCreateToken(tokenAddress); 49 | } 50 | -------------------------------------------------------------------------------- /src/mappings/sablier.ts: -------------------------------------------------------------------------------- 1 | import { createStreamTransaction, loadOrCreateToken, loadStream } from "../helpers/database"; 2 | import { 3 | CancelStream as CancelStreamEvent, 4 | CreateStream as CreateStreamEvent, 5 | WithdrawFromStream as WithdrawFromStreamEvent, 6 | } from "../types/SablierV1.1.0/Sablier"; 7 | import { Cancellation, Stream, Withdrawal } from "../types/schema"; 8 | 9 | export function handleCreateStream(event: CreateStreamEvent): void { 10 | let streamId: string = event.params.streamId.toString(); 11 | let tokenAddress: string = event.params.tokenAddress.toHex(); 12 | 13 | // Create the stream entity. 14 | let stream: Stream = new Stream(streamId); 15 | stream.deposit = event.params.deposit; 16 | stream.ratePerSecond = event.params.deposit.div(event.params.stopTime.minus(event.params.startTime)); 17 | stream.recipient = event.params.recipient; 18 | stream.sender = event.params.sender; 19 | stream.startTime = event.params.startTime; 20 | stream.stopTime = event.params.stopTime; 21 | stream.timestamp = event.block.timestamp; 22 | stream.token = tokenAddress; 23 | stream.save(); 24 | 25 | // Create adjacent but important entities. 26 | createStreamTransaction("CreateStream", event, streamId); 27 | loadOrCreateToken(tokenAddress); 28 | } 29 | 30 | export function handleWithdrawFromStream(event: WithdrawFromStreamEvent): void { 31 | let stream: Stream | null = loadStream(event.params.streamId.toString()); 32 | if (stream == null) { 33 | return; 34 | } 35 | 36 | // Create the withdrawal entity. 37 | let txhash: string = event.transaction.hash.toHex(); 38 | let withdrawal: Withdrawal = new Withdrawal(txhash + "-" + event.logIndex.toString()); 39 | withdrawal.amount = event.params.amount; 40 | withdrawal.stream = stream.id; 41 | withdrawal.timestamp = event.block.timestamp; 42 | withdrawal.token = stream.token; 43 | withdrawal.txhash = txhash; 44 | withdrawal.save(); 45 | 46 | // Create a stream transaction entity. 47 | createStreamTransaction("WithdrawFromStream", event, stream.id); 48 | } 49 | 50 | export function handleCancelStream(event: CancelStreamEvent): void { 51 | let stream: Stream | null = loadStream(event.params.streamId.toString()); 52 | if (stream == null) { 53 | return; 54 | } 55 | 56 | // Create the cancellation entity. 57 | let cancellation: Cancellation = new Cancellation(stream.id); 58 | cancellation.recipientBalance = event.params.recipientBalance; 59 | cancellation.senderBalance = event.params.senderBalance; 60 | cancellation.timestamp = event.block.timestamp; 61 | cancellation.token = stream.token; 62 | cancellation.txhash = event.transaction.hash.toHex(); 63 | cancellation.save(); 64 | 65 | // Update the stream entity. 66 | stream.cancellation = stream.id; 67 | stream.save(); 68 | 69 | // Create a stream transaction entity. 70 | createStreamTransaction("CancelStream", event, stream.id); 71 | } 72 | -------------------------------------------------------------------------------- /schema.graphql: -------------------------------------------------------------------------------- 1 | """ 2 | Generic type for ERC-20 tokens. 3 | """ 4 | type Token @entity { 5 | "The contract address" 6 | id: ID! 7 | "The ERC-20 decimals" 8 | decimals: Int 9 | "The ERC-20 name" 10 | name: String 11 | "The ERC-20 symbol" 12 | symbol: String 13 | } 14 | 15 | """ 16 | Generic type for Sablier cancellations. 17 | """ 18 | type Cancellation @entity { 19 | "The same as the stream id" 20 | id: ID! 21 | "Amount of tokens the recipient was distributed" 22 | recipientBalance: BigInt! 23 | "Amount of tokens the sender was distributed" 24 | senderBalance: BigInt! 25 | "The time when the cancellation was made" 26 | timestamp: BigInt! 27 | "The token used for payment" 28 | token: Token 29 | "Transaction hash" 30 | txhash: String! 31 | } 32 | 33 | """ 34 | Generic type for Sablier streams. 35 | """ 36 | type Stream @entity { 37 | "Details about cancellation time and the distributed amounts" 38 | cancellation: Cancellation 39 | deposit: BigInt! 40 | "The salary id in v1.0.0 and the actual stream id in v1.1.0" 41 | id: ID! 42 | "How much is being streamed every second" 43 | ratePerSecond: BigInt! 44 | "The address of the recipient account" 45 | recipient: Bytes! 46 | "The address of the sender account, who created the streamed" 47 | sender: Bytes! 48 | "The time when the stream commences" 49 | startTime: BigInt! 50 | "The time when the stream stops" 51 | stopTime: BigInt! 52 | "The time when the stream was created" 53 | timestamp: BigInt! 54 | "The token used for payment" 55 | token: Token 56 | "Exhaustive list of all transactions that interacted with the stream" 57 | txs: [StreamTransaction!] @derivedFrom(field: "stream") 58 | "Exhaustive list of all withdrawals made from the stream" 59 | withdrawals: [Withdrawal!] @derivedFrom(field: "stream") 60 | } 61 | 62 | """ 63 | Needed for retroactively indexing cancellations and withdrawals for v1.0.0 streams. 64 | """ 65 | type StreamToSalary @entity { 66 | "The stream id" 67 | id: ID! 68 | "The salary id" 69 | salaryId: BigInt! 70 | } 71 | 72 | """ 73 | Transaction that interacted with a stream. 74 | """ 75 | type StreamTransaction @entity { 76 | "Transaction hash concatenated with log index" 77 | id: ID! 78 | "Block number" 79 | block: Int! 80 | "The name of the event emitted" 81 | event: String! 82 | "The caller, or msg.sender" 83 | from: Bytes! 84 | "The stream entity associated with this transaction" 85 | stream: Stream! 86 | "Block timestamp" 87 | timestamp: BigInt! 88 | "The contract address" 89 | to: Bytes 90 | "Transaction hash" 91 | txhash: String! 92 | } 93 | 94 | """ 95 | Generic type for Sablier withdrawals. 96 | """ 97 | type Withdrawal @entity { 98 | "Transaction hash concatenated with log index" 99 | id: ID! 100 | "How many tokens were withdrawn" 101 | amount: BigInt! 102 | "The stream entity associated with this withdrawal" 103 | stream: Stream! 104 | "The time when the cancellation was made" 105 | timestamp: BigInt! 106 | "The token used for payment" 107 | token: Token 108 | "Transaction hash" 109 | txhash: String! 110 | } 111 | -------------------------------------------------------------------------------- /templates/v1.0.0-and-v1.1.0.yml: -------------------------------------------------------------------------------- 1 | specVersion: 0.0.2 2 | description: Money streaming protocol 3 | repository: https://github.com/sablier-labs/v1-subgraph 4 | schema: 5 | file: ./schema.graphql 6 | dataSources: 7 | - kind: ethereum/contract 8 | name: SablierV1.0.0 9 | network: {{network}} 10 | source: 11 | abi: Sablier 12 | address: "{{contracts.sablier.v1-0-0.address}}" 13 | startBlock: {{contracts.sablier.v1-0-0.startBlock}} 14 | mapping: 15 | kind: ethereum/events 16 | apiVersion: 0.0.5 17 | abis: 18 | - name: Sablier 19 | file: ./abis/Sablier.json 20 | entities: 21 | - Cancellation 22 | - Stream 23 | - StreamTransaction 24 | - Withdrawal 25 | eventHandlers: 26 | - event: WithdrawFromStream(indexed uint256,indexed address,uint256) 27 | handler: handleWithdrawFromStream 28 | - event: CancelStream(indexed uint256,indexed address,indexed address,uint256,uint256) 29 | handler: handleCancelStream 30 | file: ./src/mappings/sablier.ts 31 | language: wasm/assemblyscript 32 | - kind: ethereum/contract 33 | name: SablierV1.1.0 34 | network: {{network}} 35 | source: 36 | abi: Sablier 37 | address: "{{contracts.sablier.v1-1-0.address}}" 38 | startBlock: {{contracts.sablier.v1-1-0.startBlock}} 39 | mapping: 40 | kind: ethereum/events 41 | apiVersion: 0.0.5 42 | abis: 43 | - name: ERC20 44 | file: ./abis/ERC20.json 45 | - name: ERC20NameBytes32 46 | file: ./abis/ERC20NameBytes32.json 47 | - name: ERC20SymbolBytes32 48 | file: ./abis/ERC20SymbolBytes32.json 49 | - name: Sablier 50 | file: ./abis/Sablier.json 51 | entities: 52 | - Cancellation 53 | - Stream 54 | - StreamTransaction 55 | - Token 56 | - Withdrawal 57 | eventHandlers: 58 | - event: CreateStream(indexed uint256,indexed address,indexed address,uint256,address,uint256,uint256) 59 | handler: handleCreateStream 60 | - event: WithdrawFromStream(indexed uint256,indexed address,uint256) 61 | handler: handleWithdrawFromStream 62 | - event: CancelStream(indexed uint256,indexed address,indexed address,uint256,uint256) 63 | handler: handleCancelStream 64 | file: ./src/mappings/sablier.ts 65 | language: wasm/assemblyscript 66 | - kind: ethereum/contract 67 | name: Payroll 68 | network: {{network}} 69 | source: 70 | abi: Payroll 71 | address: "{{contracts.payroll.address}}" 72 | startBlock: {{contracts.payroll.startBlock}} 73 | mapping: 74 | kind: ethereum/events 75 | apiVersion: 0.0.5 76 | abis: 77 | - name: ERC20 78 | file: ./abis/ERC20.json 79 | - name: ERC20NameBytes32 80 | file: ./abis/ERC20NameBytes32.json 81 | - name: ERC20SymbolBytes32 82 | file: ./abis/ERC20SymbolBytes32.json 83 | - name: Payroll 84 | file: ./abis/Payroll.json 85 | - name: Sablier 86 | file: ./abis/Sablier.json 87 | entities: 88 | - ProxyStream 89 | eventHandlers: 90 | - event: CreateSalary(indexed uint256,indexed uint256,indexed address) 91 | handler: handleCreateSalary 92 | file: ./src/mappings/payroll.ts 93 | language: wasm/assemblyscript 94 | -------------------------------------------------------------------------------- /src/helpers/database.ts: -------------------------------------------------------------------------------- 1 | import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; 2 | 3 | import { ERC20 as Erc20Contract } from "../types/SablierV1.1.0/ERC20"; 4 | import { ERC20NameBytes32 as ERC20NameBytes32Contract } from "../types/SablierV1.1.0/ERC20NameBytes32"; 5 | import { ERC20SymbolBytes32 as ERC20SymbolBytes32Contract } from "../types/SablierV1.1.0/ERC20SymbolBytes32"; 6 | import { Stream, StreamToSalary, StreamTransaction, Token } from "../types/schema"; 7 | import { CUTOFF_STREAM_ID } from "./constants"; 8 | 9 | export function createStreamTransaction(name: string, event: ethereum.Event, streamId: string): void { 10 | let txhash: string = event.transaction.hash.toHex(); 11 | let streamTransaction: StreamTransaction = new StreamTransaction(txhash + "-" + event.logIndex.toString()); 12 | streamTransaction.event = name; 13 | streamTransaction.block = event.block.number.toI32(); 14 | streamTransaction.from = event.transaction.from; 15 | streamTransaction.stream = streamId; 16 | streamTransaction.timestamp = event.block.timestamp; 17 | streamTransaction.to = event.transaction.to; 18 | streamTransaction.txhash = txhash; 19 | streamTransaction.save(); 20 | } 21 | 22 | export function createToken(id: string): Token { 23 | let token: Token = new Token(id); 24 | let tokenAddress: Address = Address.fromString(id); 25 | let contract: Erc20Contract = Erc20Contract.bind(tokenAddress); 26 | let contractNameBytes32: ERC20NameBytes32Contract = ERC20NameBytes32Contract.bind(tokenAddress); 27 | let contractSymbolBytes32: ERC20SymbolBytes32Contract = ERC20SymbolBytes32Contract.bind(tokenAddress); 28 | 29 | let decimals: i32 = 0; 30 | let decimalsContractCall = contract.try_decimals(); 31 | if (!decimalsContractCall.reverted) { 32 | decimals = decimalsContractCall.value; 33 | } 34 | token.decimals = decimals; 35 | 36 | let name: string = "Unknown"; 37 | let nameStringCall = contract.try_name(); 38 | if (nameStringCall.reverted) { 39 | let nameBytesCall = contractNameBytes32.try_name(); 40 | if (!nameBytesCall.reverted) { 41 | name = nameBytesCall.value.toString(); 42 | } 43 | } else { 44 | name = nameStringCall.value; 45 | } 46 | token.name = name; 47 | 48 | let symbol: string = "Unknown"; 49 | let symbolStringCall = contract.try_symbol(); 50 | if (symbolStringCall.reverted) { 51 | let symbolBytesCall = contractSymbolBytes32.try_symbol(); 52 | if (!symbolBytesCall.reverted) { 53 | symbol = symbolBytesCall.value.toString(); 54 | } 55 | } else { 56 | symbol = symbolStringCall.value; 57 | } 58 | token.symbol = symbol; 59 | 60 | token.save(); 61 | return token; 62 | } 63 | 64 | export function loadOrCreateToken(id: string): Token { 65 | let token: Token | null = Token.load(id); 66 | if (token == null) { 67 | token = createToken(id); 68 | } 69 | return token as Token; 70 | } 71 | 72 | export function loadStream(id: string): Stream | null { 73 | if (BigInt.fromString(id).ge(CUTOFF_STREAM_ID)) { 74 | let stream: Stream | null = Stream.load(id); 75 | return stream; 76 | } else { 77 | // Check if the stream is connected to a salary. 78 | let streamToSalary: StreamToSalary | null = StreamToSalary.load(id); 79 | if (streamToSalary) { 80 | // If yes, we load the stream entity by passing the salary id. 81 | let stream: Stream | null = Stream.load(streamToSalary.salaryId.toString()); 82 | return stream; 83 | } else { 84 | return null; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@sablier/subgraph", 3 | "description": "Subgraph for the Sablier Legacy protocol", 4 | "version": "1.0.0", 5 | "author": { 6 | "name": "Sablier", 7 | "url": "https://sablier.com" 8 | }, 9 | "bugs": { 10 | "url": "https://github.com/sablier-labs/legacy-subgraph/issues" 11 | }, 12 | "devDependencies": { 13 | "@graphprotocol/graph-cli": "^0.23.0", 14 | "@graphprotocol/graph-ts": "^0.23.0", 15 | "@sablier/eslint-config": "^1.0.1", 16 | "@trivago/prettier-plugin-sort-imports": "^3.2.0", 17 | "@typescript-eslint/eslint-plugin": "^5.2.0", 18 | "@typescript-eslint/parser": "^5.2.0", 19 | "eslint": "^8.1.0", 20 | "eslint-config-prettier": "^8.3.0", 21 | "mustache": "^4.2.0", 22 | "prettier": "^2.4.1", 23 | "typescript": "^4.4.4" 24 | }, 25 | "license": "LGPL-3.0", 26 | "private": true, 27 | "repository": "github.com/sablier-labs/legacy-subgraph", 28 | "scripts": { 29 | "build": "graph build --debug", 30 | "clean": "rm -rf ./build ./src/types ./subgraph.yaml", 31 | "codegen": "graph codegen --debug --output-dir src/types/", 32 | "deploy": "graph deploy $SUBGRAPH --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", 33 | "deploy:arbitrum": "yarn prepare:arbitrum && SUBGRAPH=sablier-labs/sablier-arbitrum yarn deploy", 34 | "deploy:avalanche": "yarn prepare:avalanche && SUBGRAPH=sablier-labs/sablier-avalanche yarn deploy", 35 | "deploy:bsc": "yarn prepare:bsc && SUBGRAPH=sablier-labs/sablier-bsc yarn deploy", 36 | "deploy:goerli": "yarn prepare:goerli && SUBGRAPH=sablier-labs/sablier-goerli yarn deploy", 37 | "deploy:kovan": "yarn prepare:kovan && SUBGRAPH=sablier-labs/sablier-kovan yarn deploy", 38 | "deploy:mainnet": "yarn prepare:mainnet && SUBGRAPH=sablier-labs/sablier yarn deploy", 39 | "deploy:matic": "yarn prepare:matic && SUBGRAPH=sablier-labs/sablier-matic yarn deploy", 40 | "deploy:optimism": "yarn prepare:optimism && SUBGRAPH=sablier-labs/sablier-optimism yarn deploy", 41 | "deploy:rinkeby": "yarn prepare:rinkeby && SUBGRAPH=sablier-labs/sablier-rinkeby yarn deploy", 42 | "deploy:ropsten": "yarn prepare:ropsten && SUBGRAPH=sablier-labs/sablier-ropsten yarn deploy", 43 | "lint": "yarn lint:ts && yarn prettier:check", 44 | "lint:ts": "eslint --config ./.eslintrc.yml --ignore-path ./.eslintignore --ext .js,.ts .", 45 | "prepare:arbitrum": "mustache ./networks/arbitrum.json ./templates/v1.1.0.yml > subgraph.yaml", 46 | "prepare:avalanche": "mustache ./networks/avalanche.json ./templates/v1.1.0.yml > subgraph.yaml", 47 | "prepare:bsc": "mustache ./networks/bsc.json ./templates/v1.1.0.yml > subgraph.yaml", 48 | "prepare:goerli": "mustache ./networks/goerli.json ./templates/v1.1.0.yml > subgraph.yaml", 49 | "prepare:kovan": "mustache ./networks/kovan.json ./templates/v1.1.0.yml > subgraph.yaml", 50 | "prepare:mainnet": "mustache ./networks/mainnet.json ./templates/v1.0.0-and-v1.1.0.yml > subgraph.yaml", 51 | "prepare:matic": "mustache ./networks/matic.json ./templates/v1.1.0.yml > subgraph.yaml", 52 | "prepare:optimism": "mustache ./networks/optimism.json ./templates/v1.1.0.yml > subgraph.yaml", 53 | "prepare:rinkeby": "mustache ./networks/rinkeby.json ./templates/v1.0.0-and-v1.1.0.yml > subgraph.yaml", 54 | "prepare:ropsten": "mustache ./networks/ropsten.json ./templates/v1.1.0.yml > subgraph.yaml", 55 | "prettier": "prettier --config ./.prettierrc.yml --write \"**/*.{js,json,md,ts,yml}\"", 56 | "prettier:check": "prettier --check --config ./.prettierrc.yml \"**/*.{js,json,md,ts,yml}\"" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /abis/ERC20.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "name": "", 9 | "type": "string" 10 | } 11 | ], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": false, 18 | "inputs": [ 19 | { 20 | "name": "_spender", 21 | "type": "address" 22 | }, 23 | { 24 | "name": "_value", 25 | "type": "uint256" 26 | } 27 | ], 28 | "name": "approve", 29 | "outputs": [ 30 | { 31 | "name": "", 32 | "type": "bool" 33 | } 34 | ], 35 | "payable": false, 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | }, 39 | { 40 | "constant": true, 41 | "inputs": [], 42 | "name": "totalSupply", 43 | "outputs": [ 44 | { 45 | "name": "", 46 | "type": "uint256" 47 | } 48 | ], 49 | "payable": false, 50 | "stateMutability": "view", 51 | "type": "function" 52 | }, 53 | { 54 | "constant": false, 55 | "inputs": [ 56 | { 57 | "name": "_from", 58 | "type": "address" 59 | }, 60 | { 61 | "name": "_to", 62 | "type": "address" 63 | }, 64 | { 65 | "name": "_value", 66 | "type": "uint256" 67 | } 68 | ], 69 | "name": "transferFrom", 70 | "outputs": [ 71 | { 72 | "name": "", 73 | "type": "bool" 74 | } 75 | ], 76 | "payable": false, 77 | "stateMutability": "nonpayable", 78 | "type": "function" 79 | }, 80 | { 81 | "constant": true, 82 | "inputs": [], 83 | "name": "decimals", 84 | "outputs": [ 85 | { 86 | "name": "", 87 | "type": "uint8" 88 | } 89 | ], 90 | "payable": false, 91 | "stateMutability": "view", 92 | "type": "function" 93 | }, 94 | { 95 | "constant": true, 96 | "inputs": [ 97 | { 98 | "name": "_owner", 99 | "type": "address" 100 | } 101 | ], 102 | "name": "balanceOf", 103 | "outputs": [ 104 | { 105 | "name": "balance", 106 | "type": "uint256" 107 | } 108 | ], 109 | "payable": false, 110 | "stateMutability": "view", 111 | "type": "function" 112 | }, 113 | { 114 | "constant": true, 115 | "inputs": [], 116 | "name": "symbol", 117 | "outputs": [ 118 | { 119 | "name": "", 120 | "type": "string" 121 | } 122 | ], 123 | "payable": false, 124 | "stateMutability": "view", 125 | "type": "function" 126 | }, 127 | { 128 | "constant": false, 129 | "inputs": [ 130 | { 131 | "name": "_to", 132 | "type": "address" 133 | }, 134 | { 135 | "name": "_value", 136 | "type": "uint256" 137 | } 138 | ], 139 | "name": "transfer", 140 | "outputs": [ 141 | { 142 | "name": "", 143 | "type": "bool" 144 | } 145 | ], 146 | "payable": false, 147 | "stateMutability": "nonpayable", 148 | "type": "function" 149 | }, 150 | { 151 | "constant": true, 152 | "inputs": [ 153 | { 154 | "name": "_owner", 155 | "type": "address" 156 | }, 157 | { 158 | "name": "_spender", 159 | "type": "address" 160 | } 161 | ], 162 | "name": "allowance", 163 | "outputs": [ 164 | { 165 | "name": "", 166 | "type": "uint256" 167 | } 168 | ], 169 | "payable": false, 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "payable": true, 175 | "stateMutability": "payable", 176 | "type": "fallback" 177 | }, 178 | { 179 | "anonymous": false, 180 | "inputs": [ 181 | { 182 | "indexed": true, 183 | "name": "owner", 184 | "type": "address" 185 | }, 186 | { 187 | "indexed": true, 188 | "name": "spender", 189 | "type": "address" 190 | }, 191 | { 192 | "indexed": false, 193 | "name": "value", 194 | "type": "uint256" 195 | } 196 | ], 197 | "name": "Approval", 198 | "type": "event" 199 | }, 200 | { 201 | "anonymous": false, 202 | "inputs": [ 203 | { 204 | "indexed": true, 205 | "name": "from", 206 | "type": "address" 207 | }, 208 | { 209 | "indexed": true, 210 | "name": "to", 211 | "type": "address" 212 | }, 213 | { 214 | "indexed": false, 215 | "name": "value", 216 | "type": "uint256" 217 | } 218 | ], 219 | "name": "Transfer", 220 | "type": "event" 221 | } 222 | ] 223 | -------------------------------------------------------------------------------- /abis/Sablier.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, 3 | { 4 | "anonymous": false, 5 | "inputs": [ 6 | { "indexed": true, "internalType": "uint256", "name": "streamId", "type": "uint256" }, 7 | { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, 8 | { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, 9 | { "indexed": false, "internalType": "uint256", "name": "senderBalance", "type": "uint256" }, 10 | { "indexed": false, "internalType": "uint256", "name": "recipientBalance", "type": "uint256" } 11 | ], 12 | "name": "CancelStream", 13 | "type": "event" 14 | }, 15 | { 16 | "anonymous": false, 17 | "inputs": [ 18 | { "indexed": true, "internalType": "uint256", "name": "streamId", "type": "uint256" }, 19 | { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, 20 | { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, 21 | { "indexed": false, "internalType": "uint256", "name": "deposit", "type": "uint256" }, 22 | { "indexed": false, "internalType": "address", "name": "tokenAddress", "type": "address" }, 23 | { "indexed": false, "internalType": "uint256", "name": "startTime", "type": "uint256" }, 24 | { "indexed": false, "internalType": "uint256", "name": "stopTime", "type": "uint256" } 25 | ], 26 | "name": "CreateStream", 27 | "type": "event" 28 | }, 29 | { 30 | "anonymous": false, 31 | "inputs": [ 32 | { "indexed": true, "internalType": "uint256", "name": "streamId", "type": "uint256" }, 33 | { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, 34 | { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } 35 | ], 36 | "name": "WithdrawFromStream", 37 | "type": "event" 38 | }, 39 | { 40 | "constant": true, 41 | "inputs": [ 42 | { "internalType": "uint256", "name": "streamId", "type": "uint256" }, 43 | { "internalType": "address", "name": "who", "type": "address" } 44 | ], 45 | "name": "balanceOf", 46 | "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], 47 | "payable": false, 48 | "stateMutability": "view", 49 | "type": "function" 50 | }, 51 | { 52 | "constant": false, 53 | "inputs": [{ "internalType": "uint256", "name": "streamId", "type": "uint256" }], 54 | "name": "cancelStream", 55 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 56 | "payable": false, 57 | "stateMutability": "nonpayable", 58 | "type": "function" 59 | }, 60 | { 61 | "constant": false, 62 | "inputs": [ 63 | { "internalType": "address", "name": "recipient", "type": "address" }, 64 | { "internalType": "uint256", "name": "deposit", "type": "uint256" }, 65 | { "internalType": "address", "name": "tokenAddress", "type": "address" }, 66 | { "internalType": "uint256", "name": "startTime", "type": "uint256" }, 67 | { "internalType": "uint256", "name": "stopTime", "type": "uint256" } 68 | ], 69 | "name": "createStream", 70 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 71 | "payable": false, 72 | "stateMutability": "nonpayable", 73 | "type": "function" 74 | }, 75 | { 76 | "constant": true, 77 | "inputs": [{ "internalType": "uint256", "name": "streamId", "type": "uint256" }], 78 | "name": "deltaOf", 79 | "outputs": [{ "internalType": "uint256", "name": "delta", "type": "uint256" }], 80 | "payable": false, 81 | "stateMutability": "view", 82 | "type": "function" 83 | }, 84 | { 85 | "constant": true, 86 | "inputs": [{ "internalType": "uint256", "name": "streamId", "type": "uint256" }], 87 | "name": "getStream", 88 | "outputs": [ 89 | { "internalType": "address", "name": "sender", "type": "address" }, 90 | { "internalType": "address", "name": "recipient", "type": "address" }, 91 | { "internalType": "uint256", "name": "deposit", "type": "uint256" }, 92 | { "internalType": "address", "name": "tokenAddress", "type": "address" }, 93 | { "internalType": "uint256", "name": "startTime", "type": "uint256" }, 94 | { "internalType": "uint256", "name": "stopTime", "type": "uint256" }, 95 | { "internalType": "uint256", "name": "remainingBalance", "type": "uint256" }, 96 | { "internalType": "uint256", "name": "ratePerSecond", "type": "uint256" } 97 | ], 98 | "payable": false, 99 | "stateMutability": "view", 100 | "type": "function" 101 | }, 102 | { 103 | "constant": true, 104 | "inputs": [], 105 | "name": "nextStreamId", 106 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], 107 | "payable": false, 108 | "stateMutability": "view", 109 | "type": "function" 110 | }, 111 | { 112 | "constant": false, 113 | "inputs": [ 114 | { "internalType": "uint256", "name": "streamId", "type": "uint256" }, 115 | { "internalType": "uint256", "name": "amount", "type": "uint256" } 116 | ], 117 | "name": "withdrawFromStream", 118 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], 119 | "payable": false, 120 | "stateMutability": "nonpayable", 121 | "type": "function" 122 | } 123 | ] 124 | -------------------------------------------------------------------------------- /abis/Payroll.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [ 5 | { 6 | "internalType": "address", 7 | "name": "", 8 | "type": "address" 9 | }, 10 | { 11 | "internalType": "uint256", 12 | "name": "", 13 | "type": "uint256" 14 | } 15 | ], 16 | "name": "relayers", 17 | "outputs": [ 18 | { 19 | "internalType": "bool", 20 | "name": "", 21 | "type": "bool" 22 | } 23 | ], 24 | "payable": false, 25 | "stateMutability": "view", 26 | "type": "function" 27 | }, 28 | { 29 | "constant": true, 30 | "inputs": [], 31 | "name": "sablier", 32 | "outputs": [ 33 | { 34 | "internalType": "contract Sablier", 35 | "name": "", 36 | "type": "address" 37 | } 38 | ], 39 | "payable": false, 40 | "stateMutability": "view", 41 | "type": "function" 42 | }, 43 | { 44 | "constant": true, 45 | "inputs": [], 46 | "name": "getHubAddr", 47 | "outputs": [ 48 | { 49 | "internalType": "address", 50 | "name": "", 51 | "type": "address" 52 | } 53 | ], 54 | "payable": false, 55 | "stateMutability": "view", 56 | "type": "function" 57 | }, 58 | { 59 | "constant": false, 60 | "inputs": [ 61 | { 62 | "internalType": "bytes", 63 | "name": "context", 64 | "type": "bytes" 65 | } 66 | ], 67 | "name": "preRelayedCall", 68 | "outputs": [ 69 | { 70 | "internalType": "bytes32", 71 | "name": "", 72 | "type": "bytes32" 73 | } 74 | ], 75 | "payable": false, 76 | "stateMutability": "nonpayable", 77 | "type": "function" 78 | }, 79 | { 80 | "constant": true, 81 | "inputs": [], 82 | "name": "owner", 83 | "outputs": [ 84 | { 85 | "internalType": "address", 86 | "name": "", 87 | "type": "address" 88 | } 89 | ], 90 | "payable": false, 91 | "stateMutability": "view", 92 | "type": "function" 93 | }, 94 | { 95 | "constant": true, 96 | "inputs": [], 97 | "name": "isOwner", 98 | "outputs": [ 99 | { 100 | "internalType": "bool", 101 | "name": "", 102 | "type": "bool" 103 | } 104 | ], 105 | "payable": false, 106 | "stateMutability": "view", 107 | "type": "function" 108 | }, 109 | { 110 | "constant": true, 111 | "inputs": [], 112 | "name": "relayHubVersion", 113 | "outputs": [ 114 | { 115 | "internalType": "string", 116 | "name": "", 117 | "type": "string" 118 | } 119 | ], 120 | "payable": false, 121 | "stateMutability": "view", 122 | "type": "function" 123 | }, 124 | { 125 | "constant": true, 126 | "inputs": [], 127 | "name": "nextSalaryId", 128 | "outputs": [ 129 | { 130 | "internalType": "uint256", 131 | "name": "", 132 | "type": "uint256" 133 | } 134 | ], 135 | "payable": false, 136 | "stateMutability": "view", 137 | "type": "function" 138 | }, 139 | { 140 | "constant": false, 141 | "inputs": [ 142 | { 143 | "internalType": "bytes", 144 | "name": "context", 145 | "type": "bytes" 146 | }, 147 | { 148 | "internalType": "bool", 149 | "name": "success", 150 | "type": "bool" 151 | }, 152 | { 153 | "internalType": "uint256", 154 | "name": "actualCharge", 155 | "type": "uint256" 156 | }, 157 | { 158 | "internalType": "bytes32", 159 | "name": "preRetVal", 160 | "type": "bytes32" 161 | } 162 | ], 163 | "name": "postRelayedCall", 164 | "outputs": [], 165 | "payable": false, 166 | "stateMutability": "nonpayable", 167 | "type": "function" 168 | }, 169 | { 170 | "constant": false, 171 | "inputs": [ 172 | { 173 | "internalType": "address", 174 | "name": "newOwner", 175 | "type": "address" 176 | } 177 | ], 178 | "name": "transferOwnership", 179 | "outputs": [], 180 | "payable": false, 181 | "stateMutability": "nonpayable", 182 | "type": "function" 183 | }, 184 | { 185 | "anonymous": false, 186 | "inputs": [ 187 | { 188 | "indexed": true, 189 | "internalType": "uint256", 190 | "name": "salaryId", 191 | "type": "uint256" 192 | }, 193 | { 194 | "indexed": true, 195 | "internalType": "uint256", 196 | "name": "streamId", 197 | "type": "uint256" 198 | }, 199 | { 200 | "indexed": true, 201 | "internalType": "address", 202 | "name": "company", 203 | "type": "address" 204 | } 205 | ], 206 | "name": "CreateSalary", 207 | "type": "event" 208 | }, 209 | { 210 | "anonymous": false, 211 | "inputs": [ 212 | { 213 | "indexed": true, 214 | "internalType": "uint256", 215 | "name": "salaryId", 216 | "type": "uint256" 217 | }, 218 | { 219 | "indexed": true, 220 | "internalType": "uint256", 221 | "name": "streamId", 222 | "type": "uint256" 223 | }, 224 | { 225 | "indexed": true, 226 | "internalType": "address", 227 | "name": "company", 228 | "type": "address" 229 | } 230 | ], 231 | "name": "WithdrawFromSalary", 232 | "type": "event" 233 | }, 234 | { 235 | "anonymous": false, 236 | "inputs": [ 237 | { 238 | "indexed": true, 239 | "internalType": "uint256", 240 | "name": "salaryId", 241 | "type": "uint256" 242 | }, 243 | { 244 | "indexed": true, 245 | "internalType": "uint256", 246 | "name": "streamId", 247 | "type": "uint256" 248 | }, 249 | { 250 | "indexed": true, 251 | "internalType": "address", 252 | "name": "company", 253 | "type": "address" 254 | } 255 | ], 256 | "name": "CancelSalary", 257 | "type": "event" 258 | }, 259 | { 260 | "anonymous": false, 261 | "inputs": [ 262 | { 263 | "indexed": true, 264 | "internalType": "address", 265 | "name": "oldRelayHub", 266 | "type": "address" 267 | }, 268 | { 269 | "indexed": true, 270 | "internalType": "address", 271 | "name": "newRelayHub", 272 | "type": "address" 273 | } 274 | ], 275 | "name": "RelayHubChanged", 276 | "type": "event" 277 | }, 278 | { 279 | "anonymous": false, 280 | "inputs": [ 281 | { 282 | "indexed": true, 283 | "internalType": "address", 284 | "name": "previousOwner", 285 | "type": "address" 286 | }, 287 | { 288 | "indexed": true, 289 | "internalType": "address", 290 | "name": "newOwner", 291 | "type": "address" 292 | } 293 | ], 294 | "name": "OwnershipTransferred", 295 | "type": "event" 296 | }, 297 | { 298 | "constant": false, 299 | "inputs": [ 300 | { 301 | "internalType": "address", 302 | "name": "trustedSigner", 303 | "type": "address" 304 | } 305 | ], 306 | "name": "initialize", 307 | "outputs": [], 308 | "payable": false, 309 | "stateMutability": "nonpayable", 310 | "type": "function" 311 | }, 312 | { 313 | "constant": false, 314 | "inputs": [ 315 | { 316 | "internalType": "address", 317 | "name": "ownerAddress", 318 | "type": "address" 319 | }, 320 | { 321 | "internalType": "address", 322 | "name": "signerAddress", 323 | "type": "address" 324 | }, 325 | { 326 | "internalType": "address", 327 | "name": "sablierAddress", 328 | "type": "address" 329 | } 330 | ], 331 | "name": "initialize", 332 | "outputs": [], 333 | "payable": false, 334 | "stateMutability": "nonpayable", 335 | "type": "function" 336 | }, 337 | { 338 | "constant": false, 339 | "inputs": [], 340 | "name": "initialize", 341 | "outputs": [], 342 | "payable": false, 343 | "stateMutability": "nonpayable", 344 | "type": "function" 345 | }, 346 | { 347 | "constant": false, 348 | "inputs": [ 349 | { 350 | "internalType": "address", 351 | "name": "relayer", 352 | "type": "address" 353 | }, 354 | { 355 | "internalType": "uint256", 356 | "name": "salaryId", 357 | "type": "uint256" 358 | } 359 | ], 360 | "name": "whitelistRelayer", 361 | "outputs": [], 362 | "payable": false, 363 | "stateMutability": "nonpayable", 364 | "type": "function" 365 | }, 366 | { 367 | "constant": false, 368 | "inputs": [ 369 | { 370 | "internalType": "address", 371 | "name": "relayer", 372 | "type": "address" 373 | }, 374 | { 375 | "internalType": "uint256", 376 | "name": "salaryId", 377 | "type": "uint256" 378 | } 379 | ], 380 | "name": "discardRelayer", 381 | "outputs": [], 382 | "payable": false, 383 | "stateMutability": "nonpayable", 384 | "type": "function" 385 | }, 386 | { 387 | "constant": true, 388 | "inputs": [ 389 | { 390 | "internalType": "address", 391 | "name": "relay", 392 | "type": "address" 393 | }, 394 | { 395 | "internalType": "address", 396 | "name": "from", 397 | "type": "address" 398 | }, 399 | { 400 | "internalType": "bytes", 401 | "name": "encodedFunction", 402 | "type": "bytes" 403 | }, 404 | { 405 | "internalType": "uint256", 406 | "name": "transactionFee", 407 | "type": "uint256" 408 | }, 409 | { 410 | "internalType": "uint256", 411 | "name": "gasPrice", 412 | "type": "uint256" 413 | }, 414 | { 415 | "internalType": "uint256", 416 | "name": "gasLimit", 417 | "type": "uint256" 418 | }, 419 | { 420 | "internalType": "uint256", 421 | "name": "nonce", 422 | "type": "uint256" 423 | }, 424 | { 425 | "internalType": "bytes", 426 | "name": "approvalData", 427 | "type": "bytes" 428 | }, 429 | { 430 | "internalType": "uint256", 431 | "name": "", 432 | "type": "uint256" 433 | } 434 | ], 435 | "name": "acceptRelayedCall", 436 | "outputs": [ 437 | { 438 | "internalType": "uint256", 439 | "name": "", 440 | "type": "uint256" 441 | }, 442 | { 443 | "internalType": "bytes", 444 | "name": "", 445 | "type": "bytes" 446 | } 447 | ], 448 | "payable": false, 449 | "stateMutability": "view", 450 | "type": "function" 451 | }, 452 | { 453 | "constant": true, 454 | "inputs": [ 455 | { 456 | "internalType": "uint256", 457 | "name": "salaryId", 458 | "type": "uint256" 459 | } 460 | ], 461 | "name": "getSalary", 462 | "outputs": [ 463 | { 464 | "internalType": "address", 465 | "name": "company", 466 | "type": "address" 467 | }, 468 | { 469 | "internalType": "address", 470 | "name": "employee", 471 | "type": "address" 472 | }, 473 | { 474 | "internalType": "uint256", 475 | "name": "salary", 476 | "type": "uint256" 477 | }, 478 | { 479 | "internalType": "address", 480 | "name": "tokenAddress", 481 | "type": "address" 482 | }, 483 | { 484 | "internalType": "uint256", 485 | "name": "startTime", 486 | "type": "uint256" 487 | }, 488 | { 489 | "internalType": "uint256", 490 | "name": "stopTime", 491 | "type": "uint256" 492 | }, 493 | { 494 | "internalType": "uint256", 495 | "name": "remainingBalance", 496 | "type": "uint256" 497 | }, 498 | { 499 | "internalType": "uint256", 500 | "name": "rate", 501 | "type": "uint256" 502 | } 503 | ], 504 | "payable": false, 505 | "stateMutability": "view", 506 | "type": "function" 507 | }, 508 | { 509 | "constant": false, 510 | "inputs": [ 511 | { 512 | "internalType": "address", 513 | "name": "employee", 514 | "type": "address" 515 | }, 516 | { 517 | "internalType": "uint256", 518 | "name": "salary", 519 | "type": "uint256" 520 | }, 521 | { 522 | "internalType": "address", 523 | "name": "tokenAddress", 524 | "type": "address" 525 | }, 526 | { 527 | "internalType": "uint256", 528 | "name": "startTime", 529 | "type": "uint256" 530 | }, 531 | { 532 | "internalType": "uint256", 533 | "name": "stopTime", 534 | "type": "uint256" 535 | } 536 | ], 537 | "name": "createSalary", 538 | "outputs": [ 539 | { 540 | "internalType": "uint256", 541 | "name": "salaryId", 542 | "type": "uint256" 543 | } 544 | ], 545 | "payable": false, 546 | "stateMutability": "nonpayable", 547 | "type": "function" 548 | }, 549 | { 550 | "constant": false, 551 | "inputs": [ 552 | { 553 | "internalType": "address", 554 | "name": "employee", 555 | "type": "address" 556 | }, 557 | { 558 | "internalType": "uint256", 559 | "name": "salary", 560 | "type": "uint256" 561 | }, 562 | { 563 | "internalType": "address", 564 | "name": "tokenAddress", 565 | "type": "address" 566 | }, 567 | { 568 | "internalType": "uint256", 569 | "name": "startTime", 570 | "type": "uint256" 571 | }, 572 | { 573 | "internalType": "uint256", 574 | "name": "stopTime", 575 | "type": "uint256" 576 | }, 577 | { 578 | "internalType": "uint256", 579 | "name": "senderSharePercentage", 580 | "type": "uint256" 581 | }, 582 | { 583 | "internalType": "uint256", 584 | "name": "recipientSharePercentage", 585 | "type": "uint256" 586 | } 587 | ], 588 | "name": "createCompoundingSalary", 589 | "outputs": [ 590 | { 591 | "internalType": "uint256", 592 | "name": "salaryId", 593 | "type": "uint256" 594 | } 595 | ], 596 | "payable": false, 597 | "stateMutability": "nonpayable", 598 | "type": "function" 599 | }, 600 | { 601 | "constant": false, 602 | "inputs": [ 603 | { 604 | "internalType": "uint256", 605 | "name": "salaryId", 606 | "type": "uint256" 607 | }, 608 | { 609 | "internalType": "uint256", 610 | "name": "amount", 611 | "type": "uint256" 612 | } 613 | ], 614 | "name": "withdrawFromSalary", 615 | "outputs": [ 616 | { 617 | "internalType": "bool", 618 | "name": "success", 619 | "type": "bool" 620 | } 621 | ], 622 | "payable": false, 623 | "stateMutability": "nonpayable", 624 | "type": "function" 625 | }, 626 | { 627 | "constant": false, 628 | "inputs": [ 629 | { 630 | "internalType": "uint256", 631 | "name": "salaryId", 632 | "type": "uint256" 633 | } 634 | ], 635 | "name": "cancelSalary", 636 | "outputs": [ 637 | { 638 | "internalType": "bool", 639 | "name": "success", 640 | "type": "bool" 641 | } 642 | ], 643 | "payable": false, 644 | "stateMutability": "nonpayable", 645 | "type": "function" 646 | } 647 | ] 648 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2019-present Sablier 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and`show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------