@bananapus/nana-sdk-core 2.11.0 → 2.12.0
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.
- package/dist/cjs/v6/index.d.ts +1 -0
- package/dist/cjs/v6/index.d.ts.map +1 -1
- package/dist/cjs/v6/index.js +1 -0
- package/dist/cjs/v6/index.js.map +1 -1
- package/dist/cjs/v6/sticky.d.ts +70 -0
- package/dist/cjs/v6/sticky.d.ts.map +1 -0
- package/dist/cjs/v6/sticky.js +132 -0
- package/dist/cjs/v6/sticky.js.map +1 -0
- package/dist/esm/v6/index.d.ts +1 -0
- package/dist/esm/v6/index.d.ts.map +1 -1
- package/dist/esm/v6/index.js +1 -0
- package/dist/esm/v6/index.js.map +1 -1
- package/dist/esm/v6/sticky.d.ts +70 -0
- package/dist/esm/v6/sticky.d.ts.map +1 -0
- package/dist/esm/v6/sticky.js +123 -0
- package/dist/esm/v6/sticky.js.map +1 -0
- package/package.json +1 -1
package/dist/cjs/v6/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/cjs/v6/index.js
CHANGED
|
@@ -36,4 +36,5 @@ __exportStar(require("./uniswapV4Fees.js"), exports);
|
|
|
36
36
|
__exportStar(require("./permissions.js"), exports);
|
|
37
37
|
__exportStar(require("./suckers.js"), exports);
|
|
38
38
|
__exportStar(require("./loans.js"), exports);
|
|
39
|
+
__exportStar(require("./sticky.js"), exports);
|
|
39
40
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/v6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,8CAA4B;AAC5B,+CAA6B;AAC7B,iDAA+B;AAC/B,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,+CAA6B;AAC7B,qDAAmC;AACnC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC;AACjC,+CAA6B;AAC7B,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,8CAA4B;AAC5B,+CAA6B;AAC7B,iDAA+B;AAC/B,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,+CAA6B;AAC7B,qDAAmC;AACnC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC;AACjC,+CAA6B;AAC7B,6CAA2B;AAC3B,8CAA4B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { JBChainId } from "../types.js";
|
|
3
|
+
import { JBSplit } from "./splits.js";
|
|
4
|
+
/**
|
|
5
|
+
* A split routes funds to Sticky holders when its `hook` is the chain's
|
|
6
|
+
* `StickyDistributor`. The distributor reads the rest of the split this way:
|
|
7
|
+
*
|
|
8
|
+
* - `beneficiary` is the Sticky token whose holders are rewarded.
|
|
9
|
+
* - `projectId` is the reward group: {@link STICKY_DEFAULT_GROUP_ID} splits the
|
|
10
|
+
* pot by delegated voting power at the round's snapshot, and a tenure group
|
|
11
|
+
* ({@link stickyGroupId}) splits it by stake held for a range of weeks.
|
|
12
|
+
*
|
|
13
|
+
* The distributor never reverts on a bad group or beneficiary, since a
|
|
14
|
+
* split-hook revert returns the funds to the project. A `projectId` that
|
|
15
|
+
* {@link validateStickyGroupId} rejects funds the default group instead, and so
|
|
16
|
+
* does a tenure group whose beneficiary the Sticky hook does not track. The
|
|
17
|
+
* distributor has no public view for that second case: a token is tracked when
|
|
18
|
+
* `stickyHookAbi` `tokenOf(projectId)` returns the token, where `projectId` is
|
|
19
|
+
* the token's own `PROJECT_ID()`.
|
|
20
|
+
*/
|
|
21
|
+
/** The default reward group: every holder, weighted by delegated voting power. */
|
|
22
|
+
export declare const STICKY_DEFAULT_GROUP_ID = 0n;
|
|
23
|
+
/** A tenure group ID is `minWeeks * STICKY_CRITERIA_BASE + maxWeeks`. */
|
|
24
|
+
export declare const STICKY_CRITERIA_BASE = 1000n;
|
|
25
|
+
/** The highest `minWeeks` or `maxWeeks` a tenure group can use. */
|
|
26
|
+
export declare const STICKY_MAX_CRITERIA_WEEKS = 520;
|
|
27
|
+
/**
|
|
28
|
+
* A Sticky reward group. A tenure group rewards stake added between `maxWeeks`
|
|
29
|
+
* and `minWeeks` before the round started; `maxWeeks` 0 means no upper bound.
|
|
30
|
+
*/
|
|
31
|
+
export type StickyGroup = {
|
|
32
|
+
kind: "default";
|
|
33
|
+
} | {
|
|
34
|
+
kind: "tenure";
|
|
35
|
+
minWeeks: number;
|
|
36
|
+
maxWeeks: number;
|
|
37
|
+
};
|
|
38
|
+
/** The `StickyDistributor` a chain's Sticky splits must use as their hook. */
|
|
39
|
+
export declare function stickyDistributorAddress(chainId: JBChainId): Address;
|
|
40
|
+
/** Whether a split pays Sticky holders on this chain. */
|
|
41
|
+
export declare function isStickySplit(split: Pick<JBSplit, "hook">, chainId: JBChainId): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Why the distributor would not honor a group ID, or null when it would.
|
|
44
|
+
* Gives the same answer as the distributor's pure `isValidGroupId` view: 0 is
|
|
45
|
+
* valid, otherwise `minWeeks` must be 1 to 520 and `maxWeeks` must be 0 or
|
|
46
|
+
* `minWeeks` to 520.
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateStickyGroupId(groupId: bigint): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Encode a tenure group as a split `projectId`. Leave out `maxWeeks` (or pass
|
|
51
|
+
* 0) for no upper bound.
|
|
52
|
+
*
|
|
53
|
+
* @throws If the distributor would not honor the group.
|
|
54
|
+
*/
|
|
55
|
+
export declare function stickyGroupId(args: {
|
|
56
|
+
minWeeks: number;
|
|
57
|
+
maxWeeks?: number;
|
|
58
|
+
}): bigint;
|
|
59
|
+
/**
|
|
60
|
+
* The group a split `projectId` actually funds. An invalid group ID decodes as
|
|
61
|
+
* the default group, since that is where the distributor sends it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function decodeStickyGroupId(groupId: bigint): StickyGroup;
|
|
64
|
+
/**
|
|
65
|
+
* Short plain text naming who a Sticky split rewards, for confirm dialogs and
|
|
66
|
+
* activity rows. Assumes the beneficiary is a tracked Sticky token; if it is
|
|
67
|
+
* not, a tenure split funds the default group instead.
|
|
68
|
+
*/
|
|
69
|
+
export declare function describeStickySplit(split: Pick<JBSplit, "projectId">): string;
|
|
70
|
+
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["../../../src/v6/sticky.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;;;;;;;;;;;;;;GAgBG;AAEH,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C,mEAAmE;AACnE,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,8EAA8E;AAC9E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAEpE;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAC5B,OAAO,EAAE,SAAS,GACjB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBpE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAoBT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAShE;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,MAAM,CAgB7E"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STICKY_MAX_CRITERIA_WEEKS = exports.STICKY_CRITERIA_BASE = exports.STICKY_DEFAULT_GROUP_ID = void 0;
|
|
4
|
+
exports.stickyDistributorAddress = stickyDistributorAddress;
|
|
5
|
+
exports.isStickySplit = isStickySplit;
|
|
6
|
+
exports.validateStickyGroupId = validateStickyGroupId;
|
|
7
|
+
exports.stickyGroupId = stickyGroupId;
|
|
8
|
+
exports.decodeStickyGroupId = decodeStickyGroupId;
|
|
9
|
+
exports.describeStickySplit = describeStickySplit;
|
|
10
|
+
const viem_1 = require("viem");
|
|
11
|
+
const types_js_1 = require("./types.js");
|
|
12
|
+
/**
|
|
13
|
+
* A split routes funds to Sticky holders when its `hook` is the chain's
|
|
14
|
+
* `StickyDistributor`. The distributor reads the rest of the split this way:
|
|
15
|
+
*
|
|
16
|
+
* - `beneficiary` is the Sticky token whose holders are rewarded.
|
|
17
|
+
* - `projectId` is the reward group: {@link STICKY_DEFAULT_GROUP_ID} splits the
|
|
18
|
+
* pot by delegated voting power at the round's snapshot, and a tenure group
|
|
19
|
+
* ({@link stickyGroupId}) splits it by stake held for a range of weeks.
|
|
20
|
+
*
|
|
21
|
+
* The distributor never reverts on a bad group or beneficiary, since a
|
|
22
|
+
* split-hook revert returns the funds to the project. A `projectId` that
|
|
23
|
+
* {@link validateStickyGroupId} rejects funds the default group instead, and so
|
|
24
|
+
* does a tenure group whose beneficiary the Sticky hook does not track. The
|
|
25
|
+
* distributor has no public view for that second case: a token is tracked when
|
|
26
|
+
* `stickyHookAbi` `tokenOf(projectId)` returns the token, where `projectId` is
|
|
27
|
+
* the token's own `PROJECT_ID()`.
|
|
28
|
+
*/
|
|
29
|
+
/** The default reward group: every holder, weighted by delegated voting power. */
|
|
30
|
+
exports.STICKY_DEFAULT_GROUP_ID = 0n;
|
|
31
|
+
/** A tenure group ID is `minWeeks * STICKY_CRITERIA_BASE + maxWeeks`. */
|
|
32
|
+
exports.STICKY_CRITERIA_BASE = 1000n;
|
|
33
|
+
/** The highest `minWeeks` or `maxWeeks` a tenure group can use. */
|
|
34
|
+
exports.STICKY_MAX_CRITERIA_WEEKS = 520;
|
|
35
|
+
/** The `StickyDistributor` a chain's Sticky splits must use as their hook. */
|
|
36
|
+
function stickyDistributorAddress(chainId) {
|
|
37
|
+
return (0, types_js_1.v6Address)("StickyDistributor", chainId);
|
|
38
|
+
}
|
|
39
|
+
/** Whether a split pays Sticky holders on this chain. */
|
|
40
|
+
function isStickySplit(split, chainId) {
|
|
41
|
+
return (0, viem_1.isAddressEqual)(split.hook, stickyDistributorAddress(chainId));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Why the distributor would not honor a group ID, or null when it would.
|
|
45
|
+
* Gives the same answer as the distributor's pure `isValidGroupId` view: 0 is
|
|
46
|
+
* valid, otherwise `minWeeks` must be 1 to 520 and `maxWeeks` must be 0 or
|
|
47
|
+
* `minWeeks` to 520.
|
|
48
|
+
*/
|
|
49
|
+
function validateStickyGroupId(groupId) {
|
|
50
|
+
if (groupId === exports.STICKY_DEFAULT_GROUP_ID)
|
|
51
|
+
return null;
|
|
52
|
+
if (groupId < 0n)
|
|
53
|
+
return "Group ID can't be negative.";
|
|
54
|
+
const minWeeks = groupId / exports.STICKY_CRITERIA_BASE;
|
|
55
|
+
const maxWeeks = groupId % exports.STICKY_CRITERIA_BASE;
|
|
56
|
+
const limit = BigInt(exports.STICKY_MAX_CRITERIA_WEEKS);
|
|
57
|
+
if (minWeeks === 0n)
|
|
58
|
+
return "Tenure groups need a minimum of at least 1 week.";
|
|
59
|
+
if (minWeeks > limit) {
|
|
60
|
+
return `Minimum weeks can't be more than ${exports.STICKY_MAX_CRITERIA_WEEKS}.`;
|
|
61
|
+
}
|
|
62
|
+
if (maxWeeks > limit) {
|
|
63
|
+
return `Maximum weeks can't be more than ${exports.STICKY_MAX_CRITERIA_WEEKS}.`;
|
|
64
|
+
}
|
|
65
|
+
if (maxWeeks !== 0n && maxWeeks < minWeeks) {
|
|
66
|
+
return "Maximum weeks can't be less than minimum weeks.";
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Encode a tenure group as a split `projectId`. Leave out `maxWeeks` (or pass
|
|
72
|
+
* 0) for no upper bound.
|
|
73
|
+
*
|
|
74
|
+
* @throws If the distributor would not honor the group.
|
|
75
|
+
*/
|
|
76
|
+
function stickyGroupId(args) {
|
|
77
|
+
const { minWeeks, maxWeeks = 0 } = args;
|
|
78
|
+
if (!Number.isInteger(minWeeks) ||
|
|
79
|
+
!Number.isInteger(maxWeeks) ||
|
|
80
|
+
minWeeks < 0 ||
|
|
81
|
+
maxWeeks < 0) {
|
|
82
|
+
throw new Error("Sticky group weeks must be whole numbers, 0 or more.");
|
|
83
|
+
}
|
|
84
|
+
// Checked before encoding: a larger maxWeeks would carry into minWeeks.
|
|
85
|
+
if (maxWeeks > exports.STICKY_MAX_CRITERIA_WEEKS) {
|
|
86
|
+
throw new Error(`Maximum weeks can't be more than ${exports.STICKY_MAX_CRITERIA_WEEKS}.`);
|
|
87
|
+
}
|
|
88
|
+
const groupId = BigInt(minWeeks) * exports.STICKY_CRITERIA_BASE + BigInt(maxWeeks);
|
|
89
|
+
const reason = validateStickyGroupId(groupId);
|
|
90
|
+
if (reason)
|
|
91
|
+
throw new Error(reason);
|
|
92
|
+
return groupId;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The group a split `projectId` actually funds. An invalid group ID decodes as
|
|
96
|
+
* the default group, since that is where the distributor sends it.
|
|
97
|
+
*/
|
|
98
|
+
function decodeStickyGroupId(groupId) {
|
|
99
|
+
if (groupId === 0n || validateStickyGroupId(groupId) !== null) {
|
|
100
|
+
return { kind: "default" };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
kind: "tenure",
|
|
104
|
+
minWeeks: Number(groupId / exports.STICKY_CRITERIA_BASE),
|
|
105
|
+
maxWeeks: Number(groupId % exports.STICKY_CRITERIA_BASE),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function weeks(count) {
|
|
109
|
+
return count === 1 ? "1 week" : `${count} weeks`;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Short plain text naming who a Sticky split rewards, for confirm dialogs and
|
|
113
|
+
* activity rows. Assumes the beneficiary is a tracked Sticky token; if it is
|
|
114
|
+
* not, a tenure split funds the default group instead.
|
|
115
|
+
*/
|
|
116
|
+
function describeStickySplit(split) {
|
|
117
|
+
const group = decodeStickyGroupId(split.projectId);
|
|
118
|
+
if (group.kind === "default") {
|
|
119
|
+
const fallback = split.projectId === 0n
|
|
120
|
+
? ""
|
|
121
|
+
: `, since group ${split.projectId} is invalid`;
|
|
122
|
+
return `Sticky group 0 (all holders by voting power)${fallback}`;
|
|
123
|
+
}
|
|
124
|
+
if (group.maxWeeks === 0) {
|
|
125
|
+
return `Sticky holders stuck ${weeks(group.minWeeks)} or more`;
|
|
126
|
+
}
|
|
127
|
+
if (group.maxWeeks === group.minWeeks) {
|
|
128
|
+
return `Sticky holders stuck ${weeks(group.minWeeks)}`;
|
|
129
|
+
}
|
|
130
|
+
return `Sticky holders stuck ${group.minWeeks} to ${group.maxWeeks} weeks`;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=sticky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.js","sourceRoot":"","sources":["../../../src/v6/sticky.ts"],"names":[],"mappings":";;;AAyCA,4DAEC;AAGD,sCAKC;AAQD,sDAoBC;AAQD,sCAuBC;AAMD,kDASC;AAWD,kDAgBC;AAxJD,+BAA+C;AAG/C,yCAAuC;AAEvC;;;;;;;;;;;;;;;;GAgBG;AAEH,kFAAkF;AACrE,QAAA,uBAAuB,GAAG,EAAE,CAAC;AAE1C,yEAAyE;AAC5D,QAAA,oBAAoB,GAAG,KAAK,CAAC;AAE1C,mEAAmE;AACtD,QAAA,yBAAyB,GAAG,GAAG,CAAC;AAU7C,8EAA8E;AAC9E,SAAgB,wBAAwB,CAAC,OAAkB;IACzD,OAAO,IAAA,oBAAS,EAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,yDAAyD;AACzD,SAAgB,aAAa,CAC3B,KAA4B,EAC5B,OAAkB;IAElB,OAAO,IAAA,qBAAc,EAAC,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;AACvE,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAI,OAAO,KAAK,+BAAuB;QAAE,OAAO,IAAI,CAAC;IACrD,I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,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzD,CAAC;IACD,OAAO,wBAAwB,KAAK,CAAC,QAAQ,OAAO,KAAK,CAAC,QAAQ,QAAQ,CAAC;AAC7E,CAAC"}
|
package/dist/esm/v6/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/esm/v6/index.js
CHANGED
package/dist/esm/v6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { JBChainId } from "../types.js";
|
|
3
|
+
import { JBSplit } from "./splits.js";
|
|
4
|
+
/**
|
|
5
|
+
* A split routes funds to Sticky holders when its `hook` is the chain's
|
|
6
|
+
* `StickyDistributor`. The distributor reads the rest of the split this way:
|
|
7
|
+
*
|
|
8
|
+
* - `beneficiary` is the Sticky token whose holders are rewarded.
|
|
9
|
+
* - `projectId` is the reward group: {@link STICKY_DEFAULT_GROUP_ID} splits the
|
|
10
|
+
* pot by delegated voting power at the round's snapshot, and a tenure group
|
|
11
|
+
* ({@link stickyGroupId}) splits it by stake held for a range of weeks.
|
|
12
|
+
*
|
|
13
|
+
* The distributor never reverts on a bad group or beneficiary, since a
|
|
14
|
+
* split-hook revert returns the funds to the project. A `projectId` that
|
|
15
|
+
* {@link validateStickyGroupId} rejects funds the default group instead, and so
|
|
16
|
+
* does a tenure group whose beneficiary the Sticky hook does not track. The
|
|
17
|
+
* distributor has no public view for that second case: a token is tracked when
|
|
18
|
+
* `stickyHookAbi` `tokenOf(projectId)` returns the token, where `projectId` is
|
|
19
|
+
* the token's own `PROJECT_ID()`.
|
|
20
|
+
*/
|
|
21
|
+
/** The default reward group: every holder, weighted by delegated voting power. */
|
|
22
|
+
export declare const STICKY_DEFAULT_GROUP_ID = 0n;
|
|
23
|
+
/** A tenure group ID is `minWeeks * STICKY_CRITERIA_BASE + maxWeeks`. */
|
|
24
|
+
export declare const STICKY_CRITERIA_BASE = 1000n;
|
|
25
|
+
/** The highest `minWeeks` or `maxWeeks` a tenure group can use. */
|
|
26
|
+
export declare const STICKY_MAX_CRITERIA_WEEKS = 520;
|
|
27
|
+
/**
|
|
28
|
+
* A Sticky reward group. A tenure group rewards stake added between `maxWeeks`
|
|
29
|
+
* and `minWeeks` before the round started; `maxWeeks` 0 means no upper bound.
|
|
30
|
+
*/
|
|
31
|
+
export type StickyGroup = {
|
|
32
|
+
kind: "default";
|
|
33
|
+
} | {
|
|
34
|
+
kind: "tenure";
|
|
35
|
+
minWeeks: number;
|
|
36
|
+
maxWeeks: number;
|
|
37
|
+
};
|
|
38
|
+
/** The `StickyDistributor` a chain's Sticky splits must use as their hook. */
|
|
39
|
+
export declare function stickyDistributorAddress(chainId: JBChainId): Address;
|
|
40
|
+
/** Whether a split pays Sticky holders on this chain. */
|
|
41
|
+
export declare function isStickySplit(split: Pick<JBSplit, "hook">, chainId: JBChainId): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Why the distributor would not honor a group ID, or null when it would.
|
|
44
|
+
* Gives the same answer as the distributor's pure `isValidGroupId` view: 0 is
|
|
45
|
+
* valid, otherwise `minWeeks` must be 1 to 520 and `maxWeeks` must be 0 or
|
|
46
|
+
* `minWeeks` to 520.
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateStickyGroupId(groupId: bigint): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Encode a tenure group as a split `projectId`. Leave out `maxWeeks` (or pass
|
|
51
|
+
* 0) for no upper bound.
|
|
52
|
+
*
|
|
53
|
+
* @throws If the distributor would not honor the group.
|
|
54
|
+
*/
|
|
55
|
+
export declare function stickyGroupId(args: {
|
|
56
|
+
minWeeks: number;
|
|
57
|
+
maxWeeks?: number;
|
|
58
|
+
}): bigint;
|
|
59
|
+
/**
|
|
60
|
+
* The group a split `projectId` actually funds. An invalid group ID decodes as
|
|
61
|
+
* the default group, since that is where the distributor sends it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function decodeStickyGroupId(groupId: bigint): StickyGroup;
|
|
64
|
+
/**
|
|
65
|
+
* Short plain text naming who a Sticky split rewards, for confirm dialogs and
|
|
66
|
+
* activity rows. Assumes the beneficiary is a tracked Sticky token; if it is
|
|
67
|
+
* not, a tenure split funds the default group instead.
|
|
68
|
+
*/
|
|
69
|
+
export declare function describeStickySplit(split: Pick<JBSplit, "projectId">): string;
|
|
70
|
+
//# sourceMappingURL=sticky.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.d.ts","sourceRoot":"","sources":["../../../src/v6/sticky.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;;;;;;;;;;;;;;GAgBG;AAEH,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C,mEAAmE;AACnE,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,8EAA8E;AAC9E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAEpE;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAC5B,OAAO,EAAE,SAAS,GACjB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBpE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAoBT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAShE;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,MAAM,CAgB7E"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { isAddressEqual } from "viem";
|
|
2
|
+
import { v6Address } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* A split routes funds to Sticky holders when its `hook` is the chain's
|
|
5
|
+
* `StickyDistributor`. The distributor reads the rest of the split this way:
|
|
6
|
+
*
|
|
7
|
+
* - `beneficiary` is the Sticky token whose holders are rewarded.
|
|
8
|
+
* - `projectId` is the reward group: {@link STICKY_DEFAULT_GROUP_ID} splits the
|
|
9
|
+
* pot by delegated voting power at the round's snapshot, and a tenure group
|
|
10
|
+
* ({@link stickyGroupId}) splits it by stake held for a range of weeks.
|
|
11
|
+
*
|
|
12
|
+
* The distributor never reverts on a bad group or beneficiary, since a
|
|
13
|
+
* split-hook revert returns the funds to the project. A `projectId` that
|
|
14
|
+
* {@link validateStickyGroupId} rejects funds the default group instead, and so
|
|
15
|
+
* does a tenure group whose beneficiary the Sticky hook does not track. The
|
|
16
|
+
* distributor has no public view for that second case: a token is tracked when
|
|
17
|
+
* `stickyHookAbi` `tokenOf(projectId)` returns the token, where `projectId` is
|
|
18
|
+
* the token's own `PROJECT_ID()`.
|
|
19
|
+
*/
|
|
20
|
+
/** The default reward group: every holder, weighted by delegated voting power. */
|
|
21
|
+
export const STICKY_DEFAULT_GROUP_ID = 0n;
|
|
22
|
+
/** A tenure group ID is `minWeeks * STICKY_CRITERIA_BASE + maxWeeks`. */
|
|
23
|
+
export const STICKY_CRITERIA_BASE = 1000n;
|
|
24
|
+
/** The highest `minWeeks` or `maxWeeks` a tenure group can use. */
|
|
25
|
+
export const STICKY_MAX_CRITERIA_WEEKS = 520;
|
|
26
|
+
/** The `StickyDistributor` a chain's Sticky splits must use as their hook. */
|
|
27
|
+
export function stickyDistributorAddress(chainId) {
|
|
28
|
+
return v6Address("StickyDistributor", chainId);
|
|
29
|
+
}
|
|
30
|
+
/** Whether a split pays Sticky holders on this chain. */
|
|
31
|
+
export function isStickySplit(split, chainId) {
|
|
32
|
+
return isAddressEqual(split.hook, stickyDistributorAddress(chainId));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Why the distributor would not honor a group ID, or null when it would.
|
|
36
|
+
* Gives the same answer as the distributor's pure `isValidGroupId` view: 0 is
|
|
37
|
+
* valid, otherwise `minWeeks` must be 1 to 520 and `maxWeeks` must be 0 or
|
|
38
|
+
* `minWeeks` to 520.
|
|
39
|
+
*/
|
|
40
|
+
export function validateStickyGroupId(groupId) {
|
|
41
|
+
if (groupId === STICKY_DEFAULT_GROUP_ID)
|
|
42
|
+
return null;
|
|
43
|
+
if (groupId < 0n)
|
|
44
|
+
return "Group ID can't be negative.";
|
|
45
|
+
const minWeeks = groupId / STICKY_CRITERIA_BASE;
|
|
46
|
+
const maxWeeks = groupId % STICKY_CRITERIA_BASE;
|
|
47
|
+
const limit = BigInt(STICKY_MAX_CRITERIA_WEEKS);
|
|
48
|
+
if (minWeeks === 0n)
|
|
49
|
+
return "Tenure groups need a minimum of at least 1 week.";
|
|
50
|
+
if (minWeeks > limit) {
|
|
51
|
+
return `Minimum weeks can't be more than ${STICKY_MAX_CRITERIA_WEEKS}.`;
|
|
52
|
+
}
|
|
53
|
+
if (maxWeeks > limit) {
|
|
54
|
+
return `Maximum weeks can't be more than ${STICKY_MAX_CRITERIA_WEEKS}.`;
|
|
55
|
+
}
|
|
56
|
+
if (maxWeeks !== 0n && maxWeeks < minWeeks) {
|
|
57
|
+
return "Maximum weeks can't be less than minimum weeks.";
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Encode a tenure group as a split `projectId`. Leave out `maxWeeks` (or pass
|
|
63
|
+
* 0) for no upper bound.
|
|
64
|
+
*
|
|
65
|
+
* @throws If the distributor would not honor the group.
|
|
66
|
+
*/
|
|
67
|
+
export function stickyGroupId(args) {
|
|
68
|
+
const { minWeeks, maxWeeks = 0 } = args;
|
|
69
|
+
if (!Number.isInteger(minWeeks) ||
|
|
70
|
+
!Number.isInteger(maxWeeks) ||
|
|
71
|
+
minWeeks < 0 ||
|
|
72
|
+
maxWeeks < 0) {
|
|
73
|
+
throw new Error("Sticky group weeks must be whole numbers, 0 or more.");
|
|
74
|
+
}
|
|
75
|
+
// Checked before encoding: a larger maxWeeks would carry into minWeeks.
|
|
76
|
+
if (maxWeeks > STICKY_MAX_CRITERIA_WEEKS) {
|
|
77
|
+
throw new Error(`Maximum weeks can't be more than ${STICKY_MAX_CRITERIA_WEEKS}.`);
|
|
78
|
+
}
|
|
79
|
+
const groupId = BigInt(minWeeks) * STICKY_CRITERIA_BASE + BigInt(maxWeeks);
|
|
80
|
+
const reason = validateStickyGroupId(groupId);
|
|
81
|
+
if (reason)
|
|
82
|
+
throw new Error(reason);
|
|
83
|
+
return groupId;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The group a split `projectId` actually funds. An invalid group ID decodes as
|
|
87
|
+
* the default group, since that is where the distributor sends it.
|
|
88
|
+
*/
|
|
89
|
+
export function decodeStickyGroupId(groupId) {
|
|
90
|
+
if (groupId === 0n || validateStickyGroupId(groupId) !== null) {
|
|
91
|
+
return { kind: "default" };
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
kind: "tenure",
|
|
95
|
+
minWeeks: Number(groupId / STICKY_CRITERIA_BASE),
|
|
96
|
+
maxWeeks: Number(groupId % STICKY_CRITERIA_BASE),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function weeks(count) {
|
|
100
|
+
return count === 1 ? "1 week" : `${count} weeks`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Short plain text naming who a Sticky split rewards, for confirm dialogs and
|
|
104
|
+
* activity rows. Assumes the beneficiary is a tracked Sticky token; if it is
|
|
105
|
+
* not, a tenure split funds the default group instead.
|
|
106
|
+
*/
|
|
107
|
+
export function describeStickySplit(split) {
|
|
108
|
+
const group = decodeStickyGroupId(split.projectId);
|
|
109
|
+
if (group.kind === "default") {
|
|
110
|
+
const fallback = split.projectId === 0n
|
|
111
|
+
? ""
|
|
112
|
+
: `, since group ${split.projectId} is invalid`;
|
|
113
|
+
return `Sticky group 0 (all holders by voting power)${fallback}`;
|
|
114
|
+
}
|
|
115
|
+
if (group.maxWeeks === 0) {
|
|
116
|
+
return `Sticky holders stuck ${weeks(group.minWeeks)} or more`;
|
|
117
|
+
}
|
|
118
|
+
if (group.maxWeeks === group.minWeeks) {
|
|
119
|
+
return `Sticky holders stuck ${weeks(group.minWeeks)}`;
|
|
120
|
+
}
|
|
121
|
+
return `Sticky holders stuck ${group.minWeeks} to ${group.maxWeeks} weeks`;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=sticky.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky.js","sourceRoot":"","sources":["../../../src/v6/sticky.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAE,MAAM,MAAM,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;;;;;;;;;;GAgBG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,yEAAyE;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