bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 16쪽 중 4쪽
(requestId)
if
pendingAssets == 0
.
Subtracts from global
totalPendingShares
and
totalPendingAssets
.
Deletes the request record.
safeTransfer(asset(), owner, pendingAssets)
transfers directly to the request owner.
No separate user claim step required.
Emits
Redeem(operator, owner, assets, shares)
.
Emits
RedeemRequestsFulfilled(requestIds)
after the batch.
Important:
The strategy’s
asset()
balance must be sufficient at the time
safeTransfer
is called. If shards hold the assets off-chain, they must call
pushToStrategy(asset, amount)
before the operator calls
fulfillRedeemRequests
. The ERC-20 transfer will revert if the balance is insufficient.
Setting the redeem fee
strategy.
setRedeemFeeBps
(bps);
// DEFAULT_ADMIN_ROLE; bps < 10_000
A fee of
0 bps
(or an unset treasury) means no shares are deducted.
## /learn/architecture/strategies/accounting
Strategy: Accounting
Strategy accounting is based on externally posted Net Asset Value (NAV), represented by
pricePerShare
. The strategy does not compute NAV from token balances. Instead,
pricePerShare
is the single source of truth for share minting, redemption accounting, and
totalAssets()
.
NAV accounting
totalAssets()
is a
derived figure
, not a token balance sum:
totalAssets() = totalSupply() × pricePerShare / 10^decimals()
pricePerShare
represents
asset wei per one full share unit
(i.e. per
10^decimals()
share tokens). It is initialised to
10^decimals()
(1:1) at deployment and updated by an account with
PRICE_SETTER_ROLE
.
Because NAV is oracle-posted, the strategy’s actual ERC-20 balance of
asset()
may differ from
totalAssets()
at any point. Capital may be deployed to shards, invested externally, or in transit. Shards must
pushToStrategy
sufficient
asset()
before an operator calls
fulfillRedeemRequests
.
Share and asset conversions
All share and asset conversions derive from
pricePerShare
:
shares = assets × 10^decimals() / pricePerShare (floor)
assets = shares × pricePerShare / 10^decimals() (floor or ceil depending on path)
For deposits, listed deposit tokens are first converted into strategy base units via their
IAssetConverter
, then those base units are converted into shares.
For redemptions, burned shares are converted into pending redemption assets using the current
pricePerShare
:
pendingAssets = netShares × pricePerShare / 10^decimals() (floor)
Posting a new price
pricePerShare
is the strategy’s posted exchange rate:
asset wei per
10 ** decimals()
strategy shares
. It drives
totalAssets()
, deposit share minting, and async redemption asset amounts.
Unlike a simple setter,
postPricePerShare
accepts an off-chain NAV snapshot and reconciles share supply changes that happened between the snapshot and the on-chain transaction.
function
postPricePerShare
(
uint256
navAtSnapshot
,
uint256
supplyAtSnapshot
,
bool
revertOnRateLimit
)
external
;
Requires:
No pause conditions in effect
navAtSnapshot
and
supplyAtSnapshot
must not be zero.
If successful, the function stores the reconciled price and emits:
PricePerShareUpdated
(pricePerShare,
totalAssets
(), postedAt)
Inputs
Parameter
Meaning
navAtSnapshot
Total strategy NAV in
asset()
units observed off-chain at snapshot time
supplyAtSnapshot
totalSupply()
observed at the same time as the NAV snapshot
revertOnRateLimit
Whether to revert or auto-pause when the price move exceeds rate-limit capacity
The snapshot pair must be internally consistent:
navAtSnapshot
and
supplyAtSnapshot
should describe the same off-chain valuation moment.
Reconcilitation from snapshot
Deposits and async redemption requests can happen after the off-chain NAV snapshot but before the
postPricePerShare
transaction executes.
Those same-epoch flows are priced using the
old stored PPS
, because the new PPS has not yet been posted. Without reconciliation, a deposit at stale PPS could inflate on-chain NAV after the price update.
postPricePerShare
adjusts the snapshot NAV for supply changes at the old stored price, then computes the final PPS against current supply.
Async redemption
fulfillments
do not change share supply or active-share NAV; they only pay already queued requests, so they do not need reconciliation.
Hence:
If supply increased after the snapshot but before the new PPS is posted, the added shares are treated as capital that entered at the old PPS.
If supply decreased after the snapshot but before the new PPS is posted, the removed shares are treated as capital that exited at the old PPS.
Price rate limiter
pricePerShare
moves are capped by a token-bucket rate limiter. The bucket has:
maxBucketBps
: maximum burst capacity, limiting how large a single price move can be before the bucket is empty.
refillRate
: capacity refilled per second, allowing larger cumulative moves over time.
The rate limiter is configured via
setPricePerShareRateLimit(maxBucketBps, refillRate)
by
MANAGER_ROLE
. The bucket starts at zero capacity on deployment, so it must be configured before the first
postPricePerShare
succeeds.
Current bucket state, with refill virtually applied, is readable via
pricePerShareRateLimiterState()
.
## /learn/architecture/strategies/fees
Strategy: Fee System
The strategy has four distinct fee surfaces: two
flow fees
that divert tokens or shares at transaction time, and two
dilution fees
that mint new shares to a treasury over time.
Summary
Fee
Type
When it fires
What happens
Deposit fee
Flow fee
On every
deposit
/
mint
A slice of the deposit tokens is transferred to
feeTreasury
before shares are minted
Redeem fee
Flow fee
On every
requestRedeem
A slice of requested shares is transferred to
feeTreasury
; the remainder is burned
Management fee
Dilution fee
Automatically on every
deposit
/
mint
/
requestRedeem
New shares proportional to time elapsed are minted directly to
managementFeeTreasury
Performance fee
Dilution fee
On demand, called by
PERF_FEE_CLAIM_ROLE
New shares are minted to a specified recipient when
pricePerShare
exceeds the high-water mark
Deposit fee
The deposit fee is charged on the
gross deposit amount
and paid in the
deposit token
(not in shares).
feeTokens = grossAssets × depositFeeBps / 10_000 (ceiling)
netAssets = grossAssets - feeTokens
Configured per deposit asset via
setDepositFeeBps(token, bps)
(
MANAGER_ROLE
;
bps < 10_000
).
feeTokens
are transferred directly from the strategy to
feeTreasury
during the deposit transaction.
If
depositFeeBps > 0
and
feeTreasury
is not set, the deposit reverts with
StrategyDeposit_FeeTreasuryNotSet
.
Only
netAssets
are converted to shares via the
IAssetConverter
and used to determine the share mint.
Emits
DepositFeeTransferred(token, treasury, feeTokens)
.
Configuration
// Set or update fee for a listed deposit asset (MANAGER_ROLE)
strategy.
setDepositFeeBps
(tokenAddress,
50
);
// 50 bps = 0.5%
// Set the treasury to receive deposit fee tokens
strategy.
setFeeTreasury
(treasuryAddress);
// MANAGER_ROLE
Redeem fee
The redeem fee is charged on the
requested shares
and paid in shares to
feeTreasury
.
feeShares = requestedShares × redeemFeeBps / 10_000 (ceiling)
netShares = requestedShares - feeShares
Configured via
setRedeemFeeBps(bps)
(
DEFAULT_ADMIN_ROLE
;
bps < 10_000
).
feeShares
are transferred from the owner to
feeTreasury
(not burned).
Only
netShares
are burned, and only
netShares × pricePerShare
worth of
asset()
is queued for redemption payout.
If
feeShares >= requestedShares
(pathological bps + rounding), reverts
AsyncRedemption_FeeSharesGreaterThanShares
.
A fee of
0 bps
or an unset treasury means no fee is taken.
netShares == requestedShares
.
Emits
RedeemFeeCharged(treasury, feeShares)
.
Configuration
// Set redeem fee globally (DEFAULT_ADMIN_ROLE)
strategy.
setRedeemFeeBps
(
30
);
// 30 bps = 0.3%
Management fee
The management fee is an
annualized percentage of total share supply
, accrued continuously based on elapsed time.
mgmtFeeShares = totalSupply × managementFeeBps × elapsedSeconds
─────────────────────────────────────────────────
10_000 × 365 days
How it accrues
Unlike performance fees, management fees
do not require an explicit harvest transaction
. They accrue automatically as a side-effect of user interactions:
Every
deposit
/
mint
call runs
_accrueManagementFee()
before minting user shares.
Every
requestRedeem
call runs
_accrueManagementFee()
before burning shares.
When
_accrueManagementFee()
runs:
Computes
shares
from
totalSupply
,
managementFeeBps
, and
block.timestamp - lastFeeHarvestAt
.
Updates
lastFeeHarvestAt
to
block.timestamp
.
If
shares > 0
, mints them directly to
managementFeeTreasury
. Emits
ManagementFeeHarvested(treasury, shares, elapsed)
.
If the strategy is idle (no user interactions), management fee accrues silently in
lastFeeHarvestAt
state and is settled on the next user transaction.
Configuration
// Set annual management fee rate (DEFAULT_ADMIN_ROLE; bps < 10_000)
strategy.
setManagementFeeBps
(
200
);
// 200 bps = 2% per year
// Set the treasury that receives management fee shares (MANAGER_ROLE)
strategy.
setManagementFeeTreasury
(treasuryAddress);
Calling
setManagementFeeBps
resets the accrual clock: any accrued-but-un-settled fee at the old rate is
lost
(it was never minted because no interaction triggered the accrual). Coordinate off-chain before changing rates to ensure no surprise gaps.
Views
(
uint16
feeBps,
uint48
lastHarvestAt,
address
treasury)
=
strategy.
managementFee
();
Performance fee
The performance fee is triggered when
pricePerShare
rises above the stored
high-water mark (HWM)
. It is computed as a percentage of the incremental supply that would correspond to the NAV gain above the HWM.
gainShares = totalSupply × (pricePerShare - HWM) / HWM (floor)
perfFeeShares = gainShares × performanceFeeBps / 10_000 (floor)
Unlike the management fee, the performance fee requires an
explicit harvest call
by an account with
PERF_FEE_CLAIM_ROLE
.
Harvesting
// Mint performance fee shares to a specified recipient (PERF_FEE_CLAIM_ROLE)
strategy.
harvestPerformanceFee
(feeRecipient);
If
pricePerShare <= HWM
: no-op (returns silently, not a revert).
If
perfFeeShares == 0
at current PPS/HWM: no-op.
Otherwise: mints
perfFeeShares
to
feeRecipient
, raises HWM to current
pricePerShare
. Emits
PerformanceFeeHarvested(recipient, shares, oldHWM, newHWM)
.
The
feeRecipient
parameter is supplied by the caller and does not have to equal
feeTreasury
.
Updating the performance fee rate
// DEFAULT_ADMIN_ROLE; bps < 10_000
strategy.
setPerformanceFeeBps
(bps, feeRecipient, forfeitAccrued);
Before the rate is updated:
If
pricePerShare > HWM
and
forfeitAccrued = false
: accrued performance fee shares at the
old
rate are minted to
feeRecipient
.
If
forfeitAccrued = true
: the HWM is reset without minting any accrued shares.
After the update, the HWM is reset to the current
pricePerShare
. The first harvest at the new rate starts from this baseline.
Coordination note:
Updating
performanceFeeBps
resets the HWM. If
pricePerShare
has risen significantly above the old HWM, set
forfeitAccrued = false
and provide a valid
feeRecipient
to avoid forfeiting the accrued fee.
Views
(
uint16
feeBps,
uint256
previewShares,
uint256
hwm)
=
strategy.
performanceFee
();
Treasury configuration
There are two treasury addresses in the system:
Address
Purpose
Set by
feeTreasury
Receives deposit fee tokens and redeem fee shares
MANAGER_ROLE
via
setFeeTreasury
managementFeeTreasury
Receives management fee shares (minted automatically)
MANAGER_ROLE
via
setManagementFeeTreasury
Performance fee harvests accept an explicit
feeRecipient
argument at call time rather than reading from a stored address.
strategy.
setFeeTreasury
(
address
);
// MANAGER_ROLE
strategy.
setManagementFeeTreasury
(
address
);
// MANAGER_ROLE
Both must be non-zero. If
feeTreasury
is not set and a deposit fee or redeem fee is non-zero, the relevant transaction will revert.
Fee interaction overview
## /learn/architecture/strategies/shards
Strategy: Shards
Shards are separate upgradeable contracts that act as
custody and execution endpoints
for portfolio capital. They are registered with the strategy and can pull assets from it on demand, execute approved external calls (protocol interactions, bridges, DeFi integrations), and push assets back.
Shard vs Remote Shard
Shard
RemoteShard
Strategy link
Yes, holds an
IStrategy
reference
No
pullFromStrategy
Yes (
SHARD_TRANSFER_ROLE
)
No
pushToStrategy
Yes (
SHARD_TRANSFER_ROLE
)
No
Validator-gated
exec
Yes
Yes
Privileged
exec
bypass
Yes (
PRIVILEGED_EXECUTOR_ROLE
)
Yes (
PRIVILEGED_EXECUTOR_ROLE
)
ETH custody
Yes (
receive
)
Yes (
receive
)
Use
Shard
when capital moves through the strategy funding pipe (
requestFunding
/
pushToStrategy
) and other interactions happen via validator-approved
exec
.
Use
Remote Shard
when the deployment has no need to call
requestFunding
. All interactions are purely external calls approved by the validator. A single
Shard
may coordinate multiple
RemoteShard
instances (e.g. one per chain).
Strategy funding pipe (
Shard
only)
// SHARD_TRANSFER_ROLE: pull tokens from the strategy to this shard
shard.
pullFromStrategy
(IERC20 token,
uint256
amount);
// SHARD_TRANSFER_ROLE: push tokens from this shard back to the strategy
shard.
pushToStrategy
(IERC20 token,
uint256
amount);
pullFromStrategy
calls
strategy.requestFunding(token, amount)
which causes the strategy to
safeTransfer(token, shard, amount)
directly. There is no ERC-20 approve/transferFrom pattern between strategy and shard.
pushToStrategy
performs
token.safeTransfer(address(strategy), amount)
. It accepts any ERC-20 (not only
strategy.asset()
), but the typical use case is returning
asset()
to fund pending redemption fulfilments.
Both emit
PulledFromStrategy
/
PushedToStrategy
events and bypass the validator.
Shard funding guards
When a registered shard calls
requestFunding(token, amount)
:
The caller must be a registered shard; reverts
Strategy_ShardNotRegistered
otherwise.
token
must not be the strategy share token itself; reverts
Strategy_ShareTransferNotAllowed
.
amount
must be non-zero; reverts
Strategy_ZeroAmount
.
The call is
nonReentrant
.
External calls
Both
Shard
and
RemoteShard
expose two
exec
overloads for making arbitrary external calls.
Validator-gated
function
exec
(
address
to
,
uint256
value
,
bytes
calldata
data
,
bytes
calldata
validatorArgs
)
external
payable
returns
(
bytes
memory
);
Calls
validator.isAllowed(msg.sender, to, value, data, validatorArgs)
.
Reverts
Shard_CallNotAllowed
if the validator returns
false
.
On approval, executes
payable(to).call{value: value}(data)
and reverts if the call fails.
Emits
Executed(sender, to, value, data)
.
Privileged Executor
function
exec
(
address
to
,
uint256
value
,
bytes
calldata
data
)
external
payable
returns
(
bytes
memory
);
Requires
PRIVILEGED_EXECUTOR_ROLE
. Validator is not consulted.
Otherwise identical to the validator-gated path.
For emergency operations or patterns that cannot be expressed as Merkle rules.
Common behavior
payable
:
msg.value
is credited to the shard’s ETH balance before the forwarded call.
Requires
address(this).balance >= value
; reverts
Shard_InvalidEthFunding
otherwise.
nonReentrant
.
to == address(this)
is explicitly permitted (e.g. for granting roles to the shard itself via
exec
). Policy should model this surface explicitly.
Replacing the validator
shard.
setValidator
(IShardExecValidator newValidator);
// DEFAULT_ADMIN_ROLE
Replaces the active validator for all future
exec
calls. Must not be
address(0)
. Emits
ValidatorUpdated(oldValidator, newValidator)
.
Shard registration
Before a shard can call
requestFunding
, it must be registered with the strategy:
strategy.
registerShard
(shardAddress);
// DEFAULT_ADMIN_ROLE
strategy.
deregisterShard
(shardAddress);
// MANAGER_ROLE
strategy.
isRegisteredShard
(shardAddress);
// view
strategy.
shards
();
// view, returns all registered addresses
Registration does not establish any ERC-20 allowance; the strategy transfers directly on
requestFunding
.
Deregistering the current
defaultShard
automatically clears it to
address(0)
.
Default shard
strategy.
setDefaultShard
(shardAddress);
// MANAGER_ROLE (must be a registered shard or address(0))
strategy.
defaultShard
();
// view
When a
defaultShard
is configured, every successful deposit automatically forwards the net deposit tokens to that shard after minting shares. This is the primary mechanism for deploying freshly deposited capital without a separate operator step.
MerkleAllowlistValidator
MerkleAllowlistValidator
is the standard IShardExecValidator implementation. It stores a single Merkle root on-chain and validates each exec call against a rule supplied with a Merkle proof. A zero root denies all calls.
For the complete rule encoding reference, full TypeScript examples, a step-by-step worked scenario, and security considerations see
Shard Validators
.
## /learn/architecture/strategies/shard-validators
Shard Validators
Every
Shard
and
RemoteShard
instance holds a reference to exactly one
IShardExecValidator
contract. Before any validator-gated
exec
call is forwarded, the shard asks its validator:
“Is this call allowed?”
The validator is the sole on-chain policy enforcement point for what the shard can do.
The validator interface
interface
IShardExecValidator
{
function
isAllowed
(
address
sender
,
address
to
,
uint256
value
,
bytes
calldata
data
,
bytes
calldata
validatorArgs
)
external
view
returns
(
bool
);
}
sender
:
msg.sender
of the
exec
call (the logical caller the policy cares about).
to
/
value
/
data
: the proposed external call.
validatorArgs
: arbitrary bytes; encoding is defined by the specific validator. For
MerkleAllowlistValidator
this is an ABI-encoded
CallVerificationInput
(rule + Merkle proof).
The validator MUST be a pure read-only view. It indicates allowed/denied and never executes calls itself.
Plugging in and replacing validators
Each shard initialises with a validator at deploy time.
DEFAULT_ADMIN_ROLE
on the shard can replace it at any time:
shard.
setValidator
(IShardExecValidator newValidator);
// DEFAULT_ADMIN_ROLE; newValidator != address(0)
Emits
ValidatorUpdated(oldValidator, newValidator)
. Replacement takes effect immediately for all future
exec
calls. In-flight calls protected by
nonReentrant
are unaffected.
MerkleAllowlistValidator
MerkleAllowlistValidator
is the standard validator implementation. It encodes the entire allowed call policy as a Merkle tree computed off-chain; only the
root hash
lives on-chain. Each
exec
call supplies one rule and a Merkle proof, and the validator checks both the proof and the call against the rule.
Architecture
Zero root = deny all
If
_allowlistRoot == bytes32(0)
(the default on deployment),
isAllowed
always returns
false
. No calls are permitted until a valid root is set.
Root management
The validator is owned via
Ownable2Step
. Only the current owner can update the root:
validator.
setAllowlistRoot
(
bytes32
newRoot);
// onlyOwner
Emits
AllowlistRootUpdated(oldRoot, newRoot)
. Setting a zero root re-enables the deny-all state.
Domain separator
Every leaf in the tree is bound to a specific
chain
and
validator contract address
via a domain separator:
domainSeparator = keccak256(abi.encodePacked(
bytes4(0x414c4c57), // "ALLW" magic
uint8(1), // layout version
block.chainid,
address(this)
))
This means a proof built for validator
A
on chain 1 cannot be replayed against val프로젝트로 돌아가기