basket-settle
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBasket Settle
篮子结算
Propose and finalize settlement for PolyBaskets baskets. Requires the settler role.
提议并完成PolyBaskets篮子的结算。需要settler角色权限。
Setup
配置
MAINNET ONLY. Run before anything else. NEVER switch to testnet — there are no contracts there.
vara-wallet config set network mainnetbash
vara-wallet config set network mainnet
BASKET_MARKET="0x702395d43248eaa5f1fd4d9eadadc75b0fb1c7c5ae9ea20bf31375fd4358f403"
_PB="${POLYBASKETS_SKILLS_DIR:-skills}"
IDL="$_PB/idl/polymarket-mirror.idl"仅主网可用。 首先运行。切勿切换到测试网——那里没有部署合约。
vara-wallet config set network mainnetbash
vara-wallet config set network mainnet
BASKET_MARKET="0x702395d43248eaa5f1fd4d9eadadc75b0fb1c7c5ae9ea20bf31375fd4358f403"
_PB="${POLYBASKETS_SKILLS_DIR:-skills}"
IDL="$_PB/idl/polymarket-mirror.idl"Verify Settler Role
验证Settler角色
Only the address assigned as in the contract config can call settlement methods.
settler_rolebash
undefined只有在合约配置中被指定为的地址才能调用结算方法。
settler_rolebash
undefinedCheck who has settler role
查看谁拥有settler角色
vara-wallet call $BASKET_MARKET BasketMarket/GetConfig --args '[]' --idl $IDL | jq '.settler_role'
vara-wallet call $BASKET_MARKET BasketMarket/GetConfig --args '[]' --idl $IDL | jq '.settler_role'
Check agent's address
查看Agent的地址
vara-wallet wallet list | jq -r '.[0].address'
If your address does not match `settler_role`, you cannot settle. Contact the admin.vara-wallet wallet list | jq -r '.[0].address'
如果你的地址与`settler_role`不匹配,则无法进行结算。请联系管理员。Settlement Flow
结算流程
1. Check basket is Active
2. Verify all items have resolved on Polymarket
3. ProposeSettlement → starts 12-minute challenge window
4. Wait for challenge_deadline to pass
5. FinalizeSettlement → basket becomes Settled, users can claim1. 检查篮子状态为Active
2. 验证所有项目已在Polymarket上完成决议
3. 调用ProposeSettlement → 启动12分钟的挑战窗口
4. 等待challenge_deadline到期
5. 调用FinalizeSettlement → 篮子变为Settled状态,用户可领取奖励Step 1: Check Basket Status
步骤1:检查篮子状态
bash
vara-wallet call $BASKET_MARKET BasketMarket/GetBasket \
--args '[<basket_id>]' --idl $IDL | jq '.result.ok.status'Must be .
"Active"bash
vara-wallet call $BASKET_MARKET BasketMarket/GetBasket \
--args '[<basket_id>]' --idl $IDL | jq '.result.ok.status'状态必须为。
"Active"Step 2: Check Polymarket Resolution
步骤2:检查Polymarket决议状态
For each item in the basket, check if the market has resolved on Polymarket:
bash
curl -s "https://gamma-api.polymarket.com/markets?slug=<poly_slug>" | jq '.[0] | {closed, outcomePrices}'All items must be resolved () with final prices near 0 or 1.
closed: true对于篮子中的每个项目,检查其在Polymarket上的市场是否已完成决议:
bash
curl -s "https://gamma-api.polymarket.com/markets?slug=<poly_slug>" | jq '.[0] | {closed, outcomePrices}'所有项目必须已完成决议(),且最终价格接近0或1。
closed: trueStep 3: Propose Settlement
步骤3:提议结算
Build the array — one per basket item:
item_resolutionsItemResolutionjson
{
"item_index": 0,
"resolved": "YES",
"poly_slug": "will-btc-hit-100k",
"poly_condition_id": "0xabc123...",
"poly_price_yes": 9900,
"poly_price_no": 100
}Rules:
- Provide exactly one resolution per basket item
- is 0-based, must be unique, and within basket items range
item_index - must match the basket item's slug exactly
poly_slug - +
poly_price_yesshould reflect final Polymarket prices in bpspoly_price_no - is the final outcome:
resolvedor"YES""NO" - is optional
poly_condition_id
构建数组 —— 每个篮子项目对应一个:
item_resolutionsItemResolutionjson
{
"item_index": 0,
"resolved": "YES",
"poly_slug": "will-btc-hit-100k",
"poly_condition_id": "0xabc123...",
"poly_price_yes": 9900,
"poly_price_no": 100
}规则:
- 每个篮子项目必须对应一个决议
- 从0开始,必须唯一且在篮子项目范围内
item_index - 必须与篮子项目的slug完全匹配
poly_slug - +
poly_price_yes应反映Polymarket的最终价格(单位:bps)poly_price_no - 为最终结果:
resolved或"YES""NO" - 为可选参数
poly_condition_id
Example: Propose settlement for a 2-item basket
示例:为包含2个项目的篮子提议结算
bash
vara-wallet --account agent call $BASKET_MARKET BasketMarket/ProposeSettlement --voucher $VOUCHER_ID \
--args '[
0,
[
{
"item_index": 0,
"resolved": "YES",
"poly_slug": "will-btc-hit-100k",
"poly_condition_id": null,
"poly_price_yes": 9900,
"poly_price_no": 100
},
{
"item_index": 1,
"resolved": "NO",
"poly_slug": "will-eth-hit-5k",
"poly_condition_id": null,
"poly_price_yes": 200,
"poly_price_no": 9800
}
],
"Resolved via Polymarket API"
]' \
--idl $IDLAfter proposal, the basket enters status and the 12-minute challenge window begins.
SettlementPendingbash
vara-wallet --account agent call $BASKET_MARKET BasketMarket/ProposeSettlement --voucher $VOUCHER_ID \
--args '[
0,
[
{
"item_index": 0,
"resolved": "YES",
"poly_slug": "will-btc-hit-100k",
"poly_condition_id": null,
"poly_price_yes": 9900,
"poly_price_no": 100
},
{
"item_index": 1,
"resolved": "NO",
"poly_slug": "will-eth-hit-5k",
"poly_condition_id": null,
"poly_price_yes": 200,
"poly_price_no": 9800
}
],
"Resolved via Polymarket API"
]' \
--idl $IDL提议后,篮子将进入状态,12分钟的挑战窗口随即开始。
SettlementPendingStep 4: Wait for Challenge Window
步骤4:等待挑战窗口结束
bash
undefinedbash
undefinedCheck challenge deadline
查看挑战截止时间
vara-wallet call $BASKET_MARKET BasketMarket/GetSettlement
--args '[<basket_id>]' --idl $IDL | jq '.result.ok | {status, challenge_deadline, proposed_at}'
--args '[<basket_id>]' --idl $IDL | jq '.result.ok | {status, challenge_deadline, proposed_at}'
The `challenge_deadline` is a block timestamp. The liveness window is configured in `liveness_ms` (default 720000ms = 12 minutes).
Wait until the current block timestamp exceeds `challenge_deadline`.vara-wallet call $BASKET_MARKET BasketMarket/GetSettlement
--args '[<basket_id>]' --idl $IDL | jq '.result.ok | {status, challenge_deadline, proposed_at}'
--args '[<basket_id>]' --idl $IDL | jq '.result.ok | {status, challenge_deadline, proposed_at}'
`challenge_deadline`是一个区块时间戳。存活窗口由`liveness_ms`配置(默认720000ms = 12分钟)。
等待当前区块时间戳超过`challenge_deadline`即可。Step 5: Finalize Settlement
步骤5:完成结算
bash
vara-wallet --account agent call $BASKET_MARKET BasketMarket/FinalizeSettlement --voucher $VOUCHER_ID \
--args '[<basket_id>]' --idl $IDLAfter finalization:
- Basket status becomes
Settled - is set
finalized_at - Users can now claim payouts via
../basket-claim/SKILL.md
bash
vara-wallet --account agent call $BASKET_MARKET BasketMarket/FinalizeSettlement --voucher $VOUCHER_ID \
--args '[<basket_id>]' --idl $IDL完成结算后:
- 篮子状态变为
Settled - 字段将被设置
finalized_at - 用户现在可通过领取奖励
../basket-claim/SKILL.md
Verify
验证结算结果
bash
vara-wallet call $BASKET_MARKET BasketMarket/GetSettlement \
--args '[<basket_id>]' --idl $IDL | jq '.result.ok | {status, payout_per_share, finalized_at}'bash
vara-wallet call $BASKET_MARKET BasketMarket/GetSettlement \
--args '[<basket_id>]' --idl $IDL | jq '.result.ok | {status, payout_per_share, finalized_at}'Common Errors
常见错误
| Error | Cause | Fix |
|---|---|---|
| Not the settler role | Check config for settler_role address |
| Basket already in settlement | Check status |
| Already proposed | Wait and finalize |
| Wrong number of resolutions | Provide one per item |
| Slug doesn't match basket item | Use exact slug from basket |
| Same item_index twice | Make indices unique |
| Index >= items count | Use 0 to items.length-1 |
| Too early to finalize | Wait for challenge window |
| No proposal exists | Propose first |
| Settlement not yet finalized | Call FinalizeSettlement after challenge window |
| 错误 | 原因 | 解决方法 |
|---|---|---|
| 无settler角色权限 | 检查合约配置中的settler_role地址 |
| 篮子已处于结算流程中 | 检查篮子状态 |
| 已提交过结算提议 | 等待并完成最终结算 |
| 决议数量不正确 | 为每个项目提供一个决议 |
| Slug与篮子项目不匹配 | 使用篮子项目的精确Slug |
| 重复使用item_index | 确保索引唯一 |
| 索引超出项目数量范围 | 使用0到items.length-1之间的索引 |
| 未到最终结算时间 | 等待挑战窗口结束 |
| 未提交结算提议 | 先提交结算提议 |
| 结算尚未完成 | 挑战窗口结束后调用FinalizeSettlement |