unrip/test/liquidity-withdrawals.test.mjs
philipp 3f0a119987
All checks were successful
deploy / deploy (push) Successful in 24s
Add operator withdrawal path
Proof: The active NEAR Intents funded market-maker loop needs a first-class operator withdrawal action so funded inventory can be exited through repo-controlled code rather than manual follow-up.

Assumptions: The configured signer key is also a full-access key on the named NEAR account, and external-chain exits for active OMFT assets are triggered by intents.near::ft_withdraw with the token contract as receiver_id plus memo=WITHDRAW_TO:<destination>.

Still fake: Strategy and executor remain disarmed, no live inventory is credited yet, and no live mainnet trade quote has been submitted.
2026-04-02 12:24:59 +02:00

64 lines
2.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { buildBridgeWithdrawalPlan } from '../src/core/liquidity-withdrawals.mjs';
const config = {
assetRegistry: new Map([
['nep141:btc.omft.near', {
assetId: 'nep141:btc.omft.near',
chain: 'btc:mainnet',
}],
['nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near', {
assetId: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
chain: 'eth:100',
}],
]),
};
test('buildBridgeWithdrawalPlan creates an external-chain EURe withdrawal plan', () => {
const plan = buildBridgeWithdrawalPlan({
assetId: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
amount: '5000000000000000000',
destinationAddress: '0x62bda91ac00CCa4e87cE3915Db56DF06773A1747',
supportedTokens: {
eure: {
near_token_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
defuse_asset_identifier: 'eth:100:0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430',
min_withdrawal_amount: '1',
withdrawal_fee: '200000000000',
},
},
config,
});
assert.deepEqual(plan, {
asset_id: 'nep141:gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
amount: '5000000000000000000',
chain: 'eth:100',
destination_address: '0x62bda91ac00CCa4e87cE3915Db56DF06773A1747',
near_token_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
defuse_asset_identifier: 'eth:100:0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430',
receiver_id: 'gnosis-0x420ca0f9b9b604ce0fd9c18ef134c705e5fa3430.omft.near',
memo: 'WITHDRAW_TO:0x62bda91ac00CCa4e87cE3915Db56DF06773A1747',
min_withdrawal_amount: '1',
withdrawal_fee: '200000000000',
});
});
test('buildBridgeWithdrawalPlan rejects amounts below the bridge minimum', () => {
assert.throws(() => buildBridgeWithdrawalPlan({
assetId: 'nep141:btc.omft.near',
amount: '9999',
destinationAddress: 'bc1qexample',
supportedTokens: {
btc: {
near_token_id: 'btc.omft.near',
defuse_asset_identifier: 'btc:mainnet:native',
min_withdrawal_amount: '10000',
withdrawal_fee: '1500',
},
},
config,
}), /amount below minimum withdrawal: 10000/);
});