IPcl.globalPeriodicList
globalPeriodicList(address user, string asset, bool resolveAgentOwners, PageRequest pageRequest) external view returns (PeriodicVolume[] statuses, PageResponse pageResponse) 전역 정책 설정에서 user에 적용되는 모든 PERIODIC_VOLUME_POLICY 카운터를 반환합니다. 서로 다른 리셋 주기 버킷마다 항목 하나씩 포함됩니다. 동일 자산에 24시간 상한과 30일 상한이 함께 적용되는 등, 여러 전역 주기 상한을 한 번에 표시하거나 검사할 때 사용합니다.
파라미터
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
user | address | ✓ | 주기 카운터를 열거할 주소입니다. |
asset | string | ✓ | 필터링할 denom 문자열입니다. OKRW의 경우 "aokrw"를 사용합니다. |
resolveAgentOwners | bool | ✓ | true이고 user가 에이전트 지갑이면 카운터를 에이전트의 소유자(owner)들 기준으로 집계합니다. |
pageRequest | PageRequest | ✓ | 표준 페이지 요청 { key, offset, limit, countTotal, reverse }입니다. 첫 페이지 요청 시 { key: 0x, offset: 0, limit: 100, countTotal: false, reverse: false }를 전달합니다. |
반환값
타입:
(PeriodicVolume[] statuses, PageResponse pageResponse) statuses는 매칭되는 전역 주기 정책마다 { amount, maxAmount, resetPeriodSeconds, resetAt } 항목을 담은 배열입니다. pageResponse는 다음 페이지 커서와 선택적 총 개수를 담습니다.
예제
사용자에 대한 모든 전역 OKRW 주기 카운터 조회
OKRW에 대해 user에 적용되는 모든 전역 주기 카운터를 열거합니다. 설정된 리셋 주기마다 한 행씩 반환됩니다. 여러 상한(예: 일 상한과 월 상한)을 한 화면에 함께 보여주는 대시보드에 유용합니다.
import { createPublicClient, http, parseAbi } from "viem";
const PCL = "0x1000000000000000000000000000000000000005";
const pclAbi = parseAbi([
"function globalPeriodicList(address user, string asset, bool resolveAgentOwners, (bytes key, uint64 offset, uint64 limit, bool countTotal, bool reverse) pageRequest) view returns ((uint256 amount, uint256 maxAmount, uint64 resetPeriodSeconds, uint64 resetAt)[] statuses, (bytes nextKey, uint64 total) pageResponse)",
]);
const client = createPublicClient({ transport: http("https://rpc-testnet.maroo.io") });
const user = "0x5555555555555555555555555555555555555555"; // replace before production
const [statuses, pageResponse] = await client.readContract({
address: PCL,
abi: pclAbi,
functionName: "globalPeriodicList",
args: [
user,
"aokrw",
false,
{ key: "0x", offset: 0n, limit: 100n, countTotal: false, reverse: false },
],
});
for (const s of statuses) {
// e.g. daily (86400) and monthly (2592000) caps side by side
console.log(`period=${s.resetPeriodSeconds}s used=${s.amount}/${s.maxAmount} resetAt=${s.resetAt}`);
} 페이지네이션 커서로 다음 페이지 조회
표준 PageRequest / PageResponse 루프입니다. 반환된 nextKey로 key를 갱신해 빈 응답이 올 때까지 반복 조회합니다.
let key: `0x${string}` = "0x";
do {
const [statuses, pageResponse] = await client.readContract({
address: PCL,
abi: pclAbi,
functionName: "globalPeriodicList",
args: [user, "aokrw", false, { key, offset: 0n, limit: 50n, countTotal: false, reverse: false }],
});
for (const s of statuses) { /* consume */ }
key = pageResponse.nextKey as `0x${string}`;
} while (key && key !== "0x");