This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fee calculation: Support blank fixed or percent costs (#82)
- Loading branch information
Morley Zhi
authored
Jul 17, 2019
1 parent
703d864
commit 2b815b7
Showing
5 changed files
with
88 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { DepositProvider } from "./DepositProvider"; | ||
|
||
import { DepositInfo } from "../types"; | ||
|
||
describe("fetchFinalFee", () => { | ||
test("AnchorUSD", async () => { | ||
const info: DepositInfo = { | ||
USD: { | ||
assetCode: "USD", | ||
fee: { type: "simple", fixed: 5, percent: 1 }, | ||
minAmount: 15, | ||
fields: [ | ||
{ | ||
description: "your email address for transaction status updates", | ||
name: "email_address", | ||
}, | ||
{ | ||
description: "amount in USD that you plan to deposit", | ||
name: "amount", | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const provider = new DepositProvider("test"); | ||
|
||
expect( | ||
await provider.fetchFinalFee({ | ||
supportedAssets: info, | ||
assetCode: info.USD.assetCode, | ||
amount: "15", | ||
type: "", | ||
}), | ||
).toEqual(5.15); | ||
}); | ||
|
||
test("EUR from Nucleo staging", async () => { | ||
const info: DepositInfo = { | ||
EUR: { | ||
assetCode: "EUR", | ||
fee: { type: "simple", percent: 0.5 }, | ||
minAmount: 1, | ||
maxAmount: 1000000000, | ||
fields: [ | ||
{ | ||
description: "Type of deposit method for EUR", | ||
choices: ["SWIFT", "SEPA"], | ||
name: "type", | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const provider = new DepositProvider("test"); | ||
|
||
expect( | ||
await provider.fetchFinalFee({ | ||
supportedAssets: info, | ||
assetCode: info.EUR.assetCode, | ||
amount: "10", | ||
type: "", | ||
}), | ||
).toEqual(0.05); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ const parseFee = ( | |
} else { | ||
return { | ||
type: feeEnabled ? "complex" : "none", | ||
}; | ||
} as Fee; | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters