概要
OmnibusTBEControllerは、多数の投資家の資産を単一のウォレット(オムニバスウォレット)でまとめて管理するためのコントラクトです。 このコントラクトは、トークンの一括発行や一括償還といった機能に加え、証券法などの規制を遵守するために投資家の総数や国籍・種類別の人数を正確に追跡・管理する機能(投資家カウンター)を提供します。 これにより、ブロックチェーン上でのトランザクションコストを削減しつつ、米国の証券法などの規制(レギュレーション)に準拠した形で、投資家の数を正確に追跡・管理することを可能にします。
このコントラクトは、Securitizeが提供するDSプロトコルの中核的なコンポーネントの1つであり、トークン化された証券(Token-Based Equity, TBE)をオムニバス形式で扱うために設計されています。 オムニバス口座は、金融において複数の顧客の資産を1つの名義で管理するために広く利用されており、このコントラクトはその概念をブロックチェーン上に実装したものです。
主な目的は、オンチェーンでの効率化と、オフチェーンの投資家台帳との連携を円滑にすることです。個々の投資家が直接ウォレットを持つのではなく、カストディアンなどが管理するオムニバスウォレットを介してトークンを保有することで、トランザクション手数料の削減やプライバシーの向上が期待できます。
このコントラクトの役割は、トークンのライフサイクルイベント(発行、償還など)と連動して、コンプライアンス上重要な投資家カウンター(総投資家数、米国適格投資家数など)を正確に更新することです。
bulkIssuance関数が呼ばれると、指定された量のトークンがオムニバスウォレットに発行されると同時に、addToCounters関数を介して、関連するComplianceServiceコントラクトに記録されている投資家数が加算されます。
この時、ComplianceConfigurationServiceに設定された各投資家カテゴリの上限を超えないかどうかのチェックも行われ、規制遵守を徹底します。
また、adjustCounters関数は、オフチェーン(例えば、カストディアンの内部システム)で投資家の持ち分に変更があった場合に、その変更をオンチェーンのカウンターに反映させるための機能です。
これにより、オンチェーンのトークン総量に変化がなくても、投資家構成の変動を正確に記録し続けることができます。
さらに、パーティション化されたトークン(特定の属性を持つトークンを区別して管理する仕組み)にも対応しており、bulkBurn関数では、パーティションを考慮したトークン償還ロジックが実装されています。
機能
- オムニバスウォレットへの一括トークン発行
bulkIssuance関数により、指定された量のトークンをオムニバスウォレットに発行し、同時に総投資家数や米国投資家数などのカウンターを増加させます。
- オムニバスウォレットからの一括トークン償還
bulkBurn関数により、オムニバスウォレットからトークンを償還(burn)します。- トークンがパーティション化されている場合は、各パーティションの残高を考慮して償還処理を行います。
- オムニバスウォレットからの一括送付
bulkTransfer関数により、オムニバスウォレットから複数の指定されたウォレットへトークンを一度のトランザクションで移転します。
- 投資家カウンターの調整
adjustCountersおよびinternalTBETransfer関数により、オフチェーンでの投資家構成の変更をオンチェーンのカウンターに反映させます。- これにより、トークンの移動を伴わずにコンプライアンス情報を最新の状態に保ちます。
- コンプライアンスチェック
- 投資家カウンターを更新する時に、
ComplianceConfigurationServiceに設定された上限値を超えないかを検証して規制違反を防ぎます。
- 投資家カウンターを更新する時に、
フロー
一括発行 (bulkIssuance)
sequenceDiagram
participant Issuer as 発行者 (Issuer)
participant OTC as OmnibusTBEController
participant Token as DSToken
participant CS as ComplianceService
participant CCS as ComplianceConfigurationService
Issuer->>+OTC: bulkIssuance(value, totalInvestors, ...)
Note right of OTC: オムニバスウォレットへの一括トークン発行を開始します。
OTC->>+Token: issueTokensCustom(omnibusWallet, value, ...)
Note right of Token: 1. DSTokenコントラクトを呼び出し、<br>オムニバスウォレットに指定された量の<br>トークンを発行します。
Token-->>-OTC: 発行成功を返します。
OTC->>OTC: addToCounters(totalInvestors, ...)
Note right of OTC: 2. 内部のカウンター更新関数を呼び出します。
OTC->>+CS: getTotalInvestorsCount() / getUSInvestorsCount() ...
Note right of CS: ComplianceServiceに問い合わせ、<br>現在の各投資家カウンターの値を取得します。
CS-->>-OTC: 現在の投資家数を返します。
OTC->>+CCS: getTotalInvestorsLimit() / getUSInvestorsLimit() ...
Note right of CCS: ComplianceConfigurationServiceに問い合わせ、<br>各投資家カテゴリの上限値を取得します。
CCS-->>-OTC: 各種上限値を返します。
Note right of OTC: 3.「現在の投資家数 + 今回の増加分」が<br>上限値を超えないか検証します。
OTC->>+CS: setTotalInvestorsCount(...) / setUSInvestorsCount(...) ...
Note right of CS: 4. 検証をパスした後、ComplianceServiceに<br>新しいカウンター値を設定して更新します。
CS-->>-OTC: 更新成功を返します。
OTC->>+Token: emitOmnibusTBEEvent(totalInvestors, ...)
Note right of Token: 5. この操作を記録するため、DSTokenを通じて<br>OmnibusTBEOperationイベントを発行します。
Token-->>-OTC: イベント発行成功を返します。
OTC-->>-Issuer: 全ての処理が完了し、成功を返します。カウンター調整 (adjustCounters)
sequenceDiagram
participant Issuer as 発行者 (Issuer)
participant OTC as OmnibusTBEController
participant Token as DSToken
participant CS as ComplianceService
participant CCS as ComplianceConfigurationService
Issuer->>+OTC: adjustCounters(totalDelta, ...)
Note right of OTC: オフチェーンでの投資家構成の変動を<br>オンチェーンに反映させるため、カウンター調整を開始します。
Note right of OTC: 関数に渡された各投資家カテゴリの<br>変動量(デルタ)を受け取ります。
OTC->>OTC: addToCounters(totalDelta, ...)
Note right of OTC: 1. 内部のカウンター更新関数を呼び出します。
OTC->>+CS: getTotalInvestorsCount() / getUSInvestorsCount() ...
Note right of CS: ComplianceServiceに問い合わせ、<br>現在の各投資家カウンターの値を取得します。
CS-->>-OTC: 現在の投資家数を返します。
OTC->>+CCS: getTotalInvestorsLimit() / getUSInvestorsLimit() ...
Note right of CCS: ComplianceConfigurationServiceに問い合わせ、<br>各投資家カテゴリの上限値を取得します。
CCS-->>-OTC: 各種上限値を返します。
Note right of OTC: 2.「現在の投資家数 + 今回の変動量」が<br>上限値を超えないか検証します。
OTC->>+CS: setTotalInvestorsCount(...) / setUSInvestorsCount(...) ...
Note right of CS: 3. 検証をパスした後、ComplianceServiceに<br>新しいカウンター値を設定して更新します。
CS-->>-OTC: 更新成功を返します。
OTC->>+Token: emitOmnibusTBEEvent(totalDelta, ...)
Note right of Token: 4. このカウンター調整を記録するため、<br>DSTokenを通じてOmnibusTBEOperationイベントを発行します。
Token-->>-OTC: イベント発行成功を返します。
OTC-->>-Issuer: 全ての処理が完了し、成功を返します。コード
pragma solidity ^0.8.13;
import "../service/ServiceConsumer.sol";
import "../utils/ProxyTarget.sol";
import "../data-stores/OmnibusTBEControllerDataStore.sol";
import "../compliance/ComplianceServiceRegulated.sol";
import "../compliance/ComplianceConfigurationService.sol";
//SPDX-License-Identifier: UNLICENSED
contract OmnibusTBEController is ProxyTarget, Initializable, IDSOmnibusTBEController, ServiceConsumer, OmnibusTBEControllerDataStore {
using SafeMath for uint256;
string internal constant MAX_INVESTORS_IN_CATEGORY = "Max investors in category";
function initialize(address _omnibusWallet, bool _isPartitionedToken) public override initializer forceInitializeFromProxy {
VERSIONS.push(4);
ServiceConsumer.initialize();
omnibusWallet = _omnibusWallet;
isPartitionedToken = _isPartitionedToken;
}
function bulkIssuance(uint256 value, uint256 issuanceTime, uint256 totalInvestors, uint256 accreditedInvestors,
uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,
uint256[] memory euRetailCountryCounts) public override onlyIssuerOrAbove {
require(euRetailCountries.length == euRetailCountryCounts.length, 'EU Retail countries arrays do not match');
// Issue tokens
getToken().issueTokensCustom(omnibusWallet, value, issuanceTime, 0, '', 0);
addToCounters(totalInvestors, accreditedInvestors,
usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, euRetailCountries, euRetailCountryCounts, true);
emitTBEOperationEvent(totalInvestors, accreditedInvestors, usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, true);
}
function bulkBurn(uint256 value, uint256 totalInvestors, uint256 accreditedInvestors,
uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,
uint256[] memory euRetailCountryCounts) public override onlyTransferAgentOrAbove {
require(euRetailCountries.length == euRetailCountryCounts.length, 'EU Retail countries arrays do not match');
if(isPartitionedToken) {
IDSTokenPartitioned token = getTokenPartitioned();
uint256 pendingBurn = value;
uint256 currentPartitionBalance;
bytes32 partition;
while(pendingBurn > 0) {
require(token.partitionCountOf(omnibusWallet) > 0, 'Not enough tokens in partitions to burn the required value');
partition = token.partitionOf(omnibusWallet, 0);
currentPartitionBalance = token.balanceOfByPartition(omnibusWallet, partition);
require(currentPartitionBalance > 0, 'Not enough tokens in remaining partitions to burn the required value');
uint256 amountToBurn = currentPartitionBalance >= pendingBurn ? pendingBurn : currentPartitionBalance;
token.burnByPartition(omnibusWallet, amountToBurn, 'Omnibus burn by partition', partition);
pendingBurn = pendingBurn - amountToBurn;
}
} else {
// Burn non partitioned tokens
getToken().burn(omnibusWallet, value, 'Omnibus');
}
emitTBEOperationEvent(totalInvestors, accreditedInvestors, usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, false);
}
function bulkTransfer(address[] memory wallets, uint256[] memory values) public override onlyIssuerOrTransferAgentOrAbove {
require(wallets.length == values.length, 'Wallets and values lengths do not match');
for (uint i = 0; i < wallets.length; i++) {
getToken().transferFrom(omnibusWallet, wallets[i], values[i]);
}
}
function internalTBETransfer(string memory externalId, int256 totalDelta, int256 accreditedDelta,
int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,
int256[] memory euRetailCountryDeltas) public onlyIssuerOrTransferAgentOrAbove {
adjustCounters(totalDelta, accreditedDelta, usAccreditedDelta, usTotalDelta, jpTotalDelta,
euRetailCountries, euRetailCountryDeltas);
getToken().emitOmnibusTBETransferEvent(omnibusWallet, externalId);
}
function adjustCounters(int256 totalDelta, int256 accreditedDelta,
int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,
int256[] memory euRetailCountryDeltas) public override onlyIssuerOrTransferAgentOrAbove {
require(euRetailCountries.length == euRetailCountryDeltas.length, 'Array lengths do not match');
addToCounters(
totalDelta > 0 ? uint256(totalDelta) : 0,
accreditedDelta > 0 ? uint256(accreditedDelta) : 0,
usAccreditedDelta > 0 ? uint256(usAccreditedDelta) : 0,
usTotalDelta > 0 ? uint256(usTotalDelta) : 0,
jpTotalDelta > 0 ? uint256(jpTotalDelta) : 0,
euRetailCountries,
getUintEuCountriesDeltas(euRetailCountryDeltas, true),
true
);
getToken().emitOmnibusTBEEvent(
omnibusWallet,
totalDelta,
accreditedDelta,
usAccreditedDelta,
usTotalDelta,
jpTotalDelta);
}
function getOmnibusWallet() public view override returns (address) {
return omnibusWallet;
}
function addToCounters(uint256 _totalInvestors, uint256 _accreditedInvestors,
uint256 _usAccreditedInvestors, uint256 _usTotalInvestors, uint256 _jpTotalInvestors, bytes32[] memory _euRetailCountries,
uint256[] memory _euRetailCountryCounts, bool _increase) internal returns (bool) {
if(_increase) {
ComplianceServiceRegulated cs = ComplianceServiceRegulated(getDSService(COMPLIANCE_SERVICE));
IDSComplianceConfigurationService ccs = IDSComplianceConfigurationService(getDSService(COMPLIANCE_CONFIGURATION_SERVICE));
require(ccs.getNonAccreditedInvestorsLimit() == 0 || (cs.getTotalInvestorsCount() - cs.getAccreditedInvestorsCount()
+ _totalInvestors - _accreditedInvestors <= ccs.getNonAccreditedInvestorsLimit()), MAX_INVESTORS_IN_CATEGORY);
cs.setTotalInvestorsCount(increaseCounter(cs.getTotalInvestorsCount(), ccs.getTotalInvestorsLimit(), _totalInvestors));
cs.setAccreditedInvestorsCount(increaseCounter(cs.getAccreditedInvestorsCount(), ccs.getTotalInvestorsLimit(), _accreditedInvestors));
cs.setUSAccreditedInvestorsCount(increaseCounter(cs.getUSAccreditedInvestorsCount(), ccs.getUSAccreditedInvestorsLimit(), _usAccreditedInvestors));
cs.setUSInvestorsCount(increaseCounter(cs.getUSInvestorsCount(), ccs.getUSInvestorsLimit(), _usTotalInvestors));
cs.setJPInvestorsCount(increaseCounter(cs.getJPInvestorsCount(), ccs.getJPInvestorsLimit(), _jpTotalInvestors));
for (uint i = 0; i < _euRetailCountries.length; i++) {
string memory countryCode = bytes32ToString(_euRetailCountries[i]);
cs.setEURetailInvestorsCount(
countryCode,
increaseCounter(
cs.getEURetailInvestorsCount(countryCode),
ccs.getEURetailInvestorsLimit(),
_euRetailCountryCounts[i]
)
);
}
}
return true;
}
function emitTBEOperationEvent(uint256 _totalInvestors, uint256 _accreditedInvestors,
uint256 _usAccreditedInvestors, uint256 _usTotalInvestors, uint256 _jpTotalInvestors, bool /* _increase */) internal {
getToken().emitOmnibusTBEEvent(
omnibusWallet,
int256(_totalInvestors),
int256(_accreditedInvestors),
int256(_usAccreditedInvestors),
int256(_usTotalInvestors),
int256(_jpTotalInvestors)
);
}
function getUintEuCountriesDeltas(int256[] memory euCountryDeltas, bool increase) internal pure returns (uint256[] memory) {
uint256[] memory result = new uint256[](euCountryDeltas.length);
for (uint i = 0; i < euCountryDeltas.length; i++) {
if (increase) {
result[i] = euCountryDeltas[i] > 0 ? uint256(euCountryDeltas[i]) : 0;
} else {
result[i] = euCountryDeltas[i] < 0 ? uint256(euCountryDeltas[i] * -1) : 0;
}
}
return result;
}
function increaseCounter(uint256 currentValue, uint256 currentLimit, uint256 delta) internal pure returns (uint256) {
uint256 result = currentValue + delta;
require(currentLimit == 0 || result <= currentLimit, MAX_INVESTORS_IN_CATEGORY);
return result;
}
function bytes32ToString(bytes32 _bytes32) internal pure returns (string memory) {
uint8 i = 0;
while(i < 32 && _bytes32[i] != 0) {
i++;
}
bytes memory bytesArray = new bytes(i);
for (i = 0; i < 32 && _bytes32[i] != 0; i++) {
bytesArray[i] = _bytes32[i];
}
return string(bytesArray);
}
}変数
MAX_INVESTORS_IN_CATEGORY
string internal constant MAX_INVESTORS_IN_CATEGORY = "Max investors in category";投資家数がカテゴリの上限に達した場合に使用される、require文のエラーメッセージを格納する定数。
omnibusWallet
address internal omnibusWallet;このコントラクトが管理する対象となる、単一のオムニバスウォレットのアドレスを格納します。 トークンの一括発行や一括償還は、このアドレスに対して行われます。 この変数は親コントラクトであるOmnibusTBEControllerDataStoreコントラクトで定義されています。
isPartitionedToken
bool internal isPartitionedToken;管理対象のトークンがパーティション化されているかどうかを示すブール型のフラグです。
trueの場合、bulkBurnなどの関数はパーティションを考慮したロジックで動作します。
この変数もOmnibusTBEControllerDataStoreコントラクトで定義されています。
イベント
このコントラクトは直接イベントを定義していませんが、関連するDSTokenコントラクトのイベントを発行する関数を呼び出します。
OmnibusTBEOperation
// IDSToken.solで定義
event OmnibusTBEOperation(address indexed omnibusWallet, int256 totalDelta, int256 accreditedDelta,
int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta);bulkIssuanceやadjustCountersなどの操作が実行され、投資家カウンターが変動した際に発行されるイベントです。
どのオムニバスウォレットに対する操作か、そして各投資家カテゴリ(総数、適格投資家、米国投資家など)の数がどれだけ変動したか(デルタ)を記録します。
int256型であるため、増加だけでなく減少も表現できます。
OmnibusTBETransfer
// IDSToken.solで定義
event OmnibusTBETransfer(address omnibusWallet, string memory externalId);internalTBETransfer関数によって呼び出され、オムニバスウォレット内での内部的な持ち分送付が行われたことを記録するイベントです。
externalIdには、オフチェーンシステムで管理されている取引IDなどが入り、オンチェーンとオフチェーンの記録を紐付ける役割を果たします。
Modifier
このコントラクトは直接Modifierを定義していませんが、親コントラクトであるServiceConsumerから継承したアクセス制御用のModifierを各関数で使用しています。
onlyIssuerOrAbove
// ServiceConsumer.solで定義
modifier onlyIssuerOrAbove() {
IDSTrustService trustManager = getTrustService();
require(trustManager.getRole(msg.sender) == ROLE_ISSUER || trustManager.getRole(msg.sender) == ROLE_MASTER, "Insufficient trust level");
_;
}このModifierは、関数を呼び出すアカウントがISSUER(発行者)またはMASTER(最高管理者)のロールを持っていることを確認します。
TrustServiceコントラクトに問い合わせて権限を確認し、持っていない場合はトランザクションを失敗させます。
bulkIssuance関数などで使用され、トークン発行という重要な操作を実行できる者を制限します。
onlyTransferAgentOrAbove
// ServiceConsumer.solで定義
modifier onlyTransferAgentOrAbove() {
IDSTrustService trustManager = getTrustService();
require(trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT || trustManager.getRole(msg.sender) == ROLE_MASTER, "Insufficient trust level");
_;
}このModifierは、関数を呼び出すアカウントがTRANSFER_AGENT(名義書換代理人)またはMASTERのロールを持っていることを確認します。
bulkBurn関数などで使用され、トークン償還などの管理操作権限を制御します。
onlyIssuerOrTransferAgentOrAbove
// ServiceConsumer.solで定義
modifier onlyIssuerOrTransferAgentOrAbove() {
IDSTrustService trustManager = getTrustService();
require(trustManager.getRole(msg.sender) == ROLE_TRANSFER_AGENT || trustManager.getRole(msg.sender) == ROLE_ISSUER || trustManager.getRole(msg.sender) == ROLE_MASTER, "Insufficient trust level");
_;
}このModifierは、ISSUER、TRANSFER_AGENT、MASTERのいずれかのロールを持つアカウントからの呼び出しを許可します。
bulkTransferやadjustCountersなど、発行者と名義書換代理人の両方が関わる可能性のある操作で使用されます。
関数
initialize
function initialize(address _omnibusWallet, bool _isPartitionedToken) public override initializer forceInitializeFromProxy {
VERSIONS.push(4);
ServiceConsumer.initialize();
omnibusWallet = _omnibusWallet;
isPartitionedToken = _isPartitionedToken;
}コントラクトを初期化する関数。
この関数は、コントラクトがデプロイされた後に一度だけ呼び出されて基本的な設定を行います。initializerおよびforceInitializeFromProxyというModifierによって、プロキシ経由での初期化を一度きりに制限しています。
処理として、まずコントラクトのバージョン情報を記録し、親コントラクトであるServiceConsumerコントラクトの初期化処理を呼び出します。
その後、引数で受け取ったオムニバスウォレットのアドレスと、関連するトークンがパーティション管理されているかどうかのフラグを、それぞれ状態変数omnibusWalletとisPartitionedTokenに保存します。
引数
_omnibusWallet- 管理対象となるオムニバスウォレットのアドレス。
_isPartitionedToken- 管理対象のトークンがパーティション化されているかを示すブール値 (
trueまたはfalse)。
- 管理対象のトークンがパーティション化されているかを示すブール値 (
bulkIssuance
function bulkIssuance(uint256 value, uint256 issuanceTime, uint256 totalInvestors, uint256 accreditedInvestors,
uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,
uint256[] memory euRetailCountryCounts) public override onlyIssuerOrAbove {
require(euRetailCountries.length == euRetailCountryCounts.length, 'EU Retail countries arrays do not match');
// Issue tokens
getToken().issueTokensCustom(omnibusWallet, value, issuanceTime, 0, '', 0);
addToCounters(totalInvestors, accreditedInvestors,
usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, euRetailCountries, euRetailCountryCounts, true);
emitTBEOperationEvent(totalInvestors, accreditedInvestors, usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, true);
}トークンを一括で発行し、関連する投資家カウンターを更新する関数。
onlyIssuerOrAbove Modifierにより、発行者(Issuer)以上の権限を持つアカウントのみがこの関数を実行できます。
まず、DSTokenコントラクトを呼び出して、指定されたvalueの量のトークンをomnibusWalletに発行します。
次に、内部関数addToCountersを呼び出し、引数で渡された各カテゴリの投資家数(総投資家数、米国投資家数など)を、関連するComplianceServiceコントラクトに記録されているカウンターに加算します。
このとき、ComplianceConfigurationServiceに設定された上限を超えないかの検証も行われます。
最後に、この一括発行操作をブロックチェーン上に記録するため、OmnibusTBEOperationイベントを発行します。
引数
value- 発行するトークンの総量。
issuanceTime- トークンの発行日時(Unixタイムスタンプ)。
totalInvestors- この発行によって増加する総投資家数。
accreditedInvestors- 増加する適格投資家数。
usAccreditedInvestors- 増加する米国の適格投資家数。
usTotalInvestors- 増加する米国の総投資家数。
jpTotalInvestors- 増加する日本の総投資家数。
euRetailCountries- 投資家が増加するEU各国の国コード(bytes32形式)の配列。
euRetailCountryCountseuRetailCountries配列の各国に対応する、増加するリテール投資家数の配列。
bulkBurn
function bulkBurn(uint256 value, uint256 totalInvestors, uint256 accreditedInvestors,
uint256 usAccreditedInvestors, uint256 usTotalInvestors, uint256 jpTotalInvestors, bytes32[] memory euRetailCountries,
uint256[] memory euRetailCountryCounts) public override onlyTransferAgentOrAbove {
require(euRetailCountries.length == euRetailCountryCounts.length, 'EU Retail countries arrays do not match');
if(isPartitionedToken) {
IDSTokenPartitioned token = getTokenPartitioned();
uint256 pendingBurn = value;
uint256 currentPartitionBalance;
bytes32 partition;
while(pendingBurn > 0) {
require(token.partitionCountOf(omnibusWallet) > 0, 'Not enough tokens in partitions to burn the required value');
partition = token.partitionOf(omnibusWallet, 0);
currentPartitionBalance = token.balanceOfByPartition(omnibusWallet, partition);
require(currentPartitionBalance > 0, 'Not enough tokens in remaining partitions to burn the required value');
uint256 amountToBurn = currentPartitionBalance >= pendingBurn ? pendingBurn : currentPartitionBalance;
token.burnByPartition(omnibusWallet, amountToBurn, 'Omnibus burn by partition', partition);
pendingBurn = pendingBurn - amountToBurn;
}
} else {
// Burn non partitioned tokens
getToken().burn(omnibusWallet, value, 'Omnibus');
}
emitTBEOperationEvent(totalInvestors, accreditedInvestors, usAccreditedInvestors, usTotalInvestors, jpTotalInvestors, false);
}オムニバスウォレットからトークンを一括で償還(Burn)する関数。
onlyTransferAgentOrAbove Modifierにより、名義書換代理人(Transfer Agent)以上の権限を持つアカウントのみが実行できます。
まず、isPartitionedTokenフラグを確認し、トークンがパーティション化されているかを判断します。
パーティション化されている場合、償還すべき総量(value)に達するまで、オムニバスウォレットが保有するパーティションを1つずつ処理してトークンを償還します。
パーティション化されていない場合は、DSTokenコントラクトのburn関数を直接呼び出し、指定された量のトークンを償還します。
最後にOmnibusTBEOperationイベントを発行します。
この関数は引数で投資家数を受け取りますが、現在の実装では投資家カウンターを減算するロジックは含まれていません。
将来の機能拡張のために引数が予約されている可能性があります。
引数
value- 償還するトークンの総量。
totalInvestors- この償還操作に関連する総投資家数。
- 現在の実装ではカウンター更新には使用されません。
accreditedInvestors- この償還操作に関連する適格投資家数。
- 現在の実装ではカウンター更新には使用されません。
usAccreditedInvestors- この償還操作に関連する米国の適格投資家数。
- 現在の実装ではカウンター更新には使用されません。
usTotalInvestors- この償還操作に関連する米国の総投資家数。
- 現在の実装ではカウンター更新には使用されません。
jpTotalInvestors- この償還操作に関連する日本の総投資家数。
- 現在の実装ではカウンター更新には使用されません。
euRetailCountries- この償還操作に関連するEU各国の国コード(bytes32形式)の配列。
- 現在の実装ではカウンター更新には使用されません。
euRetailCountryCountseuRetailCountries配列の各国に対応するリテール投資家数の配列。- 現在の実装ではカウンター更新には使用されません。
bulkTransfer
function bulkTransfer(address[] memory wallets, uint256[] memory values) public override onlyIssuerOrTransferAgentOrAbove {
require(wallets.length == values.length, 'Wallets and values lengths do not match');
for (uint i = 0; i < wallets.length; i++) {
getToken().transferFrom(omnibusWallet, wallets[i], values[i]);
}
}オムニバスウォレットから複数の宛先へトークンを一括で送付(Transfer)する関数。
onlyIssuerOrTransferAgentOrAbove Modifierにより、発行者または名義書換代理人以上の権限を持つアカウントが実行できます。
この関数は、例えばオムニバスウォレットから個別の投資家ウォレットへトークンを分配する際に使用されます。
引数として受け取った宛先ウォレットの配列(wallets)と送付量の配列(values)をループ処理し、DSTokenコントラクトのtransferFrom関数を繰り返し呼び出すことで、オムニバスウォレットから各宛先へ指定された量のトークンを送付します。
引数
wallets- トークンの送付先となるウォレットアドレスの配列。
valueswallets配列の各アドレスに対応する、送付するトークン量の配列。
internalTBETransfer
function internalTBETransfer(string memory externalId, int256 totalDelta, int256 accreditedDelta,
int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,
int256[] memory euRetailCountryDeltas) public onlyIssuerOrTransferAgentOrAbove {
adjustCounters(totalDelta, accreditedDelta, usAccreditedDelta, usTotalDelta, jpTotalDelta,
euRetailCountries, euRetailCountryDeltas);
getToken().emitOmnibusTBETransferEvent(omnibusWallet, externalId);
}オフチェーン(ブロックチェーン外)での持ち分変動を、オンチェーンの記録に反映させるための関数。
onlyIssuerOrTransferAgentOrAbove Modifierにより、アクセスが制御されています。
この関数は、オンチェーンでの実際のトークン送付を伴わずに、投資家構成の変更を記録するために使用されます。
まずadjustCounters関数を呼び出して、引数で渡された変動量(デルタ)に基づき投資家カウンターを更新します。
その後、DSTokenコントラクトのemitOmnibusTBETransferEvent関数を呼び出し、OmnibusTBETransferイベントを発行します。
このイベントにはオフチェーンシステムで使われる取引IDなどをexternalIdとして含めることができ、オンチェーンとオフチェーンの記録を紐付けるのに役立ちます。
引数
externalId- オフチェーンシステムで管理される取引IDなどの外部識別子。
totalDelta- 総投資家数の変動量。
int256型であり、正の値は増加負の値は減少を示します。
accreditedDelta- 適格投資家数の変動量。
usAccreditedDelta- 米国の適格投資家数の変動量。
usTotalDelta- 米国の総投資家数の変動量。
jpTotalDelta- 日本の総投資家数の変動量。
euRetailCountries- リテール投資家数が変動したEU各国の国コード(bytes32形式)の配列。
euRetailCountryDeltas- euRetailCountries
配列の各国に対応する、リテール投資家数の変動量(デルタ)の配列。配列の長さと順序はeuRetailCountries`と一致している必要があります。
- euRetailCountries
adjustCounters
function adjustCounters(int256 totalDelta, int256 accreditedDelta,
int256 usAccreditedDelta, int256 usTotalDelta, int256 jpTotalDelta, bytes32[] memory euRetailCountries,
int256[] memory euRetailCountryDeltas) public override onlyIssuerOrTransferAgentOrAbove {
require(euRetailCountries.length == euRetailCountryDeltas.length, 'Array lengths do not match');
addToCounters(
totalDelta > 0 ? uint256(totalDelta) : 0,
accreditedDelta > 0 ? uint256(accreditedDelta) : 0,
usAccreditedDelta > 0 ? uint256(usAccreditedDelta) : 0,
usTotalDelta > 0 ? uint256(usTotalDelta) : 0,
jpTotalDelta > 0 ? uint256(jpTotalDelta) : 0,
euRetailCountries,
getUintEuCountriesDeltas(euRetailCountryDeltas, true),
true
);
getToken().emitOmnibusTBEEvent(
omnibusWallet,
totalDelta,
accreditedDelta,
usAccreditedDelta,
usTotalDelta,
jpTotalDelta);
}投資家カウンターの数値を直接調整する関数。
onlyIssuerOrTransferAgentOrAbove Modifierにより、アクセスが制御されています。
この関数は、内部関数addToCountersを呼び出して投資家数のカウンターを更新します。
現在の実装では、引数で渡されたデルタ値が正の場合(増加の場合)のみをカウンターに反映させます。
処理の最後に、DSTokenコントラクトのemitOmnibusTBEEvent関数を呼び出し、カウンターの変動量を記録したOmnibusTBEOperationイベントを発行します。
引数
totalDelta- 総投資家数の変動量。
int256型であり、正の値は増加負の値は減少を示します。
accreditedDelta- 適格投資家数の変動量。
usAccreditedDelta- 米国の適格投資家数の変動量。
usTotalDelta- 米国の総投資家数の変動量。
jpTotalDelta- 日本の総投資家数の変動量。
euRetailCountries- リテール投資家数が変動したEU各国の国コード(bytes32形式)の配列。
euRetailCountryDeltas- euRetailCountries
配列の各国に対応する、リテール投資家数の変動量(デルタ)の配列。配列の長さと順序はeuRetailCountries`と一致している必要があります。
- euRetailCountries
getOmnibusWallet
function getOmnibusWallet() public view override returns (address) {
return omnibusWallet;
}このコントラクトが管理しているオムニバスウォレットのアドレスを取得する関数。
戻り値
address- 設定されているオムニバスウォレットのEthereumアドレス。