@wopr-network/platform-core 1.35.1 → 1.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,8 +28,9 @@ export async function settleBtcPayment(deps, event) {
28
28
  if (await creditLedger.hasReferenceId(creditRef)) {
29
29
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
30
30
  }
31
- // Underpayment check
32
- if (event.amountUsdCents < charge.amountUsdCents) {
31
+ // 2% underpayment tolerance for oracle price drift between checkout and settlement.
32
+ const UNDERPAYMENT_TOLERANCE = 0.98;
33
+ if (event.amountUsdCents < charge.amountUsdCents * UNDERPAYMENT_TOLERANCE) {
33
34
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
34
35
  }
35
36
  const creditCents = charge.amountUsdCents;
@@ -26,7 +26,9 @@ export async function settleEthPayment(deps, event) {
26
26
  if (await creditLedger.hasReferenceId(creditRef)) {
27
27
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
28
28
  }
29
- if (event.amountUsdCents < charge.amountUsdCents) {
29
+ // 2% underpayment tolerance for oracle price drift between checkout and settlement.
30
+ const UNDERPAYMENT_TOLERANCE = 0.98;
31
+ if (event.amountUsdCents < charge.amountUsdCents * UNDERPAYMENT_TOLERANCE) {
30
32
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
31
33
  }
32
34
  const creditCents = charge.amountUsdCents;
@@ -53,7 +53,7 @@ async function handleNativeEvm(deps, method, tenant, amountUsdCents, amountUsd)
53
53
  amountUsd,
54
54
  token: "ETH",
55
55
  chain: method.chain,
56
- referenceId: `eth:${method.chain}:${depositAddress}`,
56
+ referenceId: `${method.type}:${method.chain}:${depositAddress}`,
57
57
  priceCents,
58
58
  };
59
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopr-network/platform-core",
3
- "version": "1.35.1",
3
+ "version": "1.35.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,8 +44,9 @@ export async function settleBtcPayment(deps: BtcSettlerDeps, event: BtcPaymentEv
44
44
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
45
45
  }
46
46
 
47
- // Underpayment check
48
- if (event.amountUsdCents < charge.amountUsdCents) {
47
+ // 2% underpayment tolerance for oracle price drift between checkout and settlement.
48
+ const UNDERPAYMENT_TOLERANCE = 0.98;
49
+ if (event.amountUsdCents < charge.amountUsdCents * UNDERPAYMENT_TOLERANCE) {
49
50
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
50
51
  }
51
52
 
@@ -42,7 +42,9 @@ export async function settleEthPayment(deps: EthSettlerDeps, event: EthPaymentEv
42
42
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
43
43
  }
44
44
 
45
- if (event.amountUsdCents < charge.amountUsdCents) {
45
+ // 2% underpayment tolerance for oracle price drift between checkout and settlement.
46
+ const UNDERPAYMENT_TOLERANCE = 0.98;
47
+ if (event.amountUsdCents < charge.amountUsdCents * UNDERPAYMENT_TOLERANCE) {
46
48
  return { handled: true, status: "Settled", tenant: charge.tenantId, creditedCents: 0 };
47
49
  }
48
50
 
@@ -101,7 +101,7 @@ async function handleNativeEvm(
101
101
  amountUsd,
102
102
  token: "ETH",
103
103
  chain: method.chain,
104
- referenceId: `eth:${method.chain}:${depositAddress}`,
104
+ referenceId: `${method.type}:${method.chain}:${depositAddress}`,
105
105
  priceCents,
106
106
  };
107
107
  }