市场成交与持仓数据及含吃单手续费的本地交割 #7
@@ -401,3 +401,23 @@ sequenceDiagram
|
||||
H-->>C: 404
|
||||
end
|
||||
```
|
||||
|
||||
### 在下单前判断互斥资产
|
||||
|
||||
官方 Python SDK 可以按 token_id 请求 `GET /neg-risk`。本地的 YES 和 NO 共用所属市场的分组。没有分组的已上架资产返回 false,无法匹配市场则返回 404。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
H["market_http.rs · GET /neg-risk"] --> E["exchange/neg_risk.rs"] --> S["exchange/schema.sql · neg_risk_members"]
|
||||
```
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant C as 客户端
|
||||
participant H as market_http.rs
|
||||
participant E as Exchange
|
||||
C->>H: GET /neg-risk?token_id=eb%3ANO%3Aa
|
||||
H->>E: 查询市场 a 的成员关系
|
||||
E-->>H: true
|
||||
H-->>C: 200,neg_risk 为真
|
||||
```
|
||||
|
||||
@@ -227,6 +227,13 @@ fn token_setting(
|
||||
exchange::MarketDataError::Unavailable => (500, "Internal server error"),
|
||||
};
|
||||
match name {
|
||||
"neg-risk" => {
|
||||
let flag = exchange
|
||||
.token_neg_risk(&token)
|
||||
.map_err(unavailable)?
|
||||
.ok_or((404, "market not found"))?;
|
||||
Ok(json!({"neg_risk":flag}))
|
||||
}
|
||||
"fee-rate" => {
|
||||
let fee = exchange
|
||||
.base_fee_bps(&token)
|
||||
@@ -353,8 +360,9 @@ fn respond(mut req: Request, engine: &Mutex<Exchange>) -> std::io::Result<()> {
|
||||
let (name, segment) = route
|
||||
.split_once('/')
|
||||
.map_or((route, None), |(name, id)| (name, Some(id)));
|
||||
let is_setting =
|
||||
matches!(name, "tick-size" | "fee-rate") && !segment.is_some_and(|id| id.contains('/'));
|
||||
let is_setting = path == "/neg-risk"
|
||||
|| (matches!(name, "tick-size" | "fee-rate")
|
||||
&& !segment.is_some_and(|id| id.contains('/')));
|
||||
let lookup = path
|
||||
.strip_prefix('/')
|
||||
.and_then(|p| p.split_once('/'))
|
||||
@@ -810,6 +818,11 @@ mod tests {
|
||||
("GET","/clob-markets/missing",String::new(),400,None),
|
||||
("POST","/clob-markets/map+2%2F1","{}".into(),405,None),
|
||||
("GET",tick_query.as_str(),String::new(),200,Some(json!({"minimum_tick_size":0.01}))),
|
||||
("GET","/neg-risk?token_id=eb%3AYES%3Amap%2B2%2F1",String::new(),200,Some(json!({"neg_risk":false}))),
|
||||
("GET","/neg-risk?token_id=eb%3ANO%3Amissing",String::new(),404,None),
|
||||
("GET","/neg-risk?token_id=bad",String::new(),400,None),
|
||||
("GET","/neg-risk",String::new(),400,None),
|
||||
("POST","/neg-risk",String::new(),405,None),
|
||||
("GET","/fee-rate?token_id=eb%3AYES%3Amap%2B2%2F1",String::new(),200,Some(json!({"base_fee":30}))),
|
||||
("GET","/fee-rate/eb:NO:map+2%2F1",String::new(),200,Some(json!({"base_fee":30}))),
|
||||
("GET","/fee-rate/eb:YES:s",String::new(),200,Some(json!({"base_fee":0}))),
|
||||
|
||||
@@ -1362,3 +1362,29 @@ sequenceDiagram
|
||||
E->>D: 读取成交曲线系数
|
||||
E-->>C: 按成交数量与各档价格计算费用
|
||||
```
|
||||
|
||||
### 互斥资产标识和小数份额转换
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
C["command.rs"] --> M["market.rs"] --> N["neg_risk.rs · 成员、转换、赢家准备金"]
|
||||
N --> I["inventory.rs · 百万分之一份的数量和抵押"]
|
||||
N --> L["ledger.rs · 现金与份额"]
|
||||
N --> S["schema.sql · 分组、准备金与小数余数"]
|
||||
X["lib.rs · Exchange"] --> N
|
||||
```
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant C as 客户端
|
||||
participant E as Exchange
|
||||
participant D as SQLite
|
||||
C->>E: token_neg_risk(资产 ID)
|
||||
E->>D: 检查市场和分组成员记录
|
||||
E-->>C: 成员返回 true,普通市场返回 false
|
||||
C->>E: convert,两种 NO 各 250001 微份
|
||||
E->>D: 同一事务扣除 NO 和抵押,增加其余 YES、准备金、现金和活动记录
|
||||
E-->>C: 本次释放 250001 微单位现金
|
||||
C->>E: 裁决赢家
|
||||
E->>D: 将完整准备金含小数余数划入赢家抵押
|
||||
```
|
||||
|
||||
@@ -65,7 +65,8 @@ pub(crate) enum Command {
|
||||
group: String,
|
||||
account: String,
|
||||
no_markets: Vec<String>,
|
||||
qty: i64,
|
||||
qty: Option<i64>,
|
||||
qty_micros: Option<i64>,
|
||||
},
|
||||
Split {
|
||||
market: String,
|
||||
|
||||
@@ -72,15 +72,20 @@ pub(crate) fn movement(
|
||||
tx: &Transaction,
|
||||
request: &str,
|
||||
account: &str,
|
||||
market: &str,
|
||||
target: &str,
|
||||
kind: &str,
|
||||
shares: i64,
|
||||
cash: i64,
|
||||
) -> Result<()> {
|
||||
let (market, group_id) = if kind == "CONVERSION" {
|
||||
(None, Some(target))
|
||||
} else {
|
||||
(Some(target), None)
|
||||
};
|
||||
tx.execute(
|
||||
"INSERT INTO wallet_movements(request_id,account,kind,market,shares,cash_delta,at_ms)
|
||||
VALUES(?,?,?,?,?,?,CAST(unixepoch('subsec')*1000 AS INTEGER))",
|
||||
params![request, account, kind, market, shares / UNIT, cash / 10000],
|
||||
"INSERT INTO wallet_movements(request_id,account,kind,market,group_id,shares,cash_delta,at_ms)
|
||||
VALUES(?,?,?,?,?,?,?,CAST(unixepoch('subsec')*1000 AS INTEGER))",
|
||||
params![request, account, kind, market, group_id, shares / UNIT, cash / 10000],
|
||||
)?;
|
||||
tx.execute(
|
||||
"INSERT INTO precise_movements VALUES(?,?,?,?)",
|
||||
@@ -89,6 +94,19 @@ pub(crate) fn movement(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn quantity_units(qty: Option<i64>, qty_micros: Option<i64>) -> Result<i64> {
|
||||
Ok(match (qty, qty_micros) {
|
||||
(Some(q), None) => {
|
||||
crate::validation::amount(q)?;
|
||||
q * UNIT
|
||||
}
|
||||
(None, Some(u)) if (1..=1_000_000_000 * UNIT).contains(&u) => u,
|
||||
_ => anyhow::bail!(
|
||||
"provide exactly one positive qty or qty_micros within the quantity limit"
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn pairs(
|
||||
tx: &Transaction,
|
||||
request: &str,
|
||||
@@ -108,16 +126,7 @@ pub(crate) fn pairs(
|
||||
&["preopen", "continuous", "closed"][..]
|
||||
},
|
||||
)?;
|
||||
let units = match (qty, qty_micros) {
|
||||
(Some(q), None) => {
|
||||
crate::validation::amount(q)?;
|
||||
q * UNIT
|
||||
}
|
||||
(None, Some(u)) if (1..=1_000_000_000 * UNIT).contains(&u) => u,
|
||||
_ => anyhow::bail!(
|
||||
"provide exactly one positive qty or qty_micros within the quantity limit"
|
||||
),
|
||||
};
|
||||
let units = quantity_units(qty, qty_micros)?;
|
||||
let delta = if split { units } else { -units };
|
||||
ledger::cash_micros(tx, account, -delta)?;
|
||||
for outcome in ["YES", "NO"] {
|
||||
|
||||
@@ -245,6 +245,7 @@ impl Exchange {
|
||||
"fills",
|
||||
"paired_fills",
|
||||
"neg_risk_groups",
|
||||
"neg_risk_reserve_remainders",
|
||||
"augmented_results",
|
||||
] {
|
||||
let mut stmt = tx.prepare(&format!("SELECT * FROM {table} ORDER BY rowid"))?;
|
||||
|
||||
@@ -147,7 +147,16 @@ pub(crate) fn apply(
|
||||
account,
|
||||
no_markets,
|
||||
qty,
|
||||
} => crate::neg_risk::convert(tx, &group, &account, &no_markets, qty),
|
||||
qty_micros,
|
||||
} => crate::neg_risk::convert(
|
||||
tx,
|
||||
request_id,
|
||||
&group,
|
||||
&account,
|
||||
&no_markets,
|
||||
qty,
|
||||
qty_micros,
|
||||
),
|
||||
Command::Split {
|
||||
market,
|
||||
account,
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
use crate::{
|
||||
ledger,
|
||||
validation::{amount, identifier},
|
||||
};
|
||||
use crate::{assets, inventory, ledger, validation::identifier, Exchange, MarketDataError};
|
||||
use anyhow::{ensure, Result};
|
||||
use rusqlite::{params, OptionalExtension, Transaction};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
impl Exchange {
|
||||
pub fn token_neg_risk(&self, token: &str) -> Result<Option<bool>, MarketDataError> {
|
||||
let (_, market) = assets::parse_id(token)
|
||||
.map_err(|_| MarketDataError::Invalid("Invalid token id".into()))?;
|
||||
let mut stmt=self.db.prepare_cached(
|
||||
"SELECT EXISTS(SELECT 1 FROM neg_risk_members WHERE market=m.id) FROM markets m WHERE m.id=?1"
|
||||
)?;
|
||||
Ok(stmt.query_row([market], |row| row.get(0)).optional()?)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn define(
|
||||
tx: &Transaction,
|
||||
group: &str,
|
||||
@@ -41,14 +49,16 @@ pub(crate) fn define(
|
||||
|
||||
pub(crate) fn convert(
|
||||
tx: &Transaction,
|
||||
request: &str,
|
||||
group: &str,
|
||||
account: &str,
|
||||
no_markets: &[String],
|
||||
qty: i64,
|
||||
qty: Option<i64>,
|
||||
qty_micros: Option<i64>,
|
||||
) -> Result<Value> {
|
||||
identifier(group)?;
|
||||
identifier(account)?;
|
||||
amount(qty)?;
|
||||
let units = inventory::quantity_units(qty, qty_micros)?;
|
||||
let selected: BTreeSet<&str> = no_markets.iter().map(String::as_str).collect();
|
||||
ensure!(
|
||||
!selected.is_empty() && selected.len() == no_markets.len(),
|
||||
@@ -73,39 +83,46 @@ pub(crate) fn convert(
|
||||
members.iter().all(|(_, phase)| phase != "resolved"),
|
||||
"group already resolving"
|
||||
);
|
||||
let cents = qty * 100;
|
||||
let mut yes_markets = Vec::new();
|
||||
for (market, _) in &members {
|
||||
if selected.contains(market.as_str()) {
|
||||
ledger::position(tx, account, market, "NO", -qty)?;
|
||||
ensure!(
|
||||
tx.execute(
|
||||
"UPDATE markets SET collateral=collateral-?1 WHERE id=?2 AND collateral>=?1",
|
||||
params![cents, market]
|
||||
)? == 1,
|
||||
"insufficient market backing"
|
||||
);
|
||||
inventory::position(tx, account, market, "NO", -units)?;
|
||||
inventory::backing(tx, market, -units)?;
|
||||
} else {
|
||||
ledger::position(tx, account, market, "YES", qty)?;
|
||||
inventory::position(tx, account, market, "YES", units)?;
|
||||
yes_markets.push(market);
|
||||
}
|
||||
}
|
||||
let released = (selected.len() as i64 - 1) * cents;
|
||||
tx.execute(
|
||||
"UPDATE neg_risk_groups SET reserve_cents=reserve_cents+?1 WHERE id=?2",
|
||||
params![cents, group],
|
||||
let released = (selected.len() as i64 - 1) * units;
|
||||
let reserve: i64 = tx.query_row(
|
||||
"SELECT micros FROM neg_risk_reserves WHERE id=?",
|
||||
[group],
|
||||
|r| r.get(0),
|
||||
)?;
|
||||
ledger::cash(tx, account, released)?;
|
||||
Ok(
|
||||
json!({"group":group,"qty":qty,"no_markets":no_markets,"yes_markets":yes_markets,"released_cents":released}),
|
||||
)
|
||||
let reserve = reserve
|
||||
.checked_add(units)
|
||||
.ok_or_else(|| anyhow::anyhow!("group reserve overflow"))?;
|
||||
tx.execute(
|
||||
"UPDATE neg_risk_groups SET reserve_cents=? WHERE id=?",
|
||||
params![reserve / 10000, group],
|
||||
)?;
|
||||
tx.execute("INSERT INTO neg_risk_reserve_remainders(group_id,micros) VALUES(?,?) ON CONFLICT(group_id) DO UPDATE SET micros=excluded.micros",params![group,reserve%10000])?;
|
||||
ledger::cash_micros(tx, account, released)?;
|
||||
let mut receipt = json!({"group":group,"qty":inventory::decimal(units.into(),inventory::UNIT),
|
||||
"no_markets":no_markets,"yes_markets":yes_markets,"released_cents":inventory::decimal(released.into(),10000)});
|
||||
if qty_micros.is_some() {
|
||||
inventory::movement(tx, request, account, group, "CONVERSION", units, released)?;
|
||||
receipt["qty_micros"] = json!(units);
|
||||
receipt["released_micros"] = json!(released);
|
||||
}
|
||||
Ok(receipt)
|
||||
}
|
||||
|
||||
// Run in the same transaction as the binary payout check. A failing verdict
|
||||
// rolls back the transfer as well as any optimistic-resolution state change.
|
||||
pub(crate) fn allocate_payout(tx: &Transaction, market: &str, outcome: &str) -> Result<()> {
|
||||
let group: Option<(String, Option<String>, i64)> = tx.query_row(
|
||||
"SELECT g.id,g.winner,g.reserve_cents FROM neg_risk_members n JOIN neg_risk_groups g ON g.id=n.group_id WHERE n.market=?",
|
||||
"SELECT g.id,g.winner,g.micros FROM neg_risk_members n JOIN neg_risk_reserves g ON g.id=n.group_id WHERE n.market=?",
|
||||
[market], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)),
|
||||
).optional()?;
|
||||
let Some((group, winner, reserve)) = group else {
|
||||
@@ -120,9 +137,10 @@ pub(crate) fn allocate_payout(tx: &Transaction, market: &str, outcome: &str) ->
|
||||
match outcome {
|
||||
"YES" => {
|
||||
ensure!(winner.is_none(), "group already has a winner");
|
||||
inventory::backing(tx, market, reserve)?;
|
||||
tx.execute(
|
||||
"UPDATE markets SET collateral=collateral+?1 WHERE id=?2",
|
||||
params![reserve, market],
|
||||
"DELETE FROM neg_risk_reserve_remainders WHERE group_id=?",
|
||||
[&group],
|
||||
)?;
|
||||
tx.execute(
|
||||
"UPDATE neg_risk_groups SET winner=?1,reserve_cents=0 WHERE id=?2",
|
||||
|
||||
@@ -196,6 +196,12 @@ CREATE TABLE IF NOT EXISTS neg_risk_groups (
|
||||
id TEXT PRIMARY KEY, reserve_cents INTEGER NOT NULL DEFAULT 0 CHECK(reserve_cents>=0),
|
||||
winner TEXT REFERENCES markets
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS neg_risk_reserve_remainders (
|
||||
group_id TEXT PRIMARY KEY REFERENCES neg_risk_groups(id), micros INTEGER NOT NULL CHECK(micros BETWEEN 0 AND 9999)
|
||||
);
|
||||
CREATE VIEW IF NOT EXISTS neg_risk_reserves AS
|
||||
SELECT g.id,g.winner,g.reserve_cents*10000+COALESCE(r.micros,0) AS micros
|
||||
FROM neg_risk_groups g LEFT JOIN neg_risk_reserve_remainders r ON r.group_id=g.id;
|
||||
CREATE TABLE IF NOT EXISTS neg_risk_members (
|
||||
market TEXT PRIMARY KEY REFERENCES markets, group_id TEXT NOT NULL REFERENCES neg_risk_groups,
|
||||
ordinal INTEGER NOT NULL, UNIQUE(group_id,ordinal)
|
||||
|
||||
@@ -3725,3 +3725,72 @@ fn fractional_basis_point_curve_keeps_its_precision_without_inventing_a_base_fee
|
||||
assert!(e.execute(bad).is_err());
|
||||
assert!(e.clob_market_info("invalid").unwrap().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fractional_conversions_carry_reserve_and_activity_through_restart() {
|
||||
let dir = tempdir().unwrap();
|
||||
let path = dir.path().join("fractional-negative-risk.sqlite");
|
||||
let mut e = Exchange::open(&path).unwrap();
|
||||
for line in include_str!("../../../docs/examples/neg-risk.jsonl").lines() {
|
||||
let cmd: Value = serde_json::from_str(line).unwrap();
|
||||
if cmd["op"] == "define_neg_risk" {
|
||||
assert_eq!(e.token_neg_risk("eb:NO:a").unwrap(), Some(false));
|
||||
}
|
||||
e.execute(cmd).unwrap();
|
||||
}
|
||||
let commands: Vec<Value> = include_str!("../../../docs/examples/neg-risk-fractional.jsonl")
|
||||
.lines()
|
||||
.map(|l| serde_json::from_str(l).unwrap())
|
||||
.collect();
|
||||
for cmd in &commands[..2] {
|
||||
e.execute(cmd.clone()).unwrap();
|
||||
}
|
||||
let mut invalid = commands[2].clone();
|
||||
invalid["id"] = json!("missing-no");
|
||||
invalid["no_markets"] = json!(["a", "other"]);
|
||||
let before = state(&mut e);
|
||||
assert!(e.execute(invalid).is_err());
|
||||
assert_eq!(state(&mut e), before);
|
||||
let r = e.execute(commands[2].clone()).unwrap();
|
||||
assert_eq!(r["released_micros"], 250001);
|
||||
assert_eq!(r["released_cents"], json!(25.0001));
|
||||
let during = state(&mut e);
|
||||
assert_eq!(during["neg_risk_groups"][0]["reserve_cents"], 225);
|
||||
assert_eq!(during["neg_risk_reserve_remainders"][0]["micros"], 1);
|
||||
drop(e);
|
||||
let mut e = Exchange::open(path).unwrap();
|
||||
assert_eq!(e.execute(commands[2].clone()).unwrap(), r);
|
||||
assert_eq!(e.token_neg_risk("eb:YES:a").unwrap(), Some(true));
|
||||
assert_eq!(e.token_neg_risk("eb:NO:other").unwrap(), Some(true));
|
||||
assert_eq!(e.token_neg_risk("eb:NO:missing").unwrap(), None);
|
||||
e.execute(commands[3].clone()).unwrap();
|
||||
let after = state(&mut e);
|
||||
assert_eq!(after["neg_risk_groups"][0]["reserve_cents"], 226);
|
||||
assert_eq!(after["neg_risk_reserve_remainders"][0]["micros"], 0);
|
||||
let activity = e.execute(commands[4].clone()).unwrap();
|
||||
let rows = activity["activity"].as_array().unwrap();
|
||||
assert_eq!(rows.len(), 3);
|
||||
assert_eq!(rows[1]["shares"], json!(0.250001));
|
||||
assert_eq!(rows[1]["net_cash_delta_micros"], 250001);
|
||||
assert_eq!(rows[1]["group"], "winner");
|
||||
assert_eq!(rows[2]["net_cash_delta_micros"], 9999);
|
||||
for (market, winner) in [("a", "NO"), ("b", "NO"), ("other", "YES")] {
|
||||
e.execute(json!({"op":"close","id":format!("close-{market}"),"market":market}))
|
||||
.unwrap();
|
||||
e.execute(
|
||||
json!({"op":"finalize","id":format!("final-{market}"),"market":market,"winner":winner}),
|
||||
)
|
||||
.unwrap();
|
||||
e.execute(
|
||||
json!({"op":"redeem","id":format!("claim-{market}"),"account":"user","market":market}),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
assert_eq!(
|
||||
e.execute(json!({"op":"balance","account":"user"})).unwrap()["available_micros"],
|
||||
30000000
|
||||
);
|
||||
let end = state(&mut e);
|
||||
assert_eq!(end["neg_risk_groups"][0]["reserve_cents"], 0);
|
||||
assert_eq!(end["neg_risk_reserve_remainders"], json!([]));
|
||||
}
|
||||
|
||||
@@ -87,3 +87,6 @@ GET http://127.0.0.1:9002/fee-rate/eb%3ANO%3Acup
|
||||
|
||||
### The same market reports tbf 30 and an execution fee coefficient fd.r of 0.05.
|
||||
GET http://127.0.0.1:9002/clob-markets/cup
|
||||
|
||||
### Load neg-risk.jsonl to query either token of a member of the election group.
|
||||
GET http://127.0.0.1:9002/neg-risk?token_id=eb%3ANO%3Aa
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{"op":"split","id":"fraction-a","market":"a","account":"user","qty_micros":260000}
|
||||
{"op":"split","id":"fraction-b","market":"b","account":"user","qty_micros":260000}
|
||||
{"op":"convert","id":"fraction-convert","group":"winner","account":"user","no_markets":["a","b"],"qty_micros":250001}
|
||||
{"op":"convert","id":"fraction-carry","group":"winner","account":"user","no_markets":["a","b"],"qty_micros":9999}
|
||||
{"op":"activity","account":"user","types":["CONVERSION"],"direction":"ASC"}
|
||||
@@ -434,3 +434,11 @@ Polymarket 的单资产最近成交接口规定,无成交时返回价格字符
|
||||
本地用每个市场的 taker_bps 响应两种结果资产的基础费查询。上架命令可分别指定 base_fees 与 taker_fee_rate_ppm。未提供 base_fees 时,本地 maker 默认为零,taker 使用可精确换算为整数基点的曲线系数;无法精确换算时,基础费查询返回 404,fd.r 仍保留原精度。这是旧数据的本地兼容约定。
|
||||
|
||||
重放 [费用样例](examples/fees.jsonl),cup 的 base_fee 和 tbf 都为 30,fd.r 为 0.05。100 份以 0.50 成交时,费用为 100 × 0.05 × 0.50 × 0.50,即 1.25 模拟美元。卖出一份且成交价为 0.30 时,费用为 0.01050。这组配置用于检查两个字段可独立读取,尚未取得生产市场这三项数据的同期样本。[官方费用公式](https://docs.polymarket.com/trading/fees.md)
|
||||
|
||||
### 互斥资产查询与转换精度
|
||||
|
||||
SDK 使用 `GET /neg-risk?token_id=…`,也可以从已缓存的 CLOB 市场详情 nr 判断。两结果资产共享同一市场的转换资格。Eventbook 从转换命令实际使用的分组成员表读取标志;组建前为 false,事务提交后为 true。本地资产沿用 eb:结果:市场 的 ID。官方生产查询本轮连接超时。[官方 Python SDK](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/client.py)
|
||||
|
||||
依次重放[整份选举样例](examples/neg-risk.jsonl)与[小数转换样例](examples/neg-risk-fractional.jsonl)。第二个样例中,将甲 NO、乙 NO 各 0.250001 份换成 0.250001 份「其他 YES」和 0.250001 模拟美元。此前组里已有 2 美元准备金,转换后为 2.250001。再各转换 0.009999 份,准备金恰为 2.26。两次活动按微单位分别记录现金 250001、9999。最终赢家获得全部准备金,持有人的兑换记录可在重启后核对。
|
||||
|
||||
本地 qty_micros 接受正整数,整份调用继续使用 qty,二者选一。这里对照官方合约的零转换费情形。合约还能从现金及 YES 输出扣除配置的转换费,并允许零数量空操作;当前模拟器不提供这两种行为。[官方转换合约](https://github.com/Polymarket/neg-risk-ctf-adapter/blob/main/src/NegRiskAdapter.sol)
|
||||
|
||||
Reference in New Issue
Block a user