diff --git a/queries/orderbook/barn_batch_rewards.sql b/queries/orderbook/barn_batch_rewards.sql index 760a1d3e..24601f40 100644 --- a/queries/orderbook/barn_batch_rewards.sql +++ b/queries/orderbook/barn_batch_rewards.sql @@ -55,7 +55,8 @@ order_surplus AS ( CASE WHEN o.kind = 'sell' THEN o.buy_token WHEN o.kind = 'buy' THEN o.sell_token - END AS surplus_token + END AS surplus_token, + ad.full_app_data as app_data FROM settlements s JOIN settlement_scores ss -- contains block_deadline @@ -69,6 +70,8 @@ order_surplus AS ( AND s.auction_id = oe.auction_id LEFT OUTER JOIN order_quotes oq -- contains quote amounts ON o.uid = oq.order_uid + LEFT OUTER JOIN app_data ad + on o.app_data = ad.contract_app_data WHERE ss.block_deadline >= {{start_block}} AND ss.block_deadline <= {{end_block}} @@ -78,12 +81,15 @@ order_protocol_fee AS ( os.auction_id, os.solver, os.tx_hash, + os.order_uid, os.sell_amount, os.buy_amount, os.sell_token, os.observed_fee, os.surplus, os.surplus_token, + convert_from(os.app_data, 'UTF8')::JSONB->'metadata'->'partnerFee'->>'recipient' as partner_fee_recipient, + fp.kind as protocol_fee_kind, CASE WHEN fp.kind = 'surplus' THEN CASE WHEN os.kind = 'sell' THEN @@ -140,18 +146,23 @@ order_protocol_fee AS ( ), order_protocol_fee_prices AS ( SELECT + opf.auction_id, opf.solver, opf.tx_hash, + opf.order_uid, opf.surplus, opf.protocol_fee, + opf.protocol_fee_token, + opf.partner_fee_recipient, + opf.protocol_fee_kind, CASE WHEN opf.sell_token != opf.protocol_fee_token THEN (opf.sell_amount - opf.observed_fee) / opf.buy_amount * opf.protocol_fee ELSE opf.protocol_fee END AS network_fee_correction, opf.sell_token as network_fee_token, - ap_surplus.price / pow(10, 18) as surplus_token_price, - ap_protocol.price / pow(10, 18) as protocol_fee_token_price, - ap_sell.price / pow(10, 18) as network_fee_token_price + ap_surplus.price / pow(10, 18) as surplus_token_native_price, + ap_protocol.price / pow(10, 18) as protocol_fee_token_native_price, + ap_sell.price / pow(10, 18) as network_fee_token_native_price FROM order_protocol_fee opf JOIN auction_prices ap_sell -- contains price: sell token @@ -169,8 +180,8 @@ batch_protocol_fees AS ( solver, tx_hash, -- sum(surplus * surplus_token_price) as surplus, - sum(protocol_fee * protocol_fee_token_price) as protocol_fee, - sum(network_fee_correction * network_fee_token_price) as network_fee_correction + sum(protocol_fee * protocol_fee_token_native_price) as protocol_fee, + sum(network_fee_correction * network_fee_token_native_price) as network_fee_correction FROM order_protocol_fee_prices group by @@ -214,9 +225,11 @@ reward_data AS ( 0 ) as network_fee_correction FROM - settlement_scores ss -- If there are reported scores, + settlement_scores ss + -- If there are reported scores, -- there will always be a record of auction participants - JOIN auction_participation ap ON ss.auction_id = ap.auction_id -- outer joins made in order to capture non-existent settlements. + JOIN auction_participation ap ON ss.auction_id = ap.auction_id + -- outer joins made in order to capture non-existent settlements. LEFT OUTER JOIN observed_settlements os ON os.auction_id = ss.auction_id LEFT OUTER JOIN batch_protocol_fees bpf ON bpf.tx_hash = os.tx_hash ), @@ -273,16 +286,37 @@ primary_rewards as ( GROUP BY solver ), +partner_fees_per_solver AS ( + SELECT + solver, + partner_fee_recipient, + sum(protocol_fee * protocol_fee_token_native_price) as protocol_fee_eth + FROM + order_protocol_fee_prices + WHERE partner_fee_recipient is not null + group by solver,partner_fee_recipient +), +aggregate_partner_fees_per_solver AS ( + SELECT + solver, + array_agg(parter_fee_recipient) as partner_list, + array_agg(protocol_fee_eth) as partner_payments_in_eth + FROM partner_fees_per_solver + group by solver +), aggregate_results as ( SELECT concat('0x', encode(pc.solver, 'hex')) as solver, coalesce(payment, 0) as primary_reward_eth, num_participating_batches, coalesce(protocol_fee, 0) as protocol_fee_eth, - coalesce(network_fee, 0) as network_fee_eth + coalesce(network_fee, 0) as network_fee_eth, + partner_list, + partner_payments_in_eth FROM participation_counts pc LEFT OUTER JOIN primary_rewards pr ON pr.solver = pc.solver + LEFT OUTER JOIN aggregate_partner_fees_per_solver aif on pr.solver = aif.solver ) -- select * diff --git a/queries/orderbook/prod_batch_rewards.sql b/queries/orderbook/prod_batch_rewards.sql index 121aa11d..6ff6996b 100644 --- a/queries/orderbook/prod_batch_rewards.sql +++ b/queries/orderbook/prod_batch_rewards.sql @@ -55,7 +55,8 @@ order_surplus AS ( CASE WHEN o.kind = 'sell' THEN o.buy_token WHEN o.kind = 'buy' THEN o.sell_token - END AS surplus_token + END AS surplus_token, + ad.full_app_data as app_data FROM settlements s JOIN settlement_scores ss -- contains block_deadline @@ -69,6 +70,8 @@ order_surplus AS ( AND s.auction_id = oe.auction_id LEFT OUTER JOIN order_quotes oq -- contains quote amounts ON o.uid = oq.order_uid + LEFT OUTER JOIN app_data ad + on o.app_data = ad.contract_app_data WHERE ss.block_deadline >= {{start_block}} AND ss.block_deadline <= {{end_block}} @@ -85,6 +88,8 @@ order_protocol_fee AS ( os.observed_fee, os.surplus, os.surplus_token, + convert_from(os.app_data, 'UTF8')::JSONB->'metadata'->'partnerFee'->>'recipient' as partner_fee_recipient, + fp.kind as protocol_fee_kind, CASE WHEN fp.kind = 'surplus' THEN CASE WHEN os.kind = 'sell' THEN @@ -148,6 +153,8 @@ order_protocol_fee_prices AS ( opf.surplus, opf.protocol_fee, opf.protocol_fee_token, + opf.partner_fee_recipient, + opf.protocol_fee_kind, CASE WHEN opf.sell_token != opf.protocol_fee_token THEN (opf.sell_amount - opf.observed_fee) / opf.buy_amount * opf.protocol_fee ELSE opf.protocol_fee @@ -279,16 +286,37 @@ primary_rewards as ( GROUP BY solver ), +partner_fees_per_solver AS ( + SELECT + solver, + partner_fee_recipient, + sum(protocol_fee * protocol_fee_token_native_price) as protocol_fee_eth + FROM + order_protocol_fee_prices + WHERE partner_fee_recipient is not null + group by solver,partner_fee_recipient +), +aggregate_partner_fees_per_solver AS ( + SELECT + solver, + array_agg(partner_fee_recipient) as partner_list, + array_agg(protocol_fee_eth) as partner_payments_in_eth + FROM partner_fees_per_solver + group by solver +), aggregate_results as ( SELECT concat('0x', encode(pc.solver, 'hex')) as solver, coalesce(payment, 0) as primary_reward_eth, num_participating_batches, coalesce(protocol_fee, 0) as protocol_fee_eth, - coalesce(network_fee, 0) as network_fee_eth + coalesce(network_fee, 0) as network_fee_eth, + partner_list, + partner_payments_in_eth FROM participation_counts pc LEFT OUTER JOIN primary_rewards pr ON pr.solver = pc.solver + LEFT OUTER JOIN aggregate_partner_fees_per_solver aif on pr.solver = aif.solver ) -- select * diff --git a/src/fetch/payouts.py b/src/fetch/payouts.py index ff24de3d..1ee514d5 100644 --- a/src/fetch/payouts.py +++ b/src/fetch/payouts.py @@ -295,7 +295,13 @@ def extend_payment_df(pdf: DataFrame, converter: TokenConversion) -> DataFrame: return pdf -def prepare_transfers(payout_df: DataFrame, period: AccountingPeriod) -> PeriodPayouts: +def prepare_transfers( + payout_df: DataFrame, + period: AccountingPeriod, + final_protocol_fee_wei: int, + partner_fee_tax_wei: int, + partner_fees_wei: dict[str, int], +) -> PeriodPayouts: """ Manipulates the payout DataFrame to split into ETH and COW. Specifically, We deduct total_rewards by total_execution_cost (both initially in ETH) @@ -318,13 +324,30 @@ def prepare_transfers(payout_df: DataFrame, period: AccountingPeriod) -> PeriodP overdrafts.append(overdraft) transfers += payout_datum.as_payouts() - transfers.append( - Transfer( - token=None, - recipient=PROTOCOL_FEE_SAFE, - amount_wei=int(payout_df.protocol_fee_eth.sum()), + if final_protocol_fee_wei > 0: + transfers.append( + Transfer( + token=None, + recipient=PROTOCOL_FEE_SAFE, + amount_wei=final_protocol_fee_wei, + ) + ) + if partner_fee_tax_wei > 0: + transfers.append( + Transfer( + token=None, + recipient=PROTOCOL_FEE_SAFE, + amount_wei=partner_fee_tax_wei, + ) + ) + for address in partner_fees_wei: + transfers.append( + Transfer( + token=None, + recipient=Address(address), + amount_wei=partner_fees_wei[address], + ) ) - ) return PeriodPayouts(overdrafts, transfers) @@ -390,12 +413,17 @@ def construct_payouts( dune: DuneFetcher, orderbook: MultiInstanceDBFetcher ) -> list[Transfer]: """Workflow of solver reward payout logic post-CIP27""" + # pylint: disable-msg=too-many-locals price_day = dune.period.end - timedelta(days=1) reward_token = TokenId.COW quote_rewards_df = orderbook.get_quote_rewards(dune.start_block, dune.end_block) batch_rewards_df = orderbook.get_solver_rewards(dune.start_block, dune.end_block) + partner_fees_df = batch_rewards_df[["partner_list", "partner_payments_in_eth"]] + batch_rewards_df = batch_rewards_df.drop( + ["partner_list", "partner_payments_in_eth"], axis=1 + ) merged_df = pandas.merge( quote_rewards_df, batch_rewards_df, on="solver", how="outer" ).fillna(0) @@ -420,15 +448,53 @@ def construct_payouts( performance_reward = complete_payout_df["primary_reward_cow"].sum() participation_reward = complete_payout_df["secondary_reward_cow"].sum() quote_reward = complete_payout_df["quote_reward_cow"].sum() - protocol_fee = complete_payout_df["protocol_fee_eth"].sum() + raw_protocol_fee_wei = int(complete_payout_df.protocol_fee_eth.sum()) + + # We now decompose the raw_protocol_fee_wei amount into actual + # protocol fee and partner fees. For convenience, + # we use a dictionary partner_fees_wei that contains the the + # destination address of an partner as a key, and the value is the + # amount in wei to be transferred to that address, stored as an int. + + partner_fees_wei: dict[str, int] = {} + for _, row in partner_fees_df.iterrows(): + if row["partner_list"] is None: + continue + + # We assume the two lists used below, i.e., + # partner_list and partner_payments_in_eth, + # are "aligned". + + for i in range(len(row["partner_list"])): + address = row["partner_list"][i] + if address in partner_fees_wei: + partner_fees_wei[address] += int(row["partner_payments_in_eth"][i]) + else: + partner_fees_wei[address] = int(row["partner_payments_in_eth"][i]) + total_partner_fee_wei = 0 + for address, value in partner_fees_wei.items(): + total_partner_fee_wei += value + partner_fees_wei[address] = int(0.85 * value) + + final_protocol_fee_wei = raw_protocol_fee_wei - total_partner_fee_wei + partner_fee_tax_wei = int(0.15 * total_partner_fee_wei) + total_partner_fee_wei = int(0.85 * total_partner_fee_wei) dune.log_saver.print( f"Performance Reward: {performance_reward / 10 ** 18:.4f}\n" f"Participation Reward: {participation_reward / 10 ** 18:.4f}\n" f"Quote Reward: {quote_reward / 10 ** 18:.4f}\n" - f"Protocol Fees: {protocol_fee / 10 ** 18:.4f}\n", + f"Protocol Fees: {final_protocol_fee_wei / 10 ** 18:.4f}\n" + f"Partner Fees Tax: {partner_fee_tax_wei / 10 ** 18:.4f}\n" + f"Partner Fees: {total_partner_fee_wei / 10 ** 18:.4f}\n", category=Category.TOTALS, ) - payouts = prepare_transfers(complete_payout_df, dune.period) + payouts = prepare_transfers( + complete_payout_df, + dune.period, + final_protocol_fee_wei, + partner_fee_tax_wei, + partner_fees_wei, + ) for overdraft in payouts.overdrafts: dune.log_saver.print(str(overdraft), Category.OVERDRAFT) return payouts.transfers diff --git a/src/utils/script_args.py b/src/utils/script_args.py index eb856b54..01f4ee90 100644 --- a/src/utils/script_args.py +++ b/src/utils/script_args.py @@ -67,7 +67,7 @@ def generic_script_init(description: str) -> ScriptArgs: "--min-transfer-amount-cow-atoms", type=int, help="Ignore COW transfers with amount less than this", - default=100000000000000000000, + default=20000000000000000000, ) args = parser.parse_args() return ScriptArgs( diff --git a/tests/queries/batch_rewards_test_db.sql b/tests/queries/batch_rewards_test_db.sql index 93a1bb4c..9eefd6d0 100644 --- a/tests/queries/batch_rewards_test_db.sql +++ b/tests/queries/batch_rewards_test_db.sql @@ -11,6 +11,7 @@ DROP TABLE IF EXISTS trades; DROP TABLE IF EXISTS order_execution; DROP TABLE IF EXISTS fee_policies; DROP TYPE IF EXISTS PolicyKind; +DROP TABLE IF EXISTS app_data; CREATE TABLE IF NOT EXISTS settlements ( @@ -79,7 +80,8 @@ CREATE TABLE orders ( kind OrderKind NOT NULL, partially_fillable boolean NOT NULL, full_fee_amount numeric(78,0) NOT NULL, - class OrderClass NOT NULL + class OrderClass NOT NULL, + app_data bytea NOT NULL ); CREATE TABLE IF NOT EXISTS order_quotes @@ -136,6 +138,11 @@ CREATE TABLE fee_policies ( PRIMARY KEY (auction_id, order_uid, application_order) ); +CREATE TABLE app_data ( + contract_app_data bytea PRIMARY KEY, + full_app_data bytea NOT NULL +); + TRUNCATE settlements; TRUNCATE auction_participants; @@ -146,6 +153,7 @@ TRUNCATE orders; TRUNCATE order_quotes; TRUNCATE trades; TRUNCATE fee_policies; +TRUNCATE app_data; INSERT INTO settlements (block_number, log_index, solver, tx_hash, tx_from, tx_nonce, auction_id) @@ -264,17 +272,17 @@ VALUES (51, '\x01', 500000000000000000000000000), (60, '\x01', 500000000000000000000000000), (60, '\x02', 500000000000000); -INSERT INTO orders (uid, sell_token, buy_token, sell_amount, buy_amount, fee_amount, kind, partially_fillable, full_fee_amount, class) -VALUES ('\x01'::bytea, '\x01'::bytea, '\x02'::bytea, 95000000, 94000000000000000000, 5000000, 'sell', 'f', 5000000, 'market'), -- sell market order -('\x02'::bytea, '\x01'::bytea, '\x02'::bytea, 101000000, 100000000000000000000, 5000000, 'buy', 'f', 5000000, 'market'), -- buy market order -('\x03'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't', 0, 'limit'), -- partially fillable sell limit order -('\x04'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'buy', 't', 0, 'limit'), -- partially fillable buy limit order -('\x05'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit'), -- in market sell limit order -('\x06'::bytea, '\x01'::bytea, '\x02'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f', 0, 'limit'), -- in market buy limit order -('\x07'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit'), -- in market sell limit order -('\x08'::bytea, '\x01'::bytea, '\x02'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f', 0, 'limit'), -- in market buy limit order -('\x09'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit'), -- in market sell limit order -('\x0a'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit'); -- in market sell limit order +INSERT INTO orders (uid, sell_token, buy_token, sell_amount, buy_amount, fee_amount, kind, partially_fillable, full_fee_amount, class, app_data) +VALUES ('\x01'::bytea, '\x01'::bytea, '\x02'::bytea, 95000000, 94000000000000000000, 5000000, 'sell', 'f', 5000000, 'market', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- sell market order +('\x02'::bytea, '\x01'::bytea, '\x02'::bytea, 101000000, 100000000000000000000, 5000000, 'buy', 'f', 5000000, 'market', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- buy market order +('\x03'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'sell', 't', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- partially fillable sell limit order +('\x04'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 100000000000000000000, 0, 'buy', 't', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- partially fillable buy limit order +('\x05'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit', '\xd3418777a6ec517d7310b05a2a22f3737524ae0302d1f88230f4e066a1768b74'::bytea), -- in market sell limit order with volume-based partner fee of 45bps. An example of a real order with same appdata can be found here: https://explorer.cow.fi/orders/0x398510f3b0b35c0712d3caef470f036a4fead3d21b5a37280698484a197a5da45543dc0694384bd9a7c585027d436c4daacc95c7661c7213?tab=overview +('\x06'::bytea, '\x01'::bytea, '\x02'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- in market buy limit order +('\x07'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- in market sell limit order +('\x08'::bytea, '\x01'::bytea, '\x02'::bytea, 106000000, 100000000000000000000, 0, 'buy', 'f', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- in market buy limit order +('\x09'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea), -- in market sell limit order +('\x0a'::bytea, '\x01'::bytea, '\x02'::bytea, 100000000, 94000000000000000000, 0, 'sell', 'f', 0, 'limit', '\x0000000000000000000000000000000000000000000000000000000000000000'::bytea); -- in market sell limit order INSERT INTO order_quotes (order_uid, gas_amount, gas_price, sell_token_price, sell_amount, buy_amount, solver) VALUES ('\x07'::bytea, 100000, 25000000000, 500000000., 100000000, 100000000000000000000, '\x01'::bytea), @@ -307,10 +315,13 @@ VALUES ('\x03'::bytea, 53, 0, 5931372, NULL), INSERT INTO fee_policies (auction_id, order_uid, application_order, kind, surplus_factor, surplus_max_volume_factor, volume_factor, price_improvement_factor, price_improvement_max_volume_factor) VALUES (53, '\x03'::bytea, 3, 'surplus', 0.5, 0.02, NULL, NULL, NULL), (54, '\x04'::bytea, 4, 'surplus', 0.75, 0.1, NULL, NULL, NULL), -(55, '\x05'::bytea, 5, 'volume', NULL, NULL, 0.0015, NULL, NULL), +(55, '\x05'::bytea, 5, 'volume', NULL, NULL, 0.0045, NULL, NULL), (56, '\x06'::bytea, 6, 'surplus', 0.9, 0.01, NULL, NULL, NULL), (57, '\x07'::bytea, 7, 'priceimprovement', NULL, NULL, NULL, 0.5, 0.01), (58, '\x08'::bytea, 8, 'priceimprovement', NULL, NULL, NULL, 0.5, 0.01), (59, '\x09'::bytea, 9, 'priceimprovement', NULL, NULL, NULL, 0.5, 0.01), (60, '\x0a'::bytea, 9, 'priceimprovement', NULL, NULL, NULL, 0.5, 0.01); +INSERT INTO app_data (contract_app_data, full_app_data) +VALUES ('\x0000000000000000000000000000000000000000000000000000000000000000'::bytea, '\x7b7d'::bytea), +('\xd3418777a6ec517d7310b05a2a22f3737524ae0302d1f88230f4e066a1768b74'::bytea, '\x7b22617070436f6465223a2273686170657368696674222c226d65746164617461223a7b226f72646572436c617373223a7b226f72646572436c617373223a226d61726b6574227d2c22706172746e6572466565223a7b22627073223a34382c22726563697069656e74223a22307839306134386435636637333433623038646131326530363736383062346336646266653535316265227d2c2271756f7465223a7b22736c69707061676542697073223a223530227d7d2c2276657273696f6e223a22302e392e30227d'::bytea); \ No newline at end of file diff --git a/tests/queries/test_batch_rewards.py b/tests/queries/test_batch_rewards.py index 951170d1..dbacfb9f 100644 --- a/tests/queries/test_batch_rewards.py +++ b/tests/queries/test_batch_rewards.py @@ -30,7 +30,7 @@ def test_get_batch_rewards(self): "0x5444444444444444444444444444444444444444", ], "primary_reward_eth": [ - 2071357035553330.0, # 3 * 1e18 * 5e14 / 1e18 (surplus) + 571357035553330 (protocol fee) + 2214716223003516.0, # 3 * 1e18 * 5e14 / 1e18 (surplus) + 714716223003516 (protocol fee) 3519801980198020.0, 3729797979797980.0, # 1.5e18 * 5e14 / 1e18 + 2e6 * 5e26 / 1e18 + 1e18 * 5e14 / 1e18 + 0.5e18 * 5e14 / 1e18 + 1229797979797980.0 (protocol) 6000000000000000.00000, @@ -48,7 +48,7 @@ def test_get_batch_rewards(self): 6, ], "protocol_fee_eth": [ - 571357035553330.0, # 0.5 / (1 - 0.5) * 1e18 * 5e14 / 1e18 + 0.0015 / (1 - 0.0015) * 95e18 * 5e14 / 1e18 + 714716223003516.0, # 0.5 / (1 - 0.5) * 1e18 * 5e14 / 1e18 + 0.0045 / (1 - 0.0045) * 95e18 * 5e14 / 1e18 2.0198019801980198e15, # 0.75 / (1 - 0.75) * 1e6 * 5e26 / 1e18 + 0.01 / (1 + 0.01) * 105e6 * 5e26 / 1e18 1229797979797980.0, # 0.5 / (1 - 0.5) * 0.5e18 * 5e14 / 1e18 + 0.5 / (1 - 0.5) * 1e6 * 5e26 / 1e18 + 0.01 / (1 - 0.01) * 95e18 * 5e14 / 1e18 0.0, @@ -57,7 +57,7 @@ def test_get_batch_rewards(self): 0.0, ], "network_fee_eth": [ - 7463707813908982.0, # almost 2500000000000000 + 3000000000000000 + 2500000000000000 - 5.748876684972541e14 + 7321857670537219.0, # almost 2500000000000000 + 3000000000000000 + 2500000000000000 - 6.781...1e14 6980198019801980.0, # 2500000000000000 + 4000000000000000 + 2500000000000000 - 2.0198019801980198e15 8779179226823198.0, 1050000000000000.0, @@ -65,6 +65,24 @@ def test_get_batch_rewards(self): 0.0, 0.0, ], + "partner_list": [ + ["0x90a48d5cf7343b08da12e067680b4c6dbfe551be"], + None, + None, + None, + None, + None, + None, + ], + "partner_payments_in_eth": [ + [214716223003516], + None, + None, + None, + None, + None, + None, + ], } ) self.assertIsNone(pandas.testing.assert_frame_equal(expected, batch_rewards)) diff --git a/tests/unit/test_multisend.py b/tests/unit/test_multisend.py index fffcf478..93cdfb19 100644 --- a/tests/unit/test_multisend.py +++ b/tests/unit/test_multisend.py @@ -58,7 +58,7 @@ def test_prepend_unwrap(self): hex_weth_balance = hex(weth_balance)[2:].rjust(64, "0") self.assertEqual( f"{unwrap_method_id}{hex_weth_balance}", - unwrap.data.hex(), + "0x" + unwrap.data.hex(), ) def test_multisend_encoding(self): diff --git a/tests/unit/test_payouts.py b/tests/unit/test_payouts.py index 4673f910..46a5f5b7 100644 --- a/tests/unit/test_payouts.py +++ b/tests/unit/test_payouts.py @@ -321,7 +321,10 @@ def test_prepare_transfers(self): } ) period = AccountingPeriod("1985-03-10", 1) - payout_transfers = prepare_transfers(full_payout_data, period) + protocol_fee_amount = sum(self.protocol_fee_eth) + payout_transfers = prepare_transfers( + full_payout_data, period, protocol_fee_amount, 0, {} + ) self.assertEqual( [ Transfer(