@sablier/bob 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE-BUSL.md +82 -0
  3. package/LICENSE-GPL.md +470 -0
  4. package/LICENSE.md +9 -0
  5. package/README.md +81 -0
  6. package/artifacts/BobVaultShare.json +936 -0
  7. package/artifacts/SablierBob.json +1683 -0
  8. package/artifacts/SablierEscrow.json +1316 -0
  9. package/artifacts/SablierLidoAdapter.json +1649 -0
  10. package/artifacts/erc20/IERC20.json +226 -0
  11. package/artifacts/interfaces/IBobVaultShare.json +393 -0
  12. package/artifacts/interfaces/ISablierBob.json +1171 -0
  13. package/artifacts/interfaces/ISablierEscrow.json +999 -0
  14. package/artifacts/interfaces/ISablierLidoAdapter.json +1141 -0
  15. package/artifacts/interfaces/external/ICurveStETHPool.json +128 -0
  16. package/artifacts/interfaces/external/ILidoWithdrawalQueue.json +209 -0
  17. package/artifacts/interfaces/external/IStETH.json +262 -0
  18. package/artifacts/interfaces/external/IWETH9.json +259 -0
  19. package/artifacts/interfaces/external/IWstETH.json +311 -0
  20. package/artifacts/libraries/Errors.json +868 -0
  21. package/package.json +68 -0
  22. package/src/BobVaultShare.sol +119 -0
  23. package/src/SablierBob.sol +543 -0
  24. package/src/SablierEscrow.sol +288 -0
  25. package/src/SablierLidoAdapter.sol +549 -0
  26. package/src/abstracts/SablierBobState.sol +156 -0
  27. package/src/abstracts/SablierEscrowState.sol +159 -0
  28. package/src/interfaces/IBobVaultShare.sol +51 -0
  29. package/src/interfaces/ISablierBob.sol +261 -0
  30. package/src/interfaces/ISablierBobAdapter.sol +157 -0
  31. package/src/interfaces/ISablierBobState.sol +74 -0
  32. package/src/interfaces/ISablierEscrow.sol +148 -0
  33. package/src/interfaces/ISablierEscrowState.sol +77 -0
  34. package/src/interfaces/ISablierLidoAdapter.sol +110 -0
  35. package/src/interfaces/external/ICurveStETHPool.sol +31 -0
  36. package/src/interfaces/external/ILidoWithdrawalQueue.sol +67 -0
  37. package/src/interfaces/external/IStETH.sol +18 -0
  38. package/src/interfaces/external/IWETH9.sol +19 -0
  39. package/src/interfaces/external/IWstETH.sol +32 -0
  40. package/src/libraries/Errors.sol +189 -0
  41. package/src/types/Bob.sol +49 -0
  42. package/src/types/Escrow.sol +49 -0
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@sablier/bob",
3
+ "description": "EVM smart contracts of the Sablier Bob and Sablier Escrow",
4
+ "license": "SEE LICENSE IN LICENSE",
5
+ "version": "1.0.1",
6
+ "author": {
7
+ "name": "Sablier Labs Ltd",
8
+ "url": "https://sablier.com"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/sablier-labs/evm-monorepo/issues"
12
+ },
13
+ "dependencies": {
14
+ "@chainlink/contracts": "1.3.0",
15
+ "@openzeppelin/contracts": "5.3.0",
16
+ "@prb/math": "4.1.0",
17
+ "@sablier/evm-utils": "2.0.1"
18
+ },
19
+ "overrides": {
20
+ "@openzeppelin/contracts-upgradeable": "5.3.0"
21
+ },
22
+ "devDependencies": {
23
+ "@sablier/devkit": "1",
24
+ "forge-std": "github:foundry-rs/forge-std#v1.10.0",
25
+ "lint-staged": "16.2.6",
26
+ "prettier": "3.6.2",
27
+ "solhint": "6.0.1"
28
+ },
29
+ "files": [
30
+ "artifacts",
31
+ "src",
32
+ "tests/utils",
33
+ "CHANGELOG.md",
34
+ "LICENSE.md",
35
+ "LICENSE-BUSL.md",
36
+ "LICENSE-GPL.md"
37
+ ],
38
+ "homepage": "https://github.com/sablier-labs/evm-monorepo#readme",
39
+ "keywords": [
40
+ "blockchain",
41
+ "defi",
42
+ "ethereum",
43
+ "evm",
44
+ "foundry",
45
+ "price-gated",
46
+ "sablier",
47
+ "smart-contracts",
48
+ "solidity",
49
+ "vault",
50
+ "web3",
51
+ "yield"
52
+ ],
53
+ "peerDependencies": {
54
+ "@prb/math": "4.1.0"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/sablier-labs/evm-monorepo.git",
62
+ "directory": "bob"
63
+ },
64
+ "scripts": {
65
+ "prepack": "../scripts/bash/publish-prepack.sh",
66
+ "postpack": "../scripts/bash/publish-postpack.sh"
67
+ }
68
+ }
@@ -0,0 +1,119 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ pragma solidity >=0.8.22;
3
+
4
+ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
6
+
7
+ import { IBobVaultShare } from "./interfaces/IBobVaultShare.sol";
8
+ import { ISablierBob } from "./interfaces/ISablierBob.sol";
9
+ import { Errors } from "./libraries/Errors.sol";
10
+
11
+ /// @title BobVaultShare
12
+ /// @notice ERC-20 token representing shares in a Bob vault.
13
+ /// @dev Each vault has its own BobVaultShare deployed. Only the SablierBob contract can mint and burn tokens.
14
+ /// When shares are transferred, wstETH attribution is updated proportionally via the adapter.
15
+ contract BobVaultShare is ERC20, IBobVaultShare {
16
+ /*//////////////////////////////////////////////////////////////////////////
17
+ CONSTANTS
18
+ //////////////////////////////////////////////////////////////////////////*/
19
+
20
+ /// @inheritdoc IBobVaultShare
21
+ address public immutable override SABLIER_BOB;
22
+
23
+ /// @inheritdoc IBobVaultShare
24
+ uint256 public immutable override VAULT_ID;
25
+
26
+ /*//////////////////////////////////////////////////////////////////////////
27
+ INTERNAL STORAGE
28
+ //////////////////////////////////////////////////////////////////////////*/
29
+
30
+ /// @dev The number of decimals.
31
+ uint8 internal immutable _DECIMALS;
32
+
33
+ /*//////////////////////////////////////////////////////////////////////////
34
+ MODIFIERS
35
+ //////////////////////////////////////////////////////////////////////////*/
36
+
37
+ /// @dev Reverts if caller is not the Bob contract.
38
+ modifier onlySablierBob() {
39
+ if (msg.sender != SABLIER_BOB) {
40
+ revert Errors.BobVaultShare_OnlySablierBob(msg.sender, SABLIER_BOB);
41
+ }
42
+ _;
43
+ }
44
+
45
+ /// @dev Reverts if the vault ID is not equal to {VAULT_ID}.
46
+ modifier onlyVault(uint256 vaultId) {
47
+ if (vaultId != VAULT_ID) {
48
+ revert Errors.BobVaultShare_VaultIdMismatch(vaultId, VAULT_ID);
49
+ }
50
+ _;
51
+ }
52
+
53
+ /*//////////////////////////////////////////////////////////////////////////
54
+ CONSTRUCTOR
55
+ //////////////////////////////////////////////////////////////////////////*/
56
+
57
+ /// @notice Deploys the vault share token.
58
+ /// @param name_ The name of the token (e.g., "Sablier Bob WETH Vault #1").
59
+ /// @param symbol_ The symbol of the token (e.g., "WETH-500000000000-1792790393-1" with $5000 target price) with the
60
+ /// first number being the target price denominated in Chainlink's 8-decimal format, where 1e8 is $1.
61
+ /// @param decimals_ The number of decimals.
62
+ /// @param sablierBob The address of the SablierBob contract.
63
+ /// @param vaultId The ID of the vault this share token represents.
64
+ constructor(
65
+ string memory name_,
66
+ string memory symbol_,
67
+ uint8 decimals_,
68
+ address sablierBob,
69
+ uint256 vaultId
70
+ )
71
+ ERC20(name_, symbol_)
72
+ {
73
+ _DECIMALS = decimals_;
74
+ SABLIER_BOB = sablierBob;
75
+ VAULT_ID = vaultId;
76
+ }
77
+
78
+ /*//////////////////////////////////////////////////////////////////////////
79
+ USER-FACING READ-ONLY FUNCTIONS
80
+ //////////////////////////////////////////////////////////////////////////*/
81
+
82
+ /// @notice Returns the number of decimals used by the token.
83
+ function decimals() public view override(ERC20, IERC20Metadata) returns (uint8) {
84
+ return _DECIMALS;
85
+ }
86
+
87
+ /*//////////////////////////////////////////////////////////////////////////
88
+ USER-FACING STATE-CHANGING FUNCTIONS
89
+ //////////////////////////////////////////////////////////////////////////*/
90
+
91
+ /// @inheritdoc IBobVaultShare
92
+ function mint(uint256 vaultId, address to, uint256 amount) external override onlySablierBob onlyVault(vaultId) {
93
+ _mint(to, amount);
94
+ }
95
+
96
+ /// @inheritdoc IBobVaultShare
97
+ function burn(uint256 vaultId, address from, uint256 amount) external override onlySablierBob onlyVault(vaultId) {
98
+ _burn(from, amount);
99
+ }
100
+
101
+ /*//////////////////////////////////////////////////////////////////////////
102
+ INTERNAL OVERRIDE FUNCTIONS
103
+ //////////////////////////////////////////////////////////////////////////*/
104
+
105
+ /// @dev Override to notify SablierBob when shares are transferred (not minted/burned).
106
+ /// This allows the adapter to update wstETH attribution proportionally.
107
+ function _update(address from, address to, uint256 amount) internal override {
108
+ // Get sender's balance before the transfer.
109
+ uint256 fromBalanceBefore = balanceOf(from);
110
+
111
+ // Perform the update.
112
+ super._update(from, to, amount);
113
+
114
+ // Notify SablierBob if the transfer is not a mint or burn.
115
+ if (from != address(0) && to != address(0)) {
116
+ ISablierBob(SABLIER_BOB).onShareTransfer(VAULT_ID, from, to, amount, fromBalanceBefore);
117
+ }
118
+ }
119
+ }