Reprice listed goods; honeypot stays at 1%
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a76f04c75e
commit
a44e4008c1
7 files changed
+64
-6
No files matched your search
@@ -14,6 +14,8 @@ namespace Decentralized.Domain
|
||||
public double Health;
|
||||
/// <summary>标价倍率与标价(信用点)。</summary>
|
||||
public double Mult;
|
||||
/// <summary>参考价:改价时按它重算标价。</summary>
|
||||
public long Ref;
|
||||
public int ListPrice;
|
||||
public int ListedDay, PayDay;
|
||||
public SaleState State = SaleState.Listed;
|
||||
@@ -71,11 +73,31 @@ namespace Decentralized.Domain
|
||||
double share = total > 0 ? Math.Min(1, ListFee(listPrice) / total) : 0;
|
||||
w.Taint -= w.Taint * share; w.Basis -= w.Basis * share;
|
||||
w.Add(feeAsset, -qty);
|
||||
var s = new BmSale { Item = item, Model = model, FakeOf = fakeOf, Health = health, Mult = m, ListPrice = listPrice, ListedDay = day };
|
||||
var s = new BmSale { Item = item, Model = model, FakeOf = fakeOf, Health = health, Ref = refValue, Mult = m, ListPrice = listPrice, ListedDay = day };
|
||||
Sales.Add(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
public static int RepriceFee(int newPrice) => (int)Math.Ceiling(newPrice * Tuning.BmRepriceFee);
|
||||
|
||||
/// <summary>改价:上架中的货换一个倍率,按参考价重算标价,收改价费;不改变上架日。</summary>
|
||||
public bool Reprice(BmSale s, double m, Wallet w, string feeAsset, int day, Func<string, double> price)
|
||||
{
|
||||
if (s == null || s.State != SaleState.Listed || s.Ref <= 0 || Math.Abs(m - s.Mult) < 1e-9 || m < Tuning.BmSellMin - 1e-9 || m > Tuning.BmSellMax + 1e-9 || Closed(day) || feeAsset == Assets.CRC) return false;
|
||||
int listPrice = ListPriceOf(s.Ref, m);
|
||||
double p = price(feeAsset);
|
||||
if (p <= 0) return false;
|
||||
int fee = RepriceFee(listPrice);
|
||||
double qty = fee / p;
|
||||
if (w.Avail(feeAsset) + 1e-9 < qty) return false;
|
||||
double total = w.Value(price);
|
||||
double share = total > 0 ? Math.Min(1, fee / total) : 0;
|
||||
w.Taint -= w.Taint * share; w.Basis -= w.Basis * share;
|
||||
w.Add(feeAsset, -qty);
|
||||
s.Mult = m; s.ListPrice = listPrice;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Delist(BmSale s) { s.State = SaleState.Delisted; s.Why = "delist"; }
|
||||
|
||||
/// <summary>未到账的货款(信用点):跑路时一并归零,也推高跑路概率。</summary>
|
||||
|
||||
Reference in new issue
Block a user