Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow collateral and liability points #18

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 1/points.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"name": "Pills",
"logo": "pills.svg",
"url": "https://docs.usual.money/pre-launch-rules/pills-campaign-rules",
"vaults": ["0xe3eb096CD9A87c271567b0134f6dE061c112A9E7"],
"collateralVaults": ["0xe3eb096CD9A87c271567b0134f6dE061c112A9E7"],
"entity": ["re7-labs", "mev-capital", "k3"]
},
{
"name": "Sats",
"logo": "ethena.png",
"vaults": [
"collateralVaults": [
"0xAc73efA7696DC1c1617BbC20aeC64422c8b70EDa",
"0x8dDE384022D4dE1D6C67891a8865f551c444dc4C"
],
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ Each entry in this object corresponds to a lending product, which is primarily a

### `points.json`

Each entry in this array corresponds to points available on deposits in a vault. Each item has the following
Each entry in this array corresponds to points available on deposits in a vault. Either `collateralVaults` or `liabilityVaults` or both are required. Each item has the following

* `token`: The token address (in a checksumed hex format) that the points are denominated in.
* `name`: The name of the points, for example "Euler Points". (Required)
* `description`: A long-form description of the points, displayed within points tooltips.
* `url`: A URL where users can learn more about the points.
* `logo`: The filename of a logo stored in the `logo/` directory. (Required)
* `vaults`: An array of the vault addresses (in checksumed hex format) that offer these points. Each vault does not need to exist in the `vaults.json` file. (Required)
* `collateralVaults`: An array of the vault addresses (in checksumed hex format) that offer these points. Each vault does not need to exist in the `vaults.json` file.
* `liabilityVaults`: An array of the vault addresses (in checksumed hex format) that offer these points. Each vault does not need to exist in the `vaults.json` file.
* `entity`: An entity ID that refers to the organisation responsible for governing and/or creating this vault, or a list of entity IDs if the vault is joint-managed.

## Logos
Expand Down
22 changes: 19 additions & 3 deletions verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,25 @@ function validateChain(chainId) {
throw Error(`points: missing name: ${point.name}`);
if (point.logo && !logos[point.logo])
throw Error(`points: logo not found: ${product.logo}`);
for (const addr of point.vaults) {
if (addr !== ethers.getAddress(addr))
throw Error(`points: malformed vault address: ${addr}`);

if (!point.collateralVaults?.length && !point.liabilityVaults?.length) {
throw Error(
`points: missing collateral or liability vaults for ${point.name}`,
);
}

if (point.collateralVaults) {
for (const addr of point.collateralVaults) {
if (addr !== ethers.getAddress(addr))
throw Error(`points: malformed vault address: ${addr}`);
}
}

if (point.liabilityVaults) {
for (const addr of point.liabilityVaults) {
if (addr !== ethers.getAddress(addr))
throw Error(`points: malformed vault address: ${addr}`);
}
}
for (const entity of getArray(point.entity)) {
if (!entities[entity]) throw Error(`points: no such entity ${entity}`);
Expand Down
Loading